/**
 * Operra Shell — SPA Layout
 * Sprint UX-1: Header, collapsible sidebar, responsive shell
 *
 * Coexists with existing style.css — uses CSS variables already defined.
 * No Tailwind dependency — pure CSS for the structural shell.
 */

/* ─── Shell Header ──────────────────────────────────────────── */

.shell-header {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    height: 48px;
    z-index: 1100;
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 1rem;
    background: var(--bg-secondary, #1a1a2e);
    border-bottom: 1px solid var(--border-color, #2d2d44);
    gap: 0.75rem;
    transition: left 0.25s ease;
    overflow: hidden;
}

.shell-header-left {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    min-width: 0;
    flex-shrink: 1;
    overflow: hidden;
}

.shell-header-center {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    min-width: 0;
    flex-shrink: 1;
}

.shell-header-right {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    flex-shrink: 0;
}

/* Hamburger in header (mobile) */
.shell-hamburger {
    display: none;
    background: none;
    border: none;
    color: var(--text-primary, #e0e0e0);
    cursor: pointer;
    padding: 0.25rem;
    border-radius: var(--radius-sm, 4px);
    line-height: 0;
}

.shell-hamburger:hover {
    background: var(--bg-hover, rgba(255,255,255,0.08));
}

/* Logo in header */
.shell-logo {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-weight: 700;
    font-size: 1.1rem;
    color: var(--text-primary, #e0e0e0);
    text-decoration: none;
    white-space: nowrap;
}

.shell-logo-icon {
    width: 28px;
    height: 28px;
    background: var(--accent-color, #4a6cf7);
    border-radius: 6px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 800;
    font-size: 0.85rem;
    color: #fff;
    flex-shrink: 0;
}

/* Tenant name */
.shell-tenant {
    font-size: 0.8rem;
    color: var(--text-secondary, #8888a0);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 200px;
}

/* Notification bell */
.shell-notif-btn {
    position: relative;
    background: none;
    border: none;
    color: var(--text-secondary, #8888a0);
    cursor: pointer;
    padding: 0.4rem;
    border-radius: var(--radius-sm, 4px);
    line-height: 0;
    transition: color 0.15s, background 0.15s;
}

.shell-notif-btn:hover {
    color: var(--text-primary, #e0e0e0);
    background: var(--bg-hover, rgba(255,255,255,0.08));
}

.shell-notif-badge {
    position: absolute;
    top: 2px;
    right: 2px;
    background: #ef4444;
    color: #fff;
    font-size: 0.6rem;
    font-weight: 700;
    min-width: 16px;
    height: 16px;
    line-height: 16px;
    text-align: center;
    border-radius: 8px;
    padding: 0 3px;
    pointer-events: none;
}

.shell-notif-badge:empty,
.shell-notif-badge[data-count="0"] {
    display: none;
}

/* User menu button */
.shell-user-btn {
    display: flex;
    align-items: center;
    gap: 0.4rem;
    background: none;
    border: none;
    color: var(--text-primary, #e0e0e0);
    cursor: pointer;
    padding: 0.3rem 0.5rem;
    border-radius: var(--radius-sm, 4px);
    font-size: 0.8rem;
    transition: background 0.15s;
    white-space: nowrap;
}

.shell-user-btn:hover {
    background: var(--bg-hover, rgba(255,255,255,0.08));
}

.shell-user-avatar {
    width: 26px;
    height: 26px;
    border-radius: 50%;
    background: var(--accent-color, #4a6cf7);
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    font-size: 0.7rem;
    color: #fff;
    flex-shrink: 0;
    text-transform: uppercase;
}

.shell-user-name {
    max-width: 120px;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* ─── Dropdown menus ────────────────────────────────────────── */

.shell-dropdown {
    position: absolute;
    top: 100%;
    right: 0;
    margin-top: 4px;
    background: var(--bg-secondary, #1a1a2e);
    border: 1px solid var(--border-color, #2d2d44);
    border-radius: var(--radius-md, 8px);
    box-shadow: 0 8px 24px rgba(0,0,0,0.3);
    min-width: 200px;
    z-index: 1200;
    overflow: hidden;
    animation: shell-dropdown-in 0.15s ease;
}

@keyframes shell-dropdown-in {
    from { opacity: 0; transform: translateY(-4px); }
    to { opacity: 1; transform: translateY(0); }
}

.shell-dropdown-item {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.6rem 1rem;
    font-size: 0.8rem;
    color: var(--text-primary, #e0e0e0);
    cursor: pointer;
    transition: background 0.1s;
    border: none;
    background: none;
    width: 100%;
    text-align: left;
}

.shell-dropdown-item:hover {
    background: var(--bg-hover, rgba(255,255,255,0.08));
}

.shell-dropdown-divider {
    height: 1px;
    background: var(--border-color, #2d2d44);
    margin: 0.25rem 0;
}

.shell-dropdown-label {
    padding: 0.4rem 1rem 0.2rem;
    font-size: 0.65rem;
    color: var(--text-secondary, #8888a0);
    text-transform: uppercase;
    letter-spacing: 0.05em;
    font-weight: 600;
}

/* Notification dropdown — wider */
.shell-dropdown-notif {
    min-width: 320px;
    max-height: 400px;
    overflow-y: auto;
}

.shell-notif-empty {
    padding: 2rem 1rem;
    text-align: center;
    color: var(--text-secondary, #8888a0);
    font-size: 0.8rem;
}

/* ─── Sidebar collapse ──────────────────────────────────────── */

.sidebar {
    transition: width 0.25s ease;
}

/* Push body content below fixed header */
body.shell-active {
    padding-top: 48px;
}

body.shell-active .sidebar {
    top: 48px;
    height: calc(100vh - 48px);
}

/* Fix main content height: subtract header from viewport */
body.shell-active .main-content {
    height: calc(100vh - 48px);
}

/* Tab content panels must scroll vertically */
body.shell-active .tab-content {
    overflow-y: auto;
    max-height: 100%;
}

/* Hide sidebar header (logo) when shell header is present */
body.shell-active .sidebar-header {
    display: none;
}

/* Collapsed state */
body.shell-active .sidebar.collapsed {
    width: 56px;
    overflow: hidden;
}

body.shell-active .sidebar.collapsed .sidebar-session,
body.shell-active .sidebar.collapsed .nav-section-title,
body.shell-active .sidebar.collapsed .sidebar-settings,
body.shell-active .sidebar.collapsed .sidebar-footer,
body.shell-active .sidebar.collapsed .demo-cta,
body.shell-active .sidebar.collapsed .sidebar-divider {
    display: none;
}

body.shell-active .sidebar.collapsed .nav-btn {
    justify-content: center;
    padding: 0.6rem;
}

body.shell-active .sidebar.collapsed .nav-btn span,
body.shell-active .sidebar.collapsed .nav-btn i {
    display: none;
}

body.shell-active .sidebar.collapsed .nav-btn svg {
    margin: 0;
}

/* Tooltip on collapsed icons */
body.shell-active .sidebar.collapsed .nav-btn {
    position: relative;
}

body.shell-active .sidebar.collapsed .nav-btn::after {
    content: attr(data-tab);
    position: absolute;
    left: 100%;
    top: 50%;
    transform: translateY(-50%);
    background: var(--bg-secondary, #1a1a2e);
    border: 1px solid var(--border-color, #2d2d44);
    color: var(--text-primary, #e0e0e0);
    padding: 0.3rem 0.6rem;
    border-radius: var(--radius-sm, 4px);
    font-size: 0.7rem;
    white-space: nowrap;
    pointer-events: none;
    opacity: 0;
    transition: opacity 0.15s;
    margin-left: 4px;
    z-index: 1300;
}

body.shell-active .sidebar.collapsed .nav-btn:hover::after {
    opacity: 1;
}

/* Collapse toggle button */
.shell-collapse-btn {
    position: absolute;
    bottom: 12px;
    right: -12px;
    width: 24px;
    height: 24px;
    background: var(--bg-secondary, #1a1a2e);
    border: 1px solid var(--border-color, #2d2d44);
    border-radius: 50%;
    color: var(--text-secondary, #8888a0);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1100;
    transition: transform 0.25s, color 0.15s;
    line-height: 0;
    padding: 0;
}

.shell-collapse-btn:hover {
    color: var(--text-primary, #e0e0e0);
}

body.shell-active .sidebar.collapsed .shell-collapse-btn {
    transform: rotate(180deg);
}

/* Adjust main content when sidebar collapsed */
body.shell-active .main-content {
    transition: margin-left 0.25s ease;
}

/* ─── Breadcrumb ────────────────────────────────────────────── */

.shell-breadcrumb {
    font-size: 0.75rem;
    color: var(--text-secondary, #8888a0);
    display: flex;
    align-items: center;
    gap: 0.3rem;
}

.shell-breadcrumb-sep {
    color: var(--text-secondary, #8888a0);
    opacity: 0.5;
}

.shell-breadcrumb-current {
    color: var(--text-primary, #e0e0e0);
    font-weight: 500;
}
