:root {
    --bg: #f6f8fc;
    --card: #ffffff;
    --text: #0f172a;
    --muted: #64748b;
    --border: #e2e8f0;
    --primary: #2563eb;
    --success: #16a34a;
    --warning: #d97706;
    --danger: #dc2626;
    --info: #0891b2;
    --shadow: 0 14px 36px rgba(15, 23, 42, 0.07);
}

* {
    box-sizing: border-box;
}

body {
    margin: 0;
    min-height: 100vh;
    background: radial-gradient(circle at top left, rgba(37,99,235,.08), transparent 30%), linear-gradient(180deg, #f8fbff 0%, var(--bg) 100%);
    font-family: "Segoe UI", Tahoma, sans-serif;
    color: var(--text);
}

.page-wrapper {
    max-width: 1180px;
    margin: auto;
    padding: 28px 16px;
}

.theory-hero {
    background: linear-gradient(135deg, #1d4ed8, #0f172a);
    color: #ffffff;
    border-radius: 24px;
    padding: 30px;
    box-shadow: var(--shadow);
    position: relative;
    overflow: hidden;
    margin-bottom: 24px;
}

    .theory-hero:before {
        content: "";
        position: absolute;
        width: 280px;
        height: 280px;
        background: rgba(255,255,255,.12);
        border-radius: 50%;
        right: -90px;
        top: -110px;
    }

.theory-hero-content {
    position: relative;
    z-index: 1;
}

.breadcrumb-line {
    color: rgba(255,255,255,.82);
    font-weight: 600;
    margin-bottom: 12px;
}

.page-title {
    font-size: clamp(1.6rem, 3vw, 2.35rem);
    font-weight: 850;
    margin-bottom: 10px;
}

.short-description {
    color: rgba(255,255,255,.9);
    max-width: 900px;
    margin-bottom: 0;
    font-size: 1.02rem;
    line-height: 1.7;
}

.premium-badge,
.free-badge {
    display: inline-flex;
    align-items: center;
    gap: 7px;
    padding: 8px 12px;
    border-radius: 999px;
    font-weight: 800;
    font-size: .84rem;
    margin-top: 16px;
}

.premium-badge {
    background: #fef3c7;
    color: #92400e;
}

.free-badge {
    background: #dcfce7;
    color: #166534;
}

.content-card {
    background: var(--card);
    border: 1px solid var(--border);
    border-radius: 22px;
    box-shadow: var(--shadow);
    overflow: hidden;
    margin-bottom: 22px;
}

.content-card-header {
    padding: 18px 22px;
    border-bottom: 1px solid var(--border);
    background: #f8fafc;
    font-weight: 850;
    display: flex;
    align-items: center;
    gap: 10px;
    color: #1e293b;
}

.content-card-body {
    padding: 24px;
    line-height: 1.85;
    color: #1f2937;
}

    .content-card-body h1,
    .content-card-body h2,
    .content-card-body h3,
    .content-card-body h4 {
        color: #0f172a;
        font-weight: 850;
        margin-top: 18px;
        margin-bottom: 12px;
    }

    .content-card-body h3 {
        font-size: 1.25rem;
    }

    .content-card-body p {
        margin-bottom: 14px;
    }

    .content-card-body ul,
    .content-card-body ol {
        padding-left: 1.3rem;
        margin-bottom: 0;
    }

    .content-card-body li {
        margin-bottom: 10px;
    }

.study-document-card {
    background: linear-gradient(135deg, #eff6ff, #ffffff);
    border: 1px solid #bfdbfe;
    border-radius: 22px;
    box-shadow: var(--shadow);
    padding: 22px;
    margin-bottom: 22px;
}

.study-document-icon {
    width: 54px;
    height: 54px;
    border-radius: 16px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    background: #dbeafe;
    color: #1d4ed8;
    font-size: 1.45rem;
    flex: 0 0 auto;
}

.study-document-title {
    margin: 0 0 5px;
    font-weight: 850;
    color: #0f172a;
}

.study-document-text {
    margin: 0;
    color: var(--muted);
    line-height: 1.6;
}

.action-area {
    background: #ffffff;
    border: 1px solid var(--border);
    border-radius: 22px;
    box-shadow: var(--shadow);
    padding: 20px;
    margin-top: 24px;
}

.btn-action {
    border-radius: 14px;
    font-weight: 800;
    padding: 12px 16px;
}

.empty-box,
.locked-box {
    background: #ffffff;
    border: 1px solid var(--border);
    border-radius: 22px;
    box-shadow: var(--shadow);
    padding: 34px;
    text-align: center;
}

.empty-icon,
.locked-icon {
    width: 74px;
    height: 74px;
    border-radius: 22px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    margin-bottom: 18px;
    font-size: 2rem;
}

.empty-icon {
    background: #fee2e2;
    color: #991b1b;
}

.locked-icon {
    background: #fef3c7;
    color: #92400e;
}

.preview-label {
    display: inline-flex;
    align-items: center;
    gap: 7px;
    padding: 7px 11px;
    border-radius: 999px;
    background: #dbeafe;
    color: #1d4ed8;
    font-weight: 800;
    font-size: .8rem;
    margin-bottom: 14px;
}

.premium-feature-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 12px;
}

.premium-feature-item {
    border: 1px solid var(--border);
    border-radius: 16px;
    padding: 16px;
    background: #f8fafc;
}

    .premium-feature-item strong {
        display: block;
        margin-bottom: 5px;
        color: #0f172a;
    }

    .premium-feature-item span {
        color: var(--muted);
        font-size: .9rem;
        line-height: 1.55;
    }

@media(max-width: 768px) {
    .page-wrapper {
        padding: 18px 10px;
    }

    .theory-hero {
        padding: 24px;
    }

    .content-card-body {
        padding: 18px;
    }

    .action-area .btn {
        width: 100%;
    }

    .study-document-card .btn {
        width: 100%;
    }

    .premium-feature-grid {
        grid-template-columns: 1fr;
    }
}

/* =========================================================
   EXAMKITIYARI BRAND HEADER
   ========================================================= */
.theory-brandbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 14px;
    margin-bottom: 18px;
}

.theory-brand-link {
    display: inline-flex;
    align-items: center;
    gap: 11px;
    min-width: 0;
    color: var(--text);
    text-decoration: none;
}

.theory-brand-logo {
    width: 52px;
    height: 52px;
    flex: 0 0 52px;
    border-radius: 15px;
    object-fit: contain;
    background: #fff;
    padding: 4px;
    border: 1px solid var(--border);
    box-shadow: 0 8px 20px rgba(15, 23, 42, .08);
}

.theory-brand-copy {
    min-width: 0;
}

    .theory-brand-copy strong,
    .theory-brand-copy small {
        display: block;
    }

    .theory-brand-copy strong {
        color: #0f172a;
        font-size: 1.02rem;
        font-weight: 900;
        line-height: 1.15;
    }

    .theory-brand-copy small {
        margin-top: 3px;
        color: var(--muted);
        font-size: .78rem;
        font-weight: 650;
    }

.theory-home-link {
    flex: 0 0 auto;
    display: inline-flex;
    align-items: center;
    gap: 7px;
    min-height: 40px;
    padding: 8px 13px;
    border: 1px solid #bfdbfe;
    border-radius: 999px;
    background: #eff6ff;
    color: #1d4ed8;
    font-size: .82rem;
    font-weight: 800;
    text-decoration: none;
}

    .theory-home-link:hover {
        border-color: #2563eb;
        background: #2563eb;
        color: #fff;
    }

/* =========================================================
   URDU / MIXED ENGLISH-URDU TYPOGRAPHY
   Jameel Noori is used when it exists on the visitor's
   device. Fallbacks keep Urdu readable when unavailable.
   ========================================================= */
@font-face {
    font-family: "Jameel Noori Nastaleeq";
    src: local("Jameel Noori Nastaleeq"), local("Jameel Noori Nastaliq"), local("Jameel Noori NastaleeQ");
    font-display: swap;
}

.urdu-text,
.urdu-ui {
    font-family: "Jameel Noori Nastaleeq", "Jameel Noori Nastaliq", "Noto Nastaliq Urdu", "Noto Naskh Arabic", serif !important;
    line-height: 2.05;
    letter-spacing: 0;
}

.urdu-text {
    font-size: 1.08em;
    direction: rtl;
    unicode-bidi: isolate;
}

.urdu-ui {
    font-size: 1.08em;
}

.content-card-body[dir="auto"],
.short-description[dir="auto"] {
    text-align: start;
}

.content-card-body p,
.content-card-body li,
.content-card-body blockquote,
.content-card-body h1,
.content-card-body h2,
.content-card-body h3,
.content-card-body h4,
.content-card-body h5,
.content-card-body h6,
.short-description {
    unicode-bidi: plaintext;
}

/* Long theory pages: let the browser skip off-screen rendering work. */
.content-card,
.study-document-card,
.action-area {
    content-visibility: auto;
    contain-intrinsic-size: 1px 420px;
}

@media (max-width: 575.98px) {
    .theory-brandbar {
        align-items: flex-start;
    }

    .theory-brand-logo {
        width: 46px;
        height: 46px;
        flex-basis: 46px;
    }

    .theory-brand-copy small {
        display: none;
    }

    .theory-home-link {
        min-height: 38px;
        padding: 7px 11px;
        font-size: .78rem;
    }

    .urdu-text,
    .urdu-ui {
        line-height: 2.15;
    }
}

@media (prefers-reduced-motion: reduce) {
    *,
    *::before,
    *::after {
        scroll-behavior: auto !important;
        transition: none !important;
        animation: none !important;
    }
}

/* =========================================================
   MARKET-LEVEL ARTICLE READING ENHANCEMENTS
   Keeps the existing ExamKiTiyari design while improving
   long-form theory readability, tables, images and mobile UI.
   ========================================================= */

:root {
    --reading-width: 900px;
    --reading-text: #273244;
    --reading-soft: #f8fafc;
    --reading-blue-soft: #eff6ff;
}

/* Center the actual study content and keep a comfortable reading width */
.theory-hero,
.content-card,
.study-document-card,
.action-area,
.locked-box,
.empty-box {
    max-width: var(--reading-width);
    margin-left: auto;
    margin-right: auto;
}

.theory-hero {
    margin-bottom: 22px;
}

/* Slightly calmer article surface */
.content-card {
    border-radius: 20px;
}

.content-card-header {
    padding: 17px 24px;
    font-size: 1rem;
    letter-spacing: .005em;
}

.content-card-body {
    padding: 28px 32px 32px;
    color: var(--reading-text);
    font-size: 1.02rem;
    line-height: 1.9;
    overflow-wrap: anywhere;
    word-break: normal;
}

    /* Strong reading rhythm */
    .content-card-body > *:first-child {
        margin-top: 0 !important;
    }

    .content-card-body > *:last-child {
        margin-bottom: 0 !important;
    }

    .content-card-body p {
        margin: 0 0 1.15em;
        text-align: left;
        text-justify: auto;
        hyphens: none;
    }

    /* Article headings */
    .content-card-body h1,
    .content-card-body h2,
    .content-card-body h3,
    .content-card-body h4,
    .content-card-body h5,
    .content-card-body h6 {
        color: #111827;
        line-height: 1.35;
        font-weight: 850;
        scroll-margin-top: 85px;
    }

    .content-card-body h1 {
        font-size: 1.65rem;
        margin: 1.7em 0 .7em;
    }

    .content-card-body h2 {
        font-size: 1.42rem;
        margin: 1.6em 0 .72em;
        padding-bottom: 9px;
        border-bottom: 1px solid #e8edf3;
    }

    .content-card-body h3 {
        font-size: 1.22rem;
        margin: 1.45em 0 .65em;
    }

    .content-card-body h4 {
        font-size: 1.08rem;
        margin: 1.35em 0 .55em;
    }

/* Short description should read like a professional intro */
.short-description {
    line-height: 1.82;
    text-align: left;
    text-justify: auto;
    overflow-wrap: anywhere;
}

/* Better lists */
.content-card-body ul,
.content-card-body ol {
    margin: .9em 0 1.2em;
    padding-left: 1.45rem;
}

.content-card-body li {
    margin-bottom: .55em;
    padding-left: .15rem;
}

    .content-card-body li::marker {
        color: var(--primary);
        font-weight: 800;
    }

/* Links inside theory */
.content-card-body a {
    color: #1d4ed8;
    font-weight: 650;
    text-decoration-thickness: 1px;
    text-underline-offset: 3px;
    overflow-wrap: anywhere;
}

    .content-card-body a:hover {
        color: #1e40af;
    }

/* Highlight quotes / important callouts */
.content-card-body blockquote {
    margin: 1.4em 0;
    padding: 16px 18px;
    border-left: 4px solid var(--primary);
    border-radius: 0 12px 12px 0;
    background: var(--reading-blue-soft);
    color: #334155;
}

    .content-card-body blockquote p:last-child {
        margin-bottom: 0;
    }

/* =========================================================
   IMAGES / FIGURES
   Automatically fixes images saved inside article HTML.
   ========================================================= */

.content-card-body img,
.short-description img {
    display: block;
    width: auto !important;
    max-width: 100% !important;
    height: auto !important;
    margin: 24px auto;
    border: 1px solid #e2e8f0;
    border-radius: 14px;
    object-fit: contain;
    box-shadow: 0 10px 28px rgba(15, 23, 42, .10);
}

.content-card-body figure {
    width: 100%;
    max-width: 100%;
    margin: 26px auto;
    text-align: center;
}

    .content-card-body figure img {
        margin: 0 auto;
    }

.content-card-body figcaption {
    max-width: 760px;
    margin: 9px auto 0;
    color: var(--muted);
    font-size: .86rem;
    line-height: 1.55;
    text-align: center;
}

/* Prevent inline editor styles from pushing images outside the card */
.content-card-body img[style],
.short-description img[style] {
    max-width: 100% !important;
    height: auto !important;
}

/* =========================================================
   BEAUTIFUL RESPONSIVE TABLES
   Works with normal HTML tables stored in the database.
   ========================================================= */

.content-card-body table {
    width: 100% !important;
    max-width: 100%;
    min-width: 600px;
    margin: 24px auto;
    border-collapse: separate !important;
    border-spacing: 0;
    border: 1px solid #dbe3ec;
    border-radius: 14px;
    background: #ffffff;
    font-size: .94rem;
    line-height: 1.55;
    box-shadow: 0 8px 24px rgba(15, 23, 42, .06);
    overflow: hidden;
}

.content-card-body thead th,
.content-card-body tr:first-child th {
    background: linear-gradient(180deg, #eff6ff, #eaf2ff);
    color: #17345e;
    font-weight: 800;
}

.content-card-body th,
.content-card-body td {
    padding: 12px 14px !important;
    border-right: 1px solid #e7edf4 !important;
    border-bottom: 1px solid #e7edf4 !important;
    vertical-align: top;
    text-align: left;
}

    .content-card-body th:last-child,
    .content-card-body td:last-child {
        border-right: 0 !important;
    }

.content-card-body tr:last-child td {
    border-bottom: 0 !important;
}

.content-card-body tbody tr:nth-child(even) {
    background: #fafcff;
}

.content-card-body tbody tr:hover {
    background: #f3f7ff;
}

/* Existing content-card-body becomes the safe horizontal scroll container */
.content-card-body {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
}

    /* =========================================================
   EMBEDDED MEDIA
   ========================================================= */

    .content-card-body iframe,
    .content-card-body video {
        display: block;
        width: 100% !important;
        max-width: 100%;
        margin: 24px auto;
        border: 0;
        border-radius: 14px;
        box-shadow: 0 10px 26px rgba(15, 23, 42, .10);
    }

    .content-card-body video {
        height: auto !important;
    }

    .content-card-body iframe {
        min-height: 420px;
    }

    /* =========================================================
   CODE / PRE-FORMATTED CONTENT
   ========================================================= */

    .content-card-body pre {
        max-width: 100%;
        overflow: auto;
        margin: 1.35em 0;
        padding: 16px 18px;
        border-radius: 12px;
        background: #111827;
        color: #f8fafc;
        line-height: 1.65;
    }

    .content-card-body code {
        font-family: Consolas, "Courier New", monospace;
    }

    /* =========================================================
   URDU / MIXED CONTENT REFINEMENT
   ========================================================= */

    .content-card-body .urdu-text,
    .short-description .urdu-text {
        line-height: 2.15;
    }

    .content-card-body [dir="rtl"],
    .short-description [dir="rtl"] {
        text-align: start;
        text-justify: auto;
    }

/* =========================================================
   TABLET / MOBILE
   ========================================================= */

@media (max-width: 768px) {
    .theory-hero,
    .content-card,
    .study-document-card,
    .action-area,
    .locked-box,
    .empty-box {
        max-width: 100%;
    }

    .theory-hero {
        border-radius: 18px;
        padding: 23px 20px;
    }

    .content-card {
        border-radius: 16px;
    }

    .content-card-header {
        padding: 14px 17px;
    }

    .content-card-body {
        padding: 20px 18px 23px;
        font-size: 1rem;
        line-height: 1.82;
    }

        /*
       On narrow English screens, left alignment is more readable than
       full justification because it avoids large gaps between words.
       Urdu spans continue to use their RTL rules.
    */
        .content-card-body p,
        .short-description {
            text-align: left;
            hyphens: none;
        }

        .content-card-body h1 {
            font-size: 1.42rem;
        }

        .content-card-body h2 {
            font-size: 1.27rem;
        }

        .content-card-body h3 {
            font-size: 1.14rem;
        }

        .content-card-body table {
            min-width: 540px;
            font-size: .9rem;
        }

        .content-card-body th,
        .content-card-body td {
            padding: 10px 11px !important;
        }

        .content-card-body img,
        .short-description img {
            margin: 18px auto;
            border-radius: 12px;
        }

        .content-card-body iframe {
            min-height: 270px;
        }
}

@media (max-width: 575.98px) {
    .page-wrapper {
        padding-left: 9px;
        padding-right: 9px;
    }

    .content-card-body {
        padding-left: 16px;
        padding-right: 16px;
    }

        .content-card-body .urdu-text,
        .short-description .urdu-text {
            line-height: 2.2;
        }
}

/* =========================================================
   PRINT-FRIENDLY THEORY
   ========================================================= */

@media print {
    body {
        background: #ffffff !important;
        color: #000000;
    }

    .page-wrapper {
        max-width: none;
        padding: 0;
    }

    .theory-brandbar,
    .action-area,
    .study-document-card .btn {
        display: none !important;
    }

    .theory-hero,
    .content-card,
    .study-document-card {
        max-width: 100%;
        box-shadow: none !important;
        border-color: #bfc6cf;
    }

    .content-card-body {
        overflow: visible;
    }

        .content-card-body table {
            min-width: 0;
            box-shadow: none;
        }

        .content-card-body a {
            color: #000;
            text-decoration: none;
        }

        .content-card-body img {
            box-shadow: none;
            break-inside: avoid;
        }
}

/* =========================================================
   FINAL ARTICLE SPACING FIX
   Prevents stretched / irregular gaps between words.
   ========================================================= */

.content-card-body,
.content-card-body p,
.content-card-body li,
.content-card-body blockquote,
.content-card-body td,
.content-card-body th,
.short-description {
    text-align: left !important;
    text-justify: auto !important;
    word-spacing: normal !important;
    letter-spacing: normal !important;
    white-space: normal !important;
}

    .content-card-body h1,
    .content-card-body h2,
    .content-card-body h3,
    .content-card-body h4,
    .content-card-body h5,
    .content-card-body h6 {
        word-spacing: normal !important;
        letter-spacing: normal !important;
        white-space: normal !important;
    }

    /* Preserve correct Urdu direction without stretching word spacing */
    .content-card-body .urdu-text,
    .short-description .urdu-text,
    .content-card-body [dir="rtl"],
    .short-description [dir="rtl"] {
        word-spacing: normal !important;
        letter-spacing: 0 !important;
        white-space: normal !important;
    }

    /* Keep code/preformatted content untouched */
    .content-card-body pre,
    .content-card-body code {
        white-space: pre-wrap;
        word-spacing: normal;
        letter-spacing: normal;
    }
