/* ===== VARIABLES ===== */
:root {
    --primary: #137fec;
    --primary-dark: #0f6dcf;
    --primary-light: #e8f3fd;
    --accent: #7c3aed;
    --success: #10b981;
    --warning: #f59e0b;
    --danger: #ef4444;
    --bg: #f0f4f8;
    --bg-card: #ffffff;
    --text: #0f172a;
    --text-muted: #64748b;
    --border: #e2e8f0;
    --radius: 12px;
    --radius-lg: 18px;
    --shadow: 0 4px 20px rgba(0, 0, 0, 0.07);
    --shadow-lg: 0 10px 40px rgba(0, 0, 0, 0.12);
    --font: 'Inter', sans-serif;
}

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

html {
    font-size: 15px;
}

body {
    font-family: var(--font);
    background: var(--bg);
    color: var(--text);
    min-height: 100vh;
}

/* ===== SPLASH ===== */
.splash {
    position: fixed;
    inset: 0;
    z-index: 9999;
    background: radial-gradient(circle at center, #1e3a5f, #0a1628);
    display: flex;
    align-items: center;
    justify-content: center;
    transition: opacity 0.6s ease;
}

.splash.hidden {
    opacity: 0;
    pointer-events: none;
}

.splash-inner {
    text-align: center;
}

.splash-logo-img {
    width: 140px;
    height: 140px;
    object-fit: contain;
    border-radius: 50%;
    border: 4px solid rgba(255, 255, 255, 0.2);
    box-shadow: 0 0 40px rgba(19, 127, 236, 0.5), 0 0 80px rgba(19, 127, 236, 0.2);
    margin-bottom: 1.2rem;
    animation: pulse 2.5s ease-in-out infinite;
    background: white;
    padding: 8px;
}

.splash-title {
    font-family: 'Montserrat', sans-serif;
    font-size: 2rem;
    font-weight: 900;
    color: white;
    letter-spacing: 1px;
}

.splash-sub {
    font-size: 0.9rem;
    color: rgba(255, 255, 255, 0.6);
    margin: 6px 0 28px;
    letter-spacing: 2px;
    text-transform: uppercase;
}

.splash-bar {
    width: 200px;
    height: 4px;
    background: rgba(255, 255, 255, 0.1);
    border-radius: 99px;
    overflow: hidden;
    margin: 0 auto 16px;
}

.splash-bar-fill {
    width: 40%;
    height: 100%;
    background: var(--primary);
    border-radius: 99px;
    animation: progress 1.5s infinite ease-in-out;
}

.splash-powered {
    font-size: 0.7rem;
    color: rgba(255, 255, 255, 0.35);
    text-transform: uppercase;
    letter-spacing: 2px;
}

.splash-powered strong {
    color: rgba(255, 255, 255, 0.7);
}

@keyframes pulse {

    0%,
    100% {
        transform: scale(1);
    }

    50% {
        transform: scale(1.08);
    }
}

@keyframes progress {
    0% {
        transform: translateX(-100%);
        width: 30%;
    }

    50% {
        width: 60%;
    }

    100% {
        transform: translateX(350%);
        width: 30%;
    }
}

/* ===== HEADER ===== */
.header {
    background: linear-gradient(135deg, #0f2744 0%, #1a3d6e 100%);
    padding: 0 24px;
    height: 64px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    position: sticky;
    top: 0;
    z-index: 100;
    box-shadow: 0 2px 20px rgba(0, 0, 0, 0.25);
}

.header-brand {
    display: flex;
    align-items: center;
    gap: 12px;
}

.header-logo {
    width: 46px;
    height: 46px;
    object-fit: contain;
    border-radius: 50%;
    border: 2px solid rgba(255, 255, 255, 0.3);
    background: white;
    padding: 3px;
    box-shadow: 0 2px 12px rgba(0, 0, 0, 0.3);
    flex-shrink: 0;
}

.header-title {
    font-family: 'Montserrat', sans-serif;
    font-size: 1.1rem;
    font-weight: 900;
    color: white;
    line-height: 1;
}

.header-sub {
    font-size: 0.7rem;
    color: rgba(255, 255, 255, 0.5);
    text-transform: uppercase;
    letter-spacing: 1.5px;
    margin-top: 2px;
}

.header-actions {
    display: flex;
    align-items: center;
    gap: 12px;
}

.search-box {
    display: flex;
    align-items: center;
    gap: 8px;
    background: rgba(255, 255, 255, 0.1);
    border: 1px solid rgba(255, 255, 255, 0.15);
    border-radius: 99px;
    padding: 8px 16px;
    backdrop-filter: blur(8px);
}

.search-box .material-symbols-outlined {
    color: rgba(255, 255, 255, 0.5);
    font-size: 1.1rem;
}

.search-box input {
    background: none;
    border: none;
    outline: none;
    color: white;
    font-size: 0.875rem;
    width: 200px;
    font-family: var(--font);
}

.search-box input::placeholder {
    color: rgba(255, 255, 255, 0.4);
}

/* ===== BUTTONS ===== */
.btn-primary {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    background: var(--primary);
    color: white;
    border: none;
    border-radius: 10px;
    padding: 10px 18px;
    font-size: 0.875rem;
    font-weight: 700;
    cursor: pointer;
    transition: all 0.2s;
    font-family: var(--font);
}

.btn-primary:hover {
    background: var(--primary-dark);
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(19, 127, 236, 0.4);
}

.btn-primary .material-symbols-outlined {
    font-size: 1.1rem;
}

.btn-secondary {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    background: #f1f5f9;
    color: #475569;
    border: 1px solid var(--border);
    border-radius: 10px;
    padding: 10px 18px;
    font-size: 0.875rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
    font-family: var(--font);
}

.btn-secondary:hover {
    background: #e2e8f0;
}

.btn-outline {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    background: transparent;
    color: var(--primary);
    border: 2px solid var(--primary);
    border-radius: 10px;
    padding: 10px 18px;
    font-size: 0.875rem;
    font-weight: 700;
    cursor: pointer;
    transition: all 0.2s;
    font-family: var(--font);
}

.btn-outline:hover {
    background: var(--primary-light);
}

.btn-outline .material-symbols-outlined {
    font-size: 1.1rem;
}

.btn-close {
    background: rgba(0, 0, 0, 0.08);
    border: none;
    border-radius: 50%;
    width: 34px;
    height: 34px;
    cursor: pointer;
    font-size: 1rem;
    color: var(--text-muted);
    transition: all 0.2s;
    display: flex;
    align-items: center;
    justify-content: center;
}

.btn-close:hover {
    background: rgba(0, 0, 0, 0.15);
}

/* ===== MAIN ===== */
.main {
    max-width: 1300px;
    margin: 0 auto;
    padding: 24px 20px 80px;
}

/* ===== STATS ===== */
.stats-row {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 16px;
    margin-bottom: 24px;
}

.stat-card {
    background: var(--bg-card);
    border-radius: var(--radius-lg);
    padding: 20px 24px;
    box-shadow: var(--shadow);
    display: flex;
    align-items: center;
    gap: 16px;
    border: 1px solid var(--border);
    transition: transform 0.2s;
}

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

.stat-icon {
    font-size: 2.2rem !important;
    padding: 12px;
    border-radius: 12px;
}

.stat-icon.blue {
    color: var(--primary);
    background: #dbeafe;
}

.stat-icon.green {
    color: var(--success);
    background: #d1fae5;
}

.stat-icon.purple {
    color: var(--accent);
    background: #ede9fe;
}

.stat-value {
    font-size: 2rem;
    font-weight: 800;
    color: var(--text);
    line-height: 1;
}

.stat-label {
    font-size: 0.8rem;
    color: var(--text-muted);
    font-weight: 500;
    margin-top: 4px;
}

/* ===== TABLE CARD ===== */
.table-card {
    background: var(--bg-card);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow);
    border: 1px solid var(--border);
    overflow: hidden;
}

.table-header {
    padding: 20px 24px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    border-bottom: 1px solid var(--border);
}

.table-title {
    font-size: 1.1rem;
    font-weight: 700;
    color: var(--text);
}

.table-filters select {
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 8px 12px;
    font-size: 0.85rem;
    color: var(--text);
    font-family: var(--font);
    background: white;
    cursor: pointer;
}

.table-wrap {
    overflow-x: auto;
}

.data-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.875rem;
}

