@import url('https://fonts.googleapis.com/css2?family=Poppins:wght@300;400;500;600;700&display=swap');

/* ===== CSS VARIABLES ===== */
:root {
    --primary:        #6366f1;
    --primary-dark:   #4f46e5;
    --primary-light:  rgba(99,102,241,.12);
    --secondary:      #8b5cf6;
    --accent:         #f59e0b;
    --dark:           #1e1b4b;
    --card:           #ffffff;
    --bg:             #f8fafc;
    --text:           #1e293b;
    --text-light:     #64748b;
    --border:         #e2e8f0;
    --danger:         #ef4444;
    --success:        #10b981;
    --warning:        #f59e0b;
    --info:           #3b82f6;
    --sidebar-width:  240px;
    --header-height:  62px;
    --radius:         10px;
    --radius-sm:      6px;
    --shadow:         0 4px 24px rgba(0,0,0,.09);
    --shadow-sm:      0 1px 6px rgba(0,0,0,.06);
}

/* ===== RESET & BASE ===== */
*, *::before, *::after { margin: 0; padding: 0; box-sizing: border-box; }
html { scroll-behavior: smooth; font-size: 15px; -webkit-text-size-adjust: 100%; }
body { font-family: 'Poppins', sans-serif; background: var(--bg); color: var(--text); line-height: 1.65; min-height: 100vh; }
body.urdu { font-family: 'Jameel Noori Nastaleeq','Noto Nastaliq Urdu', Arial, serif; direction: rtl; text-align: right; font-size: 16px; }

a { color: var(--primary); text-decoration: none; transition: color .2s; }
a:hover { color: var(--primary-dark); }
img { max-width: 100%; display: block; }
.container { max-width: 1200px; margin: 0 auto; padding: 0 20px; }

