/* ============================================
   RAMOZ DESIGN SYSTEM — LAYOUT
   Dark sidebar + light content, responsive
   ============================================ */

/* ============ APP SHELL ============ */
.app-shell {
    display: flex;
    min-height: 100vh;
    width: 100%;
}

/* ============ SIDEBAR ============ */
.sidebar {
    position: fixed;
    top: 0;
    right: 0;
    bottom: 0;
    width: var(--sidebar-width);
    background: var(--sidebar-bg);
    color: var(--sidebar-text);
    display: flex;
    flex-direction: column;
    z-index: 100;
    transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1), width 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    box-shadow: 4px 0 20px rgba(0, 0, 0, 0.15);
    overflow: hidden;
}

.sidebar-header {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 20px 20px;
    background: var(--sidebar-header-bg);
    border-bottom: 1px solid var(--sidebar-border);
    min-height: var(--topbar-height);
    flex-shrink: 0;
}

.sidebar-logo {
    width: 40px;
    height: 40px;
    border-radius: var(--radius-lg);
    background: linear-gradient(135deg, var(--brand-500), var(--brand-700));
    display: flex;
    align-items: center;
    justify-content: center;
    color: #fff;
    font-size: 1.3rem;
    flex-shrink: 0;
}

.sidebar-title {
    color: #fff;
    font-weight: 700;
    font-size: 1.05rem;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.sidebar-subtitle {
    color: var(--sidebar-text);
    font-size: 0.75rem;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.sidebar-body {
    flex: 1;
    overflow-y: auto;
    overflow-x: hidden;
    padding: 16px 12px;
}

.sidebar-body::-webkit-scrollbar { width: 6px; }
.sidebar-body::-webkit-scrollbar-thumb { background: #374151; }

.sidebar-section {
    margin-bottom: 8px;
}

.sidebar-section-label {
    font-size: 0.72rem;
    font-weight: 600;
    color: #4b5563;
    padding: 8px 12px 6px;
    letter-spacing: 0.04em;
    white-space: nowrap;
    overflow: hidden;
}

.sidebar-nav {
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.sidebar-link {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 11px 14px;
    border-radius: var(--radius-md);
    color: var(--sidebar-text);
    font-weight: 500;
    font-size: 0.92rem;
    text-decoration: none;
    transition: var(--transition);
    white-space: nowrap;
    position: relative;
}

.sidebar-link i {
    width: 22px;
    text-align: center;
    font-size: 1.05rem;
    flex-shrink: 0;
    color: #6b7280;
    transition: var(--transition);
}

.sidebar-link:hover {
    background: var(--sidebar-bg-hover);
    color: #e5e7eb;
}

.sidebar-link:hover i { color: var(--brand-400); }

.sidebar-link.active {
    background: var(--sidebar-bg-active);
    color: var(--sidebar-text-active);
    box-shadow: 0 4px 12px rgba(37, 99, 235, 0.35);
}

.sidebar-link.active i {
    color: #fff;
}

.sidebar-link .link-badge {
    margin-right: auto;
    background: var(--danger-500);
    color: #fff;
    font-size: 0.68rem;
    font-weight: 700;
    min-width: 20px;
    height: 20px;
    border-radius: var(--radius-full);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 0 6px;
}

.sidebar-footer {
    padding: 16px;
    border-top: 1px solid var(--sidebar-border);
    flex-shrink: 0;
}

.sidebar-footer .user-info {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px 12px;
    border-radius: var(--radius-md);
    background: var(--sidebar-bg-hover);
}

.user-avatar {
    width: 38px;
    height: 38px;
    border-radius: 50%;
    background: linear-gradient(135deg, var(--brand-500), var(--info-600));
    display: flex;
    align-items: center;
    justify-content: center;
    color: #fff;
    font-weight: 700;
    flex-shrink: 0;
    font-size: 0.95rem;
}

.user-meta { min-width: 0; }
.user-name { color: #fff; font-weight: 600; font-size: 0.9rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.user-role { color: var(--sidebar-text); font-size: 0.78rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

/* ============ MAIN AREA ============ */
.main-area {
    flex: 1;
    min-width: 0;
    margin-right: var(--sidebar-width);
    display: flex;
    flex-direction: column;
    transition: margin-right 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

/* ============ TOPBAR ============ */
.topbar {
    position: sticky;
    top: 0;
    z-index: 90;
    height: var(--topbar-height);
    background: var(--topbar-bg);
    border-bottom: 1px solid var(--topbar-border);
    display: flex;
    align-items: center;
    gap: 16px;
    padding: 0 24px;
    box-shadow: var(--shadow-xs);
}

.topbar-start { display: flex; align-items: center; gap: 14px; flex: 1; min-width: 0; }

.sidebar-toggle {
    width: 40px;
    height: 40px;
    border: 1px solid var(--border-light);
    background: var(--bg-card);
    border-radius: var(--radius-md);
    color: var(--text-secondary);
    font-size: 1.1rem;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    transition: var(--transition);
    flex-shrink: 0;
}

.sidebar-toggle:hover {
    background: var(--brand-50);
    color: var(--brand-600);
    border-color: var(--brand-300);
}

.topbar-title {
    font-size: 1.1rem;
    font-weight: 700;
    color: var(--text-primary);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.breadcrumb {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: var(--font-size-sm);
    color: var(--text-muted);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.breadcrumb a { color: var(--text-muted); }
.breadcrumb a:hover { color: var(--brand-600); }
.breadcrumb .separator { color: var(--gray-300); }

.topbar-end { display: flex; align-items: center; gap: 10px; flex-shrink: 0; }

/* ============ CONTENT ============ */
.page-content {
    flex: 1;
    padding: 28px 32px 48px;
    animation: fadeIn 0.35s cubic-bezier(0.16, 1, 0.3, 1) forwards;
}

.page-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: 16px;
    margin-bottom: 24px;
}

.page-header h1 {
    font-size: 1.4rem;
    font-weight: 800;
    display: flex;
    align-items: center;
    gap: 12px;
}

.page-header h1 i {
    color: var(--brand-600);
}

.page-header .page-subtitle {
    color: var(--text-muted);
    font-size: var(--font-size-sm);
    margin-top: 4px;
}

.page-header-actions {
    display: flex;
    align-items: center;
    gap: 10px;
    flex-wrap: wrap;
}

/* ============ SIDEBAR OVERLAY (mobile) ============ */
.sidebar-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(17, 24, 39, 0.6);
    backdrop-filter: blur(2px);
    z-index: 95;
}

/* ============ RESPONSIVE ============ */
@media (max-width: 1024px) {
    .sidebar {
        transform: translateX(100%);
        width: var(--sidebar-width) !important;
        box-shadow: -8px 0 30px rgba(0, 0, 0, 0.3);
    }

    .main-area { margin-right: 0; }

    .sidebar.open { transform: translateX(0); }
    .sidebar-overlay.show { display: block; }
}

@media (max-width: 768px) {
    .page-content { padding: 20px 16px 40px; }
    .topbar { padding: 0 16px; }
    .topbar-title { font-size: 1rem; }
    .breadcrumb { display: none; }
    .page-header { flex-direction: column; align-items: flex-start; }
    .page-header-actions { width: 100%; }
    .page-header-actions .btn { flex: 1; justify-content: center; }
}

@media (min-width: 1025px) {
    /* Nested sidebar-link labels on desktop */
    .sidebar.collapsed {
        width: var(--sidebar-width-collapsed);
    }
    .sidebar.collapsed .sidebar-title,
    .sidebar.collapsed .sidebar-subtitle,
    .sidebar.collapsed .sidebar-section-label,
    .sidebar.collapsed .sidebar-link span:not(.link-badge),
    .sidebar.collapsed .user-meta,
    .sidebar.collapsed .link-badge {
        display: none;
    }
    .sidebar.collapsed .sidebar-header { justify-content: center; padding: 20px 8px; }
    .sidebar.collapsed .sidebar-link { justify-content: center; padding: 12px; }
    .sidebar.collapsed .sidebar-footer .user-info { justify-content: center; padding: 8px; }
    .sidebar.collapsed .sidebar-footer .user-avatar { display: none; }
    .main-area.sidebar-collapsed { margin-right: var(--sidebar-width-collapsed); }
}
