:root {
    --sidebar-width: 260px;
    /* Kinetic Curator Design System Tokens */
    --primary: #4a6800;
    --primary-container: #a9e801;
    --secondary: #290fe8;
    --surface: #ffffff;
    --surface-container-low: #f4fbf7;
    --surface-container-lowest: #ffffff;
    --on-surface-variant: #434934;
    --on-surface: #121e1a;
}

body {
    background-color: var(--surface) !important;
    font-family: 'Plus Jakarta Sans', sans-serif !important;
    color: var(--on-surface) !important;
    margin: 0;
    padding: 0;
    min-height: 100vh;
}

body:not(.is-standalone) {
    height: 100vh;
    overflow: hidden;
}

body.is-standalone {
    overflow-y: auto;
    height: auto;
}

.has-background-light {
    background-color: var(--surface) !important;
}

/* --- Kinetic Curator Global Overrides --- */
.title,
.subtitle {
    font-family: 'Plus Jakarta Sans', sans-serif !important;
    color: var(--on-surface) !important;
    letter-spacing: -0.02em;
}

.card,
.box {
    border-radius: 1.5rem !important;
    background-color: var(--surface-container-lowest) !important;
    border: none !important;
    box-shadow: 0px 20px 40px rgba(18, 30, 26, 0.06) !important;
}

/* Card Internal Spacing */
.card-content {
    padding: 1.5rem !important;
}

.card-footer {
    padding: 0 1.5rem 1.5rem 1.5rem !important;
    border-top: none !important;
}

.card-header {
    border-bottom: none !important;
    padding: 1.5rem 1.5rem 0 1.5rem !important;
}

.button.is-primary {
    background: var(--primary-container) !important;
    color: var(--on-surface) !important;
    border-radius: 9999px !important;
    font-weight: 600 !important;
    border: none !important;
    transition: all 0.2s ease;
}

.button.is-primary:hover {
    background: #b6f502 !important;
    /* Slightly lighter Acid Lime */
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(169, 232, 1, 0.3);
}

.button.is-secondary {
    background: #ececfa !important;
    color: var(--secondary) !important;
    border-radius: 9999px !important;
    font-weight: 600 !important;
    border: none !important;
}

.button {
    border-radius: 9999px !important;
}

.input,
.textarea,
.select select {
    background-color: #f9fdfa !important;
    /* surface-container-highest approx */
    border-radius: 0.5rem !important;
    border: 1px solid rgba(74, 104, 0, 0.15) !important;
    /* Ghost border */
    box-shadow: none !important;
}

.input:focus,
.textarea:focus,
.select select:focus {
    background-color: var(--surface-container-lowest) !important;
    border: 2px solid var(--primary) !important;
}

/* Sidebar Overrides */
#app-sidebar {
    background: var(--surface-container-lowest) !important;
    border-right: none !important;
}

.menu-list a {
    border-radius: 9999px !important;
    padding: 0.75rem 1rem !important;
    font-weight: 500 !important;
    color: var(--on-surface-variant) !important;
    margin-bottom: 0.25rem !important;
    transition: all 0.2s;
}

.menu-list a:hover {
    background-color: var(--surface-container-low) !important;
}

.menu-list a.is-active {
    background-color: var(--primary-container) !important;
    color: var(--on-surface) !important;
    font-weight: 600 !important;
}

.menu-list a.is-active .icon {
    color: var(--on-surface) !important;
}

/* Remove default Bulma table lines */
.table {
    background: transparent !important;
}

.table td,
.table th {
    border: none !important;
    vertical-align: middle !important;
}

.table tbody tr {
    transition: transform 0.2s, box-shadow 0.2s;
    border-radius: 1rem !important;
}

.table.is-striped tbody tr:nth-child(even) {
    background-color: var(--surface-container-lowest) !important;
}

.table.is-striped tbody tr:nth-child(odd) {
    background-color: transparent !important;
}

/* ----------------------------------------- */

