:root {
    --sidebar-width: 260px;
    --brand: #0d6e4f;
    --brand-dark: #0a5740;
}

body {
    font-family: "Segoe UI", Tahoma, "Noto Naskh Arabic", "Traditional Arabic", Arial, sans-serif;
}

/* ---------- Guest / Login ---------- */
.guest-body {
    background: linear-gradient(135deg, #0d6e4f 0%, #0a5740 55%, #083d2e 100%);
    background-size: 200% 200%;
    animation: guest-gradient 18s ease-in-out infinite;
    min-height: 100vh;
    position: relative;
    overflow-x: hidden;
}

/* Islamic geometric lattice (8-point star tile) */
.guest-body::before {
    content: "";
    position: fixed;
    inset: 0;
    pointer-events: none;
    z-index: 0;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='72' height='72' viewBox='0 0 72 72'%3E%3Cg fill='none' stroke='%23ffffff' stroke-width='1'%3E%3Crect x='18' y='18' width='36' height='36'/%3E%3Crect x='18' y='18' width='36' height='36' transform='rotate(45 36 36)'/%3E%3Ccircle cx='36' cy='36' r='5'/%3E%3C/g%3E%3C/svg%3E");
    opacity: .07;
}

@keyframes guest-gradient {
    0%   { background-position: 0% 50%; }
    50%  { background-position: 100% 50%; }
    100% { background-position: 0% 50%; }
}

/* drifting light blobs */
.guest-blob {
    position: fixed;
    width: 340px;
    height: 340px;
    border-radius: 50%;
    pointer-events: none;
    z-index: 0;
    filter: blur(60px);
}

.guest-blob-1 {
    top: -80px;
    right: -60px;
    background: radial-gradient(circle, #5ee0b0 0%, transparent 70%);
    opacity: .35;
    animation: blob-drift 14s ease-in-out infinite;
}

.guest-blob-2 {
    bottom: -100px;
    left: -80px;
    background: radial-gradient(circle, #ffe9a8 0%, transparent 70%);
    opacity: .22;
    animation: blob-drift 18s ease-in-out infinite reverse;
}

@keyframes blob-drift {
    0%, 100% { transform: translate(0, 0) scale(1); }
    33%      { transform: translate(-40px, 30px) scale(1.08); }
    66%      { transform: translate(30px, -25px) scale(.94); }
}

.guest-body .container {
    position: relative;
    z-index: 1;
}

.auth-card {
    border-radius: 1rem;
    overflow: hidden;
    animation: card-in .65s cubic-bezier(.22, 1, .36, 1) both;
}

.auth-card.has-error {
    animation: card-in .65s cubic-bezier(.22, 1, .36, 1) both, shake .45s .7s ease-in-out;
}

@keyframes card-in {
    from { opacity: 0; transform: translateY(26px) scale(.97); }
    to   { opacity: 1; transform: none; }
}

@keyframes shake {
    0%, 100% { transform: translateX(0); }
    20%      { transform: translateX(-9px); }
    40%      { transform: translateX(8px); }
    60%      { transform: translateX(-5px); }
    80%      { transform: translateX(4px); }
}

/* staggered entrance */
.auth-card .text-center,
.auth-card form > div,
.auth-card form > button,
.auth-card .card-footer {
    animation: fade-up .5s both;
}

@keyframes fade-up {
    from { opacity: 0; transform: translateY(14px); }
    to   { opacity: 1; transform: none; }
}

.auth-card .text-center          { animation-delay: .2s; }
.auth-card form > div:nth-of-type(1) { animation-delay: .35s; }
.auth-card form > div:nth-of-type(2) { animation-delay: .5s; }
.auth-card form > button         { animation-delay: .65s; }
.auth-card .card-footer          { animation-delay: .8s; }

/* rotating welcome phrase */
.welcome-rotate {
    position: relative;
    min-height: 1.5em;
    color: var(--brand);
    font-weight: 600;
    font-size: .875rem;
}

.welcome-rotate span {
    position: absolute;
    inset-inline: 0;
    top: 0;
    opacity: 0;
    animation: rotate-phrase 16s infinite;
}

.welcome-rotate span:nth-child(1) { animation-delay: 0s; }
.welcome-rotate span:nth-child(2) { animation-delay: 4s; }
.welcome-rotate span:nth-child(3) { animation-delay: 8s; }
.welcome-rotate span:nth-child(4) { animation-delay: 12s; }

@keyframes rotate-phrase {
    0%    { opacity: 0; transform: translateY(8px); }
    3%    { opacity: 1; transform: translateY(0); }
    22%   { opacity: 1; transform: translateY(0); }
    25%   { opacity: 0; transform: translateY(-8px); }
    100%  { opacity: 0; transform: translateY(8px); }
}

/* brand icon soft ripple */
.brand-icon {
    width: 64px;
    height: 64px;
    border-radius: 50%;
    background: linear-gradient(135deg, var(--brand), var(--brand-dark));
    color: #fff;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.8rem;
    animation: brand-ripple 3s ease-out infinite;
}

@keyframes brand-ripple {
    0%   { box-shadow: 0 0 0 0 rgba(13, 110, 79, .35); }
    70%  { box-shadow: 0 0 0 16px rgba(13, 110, 79, 0); }
    100% { box-shadow: 0 0 0 0 rgba(13, 110, 79, 0); }
}

/* login button: periodic shine + hover lift */
.btn-login {
    position: relative;
    overflow: hidden;
    transition: transform .15s ease, box-shadow .15s ease;
}

.btn-login:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 18px rgba(10, 87, 64, .35);
}

.btn-login:active { transform: translateY(0); }

.btn-login::after {
    content: "";
    position: absolute;
    top: -50%;
    bottom: -50%;
    left: -70%;
    width: 45%;
    background: linear-gradient(100deg, transparent, rgba(255, 255, 255, .5), transparent);
    transform: skewX(-20deg);
    animation: btn-shine 4s ease-in-out 1.2s infinite;
    pointer-events: none;
}

@keyframes btn-shine {
    0%, 60%  { left: -70%; }
    85%, 100% { left: 130%; }
}

.btn-login .btn-spin { display: none; }

.btn-login.is-loading {
    pointer-events: none;
    opacity: .85;
}

.btn-login.is-loading .btn-face { visibility: hidden; }

.btn-login.is-loading .btn-spin {
    display: inline-block;
    position: absolute;
    inset: 0;
    margin: auto;
}

/* live email state */
.email-state { display: none; }

.input-group.is-ok .email-state,
.input-group.is-bad .email-state { display: flex; }

.input-group.is-ok .email-state { color: #198754; }

.input-group.is-bad .email-state { color: #dc3545; }

.input-group.is-ok .form-control { border-color: #198754; }

.input-group.is-bad .form-control { border-color: #dc3545; }

/* password toggle */
.pw-toggle {
    border: 0;
    background: transparent;
    color: #6c757d;
    cursor: pointer;
}

.pw-toggle:hover {
    color: var(--brand);
    background: rgba(13, 110, 79, .08);
}

/* focus glow */
.guest-body .form-control:focus {
    border-color: #2f9e77;
    box-shadow: 0 0 0 .25rem rgba(13, 110, 79, .22), 0 0 16px rgba(47, 158, 119, .35);
}

.guest-body .input-group:focus-within .input-group-text {
    border-color: #2f9e77;
    color: var(--brand);
}

.locale-link {
    text-decoration: none;
    padding: 2px 6px;
    border-radius: 6px;
}

.locale-link:hover {
    background: rgba(13, 110, 79, .1);
}

@media (prefers-reduced-motion: reduce) {
    .guest-body, .guest-blob, .auth-card, .brand-icon,
    .auth-card .text-center, .auth-card form > div, .auth-card form > button,
    .auth-card .card-footer, .welcome-rotate span, .btn-login::after {
        animation: none !important;
    }

    .welcome-rotate span { display: none; }

    .welcome-rotate span:first-child {
        display: block;
        opacity: 1;
    }

    .btn-login:hover { transform: none; }
}

/* ---------- App shell ---------- */
.app-body {
    background: #f4f6f8;
    min-height: 100vh;
}

.app-wrapper {
    display: flex;
    min-height: 100vh;
}

.app-sidebar {
    width: var(--sidebar-width);
    background: linear-gradient(180deg, var(--brand) 0%, var(--brand-dark) 100%);
    color: #fff;
    display: flex;
    flex-direction: column;
    flex-shrink: 0;
}

.sidebar-brand {
    display: flex;
    align-items: center;
    gap: .6rem;
    padding: 1.2rem 1.25rem;
    font-weight: 700;
    font-size: 1.05rem;
    border-bottom: 1px solid rgba(255, 255, 255, .15);
}

.sidebar-brand i {
    font-size: 1.4rem;
}

.sidebar-nav {
    padding: .75rem .5rem;
    flex: 1;
}

.sidebar-nav .nav-link {
    color: rgba(255, 255, 255, .85);
    border-radius: .6rem;
    padding: .6rem .8rem;
    margin-bottom: .25rem;
    display: flex;
    align-items: center;
    gap: .6rem;
    font-size: .95rem;
}

.sidebar-nav .nav-link:hover,
.sidebar-nav .nav-link.active {
    background: rgba(255, 255, 255, .15);
    color: #fff;
}

.sidebar-nav .soon-badge {
    font-size: .6rem;
    opacity: .7;
}

.sidebar-footer {
    padding: 1rem;
    border-top: 1px solid rgba(255, 255, 255, .15);
}

.app-content {
    flex: 1;
    display: flex;
    flex-direction: column;
    min-width: 0;
}

.app-header {
    background: #fff;
    border-bottom: 1px solid #e6eaee;
    padding: .75rem 1rem;
    min-height: 56px;
}

/* Header: user identity shrinks with ellipsis; actions (bell + locale) never wrap */
.app-header .header-user {
    display: flex;
    align-items: center;
    gap: .5rem;
    min-width: 0;
    flex: 1 1 auto;
}

.app-header .user-name {
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.app-header .locale-switcher {
    margin-bottom: 0;
    text-align: start;
    white-space: nowrap;
    flex-shrink: 0;
}

@media (max-width: 575.98px) {
    .app-header {
        padding-top: .5rem;
        padding-bottom: .5rem;
    }

    .app-header .user-name {
        font-size: .9rem;
    }

    .app-header .locale-switcher {
        font-size: .75rem;
    }

    /* "Language:" label is redundant on small screens — keep only the links */
    .app-header .locale-switcher .locale-label {
        display: none;
    }

    .app-header .locale-link {
        padding: 2px 3px;
    }
}

.app-main {
    flex: 1;
}

/* ---------- Dashboard ---------- */
.stat-card {
    border-radius: .85rem;
}

.stat-icon {
    width: 40px;
    height: 40px;
    border-radius: .6rem;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.1rem;
}

.module-btn {
    border-radius: .8rem !important;
    text-decoration: none;
    color: inherit;
    transition: transform .12s ease, box-shadow .12s ease;
}

.module-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 .35rem 1rem rgba(0, 0, 0, .08);
}

@media (max-width: 991.98px) {
    .app-sidebar {
        width: 100%;
    }
}

/* ---------- Recitation workspace (M4) ---------- */
.mushaf {
    line-height: 2.4;
    font-size: 1.35rem;
    text-align: justify;
}

.mushaf-ayah {
    display: inline;
    cursor: pointer;
    padding: .1em .25em;
    border-radius: .35rem;
    transition: background-color .15s ease, box-shadow .15s ease;
}

.mushaf-ayah .ayah-num {
    font-size: .8rem;
    color: var(--bs-secondary-color, #6c757d);
    margin: 0 .1em;
}

.mushaf-ayah:hover {
    box-shadow: 0 0 0 2px rgba(13, 110, 253, .35);
}

.mushaf-ayah.selected {
    box-shadow: 0 0 0 2px #0d6efd;
}

.mushaf-ayah.mark-fatal { background: #f8d7da; }
.mushaf-ayah.mark-major { background: #fff3cd; }
.mushaf-ayah.mark-minor { background: #cff4fc; }

.mushaf-ayah.rule-madd { box-shadow: inset 0 -3px 0 #6f42c1; }
.mushaf-ayah.rule-noon { box-shadow: inset 0 -3px 0 #198754; }
.mushaf-ayah.rule-qalqalah { box-shadow: inset 0 -3px 0 #dc3545; }
.mushaf-ayah.rule-makhraj { box-shadow: inset 0 -3px 0 #0d6efd; }
.mushaf-ayah.rule-sifat { box-shadow: inset 0 -3px 0 #fd7e14; }
.mushaf-ayah.rule-waqf { box-shadow: inset 0 -3px 0 #20c997; }

.badge.mark-fatal { background: #f8d7da; color: #842029; }
.badge.mark-major { background: #fff3cd; color: #664d03; }
.badge.mark-minor { background: #cff4fc; color: #055160; }
.badge.rule-madd { background: #6f42c1; color: #fff; }
.badge.rule-noon { background: #198754; color: #fff; }
.badge.rule-qalqalah { background: #dc3545; color: #fff; }
.badge.rule-makhraj { background: #0d6efd; color: #fff; }
.badge.rule-sifat { background: #fd7e14; color: #fff; }
.badge.rule-waqf { background: #20c997; color: #000; }

/* Skip link: hidden via clipping (no directional offset) so it can never
   extend the scrollable area — right:-9999px overflows horizontally in LTR. */
.skip-link {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
    z-index: 2000;
}

.skip-link:focus {
    position: fixed;
    width: auto;
    height: auto;
    padding: .5rem .75rem;
    margin: 0;
    overflow: visible;
    clip: auto;
    white-space: normal;
    right: 8px;
    top: 8px;
    background: #fff;
    color: #0d6efd;
    border-radius: .375rem;
    box-shadow: 0 .25rem .5rem rgba(0, 0, 0, .2);
}
