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

:root {
    --near-white: #F3F5F9;
    --light-blue-gray: #E9EFF6;
    --pale-mint: #ECF4F3;
    --soft-aqua: #DDF2F6;
    --light-sky: #C6E9F7;
    --muted-teal-gray: #BCD9DD;
    --deep-forest-teal: #405751;
    --radius: 16px;
    
    /* Animation Variables */
    --ease-elastic: cubic-bezier(0.175, 0.885, 0.32, 1.275);
    --ease-smooth: cubic-bezier(0.16, 1, 0.3, 1);
}

body {
    font-family: 'Avenir Next', 'Manrope', 'Segoe UI', sans-serif; 
    background: #61b6d4;
    min-height: 100vh;
    color: #405751;
    opacity: 0;
    animation: pageFadeIn 0.8s var(--ease-smooth) forwards;
    scrollbar-width: none;
    -ms-overflow-style: none;

}

body::-webkit-scrollbar {
    width: 0;
    height: 0;
    display: none;
}

html {
    scrollbar-width: none;
    -ms-overflow-style: none;
}

html::-webkit-scrollbar {
    width: 0;
    height: 0;
    display: none;
}

@keyframes pageFadeIn {
    to { opacity: 1; }
}

@keyframes fadeUp {
    from { 
        opacity: 0; 
        transform: translateY(20px); 
    }
    to { 
        opacity: 1; 
        transform: translateY(0); 
    }
}

.container {
    max-width: 100%;
    margin: 0 auto;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    padding: 24px;
}

/* Header */
.app-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 18px 16px;
    margin: 0 0 32px;
    background-color: #405751;
    border: 1px solid rgba(255, 255, 255, 0.12);
    border-radius: 999px;
    box-shadow: 0 16px 32px rgba(16, 29, 26, 0.25);
    position: relative;
    z-index: 10;
    font-family: 'Inter', 'Avenir Next', 'Manrope', 'Segoe UI', sans-serif;
}

.app-header__brand {
    display: flex;
    align-items: center;
    gap: 10px;
    padding-left: 10px;
}

.app-header__title {
    font-size: 20px;
    font-weight: 800;
    color: #F3F5F9;
    letter-spacing: -0.01em;
}

.app-header__nav {
    display: flex;
    gap: 8px;
    justify-content: flex-end;
    align-items: center;
    padding-right: 6px;
}

.app-header__nav a {
    text-decoration: none;
    color: rgba(243, 245, 249, 0.75);
    font-weight: 600;
    padding: 8px 16px;
    border-radius: 999px;
    font-size: 14px;
    transition: all 0.2s ease;
}

.app-header__nav a:hover {
    background-color: rgba(243, 245, 249, 0.16);
    color: #F3F5F9;
    box-shadow: 0 8px 18px rgba(20, 36, 32, 0.35);
}

.app-header__nav a.active {
    background-color: #F3F5F9;
    color: #1f2f2b;
    padding: 8px 24px;
    font-weight: 700;
    box-shadow: 0 10px 20px rgba(20, 36, 32, 0.35);
}

@media (min-width: 640px) {
    .app-header__nav {
        gap: 24px;
    }
}

.lucide {
    width: 18px;
    height: 18px;
    stroke-width: 1.6;
}

.nav-btn .lucide {
    width: 20px;
    height: 20px;
}

/* Main Content */
main {
    flex: 1;
    padding: 0 0 40px;
}

.dashboard-content {
    display: grid;
    grid-template-columns: 1fr;
    gap: 24px;
}

/* Calendar Section */
.calendar-section {
    background: rgba(233, 239, 246, 0.9);
    padding: 28px;
    border-radius: var(--radius);
    box-shadow:
        0 18px 40px rgba(64, 87, 81, 0.1),
        0 0 0 1px rgba(188, 217, 221, 0.4) inset;
    animation: fadeUp 0.8s var(--ease-smooth) 0.1s forwards;
    opacity: 0; /* Starts hidden for animation */
    transform: translateY(20px);
}

.calendar-section h2 {
    color: #405751;
    margin-bottom: 20px;
    font-size: 22px;
}

