/* =====================================================
   KAGai - Auth Pages Stylesheet
   الهوية البصرية الرسمية لمكتب الغامدي للمحاماة
   ===================================================== */

:root {
    --kg-primary:        #452916;
    --kg-primary-light:  #74411F;
    --kg-primary-dark:   #2D1810;
    --kg-brown:          #B6885E;
    --kg-accent:         #E9D3B9;
    --kg-accent-light:   #F5EDE4;
    --kg-success:        #7B9E4F;
    --kg-danger:         #A64C4C;
    --kg-warning:        #B6885E;
    --kg-white:          #FFFFFF;
    --kg-text:           #2D1810;
    --kg-text-muted:     #8B7D74;
    --kg-border:         #D9CFC4;

    --kg-shadow-sm: 0 2px 6px rgba(69, 41, 22, 0.08);
    --kg-shadow-md: 0 6px 18px rgba(69, 41, 22, 0.12);
    --kg-shadow-lg: 0 18px 40px rgba(69, 41, 22, 0.18);

    --kg-radius-sm: 8px;
    --kg-radius-md: 12px;
    --kg-radius-lg: 18px;

    --kg-transition: 0.25s cubic-bezier(0.4, 0, 0.2, 1);
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }

body.auth-body {
    font-family: 'Tajawal', 'Cairo', 'Tahoma', sans-serif;
    background: var(--kg-accent-light);
    color: var(--kg-text);
    min-height: 100vh;
    line-height: 1.6;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    overflow-x: hidden;
}