/* Dark Mode */
.dark,
.dark body {
    background-color: #1a1e1e;
    color: #e0e0e0;
}

.dark .title,
.dark .subtitle,
.dark strong,
.dark label,
.dark .card-header-title,
.dark .table th {
    color: #ffffff;
}

.dark .card,
.dark .table,
.dark .box {
    background-color: #242929;
    color: #e0e0e0;
    border-color: #333;
}

.dark .table.is-striped tbody tr:not(.is-selected):nth-child(even) {
    background-color: #2d3333;
}

.dark .input,
.dark .select select,
.dark .textarea {
    background-color: #2d3333;
    border-color: #444;
    color: #e0e0e0;
}

.dark .input::placeholder {
    color: #777;
}

.dark .hero.is-light {
    background-color: transparent;
}

.dark .notification.is-light {
    background-color: #3a1a1a;
    color: #ffcccc;
}

.dark .icon {
    color: #888;
}

.dark .button.is-primary {
    background-color: #3273dc;
    border-color: transparent;
    color: #fff;
}

.dark .button.is-primary:hover {
    background-color: #276cda;
}

.dark .navbar {
    background-color: #2b3031;
    border-bottom: 1px solid #363b3c;
}

.dark .menu-label {
    color: #888;
}

.dark .menu-list a {
    color: #dbdbdb;
}

.dark .menu-list a:hover {
    background-color: #363b3c;
}

.dark .menu-list a.is-active {
    background-color: #3273dc;
    color: #fff;
}

.dark .has-text-grey,
.dark .has-text-grey-dark,
.dark .has-text-grey-darker {
    color: #dbdbdb !important;
}

.dark .title.has-text-grey-darker,
.dark .title.has-text-grey-dark {
    color: #fff !important;
}

/* App Shell Layout */
#app-shell {
    display: flex;
    height: 100vh;
    width: 100vw;
    overflow: hidden;
}

#app-shell.is-standalone {
    height: auto;
    min-height: 100vh;
    overflow: visible;
}

#app-shell.is-standalone #main-scroll-area {
    padding: 0;
    display: block;
    /* Remove flex centering which blocks scroll */
    min-height: 100vh;
    overflow: visible;
}

#app-shell.is-standalone #app-content {
    background-color: inherit;
    height: auto;
    min-height: 100vh;
    overflow: visible;
}

#app-sidebar {
    width: var(--sidebar-width);
    flex-shrink: 0;
    height: 100%;
    background: white;
    transition: transform 0.3s ease;
    z-index: 1000;
}

.dark #app-sidebar {
    background-color: #2b3031;
    border-right-color: #363b3c;
}

#app-content {
    flex: 1;
    height: 100%;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    position: relative;
}

#main-scroll-area {
    flex: 1;
    overflow-y: auto;
    padding: 1.5rem;
}

#mobile-overlay {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.5);
    z-index: 999;
    opacity: 0;
    transition: opacity 0.3s ease;
}

/* Responsive */
@media (max-width: 1023px) {
    #main-scroll-area {
        padding: 1.5rem 1rem;
    }

    #main-scroll-area>.container.is-fluid {
        margin: 0;
        padding: 0.5rem;
    }

    #app-sidebar {
        position: fixed;
        width: 75vw;
        top: 0;
        left: 0;
        transform: translateX(-100%);
        box-shadow: 2px 0 10px rgba(0, 0, 0, 0.1);
    }

    #app-sidebar.active {
        transform: translateX(0);
    }

    #mobile-overlay.active {
        display: block;
        opacity: 1;
    }
}

/* Components */
.h-full {
    height: 100%;
}

.w-full {
    width: 100%;
}

.d-flex {
    display: flex;
}

.flex-column {
    flex-direction: column;
}

.sidebar-container {
    display: flex;
    flex-direction: column;
    height: 100%;
    position: relative;
}

.sidebar-bg-layer {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: var(--surface);
    z-index: -1;
}