.calendar-wrapper {
    background: #ECF4F3;
    padding: 22px;
    border-radius: var(--radius);
    transition: height 0.3s ease;
    position: relative;
    overflow: visible;
}

.calendar-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
    gap: 16px;
    background: rgba(233, 239, 246, 0.92);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    padding: 12px 14px;
    border-radius: var(--radius);
    box-shadow: 0 10px 24px rgba(64, 87, 81, 0.12);
    border: 1px solid rgba(188, 217, 221, 0.6);
}

.calendar-controls {
    display: flex;
    align-items: center;
    gap: 10px;
}

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

.calendar-actions .view-toggle {
    background: #E9EFF6;
}

.calendar-actions-floating {
    position: absolute;
    top: 27px;
    right: 33px;
    display: flex;
    align-items: center;
    gap: 0;
    padding: 6px;
    background: rgba(233, 239, 246, 0.7);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    border: 1px solid rgba(188, 217, 221, 0.6);
    border-radius: var(--radius);
    box-shadow: 0 10px 24px rgba(64, 87, 81, 0.12);
    width: fit-content;
    max-width: calc(100% - 28px);
    z-index: 20;
    overflow: visible;
}

.calendar-actions-floating .view-btn,
.calendar-actions-floating .primary-btn {
    position: relative;
    z-index: 2001;
}

.calendar-actions-floating.is-fixed {
    position: fixed;
    right: auto;
    z-index: 2000;
    box-shadow: 0 20px 36px rgba(64, 87, 81, 0.32);
}

.calendar-actions-floating .view-toggle {
    display: inline-flex;
    align-items: center;
    background: #E9EFF6;
    border-radius: calc(var(--radius) - 6px);
    padding: 0;
    border: 1px solid rgba(188, 217, 221, 0.7);
    overflow: hidden;
}

.calendar-actions-floating .view-btn {
    background: transparent;
    color: #405751;
    border: none;
    padding: 10px 14px;
    border-radius: 0;
    font-size: 16px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s var(--ease-elastic);
}

.calendar-actions-floating .view-btn.is-active {
    background: #405751;
    color: #F3F5F9;
}

.calendar-actions-floating .view-btn:hover {
    transform: translateY(-3px);
    box-shadow: 0 12px 24px rgba(64, 87, 81, 0.15);
}

.calendar-actions-floating .view-btn:active {
    transform: scale(0.95);
}

.calendar-actions-floating .view-btn.is-active[data-view="month"] {
    box-shadow: 8px 0 16px rgba(64, 87, 81, 0.22);
}

.calendar-actions-floating .view-btn.is-active[data-view="week"] {
    box-shadow: -8px 0 16px rgba(64, 87, 81, 0.22);
}

.calendar-actions-floating .view-btn:not(.is-active) {
    box-shadow: none;
    background: rgba(233, 239, 246, 0.7);
}

.primary-btn {
    background: #C6E9F7;
    color: #405751;
    border: none;
    padding: 14px 22px;
    border-radius: var(--radius);
    font-size: 16px;
    font-weight: 600;
    cursor: pointer;
    box-shadow: 0 8px 18px rgba(64, 87, 81, 0.12);
    transition: all 0.3s var(--ease-elastic);
}

.calendar-actions-floating .primary-btn {
    border-radius: 0 calc(var(--radius) - 6px) calc(var(--radius) - 6px) 0;
    padding: 10px 16px;
    margin-left: -1px;
}

.calendar-actions-floating .view-toggle {
    border-right: 0;
    border-radius: calc(var(--radius) - 6px) 0 0 calc(var(--radius) - 6px);
}

.primary-btn:hover {
    background: #DDF2F6;
    transform: translateY(-3px);
    box-shadow: 0 12px 24px rgba(64, 87, 81, 0.15);
}

.primary-btn:active {
    transform: scale(0.95);
}

.primary-btn--alert {
    background: #C96B6B;
    color: #F3F5F9;
}

.primary-btn--alert:hover {
    background: #D77B7B;
}

.patient-dropdown {
    position: relative;
    display: inline-flex;
}

