/* ============================================================
   OKO Launcher — Sidebar Layout & Design System
   ============================================================ */

:root {
    --sidebar-width: 65px;
    --sidebar-expanded-width: 160px;
    --content-header-height: 56px;

    --bg-app:        #0d0d0d;
    --bg-sidebar:    #111111;
    --bg-card:       #191919;
    --bg-card-alt:   #141414;
    --bg-input:      #0a0a12;
    --border-subtle:  #1e1e1e;
    --border-default: #2a2a2a;

    --text-primary:   #ffffff;
    --text-secondary: #999999;
    --text-muted:     #555555;

    --accent-blue:   #3b82f6;
    --accent-green:  #22c55e;
    --accent-purple: #7c3aed;
    --accent-orange: #f59e0b;
}

html, body {
    margin: 0;
    padding: 0;
    height: 100%;
    background: var(--bg-app);
    color: var(--text-primary);
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
}

/* ============================================================
   App Container — 2-column grid (sidebar | content)
   ============================================================ */
.app-container {
    display: grid !important;
    grid-template-columns: 110px 1fr !important;
    height: 100vh !important;
    overflow: hidden !important;
    background: var(--bg-app) !important;
}

.app-container.sidebar-expanded {
    grid-template-columns: var(--sidebar-expanded-width) 1fr !important;
}

/* ============================================================
   Sidebar
   ============================================================ */
