/* ============================================================
   ABOODVIDEO Viewer Design System V2 — Shell
   Sticky header, brand, nav, search, mobile drawer, footer.
   RTL-first. Uses canonical tokens from viewer_tokens.css.
   ============================================================ */

/* ----------------------------------------------------------------
   Global Base
   ---------------------------------------------------------------- */
*, *::before, *::after { box-sizing: border-box; }

html {
    font-family: var(--font-family);
    font-size:   var(--text-md);
    color:       var(--text);
    background:  var(--bg);
    scroll-behavior: smooth;
}

body {
    margin: 0;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

a { color: inherit; }

/* ----------------------------------------------------------------
   Layout Container
   ---------------------------------------------------------------- */
.viewer-container {
    max-width: var(--viewer-max-width);
    margin:    0 auto;
    padding:   0 24px;
    width:     100%;
}

/* ----------------------------------------------------------------
   Sticky Header
   ---------------------------------------------------------------- */
.viewer-header {
    position:      sticky;
    top:           0;
    height:        var(--viewer-header-height);
    background:    var(--sidebar-bg);
    border-bottom: 1px solid var(--border);
    z-index:       100;
    transition:    background var(--transition-base),
                   box-shadow var(--transition-base),
                   border-color var(--transition-base);
}

.viewer-header.is-scrolled {
    background:  rgba(5,7,16,0.96);
    box-shadow:  0 6px 24px rgba(0,0,0,0.50);
    border-color: var(--border-strong);
}

.viewer-header-inner {
    height:      100%;
    display:     flex;
    align-items: center;
    gap:         24px;
}

/* ----------------------------------------------------------------
   Brand Logo
   ---------------------------------------------------------------- */
.viewer-brand {
    display:         flex;
    align-items:     center;
    font-size:       20px;
    font-weight:     800;
    letter-spacing:  0.02em;
    color:           var(--text);
    text-decoration: none;
    direction:       ltr;
    flex-shrink:     0;
    white-space:     nowrap;
    line-height:     1;
}

.brand-accent {
    color:       var(--accent);
    font-weight: 900;
}

/* ----------------------------------------------------------------
   Desktop Navigation
   ---------------------------------------------------------------- */
.viewer-nav {
    display:     flex;
    align-items: center;
    gap:         4px;
    flex:        1;
    list-style:  none;
    margin:      0;
    padding:     0;
}

.viewer-nav-link {
    padding:         0 14px;
    height:          36px;
    display:         flex;
    align-items:     center;
    border-radius:   var(--radius-md);
    color:           var(--text-secondary);
    text-decoration: none;
    font-size:       var(--text-sm);
    font-weight:     500;
    transition:      background var(--transition-fast),
                     color var(--transition-fast);
    white-space:     nowrap;
}

.viewer-nav-link:hover {
    background: var(--surface-hover);
    color:      var(--text);
}

.viewer-nav-link.is-active {
    color:       var(--text);
    font-weight: 600;
    background:  var(--surface-hover);
}

/* ----------------------------------------------------------------
   Header Search
   ---------------------------------------------------------------- */
.viewer-header-search {
    flex:     1;
    max-width: 360px;
    position: relative;
}

.viewer-header-search form,
.viewer-header-search-form {
    position: relative;
    width:    100%;
}

.viewer-search-icon {
    position:       absolute;
    inset-inline-end: 10px;
    top:            50%;
    transform:      translateY(-50%);
    width:          16px;
    height:         16px;
    color:          var(--text-muted);
    pointer-events: none;
}

.viewer-header-search-input,
.viewer-search-input {
    width:         100%;
    height:        34px;
    background:    var(--surface-2);
    border:        1px solid var(--border);
    border-radius: var(--radius-md);
    padding:       0 36px 0 12px;
    color:         var(--text);
    font-family:   var(--font-family);
    font-size:     var(--text-sm);
    outline:       none;
    transition:    border-color var(--transition-fast),
                   box-shadow var(--transition-fast);
}

.viewer-header-search-input:focus,
.viewer-search-input:focus {
    border-color: var(--border-focus);
    box-shadow:   0 0 0 3px rgba(37,99,235,0.18);
}

.viewer-header-search-input::placeholder,
.viewer-search-input::placeholder {
    color: var(--text-muted);
}

/* Search shortcut badge (desktop only) */
.viewer-search-shortcut {
    position:       absolute;
    inset-inline-start: 10px;
    top:            50%;
    transform:      translateY(-50%);
    font-size:      10px;
    font-weight:    600;
    color:          var(--text-muted);
    background:     rgba(255,255,255,0.05);
    border:         1px solid var(--border);
    border-radius:  4px;
    padding:        1px 5px;
    pointer-events: none;
    line-height:    1.6;
}

/* ----------------------------------------------------------------
   Header Actions
   ---------------------------------------------------------------- */
.viewer-header-actions {
    display:     flex;
    align-items: center;
    gap:         8px;
    flex-shrink: 0;
}

.viewer-admin-link {
    display:         flex;
    align-items:     center;
    gap:             6px;
    padding:         0 12px;
    height:          32px;
    border:          1px solid var(--border-strong);
    border-radius:   var(--radius-md);
    font-size:       var(--text-xs);
    font-weight:     600;
    color:           var(--text-secondary);
    text-decoration: none;
    white-space:     nowrap;
    transition:      border-color var(--transition-fast),
                     color var(--transition-fast),
                     background var(--transition-fast);
}

.viewer-admin-link:hover {
    border-color: var(--accent);
    color:        var(--accent);
    background:   var(--accent-light);
}

.viewer-admin-link svg {
    flex-shrink: 0;
}

/* ----------------------------------------------------------------
   Hamburger Button (mobile only)
   ---------------------------------------------------------------- */
.viewer-hamburger {
    display:         none;
    align-items:     center;
    justify-content: center;
    width:           38px;
    height:          38px;
    border-radius:   var(--radius-md);
    background:      var(--surface-2);
    border:          1px solid var(--border);
    color:           var(--text);
    cursor:          pointer;
    padding:         0;
    transition:      background var(--transition-fast);
}

.viewer-hamburger:hover { background: var(--surface-3); }

.viewer-hamburger svg {
    width:  20px;
    height: 20px;
}

/* ----------------------------------------------------------------
   Mobile Drawer Backdrop
   ---------------------------------------------------------------- */
.viewer-drawer-backdrop {
    position:       fixed;
    inset:          0;
    background:     rgba(3,6,16,0.72);
    display:        none;
    z-index:        200;
    cursor:         pointer;
}

.viewer-drawer-backdrop.is-open { display: block; }

/* ----------------------------------------------------------------
   Mobile Drawer
   ---------------------------------------------------------------- */
.viewer-drawer {
    position:         fixed;
    top:              0;
    bottom:           0;
    height:           100vh;
    width:            min(280px, 88vw);
    background:       var(--sidebar-bg);
    border-inline-start: 1px solid var(--border);
    box-shadow:       -8px 0 32px rgba(0,0,0,0.60);
    z-index:          300;
    transition:       transform var(--transition-smooth);
    display:          flex;
    flex-direction:   column;
    overflow-y:       auto;
}

[dir="rtl"] .viewer-drawer {
    left: 0;
    right: auto;
    transform: translateX(-100%);
}

[dir="ltr"] .viewer-drawer {
    right: 0;
    left: auto;
    transform: translateX(100%);
}

.viewer-drawer.is-open {
    transform: translateX(0) !important;
}

@media (min-width: 901px) {
    .viewer-drawer,
    .viewer-drawer-backdrop {
        display: none !important;
    }
}

.viewer-drawer-header {
    height:          60px;
    display:         flex;
    align-items:     center;
    justify-content: space-between;
    padding:         0 20px;
    border-bottom:   1px solid var(--border);
    flex-shrink:     0;
}

.viewer-drawer-close {
    background:    var(--surface-2);
    border:        1px solid var(--border);
    color:         var(--text-secondary);
    border-radius: var(--radius-md);
    width:         34px;
    height:        34px;
    display:       flex;
    align-items:   center;
    justify-content: center;
    cursor:        pointer;
    padding:       0;
    transition:    color var(--transition-fast), background var(--transition-fast);
}

.viewer-drawer-close:hover {
    color:       var(--text);
    background:  var(--surface-hover);
}

.viewer-drawer-nav {
    list-style:     none;
    padding:        12px 8px;
    margin:         0;
    display:        flex;
    flex-direction: column;
    gap:            2px;
}

.viewer-drawer-nav li a,
.viewer-drawer-link {
    height:          40px;
    display:         flex;
    align-items:     center;
    padding:         0 12px;
    border-radius:   var(--radius-md);
    color:           var(--text-secondary);
    font-size:       var(--text-sm);
    text-decoration: none;
    font-weight:     500;
    transition:      background var(--transition-fast),
                     color var(--transition-fast);
}

.viewer-drawer-nav li a:hover,
.viewer-drawer-link:hover,
.viewer-drawer-nav li a.is-active,
.viewer-drawer-link.is-active {
    background: var(--surface-hover);
    color:      var(--text);
}

.viewer-drawer-link.is-active {
    border-inline-start: 2px solid var(--accent);
}

.viewer-drawer-search {
    padding: 12px;
}

.viewer-drawer-search .viewer-input,
.viewer-drawer-search input[type="search"] {
    width:         100%;
    height:        36px;
    background:    var(--surface-2);
    border:        1px solid var(--border);
    border-radius: var(--radius-md);
    padding:       0 12px;
    color:         var(--text);
    font-family:   var(--font-family);
    font-size:     var(--text-sm);
    outline:       none;
    transition:    border-color var(--transition-fast);
}

.viewer-drawer-search .viewer-input:focus,
.viewer-drawer-search input[type="search"]:focus {
    border-color: var(--border-focus);
}

/* ----------------------------------------------------------------
   Main Content
   ---------------------------------------------------------------- */
.viewer-main {
    flex:       1;
    min-height: calc(100vh - var(--viewer-header-height));
}

/* ----------------------------------------------------------------
   Footer
   ---------------------------------------------------------------- */
.viewer-footer {
    background:  var(--sidebar-bg);
    border-top:  1px solid var(--border);
    padding:     32px 0 24px;
    margin-top:  auto;
}

.viewer-footer-inner {
    display:        flex;
    flex-direction: column;
    align-items:    center;
    gap:            16px;
}

.viewer-footer-top {
    display:     flex;
    align-items: center;
    gap:         32px;
    flex-wrap:   wrap;
    justify-content: center;
}

.viewer-footer-links {
    list-style: none;
    display:    flex;
    gap:        24px;
    margin:     0;
    padding:    0;
    flex-wrap:  wrap;
}

.viewer-footer-links li a {
    color:           var(--text-secondary);
    text-decoration: none;
    font-size:       var(--text-sm);
    transition:      color var(--transition-fast);
}

.viewer-footer-links li a:hover { color: var(--text); }

.viewer-footer-copy {
    font-size: var(--text-xs);
    color:     var(--text-muted);
    text-align: center;
}

/* ----------------------------------------------------------------
   Error Page
   ---------------------------------------------------------------- */
.error-page {
    min-height:      60vh;
    display:         flex;
    align-items:     center;
    justify-content: center;
    padding:         24px;
}

.error-container {
    text-align: center;
    max-width:  480px;
    padding:    40px 24px;
}

.error-icon {
    margin-bottom: 24px;
    opacity:       0.6;
    display:       flex;
    align-items:   center;
    justify-content: center;
}

.error-title {
    font-size:   24px;
    font-weight: 700;
    color:       var(--text);
    margin:      0 0 12px;
}

.error-message {
    font-size: var(--text-sm);
    color:     var(--text-secondary);
    margin:    12px 0 24px;
    line-height: 1.6;
}

.error-actions {
    display:         flex;
    gap:             12px;
    justify-content: center;
    flex-wrap:       wrap;
}

/* Shared btn styles for error page */
.btn {
    display:         inline-flex;
    align-items:     center;
    justify-content: center;
    height:          var(--btn-h-lg);
    padding:         0 20px;
    border-radius:   var(--radius-md);
    font-size:       var(--text-md);
    font-weight:     600;
    text-decoration: none;
    cursor:          pointer;
    border:          none;
    transition:      background var(--transition-fast),
                     color var(--transition-fast),
                     border-color var(--transition-fast);
}

.btn-primary {
    background: var(--primary);
    color:      #fff;
}

.btn-primary:hover { background: var(--primary-hover); }

.btn-secondary {
    background: transparent;
    color:      var(--text-secondary);
    border:     1px solid var(--border-strong);
}

.btn-secondary:hover {
    background: var(--surface-hover);
    color:      var(--text);
}

.error-code {
    font-size:    var(--text-xs);
    color:        var(--text-muted);
    font-family:  var(--font-mono);
    margin-top:   20px;
}

/* Legacy viewer-btn aliases used by existing pages */
.viewer-btn          { @extend .btn; }
.viewer-btn-primary  { @extend .btn-primary; }
.viewer-btn-secondary { @extend .btn-secondary; }

/* ----------------------------------------------------------------
   Responsive — Shell
   ---------------------------------------------------------------- */
@media (max-width: 900px) {
    .viewer-nav          { display: none; }
    .viewer-hamburger    { display: flex; }
    .viewer-header-search { max-width: 220px; }
    .viewer-search-shortcut { display: none; }
}

@media (max-width: 600px) {
    .viewer-header-search { display: none; }
    .viewer-admin-link .admin-label { display: none; }
    .viewer-container { padding: 0 16px; }
}


/* P0.6 viewer shell refinements */
.viewer-main{min-height:calc(100vh - var(--topbar-height))}.viewer-container{width:min(100% - 40px,var(--viewer-max-width,1440px));margin-inline:auto}.viewer-header{background:var(--bg-surface);border-bottom:1px solid var(--border-subtle)}.viewer-nav-link.is-active{color:var(--text-primary)}.viewer-hamburger,.viewer-drawer-close{min-width:40px;min-height:40px}@media(max-width:640px){.viewer-container{width:calc(100% - 28px)}.viewer-row-section{margin-block:22px}.viewer-grid{grid-template-columns:repeat(2,minmax(0,1fr));gap:12px}}
