﻿/* ================================================================
   Base
   ================================================================ */
html, body {
    height: 100%;
    margin: 0;
    padding: 0;
    font-family: 'Segoe UI', Tahoma, Geneva, sans-serif;
}

h3 {
    color: #1a3a5c;
}

/* ================================================================
   Medico brand palette
   ================================================================
   --medico-dark:    #0d2b55  (deep navy — brand)
   --medico-mid:     #1a4a8a  (medium blue — sidebar)
   --medico-accent:  #2e80d4  (action blue — buttons / active)
   --medico-light:   #e8f1fb  (hover / active bg on sidebar)
   --medico-sidebar-w: 240px
   ================================================================ */
:root {
    --medico-dark:       #0d2b55;
    --medico-mid:        #1a4a8a;
    --medico-accent:     #2e80d4;
    --medico-light:      #d6e8f7;
    --medico-sidebar-w:  240px;
    --medico-topbar-h:   44px;
}

/* ================================================================
   Shell — authenticated layout (sidebar + main)
   ================================================================ */
.medico-shell {
    display: flex;
    height: 100vh;
    overflow: hidden;
}

.medico-shell-sidebar {
    width: var(--medico-sidebar-w);
    flex-shrink: 0;
    background: var(--medico-dark);
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.medico-shell-main {
    flex: 1;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    background: #f5f7fa;
}

/* ── Top bar ────────────────────────────────────────────────── */
.medico-topbar {
    height: var(--medico-topbar-h);
    background: #fff;
    border-bottom: 1px solid #e0e6ef;
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 1.25rem;
    flex-shrink: 0;
}

.medico-topbar-left, .medico-topbar-right {
    display: flex;
    align-items: center;
    gap: .5rem;
}

/* ── Page body (scrollable) ─────────────────────────────────── */
.medico-shell-body {
    flex: 1;
    overflow-y: auto;
    padding: 1.5rem;
}

/* ================================================================
   Sidebar component
   ================================================================ */
.medico-sidebar {
    display: flex;
    flex-direction: column;
    height: 100%;
    color: #fff;
}

/* ── Brand ──────────────────────────────────────────────────── */
.medico-sidebar-brand {
    display: flex;
    align-items: center;
    gap: .75rem;
    padding: 1.1rem 1rem 1rem;
    border-bottom: 1px solid rgba(255,255,255,.12);
    flex-shrink: 0;
}

.medico-brand-icon {
    font-size: 1.8rem;
    color: #7ec8f5;
    flex-shrink: 0;
}

.medico-brand-name {
    font-size: .95rem;
    font-weight: 700;
    letter-spacing: .12em;
    color: #fff;
    line-height: 1.2;
}

.medico-brand-sub {
    font-size: .68rem;
    color: rgba(255,255,255,.55);
    letter-spacing: .04em;
    line-height: 1.2;
}

/* ── Primary nav ────────────────────────────────────────────── */
.medico-nav {
    flex: 1;
    padding: .75rem 0;
    overflow-y: auto;
}

.medico-nav-section {
    font-size: .63rem;
    font-weight: 700;
    letter-spacing: .1em;
    color: rgba(255,255,255,.4);
    padding: .6rem 1rem .3rem;
    text-transform: uppercase;
}

.medico-nav-link {
    display: flex;
    align-items: center;
    gap: .65rem;
    padding: .5rem 1rem;
    color: rgba(255,255,255,.78);
    text-decoration: none;
    font-size: .875rem;
    border-radius: 0;
    transition: background .15s, color .15s;
    cursor: pointer;
    position: relative;
}

    .medico-nav-link:hover {
        background: rgba(255,255,255,.10);
        color: #fff;
        text-decoration: none;
    }

    .medico-nav-link.active {
        background: rgba(46,128,212,.28);
        color: #fff;
        font-weight: 600;
    }

        .medico-nav-link.active::before {
            content: '';
            position: absolute;
            left: 0;
            top: 0;
            bottom: 0;
            width: 3px;
            background: var(--medico-accent);
            border-radius: 0 2px 2px 0;
        }

.nav-icon {
    font-size: 1rem;
    width: 1.1rem;
    flex-shrink: 0;
    opacity: .8;
}

.medico-nav-auth-prompt {
    padding: 1rem;
    color: rgba(255,255,255,.4);
    font-size: .8rem;
    display: flex;
    align-items: center;
}

/* ── Footer ─────────────────────────────────────────────────── */
.medico-sidebar-footer {
    border-top: 1px solid rgba(255,255,255,.12);
    padding: .75rem 0 .5rem;
    flex-shrink: 0;
}

.medico-user-row {
    display: flex;
    align-items: center;
    gap: .6rem;
    padding: .4rem 1rem .5rem;
}

.medico-user-icon {
    font-size: 1.5rem;
    color: rgba(255,255,255,.55);
    flex-shrink: 0;
}

.medico-user-info {
    overflow: hidden;
}

.medico-user-name {
    font-size: .8rem;
    font-weight: 600;
    color: rgba(255,255,255,.9);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.medico-user-role {
    font-size: .68rem;
    color: rgba(255,255,255,.45);
}

.medico-signout {
    color: rgba(255,180,180,.75) !important;
}

    .medico-signout:hover {
        background: rgba(255,60,60,.15) !important;
        color: #ffaaaa !important;
    }

/* ================================================================
   Login page — image-left / form-right split layout
   ================================================================ */
.login-split {
    display: flex;
    min-height: 100vh;
}

/* ── Left: full marketing image panel (~68%) ─────────────────── */
.login-image-panel {
    flex: 0 0 68%;
    position: relative;
    overflow: hidden;
    /* fallback gradient if image is not yet uploaded */
    background: linear-gradient(145deg, #0a2244 0%, #0d3470 45%, #154a9c 100%);
}

.login-bg-img {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    object-fit: cover;
    object-position: center;
    display: block;
}

/* ── Right: simple form panel (~32%) ─────────────────────────── */
.login-form-panel {
    flex: 0 0 32%;
    background: #add8e6;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 2.5rem 2rem;
}

.login-form-inner {
    width: 100%;
    max-width: 300px;
}

/* Error banner */
.login-error-banner {
    background: rgba(200, 40, 40, .12);
    border: 1px solid rgba(200, 40, 40, .35);
    border-radius: 6px;
    color: #7a1010;
    font-size: .85rem;
    padding: .55rem .75rem;
    margin-bottom: 1.25rem;
    word-break: break-word;
}

/* Field group */
.login-field-group {
    margin-bottom: 1.25rem;
}

.login-field-label {
    display: block;
    font-size: .88rem;
    font-weight: 600;
    color: #1a3a5c;
    margin-bottom: .35rem;
    letter-spacing: .01em;
}

.login-field-input {
    display: block;
    width: 100%;
    padding: .55rem .75rem;
    font-size: .95rem;
    color: #1a2d45;
    background: #ffffff;
    border: 1px solid #b0c8de;
    border-radius: 6px;
    outline: none;
    box-sizing: border-box;
    transition: border-color .15s, box-shadow .15s;
}

    .login-field-input:focus {
        border-color: #2e80d4;
        box-shadow: 0 0 0 3px rgba(46,128,212,.18);
    }

    .login-field-input::placeholder {
        color: #94aec4;
    }

/* Submit row */
.login-submit-row {
    margin-top: 1.75rem;
    text-align: center;
}

.login-submit-btn {
    width: 100%;
    padding: .6rem 1rem;
    font-size: 1rem;
    font-weight: 600;
    color: #fff;
    background: #2e80d4;
    border: none;
    border-radius: 7px;
    cursor: pointer;
    letter-spacing: .03em;
    transition: background .15s;
}

    .login-submit-btn:hover:not([disabled]) {
        background: #1a6bbc;
    }

    .login-submit-btn:disabled {
        background: #90b8dd;
        cursor: default;
    }

/* ── Responsive: stack on small screens ─────────────────────── */
@media (max-width: 768px) {
    .login-split {
        flex-direction: column;
    }

    .login-image-panel {
        flex: 0 0 220px;
    }

    .login-form-panel {
        flex: 1;
        padding: 2rem 1.25rem;
    }

    .medico-shell-sidebar {
        width: 200px;
    }

    :root {
        --medico-sidebar-w: 200px;
    }
}

/* ------------------------------------------------------------------
   Existing "mf-" modal (unchanged)
-------------------------------------------------------------------*/
.mf-backdrop {
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,.5);
    z-index: 9998;
}

.mf-modal {
    position: fixed;
    left: 50%;
    top: 50%;
    transform: translate(-50%, -50%);
    width: min(1100px, 92vw);
    height: min(80vh, 800px);
    background: #fff;
    border-radius: 10px;
    box-shadow: 0 20px 60px rgba(0,0,0,.3);
    display: flex;
    flex-direction: column;
    z-index: 9999;
}

.mf-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: .75rem 1rem;
    border-bottom: 1px solid #e5e7eb;
}

.mf-title {
    font-weight: 600;
}

.mf-x {
    border: 0;
    background: transparent;
    font-size: 1.25rem;
    line-height: 1;
    cursor: pointer;
}

.mf-frame {
    flex: 1;
    width: 100%;
    border: 0;
}

/* ------------------------------------------------------------------
   Chart Modal + Tree (new)
   Higher z-index than page content, below any OS overlays
-------------------------------------------------------------------*/
.chart-modal-backdrop {
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.35);
    backdrop-filter: saturate(120%) blur(2px);
    z-index: 10040;
}

