/**
 * Pro Top Layout
 * Dark topbar with inline nav links. Same SaaS tool aesthetic as pro-tool
 * but navigation sits in the topbar instead of a left sidebar.
 */

/* =============================================
   VARIABLES (shared with pro-tool palette)
   ============================================= */
:root {
    --ptp-top:    48px;
    --ptp-dark:   #0f172a;
    --ptp-border: rgba(255,255,255,0.08);
    --ptp-muted:  rgba(255,255,255,0.38);
    --ptp-hover:  rgba(255,255,255,0.06);
    --ptp-active: rgba(255,255,255,0.12);
    --ptp-white:  #ffffff;
    --ptp-bg:     #f1f5f9;
    --ptp-accent: var(--primary-color, #6366f1);
}

/* =============================================
   KILL GHOST NAV
   ============================================= */
.app-nav {
    display: none !important;
}
.mobile-header-bar {
    display: none !important;
}
.mobile-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.55);
    z-index: 250;
}
.mobile-overlay.active {
    display: block;
}

/* =============================================
   RESET
   ============================================= */
button, .btn, .btn-primary, a.btn, input[type=submit] {
    min-height: unset;
}

html, body {
    margin: 0;
    padding: 0;
    background: var(--ptp-bg);
}

/* Flex column so content area stretches to fill between topbar and footer */
.app-layout {
    display: flex;
    flex-direction: column;
    min-height: 100vh;
    background: var(--ptp-bg);
}

/* =============================================
   TOPBAR
   ============================================= */
.ptp-topbar {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    height: var(--ptp-top);
    background: var(--ptp-dark);
    border-bottom: 1px solid var(--ptp-border);
    display: flex;
    align-items: center;
    z-index: 300;
    padding: 0 8px 0 0;
    gap: 0;
}

/* Logo */
.ptp-topbar-logo {
    display: flex;
    align-items: center;
    justify-content: center;
    height: 100%;
    padding: 0 14px;
    text-decoration: none;
    border-right: 1px solid var(--ptp-border);
    flex-shrink: 0;
    gap: 9px;
}
.ptp-topbar-logo img {
    height: 22px;
    width: auto;
    display: block;
}
.ptp-logo-initials {
    width: 26px;
    height: 26px;
    border-radius: 7px;
    background: var(--ptp-accent);
    color: #fff;
    font-size: 11px;
    font-weight: 700;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}
.ptp-topbar-appname {
    color: rgba(255,255,255,0.80);
    font-size: 13px;
    font-weight: 600;
    white-space: nowrap;
    letter-spacing: 0.01em;
}

/* Nav area — scrollable row of links */
.ptp-topbar-nav {
    display: flex;
    align-items: center;
    height: 100%;
    overflow-x: auto;
    overflow-y: hidden;
    scrollbar-width: none;
    flex: 1;
    padding: 0 6px;
    gap: 2px;
}
.ptp-topbar-nav::-webkit-scrollbar { display: none; }

.ptp-topbar-nav a {
    display: flex !important;
    align-items: center !important;
    gap: 6px !important;
    height: 34px !important;
    padding: 0 12px !important;
    border-radius: 7px !important;
    color: var(--ptp-muted) !important;
    text-decoration: none !important;
    font-size: 13px !important;
    font-weight: 500 !important;
    white-space: nowrap !important;
    flex-shrink: 0 !important;
    transition: background 0.12s, color 0.12s !important;
    border: none !important;
    background: transparent !important;
    box-shadow: none !important;
    min-height: unset !important;
}
.ptp-topbar-nav a i {
    font-size: 13px;
    flex-shrink: 0;
}
.ptp-topbar-nav a:hover {
    color: rgba(255,255,255,0.85) !important;
    background: var(--ptp-hover) !important;
}
.ptp-topbar-nav a.active {
    color: var(--ptp-white) !important;
    background: var(--ptp-active) !important;
    box-shadow: inset 0 -2px 0 var(--ptp-accent) !important;
}

/* Right-side actions */
.ptp-topbar-actions {
    display: flex;
    align-items: center;
    gap: 2px;
    flex-shrink: 0;
    padding-left: 6px;
    padding-right: 8px;
    border-left: 1px solid var(--ptp-border);
    height: 100%;
    overflow: visible;
}

.ptp-topbar-btn {
    background: none;
    border: none;
    cursor: pointer;
    color: var(--ptp-muted);
    width: 34px;
    height: 34px;
    border-radius: 7px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 15px;
    transition: background 0.15s, color 0.15s;
    position: relative;
    flex-shrink: 0;
    min-height: unset;
    padding: 0;
    z-index: 1;
}
.ptp-topbar-btn:hover {
    background: var(--ptp-hover);
    color: rgba(255,255,255,0.85);
}