.dark .sidebar-bg-layer {
    background-color: #1a1e1e;
}

.sidebar-logo-container {
    padding: 3rem 1.5rem;
    display: flex;
    justify-content: center;
}

.sidebar-overlay {
    flex: 1;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    padding: 1.5rem;
}

.dark .sidebar-overlay {
    background-color: transparent;
}

.sidebar-version {
    border-top: 1px solid rgba(0, 0, 0, 0.1);
    padding-top: 1rem;
    color: #4a4a4a;
}

.dark .sidebar-version {
    color: #a0a0a0;
    border-top-color: rgba(255, 255, 255, 0.1);
}

#theme-toggle-action {
    cursor: pointer;
    color: inherit;
}

.navbar-custom {
    padding: 0.5rem 1rem;
}

.navbar-burger-custom {
    display: block;
    margin-left: 0;
}

.dark .navbar-burger span {
    background-color: #dbdbdb;
}

/* Floating Burger for Mobile */
#nav-burger.floating-burger {
    position: fixed;
    top: 1.25rem;
    left: 1.25rem;
    z-index: 1100;
    /* Above sidebar overlay but below sidebar if possible? Sidebar is 1000. Wait, sidebar should be above. */
    background: white;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
    border-radius: 50%;
    width: 3rem;
    height: 3rem;
    display: flex;
    /* Bulma navbar-burger resets this, we need flex */
    align-items: center;
    justify-content: center;
    border: none;
    cursor: pointer;
    transition: all 0.3s ease;
}

.dark #nav-burger.floating-burger {
    background: #2b3031;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
}

#nav-burger.floating-burger span {
    left: calc(50% - 8px);
    width: 16px;
}

#nav-burger.floating-burger:active {
    transform: scale(0.9);
}

@media (min-width: 1024px) {
    #nav-burger.floating-burger {
        display: none !important;
    }
}


.avatar-placeholder {
    width: 100%;
    height: 100%;
    border-radius: 50%;
}

.profile-container {
    max-width: 960px;
}

/* Branded Login Page */
#login-hero {
    position: relative;
    background-color: #f0f7ff;
    /* Very light blue pastel */
}

.dark #login-hero {
    background-color: #1a1e1e;
}

#login-hero::before {
    content: "";
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(255, 255, 255, 0.1);
}

.dark #login-hero::before {
    background: rgba(26, 30, 30, 0.2);
    /* Dark overlay */
}

.login-logo-container {
    display: flex;
    justify-content: center;
    align-items: center;
    width: 100%;
    margin-bottom: 2rem;
    text-align: center;
}

.login-box {
    position: relative;
    z-index: 1;
}

/* Doctor Cards */
.doctor-card {
    transition: transform 0.2s ease, box-shadow 0.2s ease;
    border-radius: 12px;
    overflow: hidden;
    height: 100%;
}

.doctor-card:hover {
    transform: translateY(-5px);
    box-shadow: 0 8px 20px rgba(0, 0, 0, 0.1);
}

.dark .doctor-card {
    background-color: #242929;
    border: 1px solid #333;
}

/* Floating Notifications */
.notification-container {
    position: fixed;
    top: 2rem;
    right: 2rem;
    z-index: 9999;
    width: 350px;
    max-width: 90vw;
    pointer-events: none;
}

.notification.is-floating {
    pointer-events: auto;
    margin-bottom: 1rem;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.1);
    animation: slideInRight 0.4s cubic-bezier(0.175, 0.885, 0.32, 1.275) forwards;
    border-radius: 12px;
}