.chart-modal {
    position: fixed;
    inset: 5% 8%;
    background: #fff;
    border-radius: 12px;
    box-shadow: 0 8px 30px rgba(0,0,0,.25);
    display: flex;
    flex-direction: column;
    z-index: 10050;
    outline: 0;
}

    .chart-modal:focus-within {
        box-shadow: 0 0 0 2px #c7dfff inset;
    }

.chart-modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: .75rem 1rem;
    border-bottom: 1px solid #eee;
}

.chart-modal-body {
    flex: 1;
    display: flex;
    min-height: 400px;
    min-width: 0;
}

.chart-modal-left {
    width: 280px;
    max-width: 40vw;
    border-right: 1px solid #eee;
    overflow: auto;
    padding: .5rem;
}

.chart-modal-right {
    flex: 1;
    overflow: auto;
    padding: .75rem;
    min-width: 0;
}

.chart-modal-footer {
    padding: .5rem 1rem;
    border-top: 1px solid #eee;
    display: flex;
    align-items: center;
    gap: .5rem;
}

.tree {
    font-size: .95rem;
    line-height: 1.25rem;
}

    .tree .tree-item {
        padding: .35rem .5rem;
        border-radius: .375rem;
        cursor: pointer;
        margin-bottom: .15rem;
        white-space: nowrap;
        overflow: hidden;
        text-overflow: ellipsis;
    }

        .tree .tree-item:hover {
            background: #f5f5f5;
        }

        .tree .tree-item.active {
            background: #e9f2ff;
            border: 1px solid #c7dfff;
        }

        .tree .tree-item.disabled {
            color: #aaa;
            cursor: default;
        }

