/* ═══════════════════════════════════════════════════════════════
   ERPAMA Framework - Layout System
   Sidebar, Header, Content Area, Navigation, Grids
   ═══════════════════════════════════════════════════════════════ */

/* ── APP WRAPPER ───────────────────────────────────────────── */
.app-wrapper {
    display: flex;
    min-height: 100vh;
}

/* ── SIDEBAR ───────────────────────────────────────────────── */
.sidebar {
    position: fixed;
    left: 0;
    top: 0;
    width: var(--sidebar-width);
    height: 100vh;
    background: var(--sidebar-bg);
    border-right: 1px solid var(--sidebar-border);
    display: flex;
    flex-direction: column;
    z-index: 1040;
    transition: transform var(--transition-slow), width var(--transition-slow);
    overflow: hidden;
}

.sidebar-brand {
    padding: 1.25rem 1.5rem;
    border-bottom: 1px solid var(--sidebar-border);
    display: flex;
    align-items: center;
    gap: 0.75rem;
    min-height: var(--header-height);
    flex-shrink: 0;
}

.sidebar-logo {
    width: 40px;
    height: 40px;
    min-width: 40px;
    border-radius: var(--radius-lg);
    background: linear-gradient(135deg, var(--accent), var(--accent-secondary));
    display: flex;
    align-items: center;
    justify-content: center;
    color: #fff;
    font-size: 1.25rem;
}

.sidebar-brand-text { overflow: hidden; white-space: nowrap; }
.sidebar-title { font-weight: 700; font-size: 1.1rem; color: var(--sidebar-text-active); }
.sidebar-subtitle { font-size: 0.75rem; color: var(--sidebar-text); opacity: 0.7; }

/* Sidebar Navigation */
.sidebar-nav {
    flex: 1;
    overflow-y: auto;
    overflow-x: hidden;
    padding: 0.75rem;
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
}

.sidebar-nav::-webkit-scrollbar { width: 4px; }
.sidebar-nav::-webkit-scrollbar-thumb { background: rgba(255,255,255,0.15); border-radius: 2px; }

.sidebar-section {
    padding-top: 0.5rem;
}

.sidebar-section:first-child { padding-top: 0; }

.sidebar-section-title {
    padding: 0.5rem 0.75rem;
    font-size: 0.68rem;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: var(--sidebar-text);
    opacity: 0.6;
    font-weight: 600;
}

/* Nav Items */
.nav-item {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.625rem 0.875rem;
    border-radius: var(--radius-md);
    color: var(--sidebar-text);
    text-decoration: none;
    transition: all var(--transition-fast);
    margin-bottom: 2px;
    font-size: 0.875rem;
    cursor: pointer;
    border: none;
    background: none;
    width: 100%;
    text-align: left;
}

.nav-item:hover {
    background: rgba(255,255,255,0.08);
    color: var(--sidebar-text-active);
    text-decoration: none;
}

.nav-item.active {
    background: var(--sidebar-active-bg);
    color: var(--sidebar-text-active);
    font-weight: 500;
}

.nav-item i { font-size: 1.125rem; width: 22px; text-align: center; flex-shrink: 0; }
.nav-item span { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.nav-item .badge { margin-left: auto; font-size: 0.65rem; }

/* Sidebar Footer */
.sidebar-footer {
    padding: 1rem;
    border-top: 1px solid var(--sidebar-border);
    flex-shrink: 0;
}

.sidebar-user {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.5rem;
}

.sidebar-user-avatar {
    width: 36px;
    height: 36px;
    min-width: 36px;
    border-radius: 50%;
    background: linear-gradient(135deg, var(--accent), var(--accent-secondary));
    display: flex;
    align-items: center;
    justify-content: center;
    color: #fff;
    font-size: 0.8rem;
    font-weight: 600;
}

.sidebar-user-info { overflow: hidden; }
.sidebar-user-name { font-size: 0.8125rem; font-weight: 500; color: var(--sidebar-text-active); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.sidebar-user-role { font-size: 0.7rem; color: var(--sidebar-text); opacity: 0.7; }

/* Sidebar Status */
.sidebar-status { padding: 0.75rem; }
.sidebar-status-header { display: flex; align-items: center; justify-content: space-between; margin-bottom: 0.5rem; }
.sidebar-status-label { font-size: 0.75rem; color: var(--sidebar-text); opacity: 0.7; }
.sidebar-status-value { font-size: 0.75rem; color: var(--accent); display: flex; align-items: center; gap: 4px; }

/* ── MAIN CONTENT ──────────────────────────────────────────── */
.main-content {
    flex: 1;
    margin-left: var(--sidebar-width);
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    transition: margin-left var(--transition-slow);
}

/* ── HEADER ────────────────────────────────────────────────── */
.header {
    position: sticky;
    top: 0;
    z-index: 1030;
    background: var(--header-bg);
    backdrop-filter: var(--header-blur);
    -webkit-backdrop-filter: var(--header-blur);
    border-bottom: 1px solid var(--border);
    min-height: var(--header-height);
}

.header-content {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 2rem;
    min-height: var(--header-height);
    gap: 1rem;
}

.header-left {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    min-width: 0;
}

.header-title {
    font-size: 1.25rem;
    font-weight: 600;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.header-subtitle { font-size: 0.8125rem; color: var(--text-muted); }

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

/* Header buttons */
.header-btn {
    width: 38px;
    height: 38px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: var(--radius-md);
    border: 1px solid var(--border);
    background: transparent;
    color: var(--text-primary);
    cursor: pointer;
    transition: all var(--transition-fast);
    position: relative;
}
.header-btn:hover { background: var(--bg-tertiary); }
.header-btn .notification-dot {
    position: absolute;
    top: 6px;
    right: 6px;
    width: 8px;
    height: 8px;
    background: var(--danger);
    border-radius: 50%;
}

/* User section */
.user-section {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding-left: 1rem;
    border-left: 1px solid var(--border);
}

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

.user-info { min-width: 0; }
.user-name { font-size: 0.875rem; font-weight: 500; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.user-role { font-size: 0.75rem; color: var(--text-muted); }

/* Mobile menu button */
.mobile-menu-btn {
    display: none;
    padding: 0.5rem;
    background: transparent;
    border: none;
    color: var(--text-primary);
    cursor: pointer;
    font-size: 1.5rem;
    line-height: 1;
}

/* Mobile overlay */
.mobile-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.5);
    z-index: 1039;
    opacity: 0;
    transition: opacity var(--transition-slow);
}
.mobile-overlay.active { display: block; opacity: 1; }

/* ── PAGE CONTENT ──────────────────────────────────────────── */
.page-content {
    padding: 2rem;
    flex: 1;
}

.page { display: none; }
.page.active { display: block; animation: fadeIn 0.2s ease; }

/* ── GRID SYSTEM ───────────────────────────────────────────── */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 1.5rem;
}

.charts-grid {
    display: grid;
    grid-template-columns: 2fr 1fr;
    gap: 1.5rem;
}

.analytics-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 1.5rem;
}

