:root {
    --bg-dark: #0f172a;
    --bg-card: rgba(30, 41, 59, 0.7);
    --bg-card-hover: rgba(51, 65, 85, 0.8);
    --border-color: rgba(255, 255, 255, 0.1);
    --primary-gradient: linear-gradient(135deg, #3b82f6 0%, #1d4ed8 100%);
    --accent-teal: #14b8a6;
    --accent-emerald: #10b981;
    --accent-amber: #f59e0b;
    --accent-rose: #f43f5e;
    --text-primary: #f8fafc;
    --text-secondary: #94a3b8;
    --sidebar-width: 260px;
}

* {
    box-sizing: border-box;
}

body, html {
    font-family: 'Roboto', system-ui, sans-serif;
    background-color: var(--bg-dark);
    background-image: 
        radial-gradient(at 0% 0%, rgba(59, 130, 246, 0.15) 0px, transparent 50%),
        radial-gradient(at 100% 100%, rgba(20, 184, 166, 0.15) 0px, transparent 50%);
    color: var(--text-primary);
    min-height: 100vh;
    margin: 0;
    padding: 0;
}

h1:focus, h2:focus, h3:focus, h4:focus {
    outline: none !important;
}

/* App Container Layout */
.app-container {
    display: flex;
    flex-direction: column;
    min-height: 100vh;
    width: 100vw;
    overflow-x: hidden;
}

/* Glassmorphism Header */
.app-header {
    background: rgba(15, 23, 42, 0.9);
    backdrop-filter: blur(12px);
    border-bottom: 1px solid var(--border-color);
    height: 70px;
    min-height: 70px;
    width: 100%;
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 2rem;
    position: sticky;
    top: 0;
    z-index: 100;
}

.brand-badge {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    font-weight: 800;
    font-size: 1.25rem;
    background: linear-gradient(135deg, #60a5fa, #34d399);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
}

/* Main Body with Sidebar + Content Side-by-Side */
.app-body {
    display: flex !important;
    flex-direction: row !important;
    flex-wrap: nowrap !important;
    align-items: stretch !important;
    flex: 1 1 auto;
    width: 100%;
    min-height: calc(100vh - 70px);
}

.app-sidebar {
    width: 260px !important;
    min-width: 260px !important;
    max-width: 260px !important;
    flex-shrink: 0 !important;
    background: rgba(30, 41, 59, 0.5);
    backdrop-filter: blur(10px);
    border-right: 1px solid var(--border-color);
    padding: 1.5rem 1rem;
    display: flex;
    flex-direction: column;
}

.nav-item-custom {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.85rem 1rem;
    color: var(--text-secondary);
    border-radius: 10px;
    text-decoration: none;
    font-weight: 500;
    transition: all 0.2s ease;
}

.nav-item-custom:hover, .nav-item-custom.active {
    background: var(--primary-gradient);
    color: #ffffff;
    box-shadow: 0 4px 15px rgba(59, 130, 246, 0.4);
}

/* Main Content Area */
.app-content {
    flex: 1 1 auto !important;
    min-width: 0 !important;
    padding: 2rem;
    overflow-y: auto;
}

/* Cards */
.glass-card {
    background: var(--bg-card);
    backdrop-filter: blur(16px);
    border: 1px solid var(--border-color);
    border-radius: 16px;
    padding: 1.75rem;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.3);
    margin-bottom: 1.5rem;
}

.glass-card-header {
    font-size: 1.25rem;
    font-weight: 700;
    margin-bottom: 1.25rem;
    display: flex;
    align-items: center;
    justify-content: space-between;
}

/* Metric Badges & Status */
.status-pill {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.35rem 0.85rem;
    border-radius: 20px;
    font-size: 0.85rem;
    font-weight: 600;
}

.status-synced {
    background: rgba(16, 185, 129, 0.15);
    color: #34d399;
    border: 1px solid rgba(16, 185, 129, 0.3);
}

.status-pending {
    background: rgba(245, 158, 11, 0.15);
    color: #fbbf24;
    border: 1px solid rgba(245, 158, 11, 0.3);
}

.status-failed {
    background: rgba(244, 63, 94, 0.15);
    color: #f87171;
    border: 1px solid rgba(244, 63, 94, 0.3);
}

/* Form Controls */
.form-label-custom {
    font-size: 0.875rem;
    font-weight: 600;
    color: var(--text-secondary);
    margin-bottom: 0.5rem;
    display: block;
}

.form-control-custom {
    width: 100%;
    background: rgba(15, 23, 42, 0.8);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    padding: 0.75rem 1rem;
    color: var(--text-primary);
    font-family: inherit;
    transition: all 0.2s ease;
}

.form-control-custom:focus {
    outline: none;
    border-color: #60a5fa;
    box-shadow: 0 0 0 3px rgba(96, 165, 250, 0.25);
}

.btn-primary-custom {
    background: var(--primary-gradient);
    color: #ffffff;
    border: none;
    border-radius: 10px;
    padding: 0.75rem 1.5rem;
    font-weight: 700;
    cursor: pointer;
    transition: all 0.2s ease;
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    text-decoration: none;
}

.btn-primary-custom:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(59, 130, 246, 0.4);
    color: #ffffff;
}