.patient-dropdown__menu {
    position: absolute;
    left: 0;
    right: 0;
    top: calc(100% + 2px);
    width: 100%;
    max-height: 260px;
    overflow-y: auto;
    background: #E9EFF6;
    border: 1px solid rgba(64, 87, 81, 0.12);
    border-radius: 0 0 var(--radius) var(--radius);
    box-shadow: 0 12px 30px rgba(64, 87, 81, 0.12);
    padding: 0;
    display: none;
    z-index: 20;
    opacity: 0;
    transform: translateY(-6px);
    transition: opacity 0.35s var(--ease-smooth), transform 0.35s var(--ease-smooth);
    scrollbar-width: none;
    -ms-overflow-style: none;
}

.patient-dropdown__menu::-webkit-scrollbar {
    width: 0;
    height: 0;
    display: none;
}

.patient-dropdown__menu.is-open {
    display: block;
    opacity: 1;
    transform: translateY(0);
}

.patient-dropdown__item {
    padding: 8px 12px;
    border-radius: 0;
    font-size: 13px;
    color: #405751;
    cursor: pointer;
    transition: background 0.2s ease;
    position: relative;
    padding-right: 22px;
}

.patient-dropdown__item:hover {
    background: rgba(198, 233, 247, 0.6);
}

.patient-dropdown__item::after {
    content: "";
    position: absolute;
    top: 0;
    right: 0;
    bottom: 0;
    width: 8px;
    border-radius: 0;
    background: var(--risk-color, #BCD9DD);
}

.calendar-header h3 {
    font-size: 18px;
    color: #405751;
    min-width: 150px;
    text-align: center;
    font-feature-settings: "tnum"; /* Tabular numbers prevent jitter */
}

.nav-btn {
    background-color: #C6E9F7;
    color: #405751;
    border: none;
    padding: 12px 18px;
    border-radius: var(--radius);
    cursor: pointer;
    font-size: 20px;
    box-shadow: 0 6px 16px rgba(64, 87, 81, 0.12);
    transition: all 0.2s ease;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 48px;
}

.nav-btn:hover {
    background-color: #DDF2F6;
    transform: translateY(-2px);
}

.nav-btn:active {
    transform: scale(0.9);
}

/* Calendar Grid */
.calendar {
    background: #E9EFF6;
    border-radius: var(--radius);
    padding: 14px;
    --calendar-grid-height: 990px;
    --week-slot-height: 46px;
    overflow-x: auto;
}

.calendar-body {
    display: grid;
    grid-template-columns: 1fr;
    gap: 10px;
    /* Smooth fade for content switching */
    transition: opacity 0.2s ease;
}

.calendar-body.fade-out {
    opacity: 0.5;
    pointer-events: none;
}

.calendar.mode-week .calendar-body {
    grid-template-columns: 56px 1fr;
    align-items: start;
}

.weekdays {
    display: grid;
    grid-template-columns: repeat(7, 1fr);
    gap: 0;
    margin-bottom: 10px;
}

.weekday {
    text-align: center;
    font-weight: bold;
    color: #405751;
    padding: 10px 5px;
    font-size: 12px;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    opacity: 0.8;
}

#calendarGrid {
    display: grid;
    grid-template-columns: repeat(7, minmax(0, 1fr));
    grid-auto-rows: 165px;
    gap: 0;
    min-height: var(--calendar-grid-height);
}

#calendarGrid.view-week {
    grid-template-columns: repeat(7, 1fr);
    grid-auto-rows: 1fr;
    height: var(--calendar-grid-height);
    background-image:
        linear-gradient(to right, rgba(64, 87, 81, 0.1) 0 1px, transparent 1px),
        linear-gradient(to bottom, transparent 0, transparent calc(var(--week-slot-height) - 1px), rgba(64, 87, 81, 0.1) calc(var(--week-slot-height) - 1px), rgba(64, 87, 81, 0.1) var(--week-slot-height));
    background-size: 100% 100%, 100% var(--week-slot-height);
    background-repeat: no-repeat, repeat-y;
}

.time-column {
    display: none;
    flex-direction: column;
    height: var(--calendar-grid-height);
    justify-content: space-between;
    color: rgba(64, 87, 81, 0.6);
    font-size: 10px;
    padding-top: 4px;
}