/* base.css's .lang-menu-btn sets color:var(--primary-color) !important,
   which reads as low-contrast on the dark topbar — override it back to the
   same muted topbar-icon color every other .ptp-topbar-btn uses. */
.ptp-topbar-btn.lang-menu-btn {
    color: var(--ptp-muted) !important;
    padding: 0 !important;
    font-size: 15px !important;
}
.ptp-topbar-btn.lang-menu-btn:hover {
    background: var(--ptp-hover) !important;
    color: rgba(255,255,255,0.85) !important;
}
.ptp-lang-wrap .lang-dropdown {
    top: calc(100% + 10px);
}

/* Notify badge */
.ptp-topbar-btn .notify-badge {
    position: absolute;
    top: 5px;
    right: 5px;
    min-width: 7px;
    height: 7px;
    border-radius: 50%;
    background: #ef4444;
    border: 1.5px solid var(--ptp-dark);
    font-size: 0;
}
.ptp-topbar-btn .notify-badge:not(:empty) {
    min-width: 15px;
    height: 15px;
    top: 3px;
    right: 3px;
    font-size: 9px;
    color: #fff;
    font-weight: 700;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0 2px;
}

/* Avatar button */
.ptp-topbar-avatar {
    background: none !important;
    border: none !important;
    cursor: pointer;
    padding: 0 !important;
    border-radius: 50%;
    width: 28px;
    height: 28px;
    min-height: unset;
    overflow: hidden;
    display: flex;
    align-items: center;
    justify-content: center;
    margin-left: 4px;
    flex-shrink: 0;
    opacity: 0.85;
    transition: opacity 0.15s;
}
.ptp-topbar-avatar:hover { opacity: 1; }
.ptp-topbar-avatar img,
.ptp-topbar-avatar > span {
    width: 28px !important;
    height: 28px !important;
    border-radius: 50% !important;
    font-size: 11px !important;
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
    flex-shrink: 0 !important;
}

/* User dropdown */
.ptp-user-wrap {
    position: relative;
    display: flex;
    align-items: center;
}
.ptp-user-dropdown {
    display: none;
    position: fixed;
    top: calc(var(--ptp-top) + 6px);
    right: 12px;
    width: 220px;
    background: #fff;
    border-radius: 10px;
    box-shadow: 0 8px 30px rgba(0,0,0,0.18);
    z-index: 9999;
    overflow: hidden;
    border: 1px solid #e5e7eb;
}
.ptp-user-dropdown.show { display: block !important; }

/* Mobile drawer — hidden by default on ALL viewports. The mobile media
   query below re-enables it (display:block + fixed positioning + slide
   transform) only under 768px. Confirmed real bug: when the open/close
   mechanism switched from a display:none/block toggle to a transform-only
   slide (to animate), this base display:none was dropped along with it —
   translateX() alone does not remove an element from normal document flow,
   so on desktop (where the whole mobile-only media query block does not
   apply at all) the drawer rendered as a plain, unstyled, always-visible
   list of links directly under the topbar. */
.ptp-mobile-drawer { display: none; }

/* Hamburger — inline in the topbar, right after the logo. Mobile only
   (desktop-hidden below); the inline nav takes over on desktop instead. */
.ptp-hamburger {
    display: none !important;
    background: none;
    border: none;
    cursor: pointer;
    color: var(--ptp-muted);
    width: 34px;
    height: 34px;
    min-height: unset;
    border-radius: 7px;
    align-items: center;
    justify-content: center;
    font-size: 15px;
    margin-left: 4px;
    flex-shrink: 0;
    padding: 0;
}
.ptp-hamburger:hover {
    background: var(--ptp-hover);
    color: rgba(255,255,255,0.85);
}

/* =============================================
   MAIN CONTENT
   ============================================= */
.ptp-main {
    margin-top: var(--ptp-top);
    flex: 1;
    background: var(--ptp-bg);
    padding: 24px;
    box-sizing: border-box;
}


/* =============================================
   FOOTER
   ============================================= */