@keyframes slideInRight {
    from {
        opacity: 0;
        transform: translateX(100%);
    }

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

/* Responsive Stacked Table */
@media screen and (max-width: 1023px) {
    .responsive-table thead {
        display: none;
    }

    .responsive-table tr {
        display: block;
        padding: 1rem;
        border-bottom: 2px solid #eee;
        position: relative;
    }

    .dark .responsive-table tr {
        border-bottom: 2px solid #333;
    }

    .responsive-table td {
        display: flex;
        justify-content: space-between;
        align-items: center;
        text-align: right;
        padding: 0.5rem 0.75rem !important;
        border: none !important;
        min-height: 2.5rem;
    }

    .responsive-table td::before {
        content: attr(data-label);
        font-weight: 700;
        text-transform: uppercase;
        font-size: 0.65rem;
        color: #888;
        display: block;
        text-align: left;
        margin-right: 1rem;
    }

    .responsive-table td.has-text-right {
        text-align: right !important;
    }

    .responsive-table .buttons.is-right {
        justify-content: flex-end;
    }
}

/* Loading Overlay and Spinner */
.loading-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(255, 255, 255, 0.4);
    backdrop-filter: blur(4px);
    z-index: 10000;
    display: none;
    align-items: center;
    justify-content: center;
    flex-direction: column;
    animation: fadeIn 0.3s ease-out;
}

.dark .loading-overlay {
    background: rgba(0, 0, 0, 0.4);
}

.loading-spinner {
    width: 50px;
    height: 50px;
    border: 3px solid rgba(50, 115, 220, 0.1);
    border-top-color: #3273dc;
    border-radius: 50%;
    animation: spin 1s linear infinite;
    margin-bottom: 1rem;
}

.loading-text {
    font-weight: bold;
    color: #3273dc;
    font-size: 1.1rem;
    text-shadow: 0 0 10px rgba(255, 255, 255, 0.8);
}

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

@keyframes fadeIn {
    from {
        opacity: 0;
    }

    to {
        opacity: 1;
    }
}

/* Optimization badge/overlay for specific slots */
.processing-indicator {
    display: inline-flex;
    align-items: center;
    padding: 4px 12px;
    background: #ebfffc;
    color: #00947e;
    border-radius: 20px;
    font-size: 0.75rem;
    font-weight: bold;
    margin-top: 8px;
    animation: pulse 1.5s infinite;
}

@keyframes pulse {
    0% {
        opacity: 0.6;
    }

    50% {
        opacity: 1;
    }

    100% {
        opacity: 0.6;
    }
}

/* ─── EMBED MODE ────────────────────────────────────────────────────────────
 * Applied when FizzFrame is loaded inside a cross-origin iframe shell.
 * Strategy:
 *   - html + body fill the iframe viewport (height: 100%, overflow: hidden)
 *   - #app-shell is a flex column that also fills 100%
 *   - #main-scroll-area is the SINGLE scroll zone (overflow-y: auto)
 *   - overscroll-behavior: contain on the scroll zone prevents elastic bounce
 *     from propagating up through the iframe to the parent window
 * ──────────────────────────────────────────────────────────────────────── */

body.is-embedded #app-sidebar { display: none !important; }
body.is-embedded #mobile-overlay { display: none !important; }
body.is-embedded #nav-burger { display: none !important; }

/* Height chain: iframe viewport → html → body */
html.is-embedded,
html.is-embedded body {
    height: 100%;
    margin: 0;
    padding: 0;
    overflow: hidden;
}

/* Shell fills full height as a vertical flex column */
body.is-embedded #app-shell {
    height: 100%;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

/* Content area: no sidebar offset, fills remaining height */
body.is-embedded #app-content {
    flex: 1;
    margin-left: 0 !important;
    width: 100% !important;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    min-width: 0;
}

/* Header stays pinned at the top */
body.is-embedded .app-header {
    flex-shrink: 0;
    position: relative !important;
    top: 0 !important;
}

/* THE scroll zone — overflow-y: auto scrolls content;
   overscroll-behavior: contain stops scroll from leaking to the parent shell */
body.is-embedded #main-scroll-area {
    flex: 1;
    overflow-y: auto;
    overflow-x: hidden;
    -webkit-overflow-scrolling: touch;
    overscroll-behavior: contain;
    height: 0; /* flex: 1 handles actual size; height: 0 prevents content blowout */
}