/* 
 * =========================================
 * DESIGN SYSTEM TOKENS
 * ========================================= 
 * We use CSS custom properties to maintain a single source of truth 
 * for our application's design system, including layout, colors, and typography.
 */
:root {
    /* --- Layout Tokens --- */
    --sidebar-width: 260px;
    /* Fixed width for the desktop sidebar navigation */

    /* --- Border Radius Tokens --- */
    --radius-sm: 4px;   /* Small inputs, badges */
    --radius-md: 8px;   /* Buttons, small components */
    --radius-lg: 12px;  /* Cards, modals, major containers */
    --radius-full: 9999px; /* Pill shapes, avatars */

    /* --- Typography Tokens --- */
    /* Font Families */
    --font-family-body: 'Inter', -apple-system, blinkmacsystemfont, 'Segoe UI', roboto, oxygen, ubuntu, cantarell, 'Open Sans', 'Helvetica Neue', sans-serif;
    --font-family-heading: 'Outfit', var(--font-family-body);

    /* Font Sizes */
    --font-size-xs: 0.75rem;
    --font-size-sm: 0.875rem;
    --font-size-base: 1rem;
    --font-size-md: 1.125rem;
    --font-size-lg: 1.25rem;
    --font-size-xl: 1.5rem;
    --font-size-2xl: 1.875rem;

    /* Font Weights */
    --font-weight-normal: 400;
    --font-weight-medium: 500;
    --font-weight-semibold: 600;
    --font-weight-bold: 700;

    /* --- Theme Core Colors --- */
    /* Primary brand colors used for establishing the Magnus RX identity */
    --color-primary: #00d1b2;
    /* Primary brand teal */
    --color-primary-dark: #00a8a8;
    /* Darker primary for text and accents */

    /* --- Functional Action Colors --- */
    /* Used for buttons and interactive elements to indicate intent */
    --color-positive: #00d1b2;
    /* Positive/Confirm actions (mapped to primary teal) */
    --color-positive-hover: #00b89c;
    /* Slightly darker positive state for hover interactions */
    --color-negative: #ff3860;
    /* Destructive/Cancel actions */
    --color-negative-hover: #e82c53;
    /* Slightly darker negative state for hover interactions */

    /* --- Background & Surface Colors --- */
    /* Base background colors for the app shell and surface elements like cards */
    --bg-light: #f5f7fa;
    /* App background for light mode */
    --bg-dark: #1a1e1e;
    /* App background for dark mode */
    --bg-card-dark: #242929;
    /* Surface background for dark mode panels/cards */
    --bg-input-dark: #2d3333;
    /* Surface background for input fields in dark mode */
    --border-dark: #333333;
    /* Default border color in dark mode */

    /* --- Typography Colors --- */
    --text-light-default: #363636;
    /* Base text color for light mode */
    --text-dark-default: #e0e0e0;
    /* Base text color for dark mode */
    --text-muted-dark: #888888;
    /* Muted text color for secondary info in dark mode */
}

body {
    background-color: var(--bg-light);
    font-family: var(--font-family-body);
    font-size: var(--font-size-base);
    color: var(--text-light-default);
    margin: 0;
    padding: 0;
    height: 100vh;
    overflow: hidden;
    /* Prevent body scroll, handle scrollable areas inside content */
}

h1, h2, h3, h4, h5, h6, .title, .subtitle {
    font-family: var(--font-family-heading);
    font-weight: var(--font-weight-bold);
}

/* 
 * =========================================
 * DARK MODE OVERRIDES
 * ========================================= 
 * Overrides for Bulma components to support our custom dark theme tokens.
 */
.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 #main-scroll-area {
    padding: 0;
    margin: 0;
    display: block;
    height: 100vh;
    width: 100vw;
    overflow: hidden;
}

#app-shell.is-standalone .container.is-fluid {
    width: 100%;
    max-width: none;
    padding: 0;
    margin: 0;
    height: 100%;
}

#app-shell.is-standalone #app-content {
    background-color: transparent;
}

#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: 0;
    }

    #app-shell.is-standalone #main-scroll-area>.container.is-fluid {
        margin: 0 !important;
        padding: 0 !important;
    }

    #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;
    }
}

/* Page Content Wrapper — used as the single outer div in every {% block content %} */
.page-content {
    padding: 1.25rem 0 2rem;
}

@media (max-width: 1023px) {
    .page-content {
        padding: 0.75rem .4rem 1.5rem;
    }
}

/* 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-image: url('/static/img/bg.jpg');
    background-size: cover;
    background-position: center;
    z-index: -1;
}

.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;
    background-color: rgba(255, 255, 255, 0.2);
    backdrop-filter: blur(8px);
    padding: 1.5rem;
    border-top: 1px solid rgba(0, 0, 0, 0.05);
}

.dark .sidebar-overlay {
    background-color: rgba(30, 30, 30, 0.6);
    border-top-color: rgba(255, 255, 255, 0.1);
}

.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);
}

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

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

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

.avatar-placeholder {
    width: 100%;
    height: 100%;
    border-radius: var(--radius-full);
}

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

/* Branded Login Page */
#login-hero {
    position: relative;
    background-image: url('/static/img/bg.jpg');
    background-size: cover;
    background-position: center center;
    background-repeat: no-repeat;
    width: 100%;
    height: 100vh;
}

#login-hero::before {
    content: "";
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(255, 255, 255, 0.3);
    /* Light overlay */
    backdrop-filter: blur(5px);
}

.dark #login-hero::before {
    background: rgba(26, 30, 30, 0.6);
    /* 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: var(--radius-lg);
    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;
}

/* 
 * =========================================
 * COMPONENT SPECIFIC STYLES
 * ========================================= 
 */
/* Global Action Buttons */
/* Using design tokens for consistent theming across interactive elements */
.btn-positive {
    background-color: var(--color-positive) !important;
    color: white !important;
    transition: all 0.2s ease;
    border-radius: var(--radius-md);
    font-weight: var(--font-weight-medium);
}

.btn-positive:hover:not([disabled]) {
    background-color: var(--color-positive-hover) !important;
    transform: translateY(-1px);
    box-shadow: 0 4px 8px rgba(0, 209, 178, 0.2);
}

.btn-positive[disabled] {
    opacity: 0.5 !important;
    background-color: var(--color-positive) !important;
    color: white !important;
    cursor: not-allowed;
    box-shadow: none !important;
}

.btn-negative {
    background-color: var(--color-negative) !important;
    color: white !important;
    transition: all 0.2s ease;
    border-radius: var(--radius-md);
    font-weight: var(--font-weight-medium);
}

.btn-negative:hover:not([disabled]) {
    background-color: var(--color-negative-hover) !important;
    transform: translateY(-1px);
    box-shadow: 0 4px 8px rgba(255, 56, 96, 0.2);
}

.btn-negative[disabled] {
    opacity: 0.5 !important;
    background-color: var(--color-negative) !important;
    color: white !important;
    cursor: not-allowed;
    box-shadow: none !important;
}

/* Section Headings */
/* Standardized styling for block headers like "Target List" or "Territory Info" */
.section-header {
    color: var(--color-primary-dark);
    font-size: var(--font-size-xs);
    letter-spacing: 0.05em;
    text-transform: uppercase;
    font-weight: var(--font-weight-bold);
    border-bottom: 2px solid #00d1b222;
    padding-bottom: 4px;
    display: block;
}

.dark .section-header {
    color: #00d1b2;
    border-bottom-color: #00d1b244;
}