/* ===================================================================
   Master Responsive Stylesheet - Rida Ikrar Learning Portal & Command Center
   Compatible with Vanilla CSS, Tailwind CSS, & Alpine.js
   =================================================================== */

:root {
    --bg-primary: #f8fafc;
    --bg-secondary: #ffffff;
    --bg-card: #ffffff;
    --bg-sidebar: #f1f5f9;
    --text-primary: #0f172a;
    --text-secondary: #475569;
    --text-muted: #94a3b8;
    --border-color: #e2e8f0;
    --accent-blue: #0284c7;
    --accent-hover: #0369a1;
    --accent-green: #10b981;
    --accent-amber: #d97706;
    --accent-purple: #7c3aed;
    --accent-rose: #e11d48;
    --card-shadow: 0 4px 6px -1px rgb(0 0 0 / 0.07), 0 2px 4px -2px rgb(0 0 0 / 0.05);
    --card-hover-shadow: 0 12px 20px -3px rgb(0 0 0 / 0.12), 0 4px 6px -4px rgb(0 0 0 / 0.05);
    --radius-sm: 6px;
    --radius-md: 10px;
    --radius-lg: 16px;
    --transition: all 0.2s ease-in-out;
}

[data-theme="dark"], .dark {
    --bg-primary: #0f172a;
    --bg-secondary: #1e293b;
    --bg-card: #1e293b;
    --bg-sidebar: #111827;
    --text-primary: #f8fafc;
    --text-secondary: #cbd5e1;
    --text-muted: #64748b;
    --border-color: #334155;
    --accent-blue: #38bdf8;
    --accent-hover: #0284c7;
    --card-shadow: 0 4px 6px -1px rgb(0 0 0 / 0.3);
    --card-hover-shadow: 0 12px 20px -3px rgb(0 0 0 / 0.45);
}

* { box-sizing: border-box; margin: 0; padding: 0; }

body {
    font-family: 'Plus Jakarta Sans', 'Inter', system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
    background-color: var(--bg-primary);
    color: var(--text-primary);
    line-height: 1.6;
    transition: var(--transition);
}

/* ==========================================
   Universal Header & Navigation Compatibility
   ========================================== */
.navbar, .site-header, .top-nav, .module-header {
    background-color: var(--bg-secondary);
    border-bottom: 1px solid var(--border-color);
    position: sticky;
    top: 0;
    z-index: 100;
    padding: 0.85rem 1.5rem;
    box-shadow: 0 1px 3px 0 rgb(0 0 0 / 0.05);
}

.nav-container, .header-inner, .nav-bar {
    max-width: 1400px;
    margin: 0 auto;
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 1.5rem;
}

.nav-logo, .brand-logo {
    display: flex;
    align-items: center;
    gap: 0.6rem;
    text-decoration: none;
    color: var(--text-primary);
    font-weight: 800;
    font-size: 1.15rem;
}

.nav-links, .header-nav {
    display: flex;
    align-items: center;
    gap: 0.4rem;
    flex-wrap: wrap;
}

.nav-links a, .header-nav a, .nav-link, .back-link {
    color: var(--text-secondary);
    text-decoration: none;
    font-weight: 600;
    font-size: 0.88rem;
    padding: 0.45rem 0.8rem;
    border-radius: var(--radius-sm);
    transition: var(--transition);
}

.nav-links a:hover, .header-nav a:hover, .nav-links a.active, .nav-link:hover, .back-link:hover {
    color: var(--accent-blue);
    background: var(--bg-sidebar);
}

.theme-toggle-btn, .theme-btn {
    background: var(--bg-sidebar);
    border: 1px solid var(--border-color);
    color: var(--text-primary);
    padding: 0.45rem 0.85rem;
    border-radius: var(--radius-sm);
    font-size: 0.85rem;
    font-weight: 600;
    cursor: pointer;
    transition: var(--transition);
}

