/* ==========================================================================
   OroVision Dental OPD - Central Stylesheet
   Consistent clinical theme, unified fonts, and responsive layout
   ========================================================================== */

/* 1. Global Variables & Typography */
:root {
    --primary: #1e40af;          /* Deep clinical blue */
    --primary-hover: #1d4ed8;
    --primary-focus: rgba(30, 64, 175, 0.18);
    --secondary: #0d9488;        /* Teal accent */
    --bg-color: #f8fafc;         /* Soft clinical slate background */
    --card-bg: #ffffff;
    --text-main: #0f172a;        /* High-contrast dark slate */
    --text-muted: #64748b;
    --border-color: #cbd5e1;
    --border-focus: #3b82f6;
    --danger: #dc2626;
    --danger-light: #fee2e2;
    --success: #16a34a;
    --success-light: #dcfce7;
    --font-stack: "Inter", system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;

    /* FDI Tooth Chart Condition Colors */
    --c-decayed: #ef4444;       /* Red */
    --c-missing: #94a3b8;       /* Slate Grey */
    --c-filled: #3b82f6;        /* Blue */
    --c-retained: #f97316;      /* Orange */
    --c-mobile: #eab308;        /* Yellow */
    --c-attrition: #a855f7;     /* Purple */
    --c-abrasion: #78350f;      /* Brown */
    --c-erosion: #ec4899;       /* Pink */
    --c-normal: #ffffff;        /* White */
}

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

body {
    font-family: var(--font-stack);
    background-color: var(--bg-color);
    color: var(--text-main);
    line-height: 1.5;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

/* Ensure all form controls share the exact same font family */
input, select, textarea, button, label {
    font-family: inherit;
    font-size: 14px;
}

/* 2. Top Navigation Bar */
.navbar {
    background-color: var(--primary);
    color: #ffffff;
    padding: 14px 28px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.08);
}

.navbar-brand {
    font-size: 20px;
    font-weight: 700;
    color: #ffffff;
    text-decoration: none;
    display: flex;
    align-items: center;
    gap: 8px;
}

.navbar-brand span {
    color: #93c5fd;
}

.navbar-links {
    display: flex;
    align-items: center;
    gap: 16px;
}

.navbar-links a {
    color: #e0e7ff;
    text-decoration: none;
    font-size: 14px;
    font-weight: 500;
    padding: 7px 14px;
    border-radius: 6px;
    transition: background 0.15s ease, color 0.15s ease;
}

.navbar-links a:hover {
    background-color: rgba(255, 255, 255, 0.15);
    color: #ffffff;
}

.navbar-links .btn-nav {
    background-color: #ffffff;
    color: var(--primary);
    font-weight: 600;
}

.navbar-links .btn-nav:hover {
    background-color: #eff6ff;
    color: var(--primary-hover);
}

/* 3. Main Container */
.main-container {
    max-width: 1050px;
    width: 94%;
    margin: 28px auto;
    flex: 1;
}

/* 4. Alert Banners */
.alerts-wrapper {
    margin-bottom: 20px;
}

.alert {
    padding: 12px 16px;
    border-radius: 6px;
    margin-bottom: 12px;
    font-size: 14px;
    font-weight: 500;
    border: 1px solid transparent;
}

.alert-success {
    background-color: var(--success-light);
    color: #166534;
    border-color: #bbf7d0;
}

.alert-error {
    background-color: var(--danger-light);
    color: #991b1b;
    border-color: #fecaca;
}

/* 5. Card Component & Section Headings */
.card {
    background-color: var(--card-bg);
    border: 1px solid var(--border-color);
    border-radius: 10px;
    padding: 24px;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.04);
    margin-bottom: 24px;
}

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

.section-title {
    font-size: 16px;
    font-weight: 700;
    color: var(--primary);
    margin-bottom: 18px;
    display: flex;
    align-items: center;
    gap: 8px;
    padding-bottom: 8px;
    border-bottom: 2px solid #eff6ff;
}