.data-table thead tr {
    background: #f8fafc;
}

.data-table th {
    padding: 12px 16px;
    text-align: left;
    font-weight: 700;
    font-size: 0.78rem;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: var(--text-muted);
    border-bottom: 1px solid var(--border);
    white-space: nowrap;
}

.data-table td {
    padding: 14px 16px;
    border-bottom: 1px solid #f1f5f9;
    vertical-align: middle;
}

.data-table tbody tr:hover {
    background: #f8fafc;
}

.data-table tbody tr:last-child td {
    border-bottom: none;
}

.patient-name {
    font-weight: 700;
    color: var(--text);
}

.patient-phone {
    font-size: 0.8rem;
    color: var(--text-muted);
    margin-top: 2px;
}

.badge {
    display: inline-flex;
    align-items: center;
    padding: 4px 10px;
    border-radius: 99px;
    font-size: 0.75rem;
    font-weight: 700;
}

.badge-blue {
    background: #dbeafe;
    color: #1d4ed8;
}

.badge-purple {
    background: #ede9fe;
    color: #6d28d9;
}

.badge-green {
    background: #d1fae5;
    color: #065f46;
}

.badge-yellow {
    background: #fef3c7;
    color: #92400e;
}

.badge-pink {
    background: #fce7f3;
    color: #9d174d;
}

