/* -------------------------------------------------------
   Farsi Lernen — Modern Blue/Purple Redesign
   Mobile-first, max-width 480px centred on desktop
   ------------------------------------------------------- */

/* ---- Reset & Base ---- */
*, *::before, *::after {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

:root {
    --indigo:        #4f46e5;
    --indigo-dark:   #3730a3;
    --violet:        #7c3aed;
    --purple:        #8b5cf6;
    --purple-light:  #a78bfa;
    --blue:          #3b82f6;
    --blue-light:    #bfdbfe;

    --grad-primary:  linear-gradient(135deg, #4f46e5 0%, #7c3aed 100%);
    --grad-accent:   linear-gradient(135deg, #6366f1 0%, #a78bfa 100%);
    --grad-soft:     linear-gradient(135deg, #ede9fe 0%, #e0e7ff 100%);
    --grad-bg:       linear-gradient(150deg, #e0e7ff 0%, #ede9fe 45%, #fae8ff 100%);

    --bg:            #eeeaf8;
    --surface:       rgba(255, 255, 255, 0.82);
    --surface-solid: #ffffff;
    --border:        rgba(139, 92, 246, 0.18);
    --border-solid:  #d4d0f0;

    --text:          #1e1b4b;
    --text-muted:    #6b7280;

    --success:       #059669;
    --success-bg:    #d1fae5;
    --error:         #dc2626;
    --error-bg:      #fee2e2;

    --radius:        14px;
    --radius-sm:     8px;
    --shadow:        0 4px 24px rgba(99, 102, 241, 0.13);
    --shadow-lg:     0 8px 40px rgba(99, 102, 241, 0.20);
    --glass-blur:    blur(14px);
}

html { font-size: 16px; }

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    background: var(--grad-bg);
    background-attachment: fixed;
    color: var(--text);
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

a { color: var(--indigo); text-decoration: none; }
a:hover { text-decoration: underline; }

/* ---- Layout Shell ---- */
.site-header {
    background: var(--grad-primary);
    position: sticky;
    top: 0;
    z-index: 100;
    box-shadow: 0 2px 20px rgba(79, 70, 229, 0.35);
}

.site-header__inner {
    max-width: 480px;
    margin: 0 auto;
    padding: 0 16px;
    height: 58px;
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.site-header__logo {
    font-size: 24px;
    color: #fff;
    font-weight: 800;
    letter-spacing: .03em;
    text-decoration: none;
    text-shadow: 0 1px 6px rgba(0,0,0,.25);
}

.site-header__nav {
    display: flex;
    align-items: center;
    gap: 14px;
    font-size: 14px;
}

.site-header__nav a {
    color: rgba(255,255,255,.75);
    text-decoration: none;
    transition: color .15s;
}
.site-header__nav a:hover { color: #fff; }

.nav-user {
    color: #c4b5fd;
    font-weight: 700;
}

.nav-logout {
    color: rgba(255,255,255,.5) !important;
    font-size: 13px;
}

.page-content {
    flex: 1;
    max-width: 480px;
    width: 100%;
    margin: 0 auto;
    padding: 28px 16px 48px;
}

.site-footer {
    text-align: center;
    padding: 16px;
    font-size: 13px;
    color: var(--text-muted);
    border-top: 1px solid var(--border);
}

/* ---- Glass Cards ---- */
.card {
    background: var(--surface);
    backdrop-filter: var(--glass-blur);
    -webkit-backdrop-filter: var(--glass-blur);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    padding: 24px;
    margin-bottom: 20px;
}

.card__title {
    font-size: 17px;
    font-weight: 700;
    color: var(--indigo);
    margin-bottom: 16px;
}

/* ---- Auth Pages ---- */
.auth-wrap {
    max-width: 400px;
    margin: 48px auto 0;
    padding: 0 16px;
}

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

.auth-logo__farsi {
    font-size: 52px;
    display: block;
    line-height: 1;
    background: var(--grad-primary);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    filter: drop-shadow(0 2px 8px rgba(124,58,237,.3));
}

.auth-logo__name {
    font-size: 20px;
    font-weight: 800;
    color: var(--indigo);
    margin-top: 6px;
    letter-spacing: -.01em;
}

/* ---- Forms ---- */
.form-group {
    margin-bottom: 16px;
}

label {
    display: block;
    font-size: 12px;
    font-weight: 700;
    color: var(--purple);
    margin-bottom: 5px;
    text-transform: uppercase;
    letter-spacing: .06em;
}

input[type="text"],
input[type="email"],
input[type="password"],
input[type="number"],
textarea,
select {
    width: 100%;
    padding: 11px 14px;
    border: 1.5px solid var(--border-solid);
    border-radius: var(--radius-sm);
    font-size: 16px;
    font-family: inherit;
    color: var(--text);
    background: rgba(255,255,255,.9);
    transition: border-color .15s, box-shadow .15s;
    -webkit-appearance: none;
}

input:focus,
textarea:focus,
select:focus {
    outline: none;
    border-color: var(--purple);
    box-shadow: 0 0 0 3px rgba(139,92,246,.18);
}

/* Farsi RTL input — letter-spacing MUST be 0: any positive value
   physically separates Arabic glyphs and breaks their ligature connections */
input.farsi-input {
    direction: rtl;
    font-size: 22px;
    letter-spacing: 0;
    text-align: right;
}

/* ---- Buttons ---- */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 12px 24px;
    border-radius: var(--radius-sm);
    border: none;
    font-size: 16px;
    font-weight: 700;
    cursor: pointer;
    font-family: inherit;
    transition: opacity .15s, transform .08s, box-shadow .15s;
    text-decoration: none;
    line-height: 1;
    letter-spacing: .01em;
}

.btn:active { transform: scale(.97); }
.btn:hover  { opacity: .92; text-decoration: none; }

.btn--primary {
    background: var(--grad-primary);
    color: #fff;
    width: 100%;
    box-shadow: 0 4px 14px rgba(79,70,229,.35);
}
.btn--primary:hover { box-shadow: 0 6px 20px rgba(79,70,229,.45); opacity: 1; }

.btn--gold {
    background: var(--grad-accent);
    color: #fff;
    width: 100%;
    box-shadow: 0 4px 14px rgba(139,92,246,.35);
}
.btn--gold:hover { box-shadow: 0 6px 20px rgba(139,92,246,.45); opacity: 1; }

.btn--outline {
    background: transparent;
    color: var(--indigo);
    border: 2px solid var(--indigo);
}
.btn--outline:hover {
    background: var(--grad-primary);
    color: #fff;
    border-color: transparent;
}

.btn--sm {
    padding: 7px 14px;
    font-size: 13px;
}

.btn--danger {
    background: linear-gradient(135deg, #dc2626, #b91c1c);
    color: #fff;
    box-shadow: 0 2px 8px rgba(220,38,38,.3);
}
.btn--danger:hover { box-shadow: 0 4px 14px rgba(220,38,38,.4); opacity: 1; }

.btn-row {
    display: flex;
    gap: 10px;
    margin-top: 8px;
}

/* ---- Flash Messages ---- */
.flash {
    padding: 13px 16px;
    border-radius: var(--radius-sm);
    margin-bottom: 16px;
    font-size: 15px;
    font-weight: 500;
    backdrop-filter: var(--glass-blur);
}
.flash--success {
    background: var(--success-bg);
    color: var(--success);
    border: 1px solid #6ee7b7;
}
.flash--error {
    background: var(--error-bg);
    color: var(--error);
    border: 1px solid #fca5a5;
}

/* ---- Dashboard Stats Grid ---- */
.stats-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 12px;
    margin-bottom: 20px;
}

.stat-box {
    background: var(--surface);
    backdrop-filter: var(--glass-blur);
    -webkit-backdrop-filter: var(--glass-blur);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    padding: 20px 16px;
    text-align: center;
    position: relative;
    overflow: hidden;
}

.stat-box::before {
    content: '';
    position: absolute;
    top: 0; left: 0; right: 0;
    height: 3px;
    background: var(--grad-accent);
}

.stat-box__value {
    font-size: 32px;
    font-weight: 800;
    background: var(--grad-primary);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    line-height: 1;
}

.stat-box__label {
    font-size: 11px;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: .07em;
    margin-top: 5px;
    font-weight: 600;
}

/* ---- Training Card ---- */
.training-card {
    background: var(--surface);
    backdrop-filter: var(--glass-blur);
    -webkit-backdrop-filter: var(--glass-blur);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: var(--shadow-lg);
    padding: 36px 24px 28px;
    text-align: center;
}

.training-card__direction {
    display: inline-block;
    font-size: 11px;
    font-weight: 800;
    text-transform: uppercase;
    letter-spacing: .12em;
    background: var(--grad-accent);
    color: #fff;
    padding: 4px 14px;
    border-radius: 20px;
    margin-bottom: 24px;
}

.training-card__prompt {
    font-size: 14px;
    color: var(--text-muted);
    margin-bottom: 8px;
    font-weight: 500;
}

.training-card__stimulus {
    font-size: 30px;
    font-weight: 800;
    color: var(--indigo-dark);
    margin-bottom: 28px;
    line-height: 1.2;
}

.training-card__input {
    margin-bottom: 16px;
}

/* Feedback states */
.training-card.is-correct {
    border-top: 4px solid var(--success);
}
.training-card.is-wrong {
    border-top: 4px solid var(--error);
}

.feedback-label {
    font-size: 22px;
    font-weight: 800;
    margin-bottom: 10px;
}
.feedback-label--correct { color: var(--success); }
.feedback-label--wrong   { color: var(--error); }

.feedback-answer {
    font-size: 16px;
    color: var(--text-muted);
    margin-bottom: 24px;
}
.feedback-answer strong {
    color: var(--text);
    font-size: 18px;
}

/* ---- On-screen Farsi Keyboard ---- */
.farsi-keyboard {
    margin-top: 20px;
    background: rgba(237,233,254,.6);
    backdrop-filter: var(--glass-blur);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 14px;
}

.farsi-keyboard__keys {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    justify-content: center;
    margin-bottom: 10px;
}

.key {
    background: rgba(255,255,255,.85);
    border: 1.5px solid var(--border-solid);
    border-radius: var(--radius-sm);
    padding: 0;
    width: 44px;
    height: 44px;
    font-size: 18px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background .1s, border-color .1s, transform .08s;
    color: var(--text);
    font-family: inherit;
}

.key:hover {
    background: var(--grad-primary);
    color: #fff;
    border-color: transparent;
    box-shadow: 0 2px 8px rgba(79,70,229,.3);
}
.key:active { transform: scale(.91); }

.farsi-keyboard__controls {
    display: flex;
    gap: 8px;
    justify-content: center;
}

.key--control {
    width: auto;
    padding: 0 14px;
    font-size: 13px;
    font-weight: 700;
    background: rgba(255,255,255,.6);
    border-color: var(--border-solid);
    color: var(--text-muted);
}
.key--control:hover {
    background: var(--grad-primary);
    color: #fff;
    border-color: transparent;
}

/* ---- Word Proposal Cards ---- */
.proposal-list {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.proposal-card {
    background: var(--surface);
    backdrop-filter: var(--glass-blur);
    -webkit-backdrop-filter: var(--glass-blur);
    border: 1.5px solid var(--border);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    padding: 18px 20px;
    cursor: pointer;
    transition: border-color .15s, box-shadow .15s, transform .1s;
    text-align: left;
}

.proposal-card:hover {
    border-color: var(--purple);
    box-shadow: 0 6px 28px rgba(139,92,246,.22);
    transform: translateY(-2px);
    text-decoration: none;
}

.proposal-card__german {
    font-size: 20px;
    font-weight: 800;
    color: var(--indigo-dark);
}

.proposal-card__finglish {
    font-size: 15px;
    color: var(--text-muted);
    margin-top: 3px;
}

.proposal-card__tier {
    display: inline-block;
    font-size: 11px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: .06em;
    background: var(--grad-soft);
    color: var(--purple);
    padding: 3px 10px;
    border-radius: 20px;
    margin-top: 8px;
    border: 1px solid var(--border);
}

/* ---- Letter Unlock ---- */
.letter-preview {
    text-align: center;
    padding: 32px 0;
}

.letter-preview__char {
    font-size: 90px;
    line-height: 1;
    background: var(--grad-primary);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    filter: drop-shadow(0 4px 12px rgba(124,58,237,.25));
}

.letter-preview__finglish {
    font-size: 26px;
    color: var(--text-muted);
    margin-top: 10px;
    font-weight: 600;
}

/* ---- Admin ---- */
.admin-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 14px;
}

.admin-table th,
.admin-table td {
    text-align: left;
    padding: 10px 12px;
    border-bottom: 1px solid var(--border);
}

.admin-table th {
    font-size: 11px;
    font-weight: 800;
    text-transform: uppercase;
    letter-spacing: .07em;
    color: var(--purple);
    background: rgba(237,233,254,.4);
}

.admin-table tr:last-child td { border-bottom: none; }
.admin-table tr:hover td     { background: rgba(237,233,254,.3); }

/* letter-spacing: 0 is critical — any non-zero value breaks Arabic/Farsi
   contextual letter forms and prevents glyphs from joining */
.farsi-text {
    font-size: 1.3em;
    direction: rtl;
    unicode-bidi: embed;
    letter-spacing: 0;
    display: inline-block;
}

/* Larger variant for the training card stimulus */
.farsi-stimulus {
    font-size: 2em;
    direction: rtl;
    unicode-bidi: bidi-override;
    letter-spacing: 0;
    display: block;
    line-height: 1.4;
}

/* ---- Utility ---- */
.text-center { text-align: center; }
.text-muted  { color: var(--text-muted); }
.mt-8  { margin-top: 8px; }
.mt-16 { margin-top: 16px; }
.mt-24 { margin-top: 24px; }
.mb-16 { margin-bottom: 16px; }

.page-title {
    font-size: 24px;
    font-weight: 800;
    background: var(--grad-primary);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    margin-bottom: 22px;
    letter-spacing: -.01em;
}

.hint-text {
    font-size: 14px;
    color: var(--text-muted);
    line-height: 1.6;
    margin-bottom: 16px;
}

.cooldown-notice {
    background: linear-gradient(135deg, rgba(237,233,254,.8), rgba(224,231,255,.8));
    backdrop-filter: var(--glass-blur);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 18px;
    font-size: 15px;
    color: var(--indigo);
    font-weight: 500;
}

.divider {
    border: none;
    border-top: 1px solid var(--border);
    margin: 20px 0;
}

/* ---- Responsive ---- */
@media (max-width: 360px) {
    .stats-grid { grid-template-columns: 1fr; }
    .key { width: 38px; height: 38px; font-size: 16px; }
    .training-card__stimulus { font-size: 24px; }
}