.section-number {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 26px;
    height: 26px;
    background-color: #dbeafe;
    color: var(--primary);
    border-radius: 50%;
    font-size: 13px;
    font-weight: 700;
}

/* 6. Form Grids & Responsive Layout */
.form-grid-2 {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 18px;
}

.form-grid-3 {
    display: grid;
    grid-template-columns: 1fr 1fr 1fr;
    gap: 16px;
}

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

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

label {
    font-size: 13px;
    font-weight: 600;
    color: var(--text-main);
    margin-bottom: 6px;
}

/* Consistent Input Styling with Clear Focus Outline */
.form-input {
    width: 100%;
    padding: 10px 14px;
    border: 1.5px solid var(--border-color);
    border-radius: 6px;
    font-size: 14px;
    color: var(--text-main);
    background-color: #ffffff;
    transition: border-color 0.15s ease, box-shadow 0.15s ease;
    outline: none;
}

.form-input:focus {
    border-color: var(--border-focus);
    box-shadow: 0 0 0 3px var(--primary-focus);
}

.form-input::placeholder {
    color: #94a3b8;
}

.help-text {
    font-size: 12px;
    color: var(--text-muted);
    margin-top: 5px;
}

.error-text {
    font-size: 12px;
    color: var(--danger);
    margin-top: 5px;
    font-weight: 600;
}

/* Checkbox and Allergies Bar */
.allergies-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
    gap: 12px;
    background-color: #fff1f2;
    border: 1.5px solid #fecdd3;
    border-radius: 8px;
    padding: 16px;
    margin-bottom: 14px;
}

.checkbox-item {
    display: flex;
    align-items: center;
    gap: 8px;
    cursor: pointer;
}

.checkbox-item input[type="checkbox"] {
    width: 18px;
    height: 18px;
    accent-color: var(--danger);
    cursor: pointer;
}

.checkbox-item label {
    margin-bottom: 0;
    cursor: pointer;
    font-weight: 500;
    color: #881337;
}

/* 7. Clickable FDI Tooth Chart (Dental Odontogram) */
.odontogram-box {
    background-color: #ffffff;
    border: 1.5px solid var(--border-color);
    border-radius: 10px;
    padding: 20px;
    margin-bottom: 16px;
}

.odontogram-legend {
    display: flex;
    flex-wrap: wrap;
    gap: 10px 18px;
    padding: 12px 16px;
    background-color: #f8fafc;
    border-radius: 8px;
    margin-bottom: 20px;
    border: 1px solid #e2e8f0;
}

.legend-item {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 12px;
    font-weight: 600;
}

.legend-swatch {
    width: 14px;
    height: 14px;
    border-radius: 3px;
    border: 1px solid rgba(0, 0, 0, 0.15);
}

.odontogram-view {
    overflow-x: auto;
    padding: 10px 0;
}

.odontogram-arch-label {
    text-align: center;
    font-size: 12px;
    font-weight: 700;
    text-transform: uppercase;
    color: var(--primary);
    margin: 8px 0 4px;
    letter-spacing: 0.5px;
}

.quadrant-headers {
    display: flex;
    justify-content: space-between;
    font-size: 11px;
    font-weight: 700;
    color: var(--text-muted);
    padding: 0 10px;
    margin-bottom: 6px;
}

.teeth-row {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 4px;
    margin-bottom: 6px;
}

.teeth-divider {
    width: 2px;
    height: 38px;
    background-color: #3b82f6;
    margin: 0 8px;
}

.arch-divider-h {
    height: 2px;
    background-color: #3b82f6;
    margin: 14px auto;
    width: 90%;
    position: relative;
}

.arch-divider-h::after {
    content: "MIDLINE (OCCLUSAL PLANE)";
    position: absolute;
    left: 50%;
    top: 50%;
    transform: translate(-50%, -50%);
    background-color: #ffffff;
    padding: 0 10px;
    font-size: 10px;
    font-weight: 700;
    color: #3b82f6;
}

