/* =====================================================================
   IhsanPro component layer.
   Load order: tokens.css -> app.css -> (optional) page-specific styles.

   One brand across every screen. Before this, the app carried five
   different primaries (green marketing site, indigo dashboard, emerald
   password screens, orange super-admin, purple TV) — this unifies them
   on the Islamic green the logo and landing page already use.
   ===================================================================== */

*, *::before, *::after { box-sizing: border-box; }

body {
    margin: 0;
    font-family: var(--font);
    font-size: var(--fs-base);
    line-height: var(--lh-body);
    color: var(--text);
    background: var(--surface-alt);
    -webkit-font-smoothing: antialiased;
}

h1, h2, h3, h4 { margin: 0 0 var(--sp-3); line-height: var(--lh-tight); color: var(--ink); }
h1 { font-size: var(--fs-3xl); }
h2 { font-size: var(--fs-2xl); }
h3 { font-size: var(--fs-xl); }
h4 { font-size: var(--fs-lg); }
p { margin: 0 0 var(--sp-3); }

img, svg, video, canvas { max-width: 100%; height: auto; }

/* =====================================================================
   Buttons
   ===================================================================== */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: var(--sp-2);
    min-height: var(--tap);
    padding: 0.7rem 1.5rem;
    border: 1.5px solid transparent;
    border-radius: var(--r-md);
    font-family: var(--font);
    font-size: var(--fs-sm);
    font-weight: var(--fw-bold);
    line-height: 1.2;
    text-decoration: none;
    cursor: pointer;
    transition: background var(--dur) var(--ease), transform var(--dur) var(--ease),
                box-shadow var(--dur) var(--ease), border-color var(--dur) var(--ease);
}
.btn:disabled, .btn[disabled] { opacity: 0.55; cursor: not-allowed; transform: none !important; }