.rx-cell {
    font-family: monospace;
    font-size: 0.8rem;
    color: var(--text-muted);
}

.rx-cell span {
    color: var(--text);
    font-weight: 600;
}

.action-btns {
    display: flex;
    gap: 6px;
}

.btn-icon {
    width: 32px;
    height: 32px;
    border-radius: 8px;
    border: none;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.2s;
    font-size: 0.9rem;
}

.btn-icon.view {
    background: #e0f2fe;
    color: #0369a1;
}

.btn-icon.view:hover {
    background: #bae6fd;
}

.btn-icon.edit {
    background: #fef3c7;
    color: #92400e;
}

.btn-icon.edit:hover {
    background: #fde68a;
}

.btn-icon.del {
    background: #fee2e2;
    color: #991b1b;
}

.btn-icon.del:hover {
    background: #fca5a5;
}

.btn-icon .material-symbols-outlined {
    font-size: 1rem;
}

.empty-state {
    padding: 60px 20px;
    text-align: center;
}

.empty-state .material-symbols-outlined {
    font-size: 3.5rem;
    color: #cbd5e1;
    display: block;
    margin-bottom: 12px;
}

.empty-state p {
    color: var(--text-muted);
    margin-bottom: 20px;
    font-size: 0.95rem;
}

/* ===== MODAL ===== */
.modal-overlay {
    position: fixed;
    inset: 0;
    z-index: 500;
    background: rgba(10, 22, 40, 0.6);
    backdrop-filter: blur(4px);
    display: none;
    align-items: flex-start;
    justify-content: center;
    padding: 20px 16px;
    overflow-y: auto;
}

.modal-overlay.open {
    display: flex;
}

.modal-box {
    background: white;
    border-radius: var(--radius-lg);
    width: 100%;
    max-width: 780px;
    box-shadow: var(--shadow-lg);
    animation: slideIn 0.3s ease;
    margin: auto 0;
}

.modal-box-view {
    max-width: 700px;
}