.app-footer {
    background: var(--ptp-accent, #6366f1);
    color: rgba(255,255,255,0.85);
    padding: 12px 24px;
    font-size: 12px;
    border-top: none;
    margin-left: 0 !important;
    margin-top: 0 !important;
}
.app-footer p { margin: 0; color: rgba(255,255,255,0.85); }
.app-footer a { color: rgba(255,255,255,0.7); }

/* Override base.css mobile rules that turn the bell white — keep it dark in our topbar */
.ptp-topbar .notify-btn,
.ptp-topbar-actions .notify-btn {
    background: none !important;
    box-shadow: none !important;
    border-radius: 7px !important;
    width: 34px !important;
    height: 34px !important;
    font-size: 15px !important;
    color: var(--ptp-muted) !important;
    position: relative !important;
    top: auto !important;
    right: auto !important;
    z-index: 1 !important;
}
.ptp-topbar .notify-btn:hover,
.ptp-topbar-actions .notify-btn:hover {
    background: var(--ptp-hover) !important;
    color: rgba(255,255,255,0.85) !important;
}

/* =============================================
   AI AGENT BUTTON
   ============================================= */
#ai-agent-btn  { right: 20px !important; }
#ai-agent-panel { right: 20px !important; }

/* =============================================
   NOTIFY PANEL — reposition under topbar
   ============================================= */
@media (min-width: 768px) {
    #notifyPanel {
        position: fixed !important;
        top: calc(var(--ptp-top) + 6px) !important;
        right: 52px !important;
        left: auto !important;
        z-index: 9998 !important;
    }
}

/* =============================================
   MOBILE  (< 768px)
   ============================================= */
@media (max-width: 767px) {

    .ptp-hamburger { display: flex !important; }
    .ptp-topbar-nav { display: none; }
    .ptp-topbar-appname { display: none; }
    /* .ptp-topbar-nav (flex:1) is what normally pushes .ptp-topbar-actions
       to the right edge — hidden on mobile, so without this the actions
       group (notify/avatar) would sit right after the logo instead of
       staying flush right. */
    .ptp-topbar-actions { margin-left: auto; }

    /* Mobile drawer — full-height panel that slides in from the right edge,
       like a native app side-menu, instead of dropping down from the
       topbar. display:block here overrides the universal display:none base
       rule ONLY under this <768px media query; the slide itself is driven
       by the transform below (not by display), so .open just moves it
       on/off screen once it is actually laid out. */
    .ptp-mobile-drawer {
        display: block;
        position: fixed;
        top: 0;
        right: 0;
        bottom: 0;
        width: 78vw;
        max-width: 320px;
        background: var(--ptp-dark);
        border-left: 1px solid var(--ptp-border);
        /* Above the topbar's own z-index (300) — the drawer spans the full
           height including the area behind the topbar, and needs to win
           hit-testing there too, otherwise .ptp-topbar-actions (part of the
           300-layer topbar) intercepts clicks/taps meant for the drawer's
           own close button underneath it (confirmed real bug: the close
           button was visually correct and positioned exactly right, but
           real clicks never reached it because the topbar sat on top). */
        z-index: 301;
        padding: 8px 0 12px;
        box-shadow: -8px 0 24px rgba(0,0,0,0.4);
        transform: translateX(100%);
        transition: transform 0.25s ease;
        overflow-y: auto;
    }
    .ptp-mobile-drawer.open { transform: translateX(0); }

    .ptp-mobile-drawer-header {
        display: flex;
        align-items: center;
        justify-content: flex-end;
        padding: 10px 10px 4px;
    }
    .ptp-mobile-drawer-close {
        background: none;
        border: none;
        color: var(--ptp-muted);
        width: 34px;
        height: 34px;
        border-radius: 8px;
        display: flex;
        align-items: center;
        justify-content: center;
        font-size: 16px;
        cursor: pointer;
        padding: 0;
    }
    .ptp-mobile-drawer-close:hover { background: var(--ptp-hover); color: var(--ptp-white); }

    .ptp-mobile-drawer a {
        display: flex;
        align-items: center;
        gap: 12px;
        padding: 12px 20px;
        color: var(--ptp-muted);
        text-decoration: none;
        font-size: 14px;
        font-weight: 500;
        transition: background 0.12s, color 0.12s;
    }
    .ptp-mobile-drawer a:hover,
    .ptp-mobile-drawer a.active {
        background: var(--ptp-hover);
        color: var(--ptp-white);
    }
    .ptp-mobile-drawer a.active {
        color: var(--ptp-white);
        border-left: 3px solid var(--ptp-accent);
        padding-left: 17px;
    }
    .ptp-mobile-drawer a i { width: 18px; text-align: center; font-size: 14px; }

    /* .mobile-overlay (dimmed backdrop) is already toggled by ptpToggleDrawer
       via the existing global .mobile-overlay.active rule at the top of this
       file (z-index 250, below the drawer's 299) — no extra rule needed here,
       it works correctly as-is now that the drawer is a partial-width panel
       instead of a full-width dropdown that used to cover it anyway. */

    .ptp-main {
        padding: 16px 14px;
    }
}
