:root {
    --primary: #0284C7; /* Professional Sky Blue */
    --primary-light: #E0F2FE; /* Very light blue for backgrounds */
    --secondary: #0369A1; /* Deeper blue for hover */
    --accent: #10B981; /* Emerald/Mint Green - Medical */
    --background: #F8FAFC; /* Slate 50 - Very soft off-white background */
    --surface: #FFFFFF; /* Pure white for cards */
    --surface-light: rgba(255, 255, 255, 0.85); /* Glassmorphism light */
    --text: #0F172A; /* Slate 900 - Dark text */
    --text-muted: #64748B; /* Slate 500 - Subtitles */
    --border: #E2E8F0; /* Slate 200 - Soft borders */
    --danger: #EF4444; /* Red */
    --radius: 16px;
    --transition: 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    --font-heading: 'Outfit', sans-serif;
    --font-body: 'Inter', sans-serif;
    --shadow-soft: 0 10px 25px -5px rgba(0, 0, 0, 0.05), 0 8px 10px -6px rgba(0, 0, 0, 0.01);
    --shadow-hover: 0 20px 25px -5px rgba(0, 0, 0, 0.1), 0 10px 10px -5px rgba(0, 0, 0, 0.04);
}

* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

body {
    font-family: var(--font-body);
    background-color: var(--background);
    color: var(--text);
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    overflow-x: hidden;
    position: relative;
    background-image: 
        radial-gradient(at 0% 0%, rgba(2, 132, 199, 0.08) 0px, transparent 50%),
        radial-gradient(at 100% 100%, rgba(16, 185, 129, 0.05) 0px, transparent 50%),
        radial-gradient(at 100% 0%, rgba(3, 105, 161, 0.05) 0px, transparent 50%);
    background-attachment: fixed;
}

h1, h2, h3, h4, h5, h6 {
    font-family: var(--font-heading);
    font-weight: 600;
    color: var(--text);
}

a {
    color: var(--primary);
    text-decoration: none;
    transition: color var(--transition);
}

a:hover {
    color: var(--secondary);
}

/* Glassmorphism Classes */
.glass {
    background: var(--surface-light);
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
    border: 1px solid rgba(255, 255, 255, 1);
    border-radius: var(--radius);
    box-shadow: var(--shadow-soft);
}

/* Layout */
.app-container {
    display: flex;
    min-height: 100vh;
}

/* Sidebar */
.sidebar {
    width: 260px;
    background: var(--surface);
    border-right: 1px solid var(--border);
    display: flex;
    flex-direction: column;
    padding: 1.5rem 0;
    z-index: 10;
    box-shadow: 2px 0 15px rgba(0,0,0,0.02);
}

.sidebar-header {
    padding: 0 1.5rem 1.5rem;
    border-bottom: 1px solid var(--border);
    margin-bottom: 1.5rem;
    display: flex;
    align-items: center;
}

.sidebar-brand {
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.sidebar-brand h1 {
    font-size: 1.5rem;
    background: linear-gradient(135deg, var(--primary), var(--secondary));
    -webkit-background-clip: text;
    background-clip: text;
    -webkit-text-fill-color: transparent;
    font-weight: 700;
    letter-spacing: -0.5px;
}

.sidebar-brand::before {
    content: '\f479'; /* fa-prescription-bottle-medical */
    font-family: 'Font Awesome 6 Free';
    font-weight: 900;
    color: var(--primary);
    font-size: 1.4rem;
}

.sidebar-nav {
    display: flex;
    flex-direction: column;
    gap: 0.35rem;
    padding: 0 1rem;
}

.nav-item {
    padding: 0.85rem 1rem;
    border-radius: 10px;
    color: var(--text-muted);
    font-weight: 500;
    font-size: 0.95rem;
    transition: all var(--transition);
    display: flex;
    align-items: center;
    gap: 0.85rem;
}

.nav-item:hover {
    background: var(--primary-light);
    color: var(--primary);
}

.nav-item.active {
    background: linear-gradient(135deg, var(--primary), var(--secondary));
    color: #fff;
    box-shadow: 0 4px 10px rgba(2, 132, 199, 0.2);
}

.nav-item i {
    font-size: 1.1rem;
    width: 20px;
    text-align: center;
}

/* Main Content */
.main-content {
    flex: 1;
    padding: 2.5rem;
    display: flex;
    flex-direction: column;
    gap: 2rem;
    max-width: 1400px;
    margin: 0 auto;
    width: 100%;
}

/* Components */
.card {
    padding: 1.75rem;
    border-radius: var(--radius);
    background: var(--surface);
    border: 1px solid rgba(255, 255, 255, 0.8);
    box-shadow: var(--shadow-soft);
    transition: transform var(--transition), box-shadow var(--transition);
}

.card-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1.5rem;
    border-bottom: 1px solid var(--border);
    padding-bottom: 1rem;
}

.card-header h2 {
    font-size: 1.25rem;
    color: var(--text);
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
    gap: 1.5rem;
}

