/* =========================================
   CORE SYSTEM VARIABLES (Design Tokens)
========================================= */
:root {
    --bg-main: #f0fdf4;
    --bg-surface: #ffffff;
    --text-primary: #1e293b;
    --text-secondary: #64748b;
    --brand-primary: #059669;
    --brand-hover: #047857;
    --border-color: #e2e8f0;
    --shadow-sm: 0 1px 3px rgba(0,0,0,0.1);
    --shadow-lg: 0 10px 15px -3px rgba(0,0,0,0.1);
    --radius: 12px;
    --transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

[data-theme="dark"] {
    --bg-main: #0f172a;
    --bg-surface: #1e293b;
    --text-primary: #f8fafc;
    --text-secondary: #94a3b8;
    --border-color: #334155;
    --brand-primary: #10b981;
}

/* =========================================
   GLOBAL RESETS & TYPOGRAPHY
========================================= */
* { box-sizing: border-box; margin: 0; padding: 0; }

body {
    background-color: var(--bg-main);
    color: var(--text-primary);
    font-family: system-ui, -apple-system, sans-serif;
    line-height: 1.6;
    transition: var(--transition);
    overflow-x: hidden;
    padding-bottom: 100px; /* Space for player */
}

.urdu {
    font-family: 'Jameel Noori Nastaleeq', Arial, sans-serif;
    font-size: 1.2rem;
    line-height: 2;
}

/* =========================================
   HEADER & NAVIGATION
========================================= */
.system-header {
    background: var(--bg-surface);
    border-bottom: 1px solid var(--border-color);
    position: sticky; top: 0; z-index: 100;
    box-shadow: var(--shadow-sm);
}

.nav-container {
    max-width: 1200px; margin: 0 auto; padding: 1rem 2rem;
    display: flex; justify-content: space-between; align-items: center;
}

.logo { color: var(--brand-primary); font-size: 2rem; font-weight: bold; }

/* =========================================
   BUTTONS & CONTROLS
========================================= */
.btn {
    border: none; cursor: pointer; border-radius: 8px;
    padding: 0.5rem 1rem; font-weight: 600;
    transition: var(--transition); background: var(--bg-surface);
    color: var(--text-primary); border: 1px solid var(--border-color);
}
.btn-primary { background: var(--brand-primary); color: white; border: none; }
.btn-primary:hover { background: var(--brand-hover); transform: translateY(-2px); }
.btn-icon { font-size: 1.2rem; padding: 0.5rem; border-radius: 50%; }
.btn-round { border-radius: 50px; padding: 0.5rem 1.5rem; }

/* =========================================
   TOOLBAR (Search & Filters)
========================================= */
.app-container { max-width: 1200px; margin: 2rem auto; padding: 0 1rem; }

.toolbar { display: flex; flex-direction: column; gap: 1rem; margin-bottom: 2rem; }

.search-box {
    display: flex; align-items: center; background: var(--bg-surface);
    border: 1px solid var(--border-color); border-radius: var(--radius);
    padding: 0.5rem 1rem; box-shadow: var(--shadow-sm);
}
.search-box input {
    flex: 1; border: none; background: transparent; color: var(--text-primary);
    outline: none; padding-right: 1rem; font-size: 1.1rem;
}

.filter-group { display: flex; gap: 0.5rem; flex-wrap: wrap; }
.filter-btn {
    background: var(--bg-surface); border: 1px solid var(--border-color);
    color: var(--text-primary); padding: 0.5rem 1rem; border-radius: 20px;
    cursor: pointer; transition: var(--transition);
}
.filter-btn.active, .filter-btn:hover { background: var(--brand-primary); color: white; }

/* =========================================
   GRID & CARDS (Dynamic Rendering)
========================================= */
.content-grid {
    display: grid; gap: 1.5rem;
    grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
}

.card {
    background: var(--bg-surface); border: 1px solid var(--border-color);
    border-radius: var(--radius); padding: 1.5rem;
    display: flex; flex-direction: column; gap: 1rem;
    transition: var(--transition); position: relative; overflow: hidden;
}
.card:hover { transform: translateY(-5px); box-shadow: var(--shadow-lg); border-color: var(--brand-primary); }

.tag {
    align-self: flex-start; padding: 0.2rem 0.8rem;
    border-radius: 12px; font-size: 0.8rem; font-weight: bold;
}
.tag-audio { background: #dcfce7; color: #166534; }
.tag-pdf { background: #e0f2fe; color: #0369a1; }

.card-title { font-size: 1.3rem; margin: 0; color: var(--text-primary); }
.card-actions { display: flex; gap: 0.5rem; margin-top: auto; }

/* =========================================
   MEDIA PLAYER (Bottom Fixed)
========================================= */
.media-player {
    position: fixed; bottom: 0; left: 0; right: 0;
    background: var(--bg-surface); border-top: 1px solid var(--border-color);
    padding: 1rem 2rem; display: flex; justify-content: space-between;
    align-items: center; box-shadow: 0 -4px 20px rgba(0,0,0,0.1);
    transform: translateY(100%); transition: transform 0.4s ease-out; z-index: 1000;
}
.media-player.active { transform: translateY(0); }

.player-controls { display: flex; align-items: center; gap: 1rem; flex: 1; max-width: 600px; margin: 0 2rem; }
.progress-wrapper { display: flex; align-items: center; gap: 1rem; width: 100%; font-family: monospace; }
input[type="range"] { flex: 1; accent-color: var(--brand-primary); }

/* =========================================
   MODAL (For PDF) & UTILITIES
========================================= */
.modal {
    position: fixed; inset: 0; background: rgba(0,0,0,0.7);
    display: flex; justify-content: center; align-items: center; z-index: 2000;
    opacity: 0; pointer-events: none; transition: var(--transition);
}
.modal.active { opacity: 1; pointer-events: auto; }
.modal-content {
    background: var(--bg-surface); width: 90%; max-width: 800px; height: 80vh;
    border-radius: var(--radius); display: flex; flex-direction: column; overflow: hidden;
}
.modal-header { padding: 1rem 2rem; border-bottom: 1px solid var(--border-color); display: flex; justify-content: space-between; }
.modal-body { padding: 2rem; flex: 1; overflow-y: auto; display: grid; place-items: center; }
.pdf-placeholder { width: 100%; height: 100%; border: 2px dashed var(--border-color); border-radius: var(--radius); }

.hidden { display: none !important; }

/* Toast Notifications */
.toast-container { position: fixed; top: 20px; right: 20px; z-index: 9999; display: flex; flex-direction: column; gap: 10px; }
.toast { background: var(--brand-primary); color: white; padding: 1rem 2rem; border-radius: var(--radius); animation: slideIn 0.3s ease; }
@keyframes slideIn { from { transform: translateX(100%); } to { transform: translateX(0); } }