/* ===== BUTTONS ===== */
.btn { display: inline-flex; align-items: center; gap: 6px; padding: 8px 18px; border-radius: var(--radius-sm); border: none; cursor: pointer; font-size: .88rem; font-weight: 500; font-family: inherit; transition: all .18s; white-space: nowrap; text-decoration: none; }
.btn-primary { background: var(--primary); color: #fff; }
.btn-primary:hover { background: var(--primary-dark); color: #fff; transform: translateY(-1px); box-shadow: 0 4px 12px rgba(99,102,241,.3); }
.btn-secondary { background: var(--border); color: var(--text); }
.btn-secondary:hover { background: #d1d5db; color: var(--text); }
.btn-outline { background: transparent; color: #fff; border: 1.5px solid rgba(255,255,255,.45); }
.btn-outline:hover { background: rgba(255,255,255,.12); color: #fff; }
.btn-danger { background: var(--danger); color: #fff; }
.btn-danger:hover { background: #dc2626; color: #fff; }
.btn-success { background: var(--success); color: #fff; }
.btn-warning { background: var(--warning); color: #fff; }
.btn-sm { padding: 4px 10px; font-size: .78rem; }
.btn-lg { padding: 12px 28px; font-size: 1rem; }

/* ===== BADGES ===== */
.badge { display: inline-block; padding: 2px 10px; border-radius: 20px; font-size: .72rem; font-weight: 600; }
.badge-success { background: rgba(16,185,129,.12); color: #059669; }
.badge-danger  { background: rgba(239,68,68,.12);  color: #dc2626; }
.badge-warning { background: rgba(245,158,11,.12); color: #d97706; }
.badge-info    { background: rgba(59,130,246,.12);  color: #2563eb; }
.badge-blue    { background: rgba(59,130,246,.12);  color: #2563eb; }
.badge-purple  { background: rgba(139,92,246,.12);  color: #7c3aed; }
.badge-secondary{ background: rgba(100,116,139,.12);color: #475569; }

/* ===== FORMS ===== */
.form-group { margin-bottom: 16px; }
.form-label { display: block; font-size: .84rem; font-weight: 600; margin-bottom: 5px; color: var(--text); }
.form-control { width: 100%; padding: 9px 13px; border: 1.5px solid var(--border); border-radius: var(--radius-sm); font-family: inherit; font-size: .88rem; color: var(--text); background: #fff; transition: border-color .18s, box-shadow .18s; outline: none; }
.form-control:focus { border-color: var(--primary); box-shadow: 0 0 0 3px var(--primary-light); }
textarea.form-control { resize: vertical; }
select.form-control { cursor: pointer; }
.form-text { font-size: .75rem; color: var(--text-light); margin-top: 3px; display: block; }

/* ===== ALERTS ===== */
.alert { display: flex; align-items: flex-start; gap: 10px; padding: 12px 16px; border-radius: var(--radius-sm); margin-bottom: 16px; font-size: .88rem; }
.alert-success { background: rgba(16,185,129,.1);  border-left: 4px solid var(--success); color: #065f46; }
.alert-danger  { background: rgba(239,68,68,.1);   border-left: 4px solid var(--danger);  color: #991b1b; }
.alert-warning { background: rgba(245,158,11,.1);  border-left: 4px solid var(--warning); color: #92400e; }
.alert-info    { background: rgba(59,130,246,.1);   border-left: 4px solid var(--info);    color: #1e40af; }

/* ===== CARDS ===== */
.card { background: var(--card); border-radius: var(--radius); box-shadow: var(--shadow-sm); border: 1px solid var(--border); overflow: hidden; }
.card:hover { box-shadow: var(--shadow); }
.card-body { padding: 20px; }
.card-title { font-size: .95rem; font-weight: 600; margin-bottom: 8px; line-height: 1.4; }
.card-meta  { font-size: .78rem; color: var(--text-light); display: flex; gap: 12px; margin-bottom: 10px; flex-wrap: wrap; }
.card-excerpt { font-size: .85rem; color: var(--text-light); line-height: 1.6; }
.card-footer { padding: 12px 20px; border-top: 1px solid var(--border); display: flex; justify-content: space-between; align-items: center; background: var(--bg); }
.card-img { width: 100%; height: 190px; object-fit: cover; }

/* ===== HEADER ===== */
.header { background: var(--dark); color: #fff; height: var(--header-height); position: sticky; top: 0; z-index: 1000; box-shadow: 0 2px 12px rgba(0,0,0,.18); }
.header .container { display: flex; align-items: center; height: 100%; gap: 16px; }
.logo { font-size: 1.3rem; font-weight: 700; color: #fff !important; white-space: nowrap; flex-shrink: 0; }
.logo span { color: var(--accent); }
.nav { display: flex; align-items: center; gap: 2px; flex: 1; }
.nav a { color: rgba(255,255,255,.8); padding: 5px 13px; border-radius: var(--radius-sm); font-size: .86rem; font-weight: 500; transition: all .18s; display: flex; align-items: center; gap: 5px; }
.nav a:hover, .nav a.active { background: rgba(255,255,255,.14); color: #fff; }
.header-actions { display: flex; align-items: center; gap: 8px; margin-left: auto; flex-shrink: 0; }
.hamburger { display: none; background: none; border: none; cursor: pointer; padding: 5px; }
.hamburger span { display: block; width: 22px; height: 2px; background: #fff; margin: 4px 0; transition: all .3s; }

/* User menu */
.user-menu { position: relative; }
.user-avatar { width: 34px; height: 34px; border-radius: 50%; background: var(--primary); display: flex; align-items: center; justify-content: center; cursor: pointer; border: 2px solid rgba(255,255,255,.25); overflow: hidden; flex-shrink: 0; }
.user-avatar img { width: 100%; height: 100%; object-fit: cover; }
.user-dropdown { position: absolute; right: 0; top: calc(100% + 8px); background: #fff; border-radius: var(--radius); box-shadow: var(--shadow); width: 210px; display: none; z-index: 1001; overflow: hidden; border: 1px solid var(--border); }
.user-menu:hover .user-dropdown { display: block; }
.user-dropdown-header { padding: 12px 14px; background: var(--dark); color: #fff; }
.user-dropdown-header .name { font-weight: 600; font-size: .85rem; }
.user-dropdown-header .role { font-size: .72rem; opacity: .75; }
.user-dropdown a { display: flex; align-items: center; gap: 9px; padding: 8px 14px; color: var(--text); font-size: .84rem; transition: background .15s; }
.user-dropdown a:hover { background: var(--bg); color: var(--primary); }
.user-dropdown a i { width: 15px; opacity: .7; }
.user-dropdown hr { border: none; border-top: 1px solid var(--border); margin: 3px 0; }

/* Lang switcher */
.lang-switcher { display: flex; gap: 3px; }
.lang-btn { padding: 3px 9px; border-radius: 20px; font-size: .75rem; border: 1.5px solid rgba(255,255,255,.3); color: rgba(255,255,255,.75); cursor: pointer; background: transparent; transition: all .18s; }
.lang-btn:hover, .lang-btn.active { background: var(--accent); color: #fff; border-color: var(--accent); }

/* ===== HERO ===== */
.hero { background: linear-gradient(135deg, var(--dark) 0%, var(--primary) 60%, var(--secondary) 100%); color: #fff; padding: 70px 0 60px; text-align: center; }
.hero h1 { font-size: 2.5rem; font-weight: 700; margin-bottom: 14px; line-height: 1.2; }
.hero p { font-size: 1.05rem; opacity: .9; max-width: 560px; margin: 0 auto 28px; }
.hero-actions { display: flex; gap: 12px; justify-content: center; flex-wrap: wrap; }

/* ===== GRIDS ===== */
.grid-2 { display: grid; grid-template-columns: repeat(2,1fr); gap: 20px; }
.grid-3 { display: grid; grid-template-columns: repeat(3,1fr); gap: 20px; }
.grid-4 { display: grid; grid-template-columns: repeat(4,1fr); gap: 20px; }

/* ===== PAGE HEADER ===== */
.page-header { background: var(--dark); color: #fff; padding: 30px 0; margin-bottom: 32px; }
.page-header h1 { font-size: 1.6rem; font-weight: 700; display: flex; align-items: center; gap: 10px; }

/* ===== SEARCH BAR ===== */
.search-bar { display: flex; background: #fff; border-radius: var(--radius-sm); box-shadow: var(--shadow-sm); overflow: hidden; border: 1.5px solid var(--border); }
.search-bar input { flex: 1; padding: 9px 14px; border: none; outline: none; font-family: inherit; font-size: .88rem; }
.search-bar button { background: var(--primary); color: #fff; border: none; padding: 9px 18px; cursor: pointer; font-size: .88rem; transition: background .18s; }
.search-bar button:hover { background: var(--primary-dark); }

/* ===== CATEGORY PILLS ===== */
.category-pills { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 20px; }
.cat-pill { padding: 5px 14px; border-radius: 20px; font-size: .78rem; border: 1.5px solid var(--border); color: var(--text-light); transition: all .18s; cursor: pointer; }
.cat-pill:hover, .cat-pill.active { background: var(--primary); color: #fff; border-color: var(--primary); }

/* ===== SECTION HEADERS ===== */
.section-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 20px; }
.section-title { font-size: 1.2rem; font-weight: 700; position: relative; padding-left: 12px; }
.section-title::before { content: ''; position: absolute; left: 0; top: 50%; transform: translateY(-50%); width: 4px; height: 70%; background: var(--primary); border-radius: 2px; }

/* ===== TABS ===== */
.tabs { display: flex; border-bottom: 2px solid var(--border); margin-bottom: 20px; overflow-x: auto; }
.tab-btn { padding: 8px 18px; font-size: .86rem; font-weight: 500; background: none; border: none; cursor: pointer; color: var(--text-light); border-bottom: 2px solid transparent; margin-bottom: -2px; transition: all .18s; font-family: inherit; white-space: nowrap; }
.tab-btn.active { color: var(--primary); border-bottom-color: var(--primary); }

/* ===== FEATURED POST ===== */
.featured-post { position: relative; border-radius: var(--radius); overflow: hidden; height: 400px; }
.featured-post img { width: 100%; height: 100%; object-fit: cover; }
.featured-post-overlay { position: absolute; bottom: 0; left: 0; right: 0; background: linear-gradient(to top,rgba(0,0,0,.8) 0%,transparent 100%); padding: 28px 22px 22px; color: #fff; }
.featured-post-overlay h2 { font-size: 1.3rem; font-weight: 700; margin-bottom: 6px; }

/* ===== AUTH PAGE ===== */
.auth-page { min-height: calc(100vh - var(--header-height) - 60px); display: flex; align-items: center; justify-content: center; padding: 40px 20px; }
.auth-card { background: #fff; border-radius: var(--radius); box-shadow: var(--shadow); width: 100%; max-width: 420px; overflow: hidden; }
.auth-card-header { background: var(--dark); color: #fff; padding: 24px 28px; }
.auth-card-header h2 { font-size: 1.2rem; font-weight: 700; display: flex; align-items: center; gap: 8px; }
.auth-card-header p { font-size: .82rem; opacity: .7; margin-top: 4px; }
.auth-card-body { padding: 28px; }
.auth-footer { text-align: center; margin-top: 16px; font-size: .82rem; color: var(--text-light); }

/* ===== PROFILE ===== */
.profile-card { background: #fff; border-radius: var(--radius); box-shadow: var(--shadow-sm); overflow: hidden; }
.profile-cover { height: 150px; background: linear-gradient(135deg, var(--dark), var(--primary)); }
.profile-info { padding: 0 22px 22px; text-align: center; }
.profile-avatar-wrap { margin-top: -48px; margin-bottom: 10px; }
.profile-avatar { width: 96px; height: 96px; border-radius: 50%; border: 4px solid #fff; object-fit: cover; background: var(--primary); display: inline-block; }
.profile-name { font-size: 1.2rem; font-weight: 700; }
.profile-meta { color: var(--text-light); font-size: .82rem; margin-top: 3px; }
.profile-stats { display: flex; justify-content: center; gap: 28px; margin: 14px 0; padding: 14px 0; border-top: 1px solid var(--border); border-bottom: 1px solid var(--border); }
.profile-stat-val { font-size: 1.3rem; font-weight: 700; color: var(--primary); }
.profile-stat-label { font-size: .72rem; color: var(--text-light); }

/* ===== BOOK CARD ===== */
.book-card { background: #fff; border-radius: var(--radius); box-shadow: var(--shadow-sm); overflow: hidden; display: flex; flex-direction: column; transition: transform .2s, box-shadow .2s; border: 1px solid var(--border); }
.book-card:hover { transform: translateY(-3px); box-shadow: var(--shadow); }
.book-cover { height: 190px; background: linear-gradient(135deg,var(--dark),var(--primary)); display: flex; align-items: center; justify-content: center; overflow: hidden; }
.book-cover img { width: 100%; height: 100%; object-fit: cover; }
.book-cover-placeholder { font-size: 2.8rem; color: rgba(255,255,255,.4); }
.book-body { padding: 14px; flex: 1; }
.book-title { font-size: .9rem; font-weight: 600; margin-bottom: 5px; line-height: 1.4; }
.book-author { font-size: .78rem; color: var(--text-light); margin-bottom: 8px; }
.book-footer { padding: 10px 14px; border-top: 1px solid var(--border); display: flex; justify-content: space-between; align-items: center; }

/* ===== PDF VIEWER ===== */
.pdf-viewer { background: #fff; border-radius: var(--radius); box-shadow: var(--shadow-sm); overflow: hidden; }
.pdf-toolbar { background: var(--dark); color: #fff; padding: 10px 16px; display: flex; align-items: center; gap: 12px; }
.pdf-frame { width: 100%; height: 700px; border: none; }

/* ===== SUBSCRIPTION ===== */
.plan-cards { display: grid; grid-template-columns: repeat(2,1fr); gap: 22px; max-width: 680px; margin: 0 auto; }
.plan-card { background: #fff; border-radius: 14px; box-shadow: var(--shadow); padding: 28px; text-align: center; position: relative; border: 2px solid transparent; transition: all .2s; }
.plan-card.popular { border-color: var(--primary); }
.plan-card:hover { transform: translateY(-3px); }
.plan-badge { position: absolute; top: -11px; left: 50%; transform: translateX(-50%); background: var(--primary); color: #fff; padding: 3px 13px; border-radius: 20px; font-size: .74rem; font-weight: 600; }
.plan-name { font-size: 1.2rem; font-weight: 700; margin-bottom: 7px; }
.plan-price { font-size: 2.5rem; font-weight: 800; color: var(--primary); line-height: 1; }
.plan-price sup { font-size: 1.1rem; vertical-align: super; }
.plan-price span { font-size: .9rem; font-weight: 400; color: var(--text-light); }
.plan-features { list-style: none; text-align: left; margin: 20px 0; }
.plan-features li { padding: 6px 0; font-size: .86rem; display: flex; align-items: center; gap: 8px; border-bottom: 1px solid var(--border); }
.plan-features li:last-child { border: none; }
.plan-features li::before { content: '✓'; color: var(--success); font-weight: 700; }

/* ===== FOOTER ===== */
.footer { background: var(--dark); color: rgba(255,255,255,.65); padding: 45px 0 18px; margin-top: 60px; }
.footer-grid { display: grid; grid-template-columns: 1.5fr 1fr 1fr 1fr; gap: 36px; margin-bottom: 32px; }
.footer-brand { font-size: 1.3rem; font-weight: 700; color: #fff; margin-bottom: 8px; }
.footer-brand span { color: var(--accent); }
.footer-desc { font-size: .83rem; line-height: 1.7; }
.footer-heading { font-weight: 600; color: rgba(255,255,255,.9); margin-bottom: 12px; font-size: .88rem; }
.footer-links { list-style: none; }
.footer-links li { margin-bottom: 7px; }
.footer-links a { color: rgba(255,255,255,.55); font-size: .82rem; transition: color .18s; }
.footer-links a:hover { color: #fff; }
.footer-bottom { border-top: 1px solid rgba(255,255,255,.08); padding-top: 18px; display: flex; justify-content: space-between; align-items: center; font-size: .78rem; }

/* ===== TABLE ===== */
.table-wrapper { background: #fff; border-radius: var(--radius); box-shadow: var(--shadow-sm); overflow: hidden; border: 1px solid var(--border); }
.table { width: 100%; border-collapse: collapse; }
.table th { background: var(--bg); padding: 10px 14px; text-align: left; font-size: .75rem; font-weight: 600; color: var(--text-light); text-transform: uppercase; letter-spacing: .05em; border-bottom: 1px solid var(--border); white-space: nowrap; }
.table td { padding: 10px 14px; border-bottom: 1px solid var(--border); font-size: .84rem; vertical-align: middle; }
.table tr:last-child td { border: none; }
.table tr:hover td { background: var(--primary-light); }

/* ===== *** ADMIN PANEL *** ===== */
.admin-layout { display: grid; grid-template-columns: var(--sidebar-width) 1fr; min-height: calc(100vh - var(--header-height)); }

/* Sidebar */
.admin-sidebar {
    background: #0f0d2e;
    color: #fff;
    padding: 0 0 20px;
    position: sticky;
    top: var(--header-height);
    height: calc(100vh - var(--header-height));
    overflow-y: auto;
    overflow-x: hidden;
    scrollbar-width: thin;
    scrollbar-color: rgba(255,255,255,.12) transparent;
    font-size: .82rem;
    flex-shrink: 0;
}
.admin-sidebar::-webkit-scrollbar { width: 4px; }
.admin-sidebar::-webkit-scrollbar-thumb { background: rgba(255,255,255,.12); border-radius: 4px; }

.admin-sidebar-brand {
    padding: 16px 16px 12px;
    border-bottom: 1px solid rgba(255,255,255,.07);
    font-size: .95rem;
    font-weight: 700;
    color: #fff;
    margin-bottom: 4px;
}

.sidebar-user-strip {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 14px 12px;
    border-bottom: 1px solid rgba(255,255,255,.07);
    margin-bottom: 4px;
}
.sidebar-avatar {
    width: 34px;
    height: 34px;
    border-radius: 50%;
    background: var(--primary);
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    overflow: hidden;
    font-size: .9rem;
}
.sidebar-avatar img { width: 100%; height: 100%; object-fit: cover; }

.admin-sidebar-section {
    padding: 10px 14px 4px;
    font-size: .64rem;
    text-transform: uppercase;
    letter-spacing: .09em;
    color: rgba(255,255,255,.35);
    margin-top: 6px;
    font-weight: 600;
}

.sidebar-link {
    display: flex !important;
    align-items: center;
    gap: 9px;
    padding: 8px 14px !important;
    color: rgba(255,255,255,.62) !important;
    font-size: .82rem !important;
    transition: all .15s;
    border-left: 3px solid transparent;
    text-decoration: none;
    white-space: nowrap;
}
.sidebar-link i { width: 16px; flex-shrink: 0; opacity: .8; font-size: .85rem; }
.sidebar-link span { overflow: hidden; text-overflow: ellipsis; }
.sidebar-link:hover, .sidebar-link.active {
    background: rgba(255,255,255,.06) !important;
    color: #fff !important;
    border-left-color: var(--primary) !important;
}
.sidebar-logout { color: rgba(239,68,68,.75) !important; }
.sidebar-logout:hover { color: #ef4444 !important; background: rgba(239,68,68,.1) !important; }

/* Admin main area */
.admin-main { padding: 24px 28px; background: var(--bg); min-width: 0; }
.admin-title { font-size: 1.35rem; font-weight: 700; margin-bottom: 4px; display: flex; align-items: center; gap: 9px; }
.admin-subtitle { color: var(--text-light); font-size: .85rem; margin-bottom: 22px; }

/* Stats grid */
.stats-grid { display: grid; grid-template-columns: repeat(4,1fr); gap: 16px; margin-bottom: 24px; }
.stat-card { background: #fff; border-radius: var(--radius); padding: 18px 20px; box-shadow: var(--shadow-sm); display: flex; align-items: center; gap: 14px; border: 1px solid var(--border); }
.stat-icon { width: 46px; height: 46px; border-radius: 10px; display: flex; align-items: center; justify-content: center; font-size: 1.2rem; flex-shrink: 0; }
.stat-icon.green  { background: rgba(16,185,129,.1);  color: var(--success); }
.stat-icon.blue   { background: rgba(59,130,246,.1);   color: var(--info); }
.stat-icon.orange { background: rgba(245,158,11,.1);  color: var(--warning); }
.stat-icon.red    { background: rgba(239,68,68,.1);   color: var(--danger); }
.stat-icon.purple { background: rgba(139,92,246,.1);  color: var(--secondary); }
.stat-value { font-size: 1.6rem; font-weight: 700; line-height: 1; }
.stat-label { font-size: .76rem; color: var(--text-light); margin-top: 2px; }

/* ===== RESPONSIVE ===== */
@media (max-width: 1100px) {
    :root { --sidebar-width: 220px; }
    .grid-4 { grid-template-columns: repeat(2,1fr); }
    .stats-grid { grid-template-columns: repeat(2,1fr); }
    .footer-grid { grid-template-columns: 1fr 1fr; }
}
@media (max-width: 900px) {
    .grid-3 { grid-template-columns: repeat(2,1fr); }
}
@media (max-width: 768px) {
    html { font-size: 14px; }
    .grid-2, .grid-3 { grid-template-columns: 1fr; }
    .hero h1 { font-size: 1.8rem; }
    .hamburger { display: block; }
    .nav { display: none; position: absolute; top: var(--header-height); left: 0; right: 0; background: var(--dark); padding: 8px; flex-direction: column; z-index: 999; }
    .nav.open { display: flex; }
    .admin-layout { grid-template-columns: 1fr; }
    .admin-sidebar { position: fixed; left: -260px; top: 0; height: 100vh; z-index: 9999; transition: left .3s; width: 240px; padding-top: 10px; }
    .admin-sidebar.open { left: 0; }
    .admin-main { padding: 16px; }
    .stats-grid { grid-template-columns: repeat(2,1fr); gap: 12px; }
    .plan-cards { grid-template-columns: 1fr; }
}
@media (max-width: 480px) {
    html { font-size: 13px; }
    .grid-4 { grid-template-columns: 1fr; }
    .stats-grid { grid-template-columns: 1fr 1fr; }
    .footer-grid { grid-template-columns: 1fr; }
    .admin-main { padding: 12px; }
}