.calendar.mode-week .time-column {
    display: flex;
}

.time-slot {
    height: var(--week-slot-height);
    display: flex;
    align-items: flex-start;
    justify-content: flex-end;
    padding-right: 6px;
}

.calendar-day {
    display: flex;
    align-items: flex-start;
    justify-content: flex-start;
    border: 1px solid #BCD9DD;
    border-radius: var(--radius);
    cursor: pointer;
    font-size: 12px;
    font-weight: 600;
    padding: 8px;
    gap: 6px;
    flex-direction: column;
    transition: all 0.3s cubic-bezier(0.25, 0.8, 0.25, 1);
    background-color: #F3F5F9;
    width: 100%;
    height: 100%;
    position: relative;
    overflow: hidden;
}

.calendar.mode-week .calendar-day {
    aspect-ratio: auto;
    height: 100%;
}

.appointments {
    display: flex;
    flex-direction: column;
    gap: 6px;
    width: 100%;
    overflow: hidden;
}

.calendar.mode-week .appointments {
    position: absolute;
    inset: 28px 0 8px 0;
    gap: 0;
    overflow: visible;
}

.appointment-block {
    border: 1px solid rgba(64, 87, 81, 0.12);
    border-radius: var(--radius);
    padding: 6px 8px;
    font-size: 11px;
    font-weight: 600;
    font-family: 'Avenir Next', 'Manrope', 'Segoe UI', sans-serif;
    text-align: left;
    color: #1f2f2b;
    cursor: pointer;
    transition: transform 0.2s ease, box-shadow 0.2s ease;
    overflow: hidden;
    white-space: nowrap;
    text-overflow: ellipsis;
    box-sizing: border-box;
    position: relative;
    background: #BCD9DD;
}

.appointment-block--week {
    white-space: normal;
    display: flex;
    flex-direction: column;
    gap: 2px;
    line-height: 1.2;
}

.appointment-block--week .appt-time {
    font-size: 11px;
    font-weight: 700;
}

.appointment-block--week .appt-patient {
    font-size: 11px;
    font-weight: 500;
    opacity: 0.9;
}