.stat-card {
    padding: 1.5rem;
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    border-radius: 12px;
    background: var(--surface);
    border: 1px solid var(--border);
    position: relative;
    overflow: hidden;
    box-shadow: 0 4px 6px rgba(0,0,0,0.02);
    transition: transform var(--transition), box-shadow var(--transition);
}

.stat-card:hover {
    transform: translateY(-3px);
    box-shadow: var(--shadow-hover);
}

.stat-card::before {
    content: '';
    position: absolute;
    top: 0; left: 0; right: 0; height: 4px;
    background: linear-gradient(90deg, var(--primary), var(--accent));
}

.stat-title {
    color: var(--text-muted);
    font-size: 0.85rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.stat-value {
    font-size: 2.25rem;
    font-weight: 700;
    font-family: var(--font-heading);
    color: var(--text);
}

.stat-icon {
    position: absolute;
    right: 1.5rem;
    bottom: 1.5rem;
    font-size: 2.5rem;
    opacity: 0.1;
    color: var(--primary);
    transition: transform var(--transition);
}
.stat-card:hover .stat-icon {
    transform: scale(1.1) rotate(-5deg);
    opacity: 0.15;
}

/* Forms */
.form-group {
    margin-bottom: 1.5rem;
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.form-label {
    font-weight: 600;
    font-size: 0.875rem;
    color: var(--text);
}

.form-control, .form-select {
    width: 100%;
    padding: 0.75rem 1rem;
    border-radius: 10px;
    background: var(--surface);
    border: 1px solid var(--border);
    color: var(--text);
    font-family: var(--font-body);
    font-size: 0.95rem;
    transition: all var(--transition);
    box-shadow: 0 1px 2px rgba(0,0,0,0.02);
}

.form-control:focus, .form-select:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 4px var(--primary-light);
    background: #fff;
}

.form-control::placeholder {
    color: #94A3B8; /* Slate 400 */
}

/* Checkbox specific */
.check-wrap {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    margin-bottom: 1rem;
    padding: 0.5rem;
    border-radius: 8px;
    transition: background var(--transition);
}
.check-wrap:hover {
    background: var(--primary-light);
}
.check-wrap input[type="checkbox"] {
    width: 1.25rem;
    height: 1.25rem;
    accent-color: var(--primary);
    cursor: pointer;
}
.check-wrap label {
    font-weight: 500;
    cursor: pointer;
    flex: 1;
}

/* Buttons */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    padding: 0.75rem 1.5rem;
    border-radius: 10px;
    font-weight: 600;
    cursor: pointer;
    transition: all var(--transition);
    border: 1px solid transparent;
    font-family: var(--font-body);
    font-size: 0.95rem;
}

.btn-primary {
    background: linear-gradient(135deg, var(--primary), var(--secondary));
    color: #fff;
    box-shadow: 0 4px 10px rgba(2, 132, 199, 0.25);
}

.btn-primary:hover {
    background: linear-gradient(135deg, var(--secondary), var(--primary));
    transform: translateY(-2px);
    box-shadow: 0 6px 15px rgba(2, 132, 199, 0.3);
}

.btn-danger {
    background: var(--danger);
    color: white;
    box-shadow: 0 4px 10px rgba(239, 68, 68, 0.2);
}
.btn-danger:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 15px rgba(239, 68, 68, 0.3);
}

.btn-sm {
    padding: 0.4rem 0.8rem;
    font-size: 0.85rem;
    border-radius: 8px;
}

/* Table */
.table-wrapper {
    overflow-x: auto;
    border-radius: 12px;
    border: 1px solid var(--border);
    background: var(--surface);
}

table {
    width: 100%;
    border-collapse: collapse;
}

th, td {
    padding: 1.25rem 1rem;
    text-align: left;
    border-bottom: 1px solid var(--border);
}

th {
    font-weight: 600;
    color: var(--text-muted);
    font-size: 0.8rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    background: #F1F5F9; /* Slate 100 */
}

tr {
    transition: background var(--transition);
}

tr:hover {
    background: var(--primary-light);
}

td {
    color: var(--text);
    font-size: 0.95rem;
    vertical-align: middle;
}

.badge {
    padding: 0.35rem 0.75rem;
    border-radius: 9999px;
    font-size: 0.75rem;
    font-weight: 600;
    display: inline-flex;
    align-items: center;
    gap: 0.3rem;
}