.btn-primary { background: var(--primary); color: #fff; box-shadow: var(--shadow-brand); }
.btn-primary:hover:not(:disabled) { background: var(--primary-dark); transform: translateY(-2px); }

.btn-gold { background: var(--gold); color: #fff; }
.btn-gold:hover:not(:disabled) { background: #92400E; transform: translateY(-2px); }

.btn-outline { background: transparent; color: var(--primary); border-color: var(--primary); }
.btn-outline:hover:not(:disabled) { background: var(--primary-050); }

.btn-ghost { background: var(--surface); color: var(--text); border-color: var(--line); }
.btn-ghost:hover:not(:disabled) { background: var(--surface-alt); }

.btn-danger { background: var(--danger); color: #fff; }
.btn-danger:hover:not(:disabled) { background: #991B1B; }

.btn-block { width: 100%; }
.btn-lg { font-size: var(--fs-base); padding: 0.9rem 1.9rem; }

/* =====================================================================
   Forms
   ===================================================================== */
.form-group { margin-bottom: var(--sp-4); text-align: start; }

label {
    display: block;
    margin-bottom: var(--sp-2);
    font-size: var(--fs-sm);
    font-weight: var(--fw-medium);
    color: var(--ink-soft);
}

input, select, textarea, .form-control {
    width: 100%;
    min-height: var(--tap);
    padding: 0.7rem 0.9rem;
    border: 1.5px solid var(--line);
    border-radius: var(--r-md);
    background: var(--surface);
    color: var(--text);
    font-family: var(--font);
    /* 16px floor stops iOS Safari zooming the page on focus. */
    font-size: max(1rem, var(--fs-base));
    transition: border-color var(--dur) var(--ease), box-shadow var(--dur) var(--ease);
}
input:focus, select:focus, textarea:focus, .form-control:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px var(--primary-100);
}
input::placeholder, textarea::placeholder { color: #94A3B8; }

/* =====================================================================
   Auth screens (login, signup, forgot, reset)
   ===================================================================== */
.auth-page,
body.auth-page {
    /* dvh keeps the card centred when mobile browser chrome shows/hides. */
    min-height: 100dvh;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: var(--sp-4);
    background:
        radial-gradient(1100px 520px at 82% -12%, var(--primary-050) 0%, transparent 58%),
        radial-gradient(760px 420px at 8% 108%, var(--gold-050) 0%, transparent 55%),
        var(--surface-alt);
}

.auth-container {
    width: 100%;
    max-width: 440px;
    padding: clamp(1.5rem, 1rem + 3vw, 2.75rem);
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: var(--r-xl);
    box-shadow: var(--shadow-lg);
    text-align: center;
}

.auth-brand {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 62px;
    height: 62px;
    margin-bottom: var(--sp-4);
    border-radius: var(--r-lg);
    background: var(--primary-050);
    color: var(--primary);
    font-size: 1.7rem;
}
.auth-icon { color: var(--primary); }

.auth-container h1,
.auth-container h2 {
    font-size: var(--fs-2xl);
    margin-bottom: var(--sp-2);
}
.auth-sub {
    margin-bottom: var(--sp-5);
    font-size: var(--fs-sm);
    color: var(--text-muted);
}

.auth-container .btn { width: 100%; }

.error {
    display: none;
    margin-bottom: var(--sp-4);
    padding: 0.7rem 0.9rem;
    border: 1px solid #FECACA;
    border-radius: var(--r-md);
    background: #FEF2F2;
    color: var(--danger);
    font-size: var(--fs-sm);
    text-align: start;
}
.success-msg {
    margin-bottom: var(--sp-4);
    padding: 0.7rem 0.9rem;
    border: 1px solid var(--primary-100);
    border-radius: var(--r-md);
    background: var(--primary-050);
    color: var(--primary-dark);
    font-size: var(--fs-sm);
}

.link, .links {
    margin-top: var(--sp-5);
    font-size: var(--fs-sm);
    color: var(--text-muted);
}
.link a, .links a {
    display: inline-flex;
    align-items: center;
    gap: var(--sp-1);
    min-height: var(--tap);
    padding-inline: var(--sp-1);
    color: var(--primary);
    font-weight: var(--fw-bold);
    text-decoration: none;
}
.link a:hover, .links a:hover { text-decoration: underline; }

.divider-container { margin: var(--sp-5) 0 var(--sp-4); }
.divider {
    display: flex;
    align-items: center;
    gap: var(--sp-3);
    color: var(--text-muted);
    font-size: var(--fs-sm);
}
.divider::before, .divider::after {
    content: '';
    flex: 1;
    border-bottom: 1px solid var(--line);
}

/* =====================================================================
   Surfaces
   ===================================================================== */
.card {
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: var(--r-lg);
    box-shadow: var(--shadow-sm);
    padding: var(--sp-5);
}

.badge {
    display: inline-flex;
    align-items: center;
    padding: 0.25rem 0.6rem;
    border-radius: var(--r-pill);
    font-size: var(--fs-xs);
    font-weight: var(--fw-bold);
}
.badge-ok { background: var(--primary-100); color: var(--primary-dark); }
.badge-bad { background: #FEE2E2; color: var(--danger); }
.badge-warn { background: var(--gold-050); color: var(--gold); }

/* =====================================================================
   Tables — scroll inside their own box, never the page
   ===================================================================== */
.table-wrap {
    max-width: 100%;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: var(--r-lg);
}
.table-wrap table { width: 100%; border-collapse: collapse; }
.table-wrap th {
    padding: var(--sp-3) var(--sp-4);
    background: var(--surface-alt);
    border-bottom: 2px solid var(--line);
    font-size: var(--fs-sm);
    color: var(--text-muted);
    text-align: start;
    white-space: nowrap;
}
.table-wrap td {
    padding: var(--sp-3) var(--sp-4);
    border-bottom: 1px solid var(--line-soft);
    font-size: var(--fs-sm);
}
.table-wrap tr:last-child td { border-bottom: 0; }

/* Nothing may push the document sideways. */
html, body { max-width: 100%; overflow-x: hidden; }