@keyframes slideIn {
    from {
        opacity: 0;
        transform: translateY(-20px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.modal-header {
    padding: 20px 24px;
    background: linear-gradient(135deg, #0f2744, #1a3d6e);
    border-radius: var(--radius-lg) var(--radius-lg) 0 0;
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.modal-title-row {
    display: flex;
    align-items: center;
    gap: 12px;
}

.modal-icon {
    font-size: 1.8rem;
}

.modal-title {
    font-weight: 800;
    font-size: 1.1rem;
    color: white;
}

.modal-sub {
    font-size: 0.75rem;
    color: rgba(255, 255, 255, 0.55);
    margin-top: 2px;
}

.modal-header .btn-close {
    color: white;
    background: rgba(255, 255, 255, 0.15);
}

.modal-header .btn-close:hover {
    background: rgba(255, 255, 255, 0.25);
}

/* FORM SECTIONS */
.form-section {
    padding: 20px 24px;
    border-bottom: 1px solid var(--border);
}

.section-label {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 0.8rem;
    font-weight: 800;
    text-transform: uppercase;
    letter-spacing: 0.8px;
    color: var(--primary);
    margin-bottom: 16px;
}

.section-label .material-symbols-outlined {
    font-size: 1.1rem;
}

.form-grid-2 {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 14px;
}

.form-group {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.form-group.full {
    grid-column: 1 / -1;
}

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

.form-group input,
.form-group select,
.form-group textarea {
    border: 1.5px solid var(--border);
    border-radius: 8px;
    padding: 10px 12px;
    font-size: 0.875rem;
    font-family: var(--font);
    color: var(--text);
    transition: border-color 0.2s;
    background: white;
}

.form-group input:focus,
.form-group select:focus,
.form-group textarea:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(19, 127, 236, 0.1);
}

.form-group textarea {
    resize: vertical;
}

/* RX TABLE */
.rx-table-wrap {
    overflow-x: auto;
}

.rx-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.85rem;
}

.rx-table th {
    background: #f8fafc;
    padding: 8px 10px;
    text-align: center;
    font-weight: 700;
    font-size: 0.75rem;
    text-transform: uppercase;
    color: var(--text-muted);
    border: 1px solid var(--border);
}

.rx-table td {
    border: 1px solid var(--border);
    padding: 4px 6px;
}

.rx-table input {
    border: none;
    border-radius: 6px;
    padding: 8px;
    font-size: 0.85rem;
    text-align: center;
    width: 100%;
    font-family: monospace;
    background: #f8fafc;
    color: var(--text);
    transition: background 0.15s;
}

.rx-table input:focus {
    outline: none;
    background: #e8f3fd;
}

.eye-label {
    font-weight: 800;
    font-size: 0.85rem;
    padding: 10px 14px !important;
    text-align: center;
    white-space: nowrap;
}

.eye-label.od {
    background: #dbeafe;
    color: #1d4ed8;
}

.eye-label.oi {
    background: #d1fae5;
    color: #065f46;
}

.modal-footer {
    padding: 16px 24px;
    display: flex;
    align-items: center;
    justify-content: flex-end;
    gap: 10px;
    border-top: 1px solid var(--border);
}

/* VIEW CONTENT */
.view-content {
    padding: 24px;
}

.view-section {
    margin-bottom: 20px;
}

.view-section-title {
    font-size: 0.75rem;
    font-weight: 800;
    text-transform: uppercase;
    letter-spacing: 1px;
    color: var(--primary);
    margin-bottom: 12px;
    display: flex;
    align-items: center;
    gap: 6px;
}

.view-rx-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.85rem;
    margin-bottom: 12px;
}

.view-rx-table th {
    background: #f8fafc;
    padding: 8px 12px;
    text-align: center;
    font-weight: 700;
    font-size: 0.75rem;
    text-transform: uppercase;
    color: var(--text-muted);
    border: 1px solid var(--border);
}

.view-rx-table td {
    border: 1px solid var(--border);
    padding: 10px 12px;
    text-align: center;
    font-family: monospace;
    font-weight: 600;
}

.view-rx-table .eye-label {
    text-align: center;
}

.view-info-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 12px;
}

.view-info-item label {
    font-size: 0.75rem;
    color: var(--text-muted);
    font-weight: 600;
    display: block;
    margin-bottom: 3px;
}

.view-info-item span {
    font-size: 0.95rem;
    font-weight: 600;
    color: var(--text);
}

.view-notes {
    background: #f8fafc;
    border-radius: 10px;
    padding: 14px;
    font-size: 0.9rem;
    color: var(--text);
    line-height: 1.7;
    white-space: pre-wrap;
}

/* ===== FOOTER ===== */
.footer {
    text-align: center;
    padding: 16px;
    font-size: 0.75rem;
    color: #94a3b8;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 20px;
    border-top: 1px solid var(--border);
    background: white;
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
}

.footer-diotrix {
    font-size: 0.7rem;
    text-transform: uppercase;
    letter-spacing: 1.5px;
}

.footer-diotrix strong {
    color: var(--primary);
}

/* ===== PRINT ===== */
.print-only {
    display: none;
}

@media print {
    @page {
        size: auto;
        margin: 0.4cm !important;
    }

    body>*:not(#print-area) {
        display: none !important;
    }

    #print-area {
        display: block !important;
    }

    .print-area {
        font-family: 'Inter', sans-serif;
        padding: 20px;
        max-width: 700px;
        margin: 0 auto;
    }

    .print-header {
        text-align: center;
        margin-bottom: 20px;
        border-bottom: 2px solid #0f2744;
        padding-bottom: 12px;
    }

    .print-header h1 {
        font-size: 1.4rem;
        font-weight: 900;
        color: #0f2744;
    }

    .print-header p {
        font-size: 0.8rem;
        color: #64748b;
    }

    .print-section {
        margin-bottom: 18px;
    }

    .print-section h3 {
        font-size: 0.8rem;
        font-weight: 800;
        text-transform: uppercase;
        letter-spacing: 1px;
        color: #137fec;
        margin-bottom: 8px;
        border-bottom: 1px solid #e2e8f0;
        padding-bottom: 4px;
    }

    .print-table {
        width: 100%;
        border-collapse: collapse;
        font-size: 0.8rem;
    }

    .print-table th,
    .print-table td {
        border: 1px solid #e2e8f0;
        padding: 6px 10px;
        text-align: center;
    }

    .print-table th {
        background: #f8fafc;
        font-weight: 700;
    }

    .print-eye-od {
        background: #dbeafe;
        color: #1d4ed8;
        font-weight: 800;
    }

    .print-eye-oi {
        background: #d1fae5;
        color: #065f46;
        font-weight: 800;
    }

    .print-info {
        display: grid;
        grid-template-columns: 1fr 1fr;
        gap: 8px;
        font-size: 0.85rem;
    }

    .print-info-item label {
        font-weight: 700;
        color: #64748b;
    }

    .print-footer {
        margin-top: 40px;
        text-align: center;
        font-size: 0.7rem;
        color: #94a3b8;
        border-top: 1px solid #e2e8f0;
        padding-top: 10px;
    }

    .print-firma {
        margin-top: 30px;
        display: flex;
        justify-content: flex-end;
    }

    .print-firma-box {
        width: 200px;
        border-top: 1px solid #333;
        text-align: center;
        padding-top: 6px;
        font-size: 0.78rem;
        color: #475569;
    }
}

/* ===== RESPONSIVE ===== */
@media (max-width: 768px) {
    .stats-row {
        grid-template-columns: 1fr;
    }

    .header {
        padding: 0 14px;
    }

    .search-box input {
        width: 130px;
    }

    .form-grid-2 {
        grid-template-columns: 1fr;
    }

    .view-info-grid {
        grid-template-columns: 1fr;
    }

    .main {
        padding: 16px 12px 80px;
    }
}