.appointment-block::after {
    content: "";
    position: absolute;
    left: 0;
    right: 0;
    bottom: 0;
    height: 4px;
    background: var(--risk-color, #405751);
}

.calendar.mode-week .appointment-block {
    position: absolute;
    left: 8px;
    right: 8px;
    max-width: calc(100% - 16px);
    border-radius: var(--radius);
    width: calc(100% - 16px);
    display: flex;
    align-items: flex-start;
    justify-content: flex-start;
    padding-top: 6px;
    padding-left: 10px;
    min-height: 40px;
    overflow: hidden;
}

.calendar.mode-week .appointment-block::after {
    top: 0;
    bottom: 0;
    left: 0;
    right: auto;
    width: 4px;
    height: auto;
    border-radius: var(--radius) 0 0 var(--radius);
}

.appointment-block:hover {
    transform: translateY(-1px);
}

.appointment-block.is-selected {
    box-shadow: 0 6px 16px rgba(64, 87, 81, 0.18);
    border-color: rgba(64, 87, 81, 0.25);
}

.appointment-block.swap-animate {
    animation: swapPulse 0.7s ease;
}

.appointment-block.swap-ghost {
    animation: none;
}

.appointment-block.swap-hidden {
    opacity: 0;
    pointer-events: none;
}

.appointment-block.swap-placeholder {
    opacity: 0.4;
    filter: saturate(0.85);
    pointer-events: none;
}

@keyframes swapPulse {
    0% {
        transform: translateY(-6px) scale(0.96);
        box-shadow: 0 0 0 rgba(64, 87, 81, 0);
    }
    50% {
        transform: translateY(0) scale(1.02);
        box-shadow: 0 12px 24px rgba(64, 87, 81, 0.22);
    }
    100% {
        transform: translateY(0) scale(1);
        box-shadow: 0 6px 16px rgba(64, 87, 81, 0.12);
    }
}

.day-number {
    font-size: 12px;
    font-weight: 600;
    line-height: 1;
    z-index: 2;
    transition: color 0.2s ease;
}

.calendar.mode-week .day-number {
    position: absolute;
    top: 8px;
    left: 8px;
}

.calendar-day:hover {
    background-color: #fff;
    border-color: #C6E9F7;
    transform: translateY(-2px) scale(1.02);
    box-shadow: 0 8px 20px rgba(64, 87, 81, 0.15);
    z-index: 5;
}

.calendar-day:active {
    transform: scale(0.98);
}

.calendar-day.other-month {
    color: #BCD9DD;
    background-color: #E9EFF6;
    cursor: default;
    opacity: 0.6;
}

.calendar-day.other-month .appointment-block {
    opacity: 0.55;
}

.calendar-day.other-month:hover {
    transform: none;
    box-shadow: none;
    border-color: #BCD9DD;
}

.calendar-day.today {
    background-color: #405751;
    color: #F3F5F9;
    font-weight: bold;
    border-color: #405751;
    box-shadow: 0 4px 12px rgba(64, 87, 81, 0.3);
}

.calendar-day.selected {
    background-color: #C6E9F7;
    color: #405751;
    border-color: #405751;
    animation: popSelect 0.3s var(--ease-elastic);
}

@keyframes popSelect {
    0% { transform: scale(1); }
    50% { transform: scale(0.95); }
    100% { transform: scale(1); }
}

/* Stats Section */
.stats-section {
    background: transparent;
    padding: 0;
    animation: fadeUp 0.8s var(--ease-smooth) 0.2s forwards;
    opacity: 0;
    transform: translateY(20px);
}

.stats-section h2 {
    color: #405751;
    margin-bottom: 12px;
    font-size: 16px;
    letter-spacing: 0.05em;
    text-transform: uppercase;
    font-weight: 700;
}

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

.stat-header {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-bottom: 6px;
    color: #405751;
}

.stat-header h3 {
    font-size: 12px;
    opacity: 0.75;
    font-weight: 600;
    text-transform: uppercase;
}

.stat-card {
    background: rgba(233, 239, 246, 0.6);
    backdrop-filter: blur(5px);
    color: #405751;
    padding: 16px;
    border-radius: var(--radius);
    text-align: left;
    box-shadow: 0 4px 6px rgba(64, 87, 81, 0.05);
    border: 1px solid rgba(188, 217, 221, 0.7);
    transition: all 0.3s ease;
    cursor: default;
}

.stat-card:hover {
    transform: translateY(-5px);
    background: rgba(233, 239, 246, 0.9);
    box-shadow: 0 10px 20px rgba(64, 87, 81, 0.1);
    border-color: #C6E9F7;
}

.stat-number {
    font-size: 24px;
    font-weight: 700;
    margin-bottom: 4px;
    color: #405751;
    /* Gradient text effect (subtle) */
    background: linear-gradient(135deg, #405751 0%, #2c3e3a 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    display: inline-block;
}

.stat-label {
    font-size: 11px;
    opacity: 0.7;
    font-weight: 500;
}

.stat-card--chart {
    padding: 14px 14px 12px;
}

.chart-wrap {
    height: 120px;
    margin: 4px 0 6px;
}

.chart-wrap canvas {
    width: 100% !important;
    height: 100% !important;
}

/* Footer */
footer {
    background-color: rgba(188, 217, 221, 0.4);
    color: #405751;
    text-align: center;
    padding: 20px;
    margin-top: auto;
}

/* Responsive Design */
@media (max-width: 768px) {
    .dashboard-content {
        grid-template-columns: 1fr;
        gap: 20px;
    }

    nav {
        flex-direction: column;
        gap: 10px;
    }

    .calendar-header {
        flex-direction: column;
        align-items: flex-start;
    }

    .calendar-actions {
        width: 100%;
        justify-content: space-between;
    }

    .stats-grid {
        grid-template-columns: 1fr;
    }
}

@media (max-width: 480px) {
    .container {
        padding: 16px;
    }

    main {
        padding: 0 0 32px;
    }

    .calendar-section,
    .stats-section {
        padding: 0;
    }

    .calendar-day {
        font-size: 12px;
    }

    .stat-number {
        font-size: 24px;
    }
}