.settings-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 1.5rem;
}

/* ── MOBILE BOTTOM NAVIGATION ──────────────────────────────── */
.mobile-bottom-nav {
    display: none;
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    background: var(--bg-card);
    border-top: 1px solid var(--border);
    z-index: 1050;
    padding: 0.5rem 0;
    padding-bottom: calc(0.5rem + env(safe-area-inset-bottom, 0px));
    box-shadow: 0 -2px 10px rgba(0,0,0,0.15);
}

.mobile-bottom-nav .bottom-nav-items {
    display: flex;
    justify-content: space-around;
    align-items: center;
}

.bottom-nav-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 0.375rem 0.5rem;
    color: var(--text-muted);
    font-size: 0.625rem;
    text-decoration: none;
    border-radius: var(--radius-md);
    transition: all var(--transition-fast);
    border: none;
    background: none;
    cursor: pointer;
    min-width: 56px;
}
.bottom-nav-item i { font-size: 1.25rem; margin-bottom: 0.125rem; }
.bottom-nav-item.active { color: var(--accent); font-weight: 600; }
.bottom-nav-item:hover { color: var(--accent); }

/* Mobile more menu */
.mobile-more-menu {
    display: none;
    position: fixed;
    bottom: 70px;
    left: 0;
    right: 0;
    background: var(--bg-card);
    border-top: 1px solid var(--border);
    z-index: 1049;
    padding: 1rem;
    box-shadow: 0 -4px 20px rgba(0,0,0,0.2);
    border-radius: var(--radius-xl) var(--radius-xl) 0 0;
    max-height: 60vh;
    overflow-y: auto;
}
.mobile-more-menu.show { display: block; animation: slideUp 0.3s ease; }

.mobile-more-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 0.75rem;
}

.mobile-more-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 0.75rem 0.375rem;
    color: var(--text-secondary);
    text-decoration: none;
    border-radius: var(--radius-md);
    font-size: 0.7rem;
    text-align: center;
    transition: all var(--transition-fast);
    border: none;
    background: none;
    cursor: pointer;
}
.mobile-more-item:hover { background: var(--bg-tertiary); }
.mobile-more-item i { font-size: 1.375rem; margin-bottom: 0.375rem; color: var(--accent); }

/* ── FOOTER ────────────────────────────────────────────────── */
.footer {
    padding: 1rem 2rem;
    border-top: 1px solid var(--border);
    font-size: 0.8125rem;
    color: var(--text-muted);
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-shrink: 0;
}

/* ── MOBILE TABLE CARDS ────────────────────────────────────── */
.mobile-cards { display: none; }

.mobile-card-item {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: 1rem;
    margin-bottom: 0.75rem;
}

.mobile-card-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 0.75rem;
    padding-bottom: 0.75rem;
    border-bottom: 1px solid var(--border);
}

.mobile-card-title { font-weight: 600; }

.mobile-card-body { display: grid; gap: 0.5rem; }

.mobile-card-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-size: 0.8125rem;
}

.mobile-card-label { color: var(--text-muted); }
.mobile-card-value { font-weight: 500; text-align: right; }

.mobile-card-actions {
    margin-top: 0.75rem;
    padding-top: 0.75rem;
    border-top: 1px solid var(--border);
    display: flex;
    gap: 0.5rem;
    justify-content: flex-end;
}