.theme-toggle-btn:hover, .theme-btn:hover {
    border-color: var(--accent-blue);
    color: var(--accent-blue);
}

/* ==========================================
   Subject Grid & Cards (Modern Edu-Portal UI)
   ========================================== */
.subjects-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(340px, 1fr));
    gap: 1.5rem;
    margin-top: 1.5rem;
}

.subject-card {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
    overflow: hidden;
    box-shadow: var(--card-shadow);
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    transition: transform 0.25s ease, box-shadow 0.25s ease, border-color 0.25s ease;
}

.subject-card:hover {
    transform: translateY(-4px);
    box-shadow: var(--card-hover-shadow);
    border-color: var(--accent-blue);
}

.card-header-bar {
    padding: 1.15rem 1.25rem;
    color: #ffffff;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.card-header-title {
    font-weight: 700;
    font-size: 1.1rem;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.card-badge {
    background: rgba(255, 255, 255, 0.25);
    backdrop-filter: blur(4px);
    padding: 0.25rem 0.65rem;
    border-radius: 999px;
    font-size: 0.78rem;
    font-weight: 700;
}

.card-body {
    padding: 1.25rem;
    display: flex;
    flex-direction: column;
    flex: 1;
}

.card-desc {
    font-size: 0.88rem;
    color: var(--text-secondary);
    line-height: 1.55;
    margin-bottom: 1.15rem;
}

.topic-list {
    list-style: none;
    padding: 0;
    margin: 0 0 1.25rem 0;
    display: flex;
    flex-direction: column;
    gap: 0.45rem;
}

.topic-item a {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0.55rem 0.85rem;
    background: var(--bg-sidebar);
    border-radius: var(--radius-sm);
    color: var(--text-primary);
    text-decoration: none;
    font-size: 0.88rem;
    font-weight: 500;
    transition: all 0.15s ease;
    border: 1px solid transparent;
}

.topic-item a:hover {
    background: var(--bg-card);
    border-color: var(--accent-blue);
    color: var(--accent-blue);
    padding-left: 1rem;
}

.topic-arrow {
    color: var(--text-muted);
    font-size: 0.85rem;
    transition: transform 0.15s ease;
}

.topic-item a:hover .topic-arrow {
    transform: translateX(3px);
    color: var(--accent-blue);
}

.card-footer-action {
    padding: 1rem 1.25rem;
    background: var(--bg-sidebar);
    border-top: 1px solid var(--border-color);
}

/* ==========================================
   Article & Module Reader Layout
   ========================================== */
.content-wrapper, .main-content, .reader-container, .article-container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 2rem 1.5rem;
}

.article-card, .module-body {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
    padding: 2.5rem;
    box-shadow: var(--card-shadow);
    margin-bottom: 2rem;
}

.breadcrumbs {
    font-size: 0.85rem;
    color: var(--text-muted);
    margin-bottom: 1.5rem;
    display: flex;
    align-items: center;
    gap: 0.5rem;
    flex-wrap: wrap;
}

.breadcrumbs a {
    color: var(--accent-blue);
    text-decoration: none;
    font-weight: 600;
}

.article-title, h1.article-title {
    font-size: 2.2rem;
    font-weight: 800;
    letter-spacing: -0.5px;
    color: var(--text-primary);
    margin: 0.75rem 0 1rem 0;
    line-height: 1.25;
}

.article-lead {
    font-size: 1.1rem;
    color: var(--text-secondary);
    line-height: 1.6;
    margin-bottom: 1.5rem;
}

.content-section {
    font-size: 1.02rem;
    line-height: 1.75;
    color: var(--text-primary);
}