.json {
    white-space: pre-wrap;
    word-break: break-word;
    font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, "Liberation Mono", monospace;
    font-size: .92rem;
    line-height: 1.25rem;
    margin: 0;
}

.muted {
    color: #6c757d;
}

/* Nice scrollbars (WebKit) */
.chart-modal-left::-webkit-scrollbar,
.chart-modal-right::-webkit-scrollbar {
    width: 10px;
    height: 10px;
}

.chart-modal-left::-webkit-scrollbar-thumb,
.chart-modal-right::-webkit-scrollbar-thumb {
    background: #d1d5db;
    border-radius: 8px;
    border: 2px solid #f8fafc;
}

    .chart-modal-left::-webkit-scrollbar-thumb:hover,
    .chart-modal-right::-webkit-scrollbar-thumb:hover {
        background: #b9c2cf;
    }

/* Responsive tweaks */
@media (max-width: 992px) {
    .chart-modal {
        inset: 6% 4%;
    }

    .chart-modal-left {
        width: 240px;
    }
}

@media (max-width: 640px) {
    .chart-modal {
        inset: 4% 3%;
    }

    .chart-modal-body {
        flex-direction: column;
    }

    .chart-modal-left {
        width: auto;
        max-width: none;
        border-right: 0;
        border-bottom: 1px solid #eee;
        max-height: 35vh;
    }

    .chart-modal-right {
        max-height: 50vh;
    }
}

/* Utility (optional) */
.badge {
    display: inline-block;
    padding: .35em .5em;
    border-radius: .5rem;
    font-weight: 600;
}

    .badge.bg-success {
        background: #16a34a;
        color: #fff;
    }

    .badge.bg-danger {
        background: #dc2626;
        color: #fff;
    }