/* Blazor Error UI Toast (Hidden by default unless exception occurs) */
#blazor-error-ui {
    background: rgba(244, 63, 94, 0.95) !important;
    backdrop-filter: blur(8px);
    color: #ffffff !important;
    bottom: 0;
    box-shadow: 0 -4px 20px rgba(0, 0, 0, 0.4);
    display: none !important;
    left: 0;
    padding: 0.75rem 1.5rem;
    position: fixed;
    width: 100%;
    z-index: 10000;
    font-size: 0.9rem;
    font-weight: 600;
}

#blazor-error-ui .dismiss {
    cursor: pointer;
    position: absolute;
    right: 1rem;
    top: 0.75rem;
    color: #ffffff;
}

/* ===================== Module 4: Visit Forms ===================== */
.visit-stepper {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 0.75rem;
    margin-bottom: 1.5rem;
}

.visit-step {
    position: relative;
    text-align: left;
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: 14px;
    padding: 1rem 1.1rem;
    color: var(--text-primary);
    font-family: inherit;
    cursor: pointer;
    transition: all 0.2s ease;
    min-height: 92px;
}

.visit-step:hover:not(:disabled) { background: var(--bg-card-hover); transform: translateY(-2px); }
.visit-step:disabled { cursor: not-allowed; opacity: 0.55; }
.visit-step.active { border-color: #60a5fa; box-shadow: 0 0 0 3px rgba(96, 165, 250, 0.25); }

.visit-step-index {
    display: inline-flex; align-items: center; justify-content: center;
    width: 28px; height: 28px; border-radius: 50%;
    font-weight: 800; font-size: 0.85rem; margin-right: 0.5rem;
    background: rgba(148, 163, 184, 0.2); color: var(--text-secondary);
}
.visit-step.st-Completed .visit-step-index { background: var(--accent-emerald); color: #fff; }
.visit-step.st-Overdue .visit-step-index { background: var(--accent-rose); color: #fff; }
.visit-step.st-Due .visit-step-index { background: #3b82f6; color: #fff; }

.visit-step-title { font-weight: 800; font-size: 1.05rem; }
.visit-step-meta { font-size: 0.78rem; color: var(--text-secondary); margin-top: 0.45rem; }

.visit-badge { font-size: 0.72rem; padding: 0.15rem 0.6rem; border-radius: 20px; font-weight: 700; float: right; }
.visit-badge.Completed { background: rgba(16, 185, 129, 0.15); color: #34d399; }
.visit-badge.Due { background: rgba(59, 130, 246, 0.18); color: #93c5fd; }
.visit-badge.Upcoming { background: rgba(148, 163, 184, 0.18); color: #cbd5e1; }
.visit-badge.Overdue { background: rgba(244, 63, 94, 0.18); color: #fda4af; animation: pulse-soft 2s infinite; }
.visit-badge.Locked { background: rgba(148, 163, 184, 0.12); color: #94a3b8; }

@keyframes pulse-soft { 0%, 100% { opacity: 1; } 50% { opacity: 0.6; } }

.visit-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 1rem 1.25rem;
    margin-bottom: 1.25rem;
}

.visit-section-title {
    font-weight: 700; font-size: 1rem; color: #60a5fa;
    border-bottom: 1px solid var(--border-color);
    padding-bottom: 0.5rem; margin: 0.5rem 0 1rem;
}

.visit-form .form-control-custom { font-size: 1.05rem; min-height: 48px; }
.visit-form .validation-message { color: #fda4af; font-size: 0.78rem; margin-top: 0.3rem; }
.visit-form .invalid { border-color: rgba(244, 63, 94, 0.7) !important; }
.input-suffix { position: relative; }
.input-suffix span { position: absolute; right: 0.9rem; top: 50%; transform: translateY(-50%); color: var(--text-secondary); font-size: 0.85rem; pointer-events: none; }

.nyha-group { display: grid; grid-template-columns: repeat(4, 1fr); gap: 0.5rem; }
.nyha-option {
    border: 1px solid var(--border-color); border-radius: 10px; min-height: 48px;
    background: rgba(15, 23, 42, 0.8); color: var(--text-primary); font-weight: 700;
    cursor: pointer; font-family: inherit; transition: all 0.15s ease;
}
.nyha-option.selected { background: var(--primary-gradient); border-color: #60a5fa; }
.nyha-option:disabled { cursor: not-allowed; opacity: 0.6; }

.lvef-na {
    display: flex; align-items: center; min-height: 48px; padding: 0 1rem;
    border: 1px dashed var(--border-color); border-radius: 8px;
    color: var(--text-secondary); font-style: italic;
}

.alert-custom { padding: 0.85rem 1rem; border-radius: 10px; margin-bottom: 1.25rem; font-size: 0.9rem; }
.alert-custom.error { background: rgba(244, 63, 94, 0.15); border: 1px solid rgba(244, 63, 94, 0.4); color: #fda4af; }
.alert-custom.success { background: rgba(16, 185, 129, 0.15); border: 1px solid rgba(16, 185, 129, 0.4); color: #6ee7b7; }
.alert-custom.info { background: rgba(59, 130, 246, 0.12); border: 1px solid rgba(59, 130, 246, 0.35); color: #93c5fd; }

@media (max-width: 768px) {
    .visit-stepper { grid-template-columns: 1fr; }
    .nyha-group { grid-template-columns: repeat(2, 1fr); }
    .gdmt-pillars-grid { grid-template-columns: 1fr; }
}

/* Module 5 – GDMT Section */
.gdmt-section {
    margin-top: 1.75rem;
    padding-top: 1.25rem;
    border-top: 1px solid var(--border-color);
}

.gdmt-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 0.75rem;
    margin-bottom: 1.15rem;
}

.gdmt-counter-wrap {
    display: flex;
    align-items: center;
    gap: 0.65rem;
    flex-wrap: wrap;
}

.gdmt-counter {
    display: inline-flex;
    align-items: center;
    gap: 0.55rem;
    padding: 0.45rem 0.9rem;
    border-radius: 999px;
    font-size: 0.92rem;
    border: 1px solid var(--border-color);
    background: rgba(15, 23, 42, 0.75);
}

.gdmt-counter.complete {
    background: rgba(16, 185, 129, 0.18);
    border-color: rgba(16, 185, 129, 0.45);
    color: #6ee7b7;
}

.gdmt-counter.partial {
    background: rgba(59, 130, 246, 0.16);
    border-color: rgba(96, 165, 250, 0.4);
    color: #93c5fd;
}

.gdmt-counter.none {
    color: var(--text-secondary);
}

.gdmt-counter-value {
    font-size: 1.05rem;
    font-weight: 800;
}

.gdmt-dots {
    display: inline-flex;
    gap: 0.28rem;
    margin-left: 0.15rem;
}

.gdmt-dot {
    width: 9px;
    height: 9px;
    border-radius: 50%;
    background: rgba(148, 163, 184, 0.3);
}

.gdmt-dot.on {
    background: #10b981;
    box-shadow: 0 0 6px rgba(16, 185, 129, 0.6);
}

.btn-gdmt-save {
    min-height: 40px;
    padding: 0.45rem 0.95rem;
    border-radius: 10px;
    border: 1px solid rgba(16, 185, 129, 0.45);
    background: rgba(16, 185, 129, 0.16);
    color: #6ee7b7;
    font-weight: 700;
    font-family: inherit;
    font-size: 0.85rem;
    cursor: pointer;
    transition: all 0.15s ease;
}

.btn-gdmt-save:hover:not(:disabled) {
    background: rgba(16, 185, 129, 0.26);
}

.btn-gdmt-save:disabled {
    opacity: 0.6;
    cursor: not-allowed;
}

.gdmt-pillars-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 1rem;
    margin-bottom: 1.25rem;
}

.gdmt-pillar-card {
    border: 1px solid var(--border-color);
    border-radius: 12px;
    padding: 1rem 1.1rem;
    background: rgba(15, 23, 42, 0.55);
    transition: border-color 0.15s ease, background 0.15s ease;
}

.gdmt-pillar-card.active {
    border-color: rgba(16, 185, 129, 0.45);
    background: rgba(16, 185, 129, 0.06);
}

.gdmt-pillar-top {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: 0.75rem;
}

.gdmt-pillar-num {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 28px;
    height: 28px;
    border-radius: 50%;
    font-weight: 800;
    font-size: 0.85rem;
    flex-shrink: 0;
    background: rgba(148, 163, 184, 0.2);
    color: var(--text-secondary);
}

.gdmt-pillar-card.active .gdmt-pillar-num {
    background: var(--accent-emerald);
    color: #fff;
}

.gdmt-pillar-title {
    font-weight: 800;
    font-size: 0.98rem;
    color: var(--text-primary);
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 0.4rem;
}

.gdmt-first-badge {
    font-size: 0.68rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.03em;
    padding: 0.12rem 0.45rem;
    border-radius: 999px;
    background: rgba(59, 130, 246, 0.2);
    border: 1px solid rgba(96, 165, 250, 0.4);
    color: #93c5fd;
}

.gdmt-pillar-sub {
    font-size: 0.75rem;
    color: var(--text-secondary);
    margin-top: 0.15rem;
}

.gdmt-toggle {
    display: inline-grid;
    grid-template-columns: 1fr 1fr;
    border: 1px solid var(--border-color);
    border-radius: 10px;
    overflow: hidden;
    flex-shrink: 0;
    background: rgba(15, 23, 42, 0.8);
}

.gdmt-toggle-btn {
    border: 0;
    min-width: 52px;
    min-height: 40px;
    padding: 0.35rem 0.75rem;
    background: transparent;
    color: var(--text-secondary);
    font-family: inherit;
    font-weight: 700;
    font-size: 0.85rem;
    cursor: pointer;
    transition: all 0.15s ease;
}

.gdmt-toggle-btn.yes {
    background: var(--accent-emerald);
    color: #fff;
}

.gdmt-toggle-btn.no {
    background: rgba(148, 163, 184, 0.25);
    color: #f8fafc;
}

.gdmt-pillar-fields {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 0.85rem;
    margin-top: 0.9rem;
    padding-top: 0.85rem;
    border-top: 1px solid rgba(148, 163, 184, 0.15);
}

@media (max-width: 560px) {
    .gdmt-pillar-fields { grid-template-columns: 1fr; }
}

.gdmt-chips {
    display: flex;
    flex-wrap: wrap;
    gap: 0.35rem;
    margin-top: 0.4rem;
}

.gdmt-chip {
    border: 1px solid var(--border-color);
    border-radius: 999px;
    padding: 0.2rem 0.6rem;
    font-size: 0.74rem;
    font-family: inherit;
    background: rgba(15, 23, 42, 0.7);
    color: var(--text-secondary);
    cursor: pointer;
    transition: all 0.12s ease;
}

.gdmt-chip:hover:not(:disabled) {
    border-color: #60a5fa;
    color: #f8fafc;
}

.gdmt-chip.selected {
    background: rgba(59, 130, 246, 0.22);
    border-color: #60a5fa;
    color: #93c5fd;
    font-weight: 700;
}

.gdmt-inactive-note {
    margin-top: 0.75rem;
    padding-top: 0.65rem;
    border-top: 1px dashed rgba(148, 163, 184, 0.15);
    font-size: 0.78rem;
    color: var(--text-secondary);
}

.gdmt-reasons-box {
    border: 1px solid var(--border-color);
    border-radius: 12px;
    padding: 1rem 1.15rem;
    background: rgba(15, 23, 42, 0.45);
}

.gdmt-reasons-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(185px, 1fr));
    gap: 0.55rem;
}

.gdmt-reason-option {
    display: flex;
    align-items: center;
    gap: 0.55rem;
    min-height: 44px;
    padding: 0.45rem 0.75rem;
    border: 1px solid var(--border-color);
    border-radius: 10px;
    background: rgba(15, 23, 42, 0.65);
    font-size: 0.86rem;
    cursor: pointer;
    user-select: none;
    transition: all 0.12s ease;
}

.gdmt-reason-option.checked {
    border-color: rgba(96, 165, 250, 0.55);
    background: rgba(59, 130, 246, 0.15);
    color: #f8fafc;
    font-weight: 600;
}

.gdmt-reason-option input[type="checkbox"] {
    width: 1.1rem;
    height: 1.1rem;
    accent-color: #3b82f6;
    cursor: pointer;
    flex-shrink: 0;
}

/* Module 6 – Clinical Events Section */
.events-cards-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 1rem;
}

@media (max-width: 900px) {
    .events-cards-grid { grid-template-columns: 1fr; }
}

.event-card.event-yes {
    border-color: rgba(245, 158, 11, 0.5);
    background: rgba(245, 158, 11, 0.08);
}

.event-card.event-death-yes {
    border-color: rgba(244, 63, 94, 0.6);
    background: rgba(244, 63, 94, 0.1);
}

.gdmt-toggle-btn.event-btn-yes {
    background: #f59e0b;
    color: #fff;
}

.gdmt-toggle-btn.event-btn-death {
    background: var(--accent-rose);
    color: #fff;
}

.gdmt-counter.event-alert-active {
    background: rgba(245, 158, 11, 0.18);
    border-color: rgba(245, 158, 11, 0.5);
    color: #fcd34d;
}

.gdmt-counter.event-alert-death {
    background: rgba(244, 63, 94, 0.2);
    border-color: rgba(244, 63, 94, 0.55);
    color: #fda4af;
}