.content-section h2 {
    font-size: 1.45rem;
    font-weight: 800;
    color: var(--text-primary);
    margin: 2rem 0 1rem 0;
    padding-bottom: 0.5rem;
    border-bottom: 2px solid var(--border-color);
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.content-section h3 {
    font-size: 1.2rem;
    font-weight: 700;
    color: var(--accent-blue);
    margin: 1.5rem 0 0.75rem 0;
}

.content-section p {
    margin-bottom: 1.2rem;
}

.content-section ul, .content-section ol {
    margin-left: 1.5rem;
    margin-bottom: 1.2rem;
}

.content-section li {
    margin-bottom: 0.4rem;
}

.content-section img {
    max-width: 100%;
    height: auto;
    border-radius: var(--radius-md);
    border: 1px solid var(--border-color);
    box-shadow: var(--card-shadow);
    margin: 1.5rem auto;
    display: block;
}

.content-section pre {
    background: #030712;
    color: #38bdf8;
    padding: 1.25rem;
    border-radius: var(--radius-md);
    overflow-x: auto;
    font-family: 'Fira Code', 'Consolas', monospace;
    font-size: 0.9rem;
    line-height: 1.5;
    margin: 1.25rem 0;
    border: 1px solid #1e293b;
}

.content-section code {
    font-family: 'Fira Code', 'Consolas', monospace;
    background: var(--bg-sidebar);
    color: var(--accent-blue);
    padding: 0.2rem 0.4rem;
    border-radius: 4px;
    font-size: 0.9em;
}

.content-section table {
    width: 100%;
    border-collapse: collapse;
    margin: 1.5rem 0;
    border-radius: var(--radius-md);
    overflow: hidden;
    border: 1px solid var(--border-color);
}

.content-section th, .content-section td {
    padding: 0.85rem 1.15rem;
    border: 1px solid var(--border-color);
    text-align: left;
}

.content-section th {
    background: var(--bg-sidebar);
    font-weight: 700;
    color: var(--text-primary);
}

/* Callouts / Alerts */
.callout, blockquote {
    background: var(--bg-sidebar);
    border-left: 4px solid var(--accent-blue);
    border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
    padding: 1rem 1.25rem;
    margin: 1.25rem 0;
    font-style: normal;
}

/* Badges */
.badge {
    display: inline-block;
    padding: 0.25rem 0.75rem;
    border-radius: 999px;
    font-size: 0.75rem;
    font-weight: 700;
    text-transform: uppercase;
}

.badge-primary { background: #e0f2fe; color: #0369a1; }
.dark .badge-primary { background: #0c4a6e; color: #38bdf8; }

/* Buttons */
.btn {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.65rem 1.25rem;
    border-radius: var(--radius-md);
    font-weight: 600;
    font-size: 0.92rem;
    text-decoration: none;
    cursor: pointer;
    border: none;
    transition: var(--transition);
}

.btn-primary { background: var(--accent-blue); color: #ffffff; }
.btn-primary:hover { background: var(--accent-hover); box-shadow: 0 4px 12px rgba(2, 132, 199, 0.3); }

.btn-secondary { background: var(--bg-sidebar); color: var(--text-primary); border: 1px solid var(--border-color); }
.btn-secondary:hover { background: var(--border-color); }

.navigation-buttons, .article-navigation {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-top: 2.5rem;
    padding-top: 1.5rem;
    border-top: 1px solid var(--border-color);
    flex-wrap: wrap;
    gap: 1rem;
}

/* ==========================================
   Mobile & Responsive Adjustments
   ========================================== */
@media (max-width: 768px) {
    .nav-links, .header-nav {
        display: flex;
        overflow-x: auto;
        white-space: nowrap;
        width: 100%;
        padding-bottom: 0.35rem;
        -webkit-overflow-scrolling: touch;
        scrollbar-width: none;
    }
    .nav-links::-webkit-scrollbar { display: none; }
    .article-card, .module-body { padding: 1.5rem 1.25rem; }
    .article-title { font-size: 1.65rem; }
    .navigation-buttons { flex-direction: column; align-items: stretch; }
    .btn { justify-content: center; }
}