.tooth-btn {
    width: 44px;
    height: 48px;
    border: 1.5px solid var(--border-color);
    border-radius: 6px;
    background-color: #ffffff;
    cursor: pointer;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    transition: transform 0.1s ease, border-color 0.15s ease, box-shadow 0.15s ease;
    user-select: none;
    padding: 2px;
}

.tooth-btn:hover {
    transform: translateY(-2px);
    border-color: var(--primary);
    box-shadow: 0 3px 6px rgba(0, 0, 0, 0.08);
}

.tooth-btn.active-selected {
    border-color: #1e40af;
    box-shadow: 0 0 0 3px rgba(30, 64, 175, 0.35);
}

.tooth-number {
    font-size: 13px;
    font-weight: 700;
    color: var(--text-main);
}

.tooth-badge {
    font-size: 9px;
    font-weight: 700;
    text-transform: uppercase;
    line-height: 1;
    margin-top: 3px;
    max-width: 40px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* Condition Modal / Floating Selector */
.condition-picker-box {
    background-color: #eff6ff;
    border: 1.5px solid #bfdbfe;
    border-radius: 8px;
    padding: 14px 18px;
    margin-top: 15px;
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
}

.condition-buttons {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}

.btn-cond {
    padding: 5px 12px;
    border-radius: 6px;
    font-size: 12px;
    font-weight: 600;
    cursor: pointer;
    border: 1.5px solid transparent;
    transition: opacity 0.15s ease;
}

.btn-cond:hover {
    opacity: 0.85;
}

/* 8. Dynamic Treatment Rendered Multi-Row Table */
.dynamic-table {
    width: 100%;
    border-collapse: collapse;
    margin-top: 10px;
}

.dynamic-table th {
    background-color: #f1f5f9;
    padding: 10px 12px;
    font-size: 12px;
    font-weight: 700;
    text-transform: uppercase;
    color: var(--text-muted);
    border: 1px solid var(--border-color);
}

.dynamic-table td {
    padding: 8px;
    border: 1px solid var(--border-color);
    vertical-align: middle;
}

.btn-remove-row {
    background-color: #fee2e2;
    color: #991b1b;
    border: 1px solid #fca5a5;
    padding: 6px 10px;
    border-radius: 4px;
    cursor: pointer;
    font-size: 12px;
    font-weight: 600;
}

.btn-remove-row:hover {
    background-color: #fecaca;
}

/* 9. Buttons & General Utility */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 10px 20px;
    border-radius: 6px;
    font-size: 14px;
    font-weight: 600;
    text-decoration: none;
    cursor: pointer;
    border: none;
    transition: background 0.15s ease, box-shadow 0.15s ease;
}

.btn-primary {
    background-color: var(--primary);
    color: #ffffff;
}

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

.btn-secondary {
    background-color: #e2e8f0;
    color: var(--text-main);
}

.btn-secondary:hover {
    background-color: #cbd5e1;
}

.btn-sm {
    padding: 6px 12px;
    font-size: 12px;
}

.form-actions {
    display: flex;
    justify-content: flex-end;
    gap: 14px;
    margin-top: 24px;
}

/* 10. Footer */
footer {
    text-align: center;
    padding: 20px;
    font-size: 13px;
    color: var(--text-muted);
    border-top: 1px solid var(--border-color);
    background-color: #ffffff;
}

/* 11. Mobile Responsiveness */
@media (max-width: 768px) {
    .navbar {
        padding: 12px 16px;
        flex-direction: column;
        gap: 10px;
        text-align: center;
    }

    .main-container {
        width: 95%;
        margin: 16px auto;
    }

    .card {
        padding: 18px 14px;
    }

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

    .form-actions {
        flex-direction: column-reverse;
    }

    .form-actions .btn {
        width: 100%;
    }
}
