/* Layout Framework */
.wrapper {
    display: flex;
    min-height: 100vh;
}

/* Sidebar */
.sidebar {
    width: 280px;
    background-color: var(--sidebar-bg);
    color: var(--text-on-primary);
    position: fixed;
    height: 100vh;
    right: 0;
    top: 0;
    transition: var(--transition);
    z-index: 1000;
}

.sidebar-header {
    padding: var(--sp-6) var(--sp-4);
    text-align: center;
    border-bottom: 1px solid rgba(255,255,255,0.1);
}

.sidebar-logo {
    width: 64px;
    height: 64px;
    margin: 0 auto var(--sp-3);
    display: block;
}

.sidebar-brand h2 {
    color: var(--accent);
    font-size: 1.1em;
    margin: 0;
    font-weight: 700;
}

.sidebar-brand p {
    font-size: 0.8em;
    opacity: 0.8;
}

.sidebar-nav {
    padding: var(--sp-4) 0;
    overflow-y: auto;
    height: calc(100vh - 160px);
}

.nav-item {
    margin: var(--sp-1) 0;
}

.nav-link {
    display: flex;
    align-items: center;
    padding: var(--sp-3) var(--sp-6);
    color: rgba(255,255,255,0.7);
    font-weight: 600;
    transition: var(--transition);
    border-right: 4px solid transparent;
}

.nav-link i {
    width: 24px;
    margin-left: 12px;
    font-size: 1.1em;
    text-align: center;
}

.nav-link:hover {
    background-color: rgba(255,255,255,0.05);
    color: var(--accent);
}

.nav-link.active {
    background-color: rgba(255,255,255,0.1);
    color: var(--accent);
    border-right: 4px solid var(--accent);
}

.nav-group-title {
    padding: var(--sp-4) var(--sp-6) var(--sp-2);
    font-size: 0.8em;
    text-transform: uppercase;
    letter-spacing: 1px;
    color: var(--accent);
    font-weight: 700;
    opacity: 0.7;
}

/* Header Bar */
.main-content {
    flex: 1;
    margin-right: 280px;
    background-color: var(--bg);
    min-height: 100vh;
    transition: var(--transition);
    max-width: 100%; /* Ensure it does not exceed the container */
}

.header {
    height: 64px;
    background-color: var(--card-bg);
    border-bottom: 1px solid var(--border);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 var(--sp-6);
    position: sticky;
    top: 0;
    z-index: 900;
}

.header-title h1 {
    font-size: 1.25em;
    margin: 0;
    color: var(--primary);
    padding-top: 8px; /* Offset for Nastaliq height */
}

.header-meta {
    display: flex;
    align-items: center;
    gap: var(--sp-4);
    font-size: 0.9em;
    color: var(--text-muted);
}

/* User Profile Header Section */
.user-profile {
    display: flex;
    align-items: center;
    gap: var(--sp-3);
    padding: var(--sp-1) var(--sp-2);
    border-radius: var(--radius-md);
    transition: var(--transition);
    cursor: default;
}

.user-avatar {
    position: relative;
    font-size: 2.2em;
    display: flex;
    align-items: center;
    justify-content: center;
}

.status-indicator {
    position: absolute;
    bottom: 2px;
    right: 2px;
    width: 10px;
    height: 10px;
    background-color: var(--success);
    border: 2px solid var(--card-bg);
    border-radius: 50%;
    animation: pulse-green 2s infinite;
}

@keyframes pulse-green {
    0% { box-shadow: 0 0 0 0 rgba(39, 174, 96, 0.4); }
    70% { box-shadow: 0 0 0 6px rgba(39, 174, 96, 0); }
    100% { box-shadow: 0 0 0 0 rgba(39, 174, 96, 0); }
}

.user-details {
    display: flex;
    flex-direction: column;
    text-align: right;
    line-height: 1.2;
}

.user-name {
    font-weight: 700;
    color: var(--primary);
    font-size: 1.05em;
    font-family: var(--font-urdu);
}

.user-role {
    font-size: 0.8em;
    color: var(--accent);
    font-weight: 600;
    opacity: 0.9;
}

.btn-icon {
    width: 38px;
    height: 38px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    padding: 0;
}


.mobile-toggle {
    display: none;
    font-size: 1.5em;
    cursor: pointer;
    color: var(--primary);
}

/* Content Area */
.content-area {
    padding: var(--sp-6);
    max-width: 1400px;
    margin: 0 auto;
}

/* Responsive Breakpoints */
@media (max-width: 1024px) {
    .sidebar {
        transform: translateX(100%);
        box-shadow: -5px 0 15px rgba(0,0,0,0.1);
    }
    
    .sidebar.show {
        transform: translateX(0);
    }
    
    .main-content {
        margin-right: 0;
        max-width: 100%;
    }
    
    .mobile-toggle {
        display: block;
    }
    
    .sidebar-overlay {
        display: none;
        position: fixed;
        top: 0;
        left: 0;
        width: 100%;
        height: 100%;
        background: rgba(0,0,0,0.5);
        z-index: 999;
    }
    
    .sidebar-overlay.show {
        display: block;
    }
}

@media (max-width: 768px) {
    .header {
        padding: 0 var(--sp-4);
        justify-content: flex-start; /* Title is RTL, but title and toggle should be far apart */
    }
    
    .header-title {
        flex: 1;
        text-align: right;
    }
    
    .header-meta {
        display: none;
    }
    
    .content-area {
        padding: var(--sp-4);
    }
}

@media (max-width: 480px) {
    .header {
        padding: 0 var(--sp-3);
    }
    
    .content-area {
        padding: var(--sp-2) var(--sp-2);
    }
    
    .header-title h1 {
        font-size: 1.1em;
    }

    .card-body {
        padding: var(--sp-3) !important;
    }
}