.app-sidebar {
    width: 110px;
    min-width: 110px;
    background: var(--bg-sidebar, #111111);
    border-right: 1px solid var(--border-subtle, #1e1e1e);
    display: flex;
    flex-direction: column;
    transition: width 0.2s ease;
    position: relative;
    z-index: 100;
}

.sidebar-logo {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    /* Match the content header's fixed height so the two headers' bottom-borders line up across the
       sidebar/content seam (the sidebar's border-right). box-sizing keeps border+padding inside the 56px. */
    height: var(--content-header-height);
    box-sizing: border-box;
    padding: 8px;
    border-bottom: 1px solid var(--border-subtle);
    flex-shrink: 0;
}

.sidebar-logo-img {
    width: 60px;
    height: auto;
    max-height: 100%;
    display: block;
    object-fit: contain;
}

.sidebar-logo-text {
    font-size: 7.5px;
    font-weight: 700;
    text-align: center;
    color: var(--text-primary);
    letter-spacing: 0.1em;
    line-height: 1.25;
    text-transform: uppercase;
    white-space: nowrap;
}

.sidebar-nav {
    flex: 1;
    width: 100%;
    display: flex !important;
    flex-direction: column;
    align-items: stretch;
    padding: 6px 0;
    overflow-y: auto;
    overflow-x: hidden;
}

.sidebar-nav::-webkit-scrollbar { width: 0; }

.sidebar-nav-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 6px;
    padding: 16px 8px;
    background: transparent;
    border: none;
    border-left: 2px solid transparent;
    color: var(--color-text-muted, #9ca3af);
    font-size: 11px;
    font-weight: 600;
    letter-spacing: 0.03em;
    cursor: pointer;
    transition: all 0.15s ease;
    width: 100%;
    text-align: center;
    position: relative;
    min-height: 70px;
}

.sidebar-nav-item:hover {
    background: rgba(255, 255, 255, 0.05);
    color: var(--color-text, #ffffff);
}

.sidebar-nav-item.active {
    background: rgba(255, 255, 255, 0.08);
    border-left-color: #ffffff;
    color: var(--color-text, #ffffff);
}

.sidebar-nav-item span {
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    width: 100%;
    text-align: center;
}

/* PNG icon brightness — dim when inactive, full when active/hover */
.sidebar-nav-item img,
.sidebar-nav-item svg,
.sidebar-bottom-btn img {
    opacity: 0.35;
    transition: opacity 0.15s;
    display: block;
    flex-shrink: 0;
}

.sidebar-nav-item:hover img,
.sidebar-nav-item:hover svg,
.sidebar-nav-item.active img,
.sidebar-nav-item.active svg,
.sidebar-bottom-btn:hover img {
    opacity: 1;
}

.sidebar-nav-item.hidden { display: none !important; }

.sidebar-bottom {
    display: flex !important;
    flex-direction: column !important;
    align-items: center !important;
    justify-content: center !important;
    /* Bottom padding reserves a slot below the help icon for the fixed collapse pip
       (.sidebar-collapse-btn-floating), which is anchored at bottom:14px. This lifts the
       help icon up so the pip reads as the bottom-most, slightly-separated sidebar control. */
    padding: 8px 0 64px 0 !important;
    gap: 8px !important;
    flex-shrink: 0;
}

.sidebar-bottom-btn {
    width: 38px;
    height: 38px;
    min-width: 38px;
    min-height: 38px;
    display: flex !important;
    align-items: center;
    justify-content: center;
    background: transparent;
    border: none;
    cursor: pointer;
    color: var(--text-primary);
    border-radius: 0;
    transition: color 0.15s, background 0.15s;
    outline: none;
    position: relative;
    z-index: 10;
    flex-shrink: 0;
}

.sidebar-bottom-btn:hover {
    color: var(--text-secondary);
    background: rgba(255, 255, 255, 0.05);
}

/* Make sure bottom button SVGs are visible */
.sidebar-bottom-btn svg {
    opacity: 0.5 !important;
    transition: opacity 0.15s;
}

.sidebar-bottom-btn:hover svg {
    opacity: 1 !important;
}

/* Make sure bottom button images use same opacity rules as nav items */
.sidebar-bottom-btn img {
    opacity: 0.35 !important;
    transition: opacity 0.15s;
    display: block !important;
}

.sidebar-bottom-btn:hover img {
    opacity: 1 !important;
}

/* Expanded state */
.app-container.sidebar-expanded .sidebar-logo {
    padding: 8px 16px;
}

.app-container.sidebar-expanded .sidebar-logo-img {
    width: 100%;
    max-width: 120px;
}

.app-container.sidebar-expanded .sidebar-nav-item {
    flex-direction: row;
    justify-content: flex-start;
    padding: 11px 16px;
    gap: 11px;
    font-size: 10px;
    min-height: 44px;
}

.app-container.sidebar-expanded .sidebar-bottom {
    flex-direction: column;
    justify-content: center;
    gap: 4px;
    padding: 8px 0 70px;
}

/* ============================================================
   Collapsed state — hide sidebar, show full content
   ============================================================ */
.app-container.sidebar-collapsed {
    grid-template-columns: 0px 1fr !important;
}

.app-container.sidebar-collapsed .app-sidebar {
    width: 0;
    min-width: 0;
    overflow: hidden;
    border-right: none;
}

/* ============================================================
   Collapse pip — the single always-fixed collapse/expand toggle.
   ------------------------------------------------------------
   ONE button in both states. It never changes position (always position:fixed),
   anchored centred under the sidebar's icon column, just below the help icon. So:
   - Expanded: it sits as the bottom-most sidebar control — same surface + dimmed
     icon as the other bottom buttons, but with a quiet box (border) around it.
   - Collapsed: the sidebar retracts out from behind it and the pip "rips out" —
     a drop-shadow lifts in, a small outward nudge, a lighter fill, brighter icon.
   Because position is constant, shadow/transform/background animate smoothly (a
   static→fixed transition could not), which is what makes the rip-out subtle.
   ============================================================ */
.sidebar-collapse-btn-floating {
    position: fixed;
    /* Centred in the 110px sidebar (button is 38px → (110-38)/2 = 36) so it lines up
       under the help icon, and stays put when the sidebar collapses to 0. */
    left: 36px;
    bottom: 14px;
    width: 38px;
    height: 38px;
    padding: 0;
    background: var(--bg-sidebar);   /* expanded: blends into the sidebar surface */
    border: 1px solid var(--border-default); /* the box around it */
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    color: var(--text-primary);
    box-shadow: none;
    transition: background 0.2s ease, border-color 0.2s ease, box-shadow 0.25s ease, transform 0.25s ease;
    z-index: 1000;
    outline: none;
}

/* The pip is the single always-visible toggle — hide the legacy in-sidebar collapse
   button so the control isn't duplicated. !important beats `.sidebar-bottom-btn { display: flex !important }`. */
#sidebar-collapse-btn {
    display: none !important;
}

.sidebar-collapse-btn-floating svg {
    width: 20px;
    height: 20px;
    opacity: 0.5; /* match the dimmed help icon when expanded */
    transition: transform 0.3s ease, opacity 0.15s ease;
}

.sidebar-collapse-btn-floating:hover {
    background: #1a1a1a;
}

.sidebar-collapse-btn-floating:hover svg {
    opacity: 1;
}

/* Collapsed: lift the pip off the (now-retracted) sidebar so it reads as hovering. */
.app-container.sidebar-collapsed .sidebar-collapse-btn-floating {
    background: var(--bg-card);
    border-color: var(--border-default);
    box-shadow: 0 6px 18px rgba(0, 0, 0, 0.5);
    transform: translateX(4px); /* subtle outward nudge — the "rip out" */
}

.app-container.sidebar-collapsed .sidebar-collapse-btn-floating svg {
    opacity: 0.9;
    transform: scaleX(-1); /* chevron points right = "expand" when collapsed */
}

/* ============================================================
   Collapsed-state nav trigger — OKO logo in the header opens the
   section-nav dropdown (restores the pre-reskin openNavDropdown).
   Interactive ONLY while collapsed; expanded, the brand mark is the
   inert .sidebar-logo at the top of the sidebar.
   ============================================================ */
.nav-logo-trigger {
    display: none; /* shown only when the sidebar is collapsed */
    align-items: center;
    gap: 4px;
    margin-right: 16px;
    padding: 4px 8px;
    background: none;
    border: 1px solid transparent;
    border-radius: 8px;
    cursor: pointer;
    color: var(--text-primary);
    position: relative; /* anchors the dropdown panel */
    transition: background 0.15s, border-color 0.15s;
}

.app-container.sidebar-collapsed .nav-logo-trigger {
    display: flex;
}

.nav-logo-trigger:hover,
.nav-logo-trigger.active {
    background: var(--bg-card);
    border-color: var(--border-default);
}

.nav-logo-trigger__logo {
    display: block;
}

.nav-logo-trigger .dropdown-caret {
    opacity: 0.6;
    transition: transform 0.15s ease;
}

.nav-logo-trigger.active .dropdown-caret {
    transform: rotate(180deg);
}

/* Section nav dropdown panel (restored from the pre-reskin header nav) */
.nav-dropdown-panel {
    position: absolute;
    top: 100%;
    left: 0;
    margin-top: 6px;
    min-width: 190px;
    max-width: 280px;
    background: var(--bg-card);
    border: 1px solid var(--border-default);
    border-radius: 8px;
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.45);
    z-index: 9000;
    padding: 4px 0;
}

.nav-dropdown-panel__item {
    display: flex;
    align-items: center;
    padding: 9px 14px;
    cursor: pointer;
    font-size: 12px;
    font-weight: 600;
    letter-spacing: 0.04em;
    color: var(--text-secondary);
    white-space: nowrap;
    transition: background 0.1s ease, color 0.1s ease;
}

.nav-dropdown-panel__item:hover {
    background: rgba(255, 255, 255, 0.06);
    color: var(--text-primary);
}

.nav-dropdown-panel__item--active {
    color: var(--accent-blue);
    background: rgba(255, 255, 255, 0.06);
}

/* ============================================================
   Content Area
   ============================================================ */
.content-area {
    display: flex;
    flex-direction: column;
    height: 100vh;
    overflow: hidden;
    min-width: 0;
    background: var(--bg-app);
}

.content-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 24px;
    height: var(--content-header-height);
    border-bottom: 1px solid var(--border-subtle);
    background: var(--bg-app) !important;
    flex-shrink: 0;
}

.content-header-left {
    display: flex;
    align-items: center;
    gap: 10px;
    min-width: 0;
}

.content-title {
    font-size: 20px;
    font-weight: 600;
    color: var(--text-primary);
    margin: 0;
    line-height: 1;
    white-space: nowrap;
}

.content-header-right {
    display: flex;
    align-items: center;
    gap: 10px;
    flex-shrink: 0;
}

.content-header-right button,
.content-header-right .header-icon-btn {
    background-color: transparent !important;
    border: none !important;
    box-shadow: none !important;
    padding: 8px !important;
}

.content-header-right button:hover,
.content-header-right .header-icon-btn:hover {
    background-color: rgba(255, 255, 255, 0.05) !important;
    border: none !important;
    box-shadow: none !important;
}

.main-content {
    flex: 1;
    overflow-y: auto;
    overflow-x: hidden;
    padding: 24px;
    background: var(--bg-app);
}

/* ============================================================
   Sub-tabs  (Settings | Users | Hostnames | ...)
   ============================================================ */
.sub-tabs {
    display: flex;
    border-bottom: 1px solid var(--border-subtle);
    margin-bottom: 24px;
}

.sub-tab {
    background: none;
    border: none;
    border-bottom: 2px solid transparent;
    padding: 10px 16px;
    font-size: 13px;
    font-weight: 500;
    color: var(--text-muted);
    cursor: pointer;
    margin-bottom: -1px;
    transition: color 0.15s, border-color 0.15s;
    outline: none;
}

.sub-tab:hover { color: var(--text-secondary); }

.sub-tab.active {
    color: var(--text-primary);
    border-bottom-color: var(--text-primary);
}

/* ============================================================
   Detail Cards  (Tenant info / Basic Info / Allowlist)
   ============================================================ */
.detail-card {
    background: var(--bg-card);
    border: 1px solid var(--border-subtle);
    border-radius: 8px;
    padding: 20px 24px;
    margin-bottom: 16px;
}

.detail-card__header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 4px;
}

