/* =========================================================
   ACE Grammar Engine
   New Sentence Approach
   File: new_sentence_approach.css
   ========================================================= */

:root {
    --ace-bg: #f4f7fb;
    --ace-surface: #ffffff;
    --ace-surface-soft: #f8fafc;
    --ace-border: #dce4ee;
    --ace-border-strong: #cbd5e1;

    --ace-text: #172033;
    --ace-muted: #64748b;
    --ace-heading: #0f172a;

    --ace-primary: #2447d8;
    --ace-primary-dark: #1736b3;
    --ace-primary-soft: #edf2ff;

    --ace-accent: #0f8b8d;
    --ace-accent-soft: #eaf8f7;

    --ace-danger: #b42318;
    --ace-danger-bg: #fff1f0;
    --ace-danger-border: #f6c7c3;

    --ace-shadow-sm: 0 2px 8px rgba(15, 23, 42, 0.05);
    --ace-shadow-md: 0 10px 30px rgba(15, 23, 42, 0.08);

    --ace-radius-sm: 8px;
    --ace-radius-md: 12px;
    --ace-radius-lg: 16px;

    --ace-transition: 160ms ease;
}

/* ---------------------------------------------------------
   Base
   --------------------------------------------------------- */

*,
*::before,
*::after {
    box-sizing: border-box;
}

html {
    scroll-behavior: smooth;
}

