/* Mihrab Al-Bahith - Premium Scholar Stylesheet */
:root {
    --primary: #064E3B; /* Deep Scholar Emerald */
    --primary-light: #10B981;
    --secondary: #D97706; /* Academic Gold */
    --accent: #B45309; 
    --bg-dark: #0F172A; /* Deep Charcoal/Navy */
    --sidebar-bg: rgba(15, 23, 42, 0.95);
    --card-bg: rgba(30, 41, 59, 0.7);
    --text-main: #F1F5F9;
    --text-muted: #94A3B8;
    --glass-bg: rgba(255, 255, 255, 0.05);
    --glass-border: rgba(255, 255, 255, 0.1);
    --gold-gradient: linear-gradient(135deg, #F59E0B 0%, #B45309 100%);
    --emerald-gradient: linear-gradient(135deg, #065F46 0%, #064E3B 100%);
    --transition: all 0.4s cubic-bezier(0.4, 0, 0.2, 1);
    --modal-bg: rgba(0, 0, 0, 0.85);
}

.hidden { display: none !important; }

.auth-pending .app-container { display: none; }
.auth-pending #auth-gate { display: flex; }

.modal-overlay {
    position: fixed;
    top: 0; left: 0;
    width: 100%; height: 100%;
    background: var(--modal-bg);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
    backdrop-filter: blur(10px);
}

* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
    font-family: 'Tajawal', sans-serif;
}

body {
    background: var(--bg-dark);
    color: var(--text-main);
    overflow: hidden;
    height: 100vh;
    display: flex;
    background-image: 
        radial-gradient(at 0% 0%, rgba(6, 78, 59, 0.15) 0px, transparent 50%),
        radial-gradient(at 100% 100%, rgba(180, 83, 9, 0.1) 0px, transparent 50%);
}

h1, h2, h3, .logo span {
    font-family: 'Amiri', serif;
    letter-spacing: 0.5px;
}

/* App Container and Layout */
.app-container {
    display: flex;
    width: 100%;
    height: 100vh;
}

/* Sidebar */
.sidebar {
    width: 280px;
    background: var(--sidebar-bg);
    border-left: 1px solid var(--glass-border);
    backdrop-filter: blur(20px);
    display: flex;
    flex-direction: column;
    padding: 2.5rem 1.5rem;
    position: relative;
    z-index: 10;
}

.logo {
    display: flex;
    align-items: center;
    gap: 15px;
    margin-bottom: 3.5rem;
    color: var(--secondary);
    font-size: 1.8rem;
}

.logo i {
    font-size: 2.2rem;
    filter: drop-shadow(0 0 10px rgba(217, 119, 6, 0.3));
}

nav {
    display: flex;
    flex-direction: column;
    gap: 1rem;
    flex-grow: 1;
}

.nav-link {
    display: flex;
    align-items: center;
    gap: 1.2rem;
    padding: 1rem 1.4rem;
    color: var(--text-muted);
    text-decoration: none;
    border-radius: 16px;
    transition: var(--transition);
    border: 1px solid transparent;
}

.nav-link i {
    font-size: 1.3rem;
}

.nav-link:hover {
    color: var(--text-main);
    background: var(--glass-bg);
}

.nav-link.active {
    background: var(--emerald-gradient);
    color: white;
    box-shadow: 0 10px 20px -5px rgba(6, 78, 59, 0.5);
    border: 1px solid rgba(255,255,255,0.1);
}

.sidebar-footer {
    margin-top: auto;
    font-size: 0.85rem;
    color: var(--text-muted);
    opacity: 0.7;
    border-top: 1px solid var(--glass-border);
    padding-top: 1.5rem;
}

/* Main Content Area */
.main-content {
    flex-grow: 1;
    display: flex;
    flex-direction: column;
    padding: 2rem 3.5rem;
    overflow-y: auto;
    scrollbar-width: thin;
    scrollbar-color: var(--glass-border) transparent;
}

.top-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 3rem;
}

.search-bar {
    background: var(--glass-bg);
    border: 1px solid var(--glass-border);
    backdrop-filter: blur(10px);
    border-radius: 40px;
    padding: 0.8rem 1.8rem;
    display: flex;
    align-items: center;
    gap: 15px;
    width: 450px;
    transition: var(--transition);
}

.search-bar:focus-within {
    border-color: var(--primary-light);
    box-shadow: 0 0 0 4px rgba(16, 185, 129, 0.1);
}