/* ===== Background ===== */
.auth-bg {
    position: fixed;
    inset: 0;
    z-index: 0;
    background:
        radial-gradient(ellipse at top right, rgba(116, 65, 31, 0.12), transparent 60%),
        radial-gradient(ellipse at bottom left,  rgba(182, 136, 94, 0.10), transparent 60%),
        linear-gradient(135deg, var(--kg-accent-light) 0%, #FCFAF6 100%);
}
.auth-bg__pattern {
    position: absolute;
    inset: 0;
    opacity: 0.04;
    background-image:
        repeating-linear-gradient(45deg, var(--kg-primary) 0 1px, transparent 1px 24px),
        repeating-linear-gradient(-45deg, var(--kg-primary) 0 1px, transparent 1px 24px);
}

/* ===== Shell ===== */
.auth-shell {
    position: relative;
    z-index: 1;
    min-height: 100vh;
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 0;
    align-items: stretch;
}

@media (max-width: 980px) {
    .auth-shell { grid-template-columns: 1fr; }
}

/* ===== Card ===== */
.auth-card {
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: stretch;
    padding: clamp(24px, 5vw, 60px);
    background: var(--kg-white);
    box-shadow: var(--kg-shadow-lg);
    max-width: 560px;
    width: 100%;
    margin: 0 auto;
    min-height: 100vh;
}

@media (min-width: 981px) {
    .auth-card {
        margin: 32px auto;
        min-height: auto;
        border-radius: var(--kg-radius-lg);
    }
}

.auth-card__header {
    text-align: center;
    margin-bottom: 32px;
}

.auth-logo {
    display: inline-flex;
    align-items: center;
    gap: 14px;
    text-decoration: none;
    color: var(--kg-primary);
}
.auth-logo__icon {
    width: 56px;
    height: 56px;
    flex-shrink: 0;
    filter: drop-shadow(0 4px 8px rgba(69, 41, 22, 0.18));
}
.auth-logo__text {
    display: flex;
    flex-direction: column;
    text-align: right;
}
.auth-logo__text strong {
    font-size: 1.5rem;
    font-weight: 900;
    color: var(--kg-primary);
    line-height: 1.1;
}
.auth-logo__text small {
    font-size: 0.78rem;
    color: var(--kg-text-muted);
    margin-top: 2px;
}

.auth-card__body { flex: 1; }

.auth-title {
    font-size: clamp(1.5rem, 4vw, 1.85rem);
    font-weight: 700;
    color: var(--kg-primary);
    margin: 0 0 10px;
}
.auth-subtitle {
    font-size: 0.96rem;
    color: var(--kg-text-muted);
    margin: 0 0 28px;
    line-height: 1.65;
}
.phone-masked {
    color: var(--kg-primary);
    font-weight: 700;
    letter-spacing: 1px;
}

.auth-card__footer {
    margin-top: 36px;
    padding-top: 22px;
    border-top: 1px solid var(--kg-border);
    text-align: center;
    color: var(--kg-text-muted);
    font-size: 0.85rem;
}
.auth-card__footer p { margin: 4px 0; }
.auth-card__footer .small { font-size: 0.78rem; opacity: 0.8; }

/* ===== Form Fields ===== */
.auth-form { display: flex; flex-direction: column; gap: 18px; }

.form-field { display: flex; flex-direction: column; gap: 6px; }

.form-label {
    font-weight: 500;
    font-size: 0.95rem;
    color: var(--kg-primary);
}
.form-label .required { color: var(--kg-danger); margin-right: 2px; }
.form-label .muted { color: var(--kg-text-muted); font-weight: 400; font-size: 0.85rem; }

.form-input {
    width: 100%;
    height: 52px;
    padding: 0 16px;
    border: 1.5px solid var(--kg-border);
    border-radius: var(--kg-radius-sm);
    background: var(--kg-white);
    color: var(--kg-text);
    font-family: inherit;
    font-size: 1rem;
    transition: border-color var(--kg-transition), box-shadow var(--kg-transition), background var(--kg-transition);
    outline: none;
}
.form-input::placeholder { color: #C9BDB1; }
.form-input:hover  { border-color: var(--kg-brown); }
.form-input:focus  {
    border-color: var(--kg-primary-light);
    background: #FFFCF9;
    box-shadow: 0 0 0 4px rgba(116, 65, 31, 0.10);
}
.form-input.is-invalid {
    border-color: var(--kg-danger);
    background: #FDF6F6;
}

.form-hint {
    font-size: 0.82rem;
    color: var(--kg-text-muted);
}
.form-error {
    font-size: 0.85rem;
    color: var(--kg-danger);
    min-height: 0;
    display: none;
}
.form-error.is-visible { display: block; }

/* ===== Phone Input ===== */
.phone-input {
    display: flex;
    align-items: stretch;
    border: 1.5px solid var(--kg-border);
    border-radius: var(--kg-radius-sm);
    overflow: hidden;
    background: var(--kg-white);
    transition: border-color var(--kg-transition), box-shadow var(--kg-transition);
}
.phone-input:focus-within {
    border-color: var(--kg-primary-light);
    box-shadow: 0 0 0 4px rgba(116, 65, 31, 0.10);
}
.phone-input__flag {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 0 14px;
    background: var(--kg-accent-light);
    border-left: 1.5px solid var(--kg-border);
    color: var(--kg-primary);
    font-weight: 600;
    direction: ltr;
}
.phone-input__code { font-size: 0.95rem; }
.phone-input__field {
    border: none !important;
    border-radius: 0 !important;
    box-shadow: none !important;
    background: transparent !important;
    flex: 1;
    direction: ltr;
    text-align: left;
    letter-spacing: 1.5px;
}

/* ===== OTP Inputs ===== */
.otp-field { display: flex; flex-direction: column; gap: 10px; }
.otp-inputs {
    display: flex;
    gap: 10px;
    justify-content: center;
    direction: ltr;
}
.otp-digit {
    width: clamp(40px, 12vw, 56px);
    height: clamp(54px, 14vw, 64px);
    text-align: center;
    font-size: 1.6rem;
    font-weight: 700;
    color: var(--kg-primary);
    border: 1.5px solid var(--kg-border);
    border-radius: var(--kg-radius-sm);
    background: var(--kg-white);
    font-family: inherit;
    transition: all var(--kg-transition);
    outline: none;
}
.otp-digit:focus {
    border-color: var(--kg-primary-light);
    background: #FFFCF9;
    box-shadow: 0 0 0 4px rgba(116, 65, 31, 0.12);
    transform: translateY(-1px);
}
.otp-digit.is-filled {
    border-color: var(--kg-success);
    background: #F4F8EE;
}
.otp-digit.is-invalid {
    border-color: var(--kg-danger);
    background: #FDF6F6;
    animation: shake 0.4s;
}
@keyframes shake {
    0%, 100% { transform: translateX(0); }
    25% { transform: translateX(-6px); }
    75% { transform: translateX(6px); }
}

.otp-timer {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 10px 14px;
    background: var(--kg-accent-light);
    border-radius: var(--kg-radius-sm);
    color: var(--kg-primary-light);
    font-size: 0.9rem;
}
.otp-timer strong {
    color: var(--kg-primary);
    font-variant-numeric: tabular-nums;
}
.otp-timer.is-expired { color: var(--kg-danger); background: #FDF6F6; }

/* ===== Buttons ===== */
.btn {
    position: relative;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    padding: 0 24px;
    height: 52px;
    border: none;
    border-radius: var(--kg-radius-sm);
    font-family: inherit;
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    text-decoration: none;
    transition: all var(--kg-transition);
    user-select: none;
}
.btn:disabled, .btn.is-loading { cursor: not-allowed; opacity: 0.75; }
.btn--primary {
    background: linear-gradient(135deg, var(--kg-primary) 0%, var(--kg-primary-light) 100%);
    color: var(--kg-accent);
    box-shadow: 0 6px 18px rgba(69, 41, 22, 0.25);
}
.btn--primary:hover:not(:disabled) {
    transform: translateY(-2px);
    box-shadow: 0 10px 24px rgba(69, 41, 22, 0.32);
}
.btn--primary:active { transform: translateY(0); }
.btn--block { width: 100%; }

.btn__spinner {
    display: none;
    width: 18px;
    height: 18px;
    border: 2px solid rgba(233, 211, 185, 0.4);
    border-top-color: var(--kg-accent);
    border-radius: 50%;
    animation: spin 0.7s linear infinite;
}
.btn.is-loading .btn__spinner { display: inline-block; }
.btn.is-loading .btn__icon,
.btn.is-loading .btn__label { opacity: 0.5; }

@keyframes spin { to { transform: rotate(360deg); } }

.btn-link {
    background: none;
    border: none;
    color: var(--kg-primary-light);
    font-family: inherit;
    font-size: 0.9rem;
    font-weight: 600;
    cursor: pointer;
    padding: 8px 4px;
    text-decoration: none;
    transition: color var(--kg-transition);
}
.btn-link:hover:not(:disabled) { color: var(--kg-primary); text-decoration: underline; }
.btn-link:disabled { color: var(--kg-text-muted); cursor: not-allowed; }
.btn-link .muted { color: var(--kg-text-muted); font-size: 0.85rem; margin-right: 4px; }

/* ===== Divider / Info ===== */
.auth-divider {
    display: flex;
    align-items: center;
    text-align: center;
    color: var(--kg-text-muted);
    font-size: 0.85rem;
    margin: 12px 0;
}
.auth-divider::before, .auth-divider::after {
    content: '';
    flex: 1;
    height: 1px;
    background: var(--kg-border);
}
.auth-divider span { padding: 0 14px; }

.auth-info {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 14px 16px;
    background: #F4F8EE;
    border: 1px solid #D8E5C2;
    border-radius: var(--kg-radius-sm);
    color: #4A6630;
    font-size: 0.88rem;
}

.auth-links {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-top: 6px;
}

.auth-terms { margin: 4px 0; }
.checkbox {
    display: flex;
    align-items: flex-start;
    gap: 10px;
    font-size: 0.88rem;
    color: var(--kg-text-muted);
    cursor: pointer;
}
.checkbox input[type="checkbox"] {
    appearance: none;
    width: 20px;
    height: 20px;
    border: 1.5px solid var(--kg-border);
    border-radius: 5px;
    background: var(--kg-white);
    cursor: pointer;
    margin-top: 2px;
    flex-shrink: 0;
    position: relative;
    transition: all var(--kg-transition);
}
.checkbox input[type="checkbox"]:checked {
    background: var(--kg-primary);
    border-color: var(--kg-primary);
}
.checkbox input[type="checkbox"]:checked::after {
    content: '✓';
    position: absolute;
    inset: 0;
    color: var(--kg-accent);
    font-size: 14px;
    font-weight: 700;
    display: flex;
    align-items: center;
    justify-content: center;
}
.checkbox a {
    color: var(--kg-primary-light);
    font-weight: 600;
    text-decoration: none;
}
.checkbox a:hover { text-decoration: underline; }

/* ===== Alerts ===== */
.alert {
    display: flex;
    align-items: flex-start;
    gap: 10px;
    padding: 12px 16px;
    border-radius: var(--kg-radius-sm);
    margin-bottom: 18px;
    font-size: 0.9rem;
    line-height: 1.55;
    animation: slideDown 0.3s ease-out;
}
.alert--error   { background: #FDF6F6; border: 1px solid #E8B8B8; color: #6E2E2E; }
.alert--success { background: #F4F8EE; border: 1px solid #C5D8A3; color: #3F5825; }
.alert svg { flex-shrink: 0; margin-top: 2px; }
@keyframes slideDown {
    from { opacity: 0; transform: translateY(-10px); }
    to   { opacity: 1; transform: translateY(0); }
}

/* ===== Features Sidebar ===== */
.auth-features {
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 60px 40px;
    background: linear-gradient(135deg, var(--kg-primary) 0%, var(--kg-primary-light) 60%, var(--kg-brown) 100%);
    color: var(--kg-accent);
    position: relative;
    overflow: hidden;
}
.auth-features::before {
    content: '';
    position: absolute;
    inset: 0;
    background:
        radial-gradient(circle at 80% 20%, rgba(233, 211, 185, 0.20), transparent 50%),
        radial-gradient(circle at 20% 80%, rgba(182, 136, 94, 0.30), transparent 50%);
}
.auth-features__inner { position: relative; max-width: 480px; }
.auth-features__title {
    font-size: clamp(1.6rem, 3vw, 2.2rem);
    font-weight: 900;
    margin: 0 0 14px;
    color: var(--kg-accent);
    line-height: 1.3;
}
.auth-features__subtitle {
    font-size: 1rem;
    color: rgba(245, 237, 228, 0.85);
    margin: 0 0 32px;
    line-height: 1.7;
}
.auth-features__list {
    list-style: none;
    padding: 0;
    margin: 0;
    display: flex;
    flex-direction: column;
    gap: 18px;
}
.auth-features__list li {
    display: flex;
    align-items: flex-start;
    gap: 14px;
    padding: 14px 16px;
    background: rgba(255, 255, 255, 0.08);
    border-radius: var(--kg-radius-md);
    backdrop-filter: blur(8px);
    border: 1px solid rgba(233, 211, 185, 0.15);
}
.auth-features__list svg {
    flex-shrink: 0;
    color: var(--kg-accent);
    opacity: 0.9;
    margin-top: 2px;
}
.auth-features__list div { display: flex; flex-direction: column; gap: 2px; }
.auth-features__list strong { color: var(--kg-white); font-size: 1rem; font-weight: 700; }
.auth-features__list span { color: rgba(245, 237, 228, 0.75); font-size: 0.85rem; }

@media (max-width: 980px) {
    .auth-features { display: none; }
}

/* ===== Small screens ===== */
@media (max-width: 480px) {
    .auth-card { padding: 24px 18px; }
    .otp-inputs { gap: 6px; }
    .auth-logo__icon { width: 48px; height: 48px; }
    .auth-logo__text strong { font-size: 1.25rem; }
}