.badge-green { background: #D1FAE5; color: #059669; border: 1px solid #A7F3D0; }
.badge-blue { background: #E0F2FE; color: #0369A1; border: 1px solid #BAE6FD; }
.badge-gray { background: #F1F5F9; color: #475569; border: 1px solid #E2E8F0; }

/* User Public Face */
.public-layout {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 100vh;
    padding: 2rem;
}

.form-box {
    width: 100%;
    max-width: 650px;
    padding: 3rem;
    background: var(--surface);
    border: none;
}

@media (max-width: 600px) {
    .public-layout {
        padding: 0;
    }
    .form-box {
        padding: 1.5rem 1rem;
        border-radius: 0;
        max-width: 100%;
        min-height: 100vh;
        box-shadow: none;
    }
    .form-header {
        margin-bottom: 1.5rem;
        padding-bottom: 1rem;
    }
    .form-header h1 {
        font-size: 1.75rem;
    }
}

.form-header {
    text-align: center;
    margin-bottom: 3rem;
    padding-bottom: 2rem;
    border-bottom: 2px dashed var(--border);
}

.form-header h1 {
    font-size: 2.25rem;
    color: var(--primary);
    margin-bottom: 0.5rem;
    letter-spacing: -0.5px;
}

.form-header p {
    color: var(--text-muted);
    font-size: 1.1rem;
}

/* QR Code Section */
.qr-container {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 3rem;
    text-align: center;
    background: #F8FAFC;
    border: 2px dashed #CBD5E1;
    border-radius: 16px;
    margin-top: 1rem;
}

#qrcode {
    background: white;
    padding: 1.5rem;
    border-radius: var(--radius);
    margin: 2rem 0;
    box-shadow: var(--shadow-soft);
}

.qr-pulse {
    animation: pulse 2.5s infinite ease-out;
}

@keyframes pulse {
    0% { transform: scale(1); box-shadow: 0 0 0 0 rgba(2, 132, 199, 0.4); }
    70% { transform: scale(1.02); box-shadow: 0 0 0 15px rgba(2, 132, 199, 0); }
    100% { transform: scale(1); box-shadow: 0 0 0 0 rgba(2, 132, 199, 0); }
}

/* Instructions */
.instructions-box {
    padding: 1.25rem;
    background: #F0FDF4; /* Green 50 */
    border-left: 4px solid var(--accent);
    border-radius: 8px;
    margin-bottom: 1.5rem;
    display: none;
    box-shadow: 0 2px 4px rgba(16, 185, 129, 0.05);
}

/* Loader */
.loader {
    width: 24px;
    height: 24px;
    border: 3px solid rgba(255,255,255,0.3);
    border-radius: 50%;
    border-top-color: #fff;
    animation: spin 1s ease-in-out infinite;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

@media print {
    body { background: white; color: black; }
    .no-print { display: none !important; }
    .print-only { display: block !important; }
    .card { border: none; box-shadow: none; background: white; }
    .sidebar { display: none; }
    .main-content { padding: 0; }
}

/* Camera Capture Styles */
.camera-container {
    background: var(--background);
    padding: 1.5rem;
    border-radius: var(--radius);
    border: 1px solid var(--border);
    box-shadow: inset 0 2px 4px rgba(0,0,0,0.02);
}

.camera-box {
    position: relative;
    width: 100%;
    aspect-ratio: 4/3;
    background: #1E293B; /* Deep Slate */
    border-radius: 12px;
    overflow: hidden;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    border: 2px dashed #475569;
    transition: all var(--transition);
}

.camera-box:hover {
    border-color: var(--primary);
    background: #334155;
}

.camera-overlay {
    text-align: center;
    color: #94A3B8;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 1rem;
}

.camera-overlay i {
    font-size: 3rem;
    color: var(--primary);
    opacity: 0.8;
}

.camera-overlay span {
    font-weight: 600;
    font-size: 1.1rem;
}

.camera-controls {
    display: flex;
    gap: 1rem;
}

#video, #photo-preview {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.camera-container .helper-text {
    margin-top: 0.75rem;
    font-size: 0.85rem;
    color: var(--text-muted);
}

/* Photo Zoom Modal */
.photo-modal {
    display: none;
    position: fixed;
    z-index: 1000;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(15, 23, 42, 0.8);
    backdrop-filter: blur(8px);
    align-items: center;
    justify-content: center;
}

.photo-modal-content {
    background: transparent;
    position: relative;
    width: 90%;
    height: 90%;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
}

.close-modal {
    position: absolute;
    top: -40px;
    right: 0;
    color: white;
    font-size: 40px;
    font-weight: bold;
    cursor: pointer;
}

.photo-zoom-container {
    width: 100%;
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
    cursor: grab;
}

.photo-zoom-container:active {
    cursor: grabbing;
}

.photo-zoom-container img {
    max-width: 90%;
    max-height: 90%;
    object-fit: contain;
    transition: transform 0.1s ease-out;
    border-radius: 12px;
    box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.5);
}

.photo-modal-controls {
    position: absolute;
    bottom: 2rem;
    background: rgba(255, 255, 255, 0.1);
    backdrop-filter: blur(12px);
    padding: 0.75rem;
    border-radius: 50px;
    display: flex;
    gap: 1rem;
    border: 1px solid rgba(255, 255, 255, 0.2);
}

.photo-modal-controls button {
    background: white;
    color: var(--text);
    border: none;
    width: 45px;
    height: 45px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    font-size: 1.2rem;
    transition: all var(--transition);
    box-shadow: 0 4px 6px rgba(0,0,0,0.1);
}

.photo-modal-controls button:hover {
    transform: scale(1.1);
    background: var(--primary);
    color: white;
}