body {
    margin: 0;
    min-height: 100vh;
    background:
        radial-gradient(circle at top left, rgba(36, 71, 216, 0.07), transparent 28rem),
        linear-gradient(180deg, #f7f9fc 0%, var(--ace-bg) 100%);
    color: var(--ace-text);
    font-family:
        Inter,
        ui-sans-serif,
        system-ui,
        -apple-system,
        BlinkMacSystemFont,
        "Segoe UI",
        Arial,
        sans-serif;
    line-height: 1.5;
}

button,
select,
input,
textarea {
    font: inherit;
}

/* ---------------------------------------------------------
   Page shell
   --------------------------------------------------------- */

.ace-page {
    width: min(1600px, calc(100% - 32px));
    margin: 0 auto;
    padding: 32px 0 48px;
}

.ace-page > h1 {
    margin: 0 0 22px;
    color: var(--ace-heading);
    font-size: clamp(1.55rem, 2vw, 2.15rem);
    font-weight: 800;
    letter-spacing: -0.035em;
}

.ace-page > h1::after {
    content: "";
    display: block;
    width: 72px;
    height: 4px;
    margin-top: 10px;
    border-radius: 999px;
    background: linear-gradient(90deg, var(--ace-primary), var(--ace-accent));
}

/* ---------------------------------------------------------
   Filter toolbar
   --------------------------------------------------------- */

.ace-filter {
    display: flex;
    flex-wrap: wrap;
    align-items: end;
    gap: 12px 14px;
    margin-bottom: 22px;
    padding: 16px;
    border: 1px solid var(--ace-border);
    border-radius: var(--ace-radius-lg);
    background: rgba(255, 255, 255, 0.92);
    box-shadow: var(--ace-shadow-sm);
    backdrop-filter: blur(10px);
}

.ace-filter label {
    align-self: center;
    margin-left: 2px;
    color: #475569;
    font-size: 0.78rem;
    font-weight: 800;
    letter-spacing: 0.055em;
    text-transform: uppercase;
}

.ace-filter select {
    min-width: 150px;
    height: 42px;
    padding: 0 38px 0 12px;
    border: 1px solid var(--ace-border-strong);
    border-radius: 10px;
    outline: none;
    background-color: #fff;
    color: var(--ace-heading);
    font-weight: 650;
    cursor: pointer;
    transition:
        border-color var(--ace-transition),
        box-shadow var(--ace-transition),
        transform var(--ace-transition);
}

.ace-filter select[name="title"] {
    min-width: min(420px, 42vw);
}

.ace-filter select:hover {
    border-color: #9eb0c7;
}

.ace-filter select:focus {
    border-color: var(--ace-primary);
    box-shadow: 0 0 0 4px rgba(36, 71, 216, 0.11);
}

.clear-filter {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-height: 42px;
    padding: 0 15px;
    border: 1px solid #cfd8e6;
    border-radius: 10px;
    background: var(--ace-surface-soft);
    color: #475569;
    font-size: 0.88rem;
    font-weight: 800;
    text-decoration: none;
    transition:
        background var(--ace-transition),
        color var(--ace-transition),
        border-color var(--ace-transition),
        transform var(--ace-transition);
}

.clear-filter:hover {
    border-color: #b9c5d6;
    background: #eef2f7;
    color: var(--ace-heading);
    transform: translateY(-1px);
}

/* ---------------------------------------------------------
   Error messages
   --------------------------------------------------------- */

.load-errors {
    margin: 0 0 18px;
    padding: 13px 15px;
    border: 1px solid var(--ace-danger-border);
    border-left: 4px solid var(--ace-danger);
    border-radius: var(--ace-radius-md);
    background: var(--ace-danger-bg);
    color: var(--ace-danger);
    box-shadow: var(--ace-shadow-sm);
    font-size: 0.92rem;
    font-weight: 650;
}

.load-errors > div + div {
    margin-top: 5px;
}

/* ---------------------------------------------------------
   Form sections
   --------------------------------------------------------- */

.form-section {
    margin: 0 0 22px;
    overflow: hidden;
    border: 1px solid var(--ace-border);
    border-radius: var(--ace-radius-lg);
    background: var(--ace-surface);
    box-shadow: var(--ace-shadow-md);
}

.form-title {
    position: relative;
    display: flex;
    align-items: center;
    min-height: 54px;
    padding: 13px 18px 13px 20px;
    border-bottom: 1px solid var(--ace-border);
    background:
        linear-gradient(90deg, var(--ace-primary-soft), #ffffff 55%);
    color: var(--ace-heading);
    font-size: 1rem;
    font-weight: 850;
    letter-spacing: -0.012em;
}

.form-title::before {
    content: "";
    width: 5px;
    height: 28px;
    margin-right: 11px;
    border-radius: 999px;
    background: linear-gradient(180deg, var(--ace-primary), var(--ace-accent));
}

/* ---------------------------------------------------------
   Data table
   --------------------------------------------------------- */

.form-section {
    overflow-x: auto;
}

table {
    width: 100%;
    min-width: 980px;
    border-collapse: separate;
    border-spacing: 0;
    table-layout: auto;
}

thead th {
    position: sticky;
    top: 0;
    z-index: 3;
    padding: 11px 14px;
    border-bottom: 1px solid var(--ace-border-strong);
    background: #f7f9fc;
    color: #526078;
    font-size: 0.73rem;
    font-weight: 850;
    letter-spacing: 0.06em;
    text-align: left;
    text-transform: uppercase;
    white-space: nowrap;
}

tbody td {
    padding: 12px 14px;
    border-bottom: 1px solid #e8edf3;
    background: #fff;
    color: #263348;
    font-size: 0.92rem;
    vertical-align: middle;
}

tbody tr:last-child td {
    border-bottom: 0;
}

tbody tr {
    transition:
        background var(--ace-transition),
        box-shadow var(--ace-transition);
}

tbody tr:nth-child(even) td {
    background: #fbfcfe;
}

tbody tr:hover td {
    background: #f2f6ff;
}

/* Record address */
.record-number {
    width: 90px;
    color: var(--ace-primary-dark);
    font-family:
        "SFMono-Regular",
        Consolas,
        "Liberation Mono",
        Menlo,
        monospace;
    font-size: 0.82rem;
    font-weight: 850;
    white-space: nowrap;
}

/* Exact title sourced from aceRecordTitles */
.master-record-title {
    min-width: 190px;
    color: var(--ace-heading);
    font-weight: 760;
}

/* Title from special-construction record */
.record-title {
    min-width: 190px;
    color: #536177;
    font-size: 0.88rem;
    font-weight: 650;
}

/* English column: the first unclassed cell following .record-title */
.record-title + td {
    min-width: 330px;
    color: #1e293b;
    font-size: 0.95rem;
    font-weight: 560;
    line-height: 1.55;
}

/* Arabic */
.arabic {
    min-width: 190px;
    color: #111827;
    direction: rtl;
    font-family:
        "Noto Naskh Arabic",
        "Amiri",
        "Scheherazade New",
        "Segoe UI",
        Arial,
        sans-serif;
    font-size: 1.35rem;
    font-weight: 650;
    line-height: 1.9;
    text-align: right;
    unicode-bidi: isolate;
}

/* ---------------------------------------------------------
   Small visual markers
   --------------------------------------------------------- */

.record-number::before {
    content: "#";
    margin-right: 2px;
    color: #8da0bd;
    font-weight: 700;
}

.master-record-title:empty::after,
.record-title:empty::after,
.arabic:empty::after {
    content: "—";
    color: #a6b1c2;
    font-family: inherit;
    font-size: 0.9rem;
    font-weight: 500;
}

/* ---------------------------------------------------------
   Scrollbar
   --------------------------------------------------------- */

.form-section::-webkit-scrollbar {
    height: 10px;
}

.form-section::-webkit-scrollbar-track {
    background: #f1f5f9;
}

.form-section::-webkit-scrollbar-thumb {
    border: 2px solid #f1f5f9;
    border-radius: 999px;
    background: #b8c4d4;
}

.form-section::-webkit-scrollbar-thumb:hover {
    background: #94a3b8;
}

/* ---------------------------------------------------------
   Responsive
   --------------------------------------------------------- */

@media (max-width: 900px) {
    .ace-page {
        width: min(100% - 20px, 1600px);
        padding-top: 20px;
    }

    .ace-filter {
        align-items: stretch;
    }

    .ace-filter label {
        width: 100%;
        margin-top: 2px;
    }

    .ace-filter select,
    .ace-filter select[name="title"] {
        width: 100%;
        min-width: 0;
    }

    .clear-filter {
        width: 100%;
    }

    .form-title {
        font-size: 0.94rem;
    }

    tbody td,
    thead th {
        padding-left: 11px;
        padding-right: 11px;
    }
}

@media (max-width: 600px) {
    .ace-page > h1 {
        font-size: 1.45rem;
    }

    .ace-filter {
        padding: 13px;
        border-radius: 13px;
    }

    .form-section {
        border-radius: 13px;
    }

    .form-title {
        min-height: 50px;
        padding: 11px 14px;
    }
}

/* ---------------------------------------------------------
   Print
   --------------------------------------------------------- */

@media print {
    body {
        background: #fff;
    }

    .ace-page {
        width: 100%;
        padding: 0;
    }

    .ace-filter,
    .load-errors {
        display: none;
    }

    .form-section {
        break-inside: avoid;
        box-shadow: none;
    }

    thead th {
        position: static;
    }

    tbody tr:hover td,
    tbody tr:nth-child(even) td,
    tbody td {
        background: #fff;
    }
}