.detail-card__title {
    font-size: 14px;
    font-weight: 600;
    color: var(--text-primary);
    margin: 0;
}

.detail-card__divider {
    border: none;
    border-top: 1px solid var(--border-subtle);
    margin: 12px 0 16px;
}

.form-grid-2 {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 16px;
}

.form-field label {
    display: block;
    font-size: 12px;
    color: var(--text-secondary);
    margin-bottom: 6px;
    font-weight: 500;
}

.form-field input,
.form-field textarea,
.form-field select {
    width: 100%;
    background: var(--bg-input);
    border: 1px solid var(--border-default);
    border-radius: 4px;
    padding: 9px 12px;
    color: var(--text-primary);
    font-size: 13px;
    box-sizing: border-box;
    outline: none;
    transition: border-color 0.15s;
}

.form-field input:focus,
.form-field textarea:focus,
.form-field select:focus {
    border-color: #444;
}

/* ============================================================
   Badges & Tags
   ============================================================ */
.badge {
    display: inline-flex;
    align-items: center;
    padding: 2px 8px;
    border-radius: 4px;
    font-size: 11px;
    font-weight: 700;
    letter-spacing: 0.05em;
    text-transform: uppercase;
}

.badge--active        { background: rgba(34,197,94,0.15);   color: var(--accent-green); }
.badge--queue         { background: rgba(120,120,120,0.12); color: var(--text-muted); }
.badge--pro           { background: rgba(124,58,237,0.2);   color: #a78bfa; }
.badge--provisioning  { background: rgba(59,130,246,0.15);  color: var(--accent-blue); }

.tag-chip {
    display: inline-flex;
    align-items: center;
    padding: 3px 10px;
    border: 1px solid var(--border-default);
    border-radius: 4px;
    font-size: 12px;
    color: var(--text-secondary);
}

/* ============================================================
   App Cards Grid  (Apps tab)
   ============================================================ */
.app-cards-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: 16px;
    margin-bottom: 32px;
}