.search-bar input {
    background: transparent;
    border: none;
    color: var(--text-main);
    outline: none;
    width: 100%;
    font-size: 1rem;
}

.avatar {
    width: 48px;
    height: 48px;
    background: var(--emerald-gradient);
    border-radius: 14px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: bold;
    color: #FFF;
    border: 1px solid rgba(255,255,255,0.2);
    box-shadow: 0 4px 12px rgba(0,0,0,0.3);
}

/* Glass Cards */
.glass-card {
    background: var(--card-bg);
    border: 1px solid var(--glass-border);
    backdrop-filter: blur(12px);
    border-radius: 24px;
    padding: 2rem;
    margin-bottom: 2rem;
    transition: var(--transition);
}

.glass-card:hover {
    border-color: rgba(255, 255, 255, 0.2);
    transform: translateY(-4px);
    box-shadow: 0 20px 40px -10px rgba(0, 0, 0, 0.4);
}

.section-title {
    font-size: 2rem;
    margin-bottom: 2rem;
    display: flex;
    align-items: center;
    gap: 18px;
    color: var(--text-main);
}

.section-title i {
    color: var(--secondary);
}

/* Stats and Progress */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
    gap: 1.5rem;
    margin-bottom: 3rem;
}

.stat-item {
    text-align: center;
    position: relative;
    overflow: hidden;
}

.stat-item::before {
    content: '';
    position: absolute;
    top: 0; left: 0; width: 4px; height: 100%;
    background: var(--gold-gradient);
}

.stat-value {
    font-size: 2.8rem;
    font-weight: 800;
    background: var(--gold-gradient);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
}

/* Table Enhancements */
.ref-table {
    width: 100%;
    border-collapse: separate;
    border-spacing: 0 8px;
}

.ref-table th {
    padding: 1.5rem;
    text-align: right;
    color: var(--text-muted);
    font-weight: 600;
    text-transform: uppercase;
    font-size: 0.85rem;
    letter-spacing: 1px;
}

.ref-table tr td {
    background: rgba(255, 255, 255, 0.03);
    padding: 1.4rem;
    transition: var(--transition);
}

.ref-table tr td:first-child { border-radius: 12px 0 0 12px; }
.ref-table tr td:last-child { border-radius: 0 12px 12px 0; }

.ref-table tr:hover td {
    background: rgba(255, 255, 255, 0.08);
}

/* Status Badges */
.badge {
    padding: 6px 14px;
    border-radius: 30px;
    font-size: 0.75rem;
    font-weight: bold;
    text-transform: uppercase;
}

.badge-draft { background: rgba(148, 163, 184, 0.2); color: #94A3B8; }
.badge-review { background: rgba(245, 158, 11, 0.2); color: #F59E0B; }
.badge-final { background: rgba(16, 185, 129, 0.2); color: #10B981; }

/* Buttons */
.btn-primary {
    background: var(--emerald-gradient);
    color: white;
    border: 1px solid rgba(255,255,255,0.1);
    padding: 0.8rem 1.8rem;
    border-radius: 14px;
    cursor: pointer;
    font-weight: 700;
    transition: var(--transition);
    display: inline-flex;
    align-items: center;
    gap: 12px;
}

.btn-primary:hover {
    filter: brightness(1.2);
    box-shadow: 0 8px 16px rgba(6, 78, 59, 0.4);
}

/* Modals */
.modal-content.glass {
    background: var(--bg-dark);
    border: 1px solid var(--glass-border);
    box-shadow: 0 40px 100px -20px rgba(0, 0, 0, 0.8);
    position: relative;
}

/* AI Highlight Box */
.ai-insight {
    background: linear-gradient(135deg, rgba(6, 78, 59, 0.2) 0%, rgba(15, 23, 42, 0.2) 100%);
    border-right: 4px solid var(--primary-light);
    border-radius: 16px;
    padding: 1.5rem;
    margin-top: 1.5rem;
}

.ai-insight h4 {
    color: var(--primary-light);
    margin-bottom: 8px;
    font-size: 0.9rem;
}

.fade-in {
    animation: fadeIn 0.5s ease-out forwards;
}

@keyframes fadeIn {
    from { opacity: 0; transform: translateY(10px); }
    to { opacity: 1; transform: translateY(0); }
}

.viewer-header h3 {
    font-family: 'Amiri', serif;
}