.app-card {
    background: var(--bg-card);
    border: 1px solid var(--border-subtle);
    border-radius: 8px;
    padding: 16px;
    cursor: pointer;
    transition: border-color 0.15s;
}

.app-card:hover { border-color: #333; }

.app-card__header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 10px;
}

.app-card__name-row {
    display: flex;
    align-items: center;
    gap: 10px;
}

.app-card__icon {
    width: 36px;
    height: 36px;
    border-radius: 6px;
    background: var(--bg-card-alt);
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.app-card__name {
    font-size: 15px;
    font-weight: 600;
    color: var(--text-primary);
}

.app-card__desc {
    font-size: 13px;
    color: var(--text-secondary);
    line-height: 1.5;
    margin: 0;
}

.provisioning-bar {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 10px;
    color: var(--accent-blue);
    font-weight: 700;
    letter-spacing: 0.06em;
    text-transform: uppercase;
}

.provisioning-bar__track {
    flex: 1;
    height: 3px;
    background: rgba(59,130,246,0.2);
    border-radius: 2px;
    overflow: hidden;
}

.provisioning-bar__fill {
    height: 100%;
    background: var(--accent-blue);
    border-radius: 2px;
    transition: width 0.3s;
}

/* ============================================================
   Buttons
   ============================================================ */
.btn-outline {
    background: transparent;
    border: 1px solid var(--border-default);
    color: var(--text-primary);
    padding: 5px 14px;
    border-radius: 5px;
    font-size: 13px;
    font-weight: 500;
    cursor: pointer;
    transition: border-color 0.15s, background 0.15s;
    outline: none;
}

.btn-outline:hover {
    border-color: #555;
    background: rgba(255,255,255,0.04);
}

.btn-primary-blue {
    background: var(--accent-blue);
    border: none;
    color: #fff;
    padding: 10px 22px;
    border-radius: 6px;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    transition: background 0.15s;
    outline: none;
}

.btn-primary-blue:hover { background: #2563eb; }

/* ============================================================
   Breadcrumb  (Settings  Nodey_01 ▼  Active)
   ============================================================ */
.breadcrumb {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 20px;
    font-weight: 600;
    color: var(--text-primary);
}

.breadcrumb__tenant {
    color: var(--accent-blue);
    display: flex;
    align-items: center;
    gap: 3px;
    cursor: pointer;
}

/* ============================================================
   Version footer
   ============================================================ */
.env-version-footer {
    position: fixed;
    bottom: 8px;
    right: 12px;
    font-size: 11px;
    color: var(--text-muted);
    pointer-events: none;
    z-index: 50;
    letter-spacing: 0.04em;
}

/* ============================================================
   Hide old top-header artefacts if they still exist in DOM
   ============================================================ */
.app-header,
.nav-dropdown-wrapper,
.header-center,
.header-left,
.header-right {
    display: none !important;
}

/* Rotate the collapse button arrow when sidebar is collapsed */
.app-container.sidebar-collapsed #sidebar-collapse-btn svg,
.app-container.sidebar-collapsed #sidebar-collapse-btn-floating svg {
    transform: rotate(180deg);
}

#sidebar-collapse-btn svg,
#sidebar-collapse-btn-floating svg {
    transition: transform 0.3s ease;
    opacity: 1 !important;
}
