@import url('https://fonts.googleapis.com/css2?family=Tajawal:wght@400;500;700;800&display=swap');

:root {
    --ink: #1f2430;
    --paper: #fdfaf3;
    --sand: #f2e9d8;
    --gold: #c8963e;
    --gold-dark: #a5762a;
    --teal: #2d6a6e;
    --teal-dark: #1f4d50;
    --muted: #7d7568;
    --card-shadow: 0 6px 20px rgba(31, 36, 48, 0.08);
    --radius: 16px;
}

* {
    box-sizing: border-box;
}

html, body {
    margin: 0;
    min-height: 100%;
    font-family: 'Tajawal', 'Segoe UI', sans-serif;
    background: var(--paper);
    color: var(--ink);
}

.app-shell {
    display: flex;
    flex-direction: column;
    min-height: 100vh;
}

/* ===== Header ===== */
.app-header {
    background: linear-gradient(135deg, var(--teal) 0%, var(--teal-dark) 100%);
    color: #fff;
    padding: 2.2rem 1.5rem 2.6rem;
    position: relative;
    overflow: hidden;
}

.app-header::after {
    content: "";
    position: absolute;
    inset: 0;
    background-image: radial-gradient(circle at 15% 30%, rgba(255,255,255,0.08) 0, transparent 40%),
                       radial-gradient(circle at 85% 70%, rgba(255,255,255,0.06) 0, transparent 45%);
}

.header-inner {
    max-width: 720px;
    margin: 0 auto;
    display: flex;
    align-items: center;
    gap: 1rem;
    position: relative;
    z-index: 1;
}

.logo-mark {
    flex-shrink: 0;
    width: 58px;
    height: 58px;
    border-radius: 50%;
    background: var(--gold);
    color: var(--teal-dark);
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 800;
    font-size: 1.1rem;
    box-shadow: 0 4px 14px rgba(0,0,0,0.25);
}

.header-text h1 {
    margin: 0;
    font-size: 1.6rem;
    font-weight: 800;
}

.header-text p {
    margin: 0.2rem 0 0;
    font-size: 0.95rem;
    color: rgba(255,255,255,0.85);
}

/* ===== Main ===== */
.app-main {
    flex: 1;
    max-width: 720px;
    width: 100%;
    margin: -1.4rem auto 0;
    padding: 0 1.25rem 3rem;
    position: relative;
    z-index: 2;
}

/* ===== Search box ===== */
.search-box {
    display: flex;
    align-items: center;
    gap: 0.6rem;
    background: #fff;
    border-radius: 999px;
    padding: 0.85rem 1.3rem;
    box-shadow: var(--card-shadow);
    border: 1px solid var(--sand);
}

.search-icon {
    font-size: 1.1rem;
    opacity: 0.6;
}

.search-input {
    flex: 1;
    border: none;
    outline: none;
    font-family: inherit;
    font-size: 1.05rem;
    background: transparent;
    color: var(--ink);
}

.search-input::placeholder {
    color: var(--muted);
}

/* ===== State messages ===== */
.state-message {
    margin-top: 2.5rem;
    text-align: center;
    color: var(--muted);
    font-size: 1rem;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.6rem;
}

.state-message.hint {
    color: var(--muted);
    opacity: 0.85;
}

.state-message.empty {
    color: var(--gold-dark);
    font-weight: 500;
}

.spinner {
    width: 16px;
    height: 16px;
    border: 2px solid var(--sand);
    border-top-color: var(--teal);
    border-radius: 50%;
    animation: spin 0.7s linear infinite;
}

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

/* ===== Results ===== */
.results-grid {
    margin-top: 1.6rem;
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.word-card {
    background: #fff;
    border-radius: var(--radius);
    box-shadow: var(--card-shadow);
    border: 1px solid var(--sand);
    overflow: hidden;
    animation: rise 0.25s ease-out;
}

@keyframes rise {
    from { opacity: 0; transform: translateY(6px); }
    to { opacity: 1; transform: translateY(0); }
}

.word-card-header {
    display: flex;
    align-items: baseline;
    justify-content: space-between;
    gap: 0.75rem;
    padding: 1rem 1.25rem;
    background: var(--sand);
}

.colloquial-text {
    font-size: 1.35rem;
    font-weight: 800;
    color: var(--teal-dark);
}

.dialect-badge {
    font-size: 0.78rem;
    padding: 0.2rem 0.7rem;
    border-radius: 999px;
    background: var(--gold);
    color: #fff;
    font-weight: 700;
    white-space: nowrap;
}

.formal-matches {
    display: flex;
    flex-direction: column;
}

.formal-match {
    padding: 1rem 1.25rem;
    border-top: 1px dashed var(--sand);
}

.formal-match:first-child {
    border-top: none;
}

.formal-text {
    font-size: 1.15rem;
    font-weight: 700;
    color: var(--ink);
    display: flex;
    align-items: center;
    gap: 0.6rem;
    flex-wrap: wrap;
}

.root-tag {
    font-size: 0.75rem;
    font-weight: 500;
    color: var(--muted);
    background: var(--paper);
    border: 1px solid var(--sand);
    border-radius: 6px;
    padding: 0.1rem 0.5rem;
}

.meaning {
    margin: 0.4rem 0 0;
    color: var(--muted);
    font-size: 0.95rem;
    line-height: 1.6;
}

.examples {
    margin: 0.6rem 0 0;
    padding-inline-start: 1.2rem;
    color: var(--teal-dark);
    font-size: 0.92rem;
    line-height: 1.7;
}

.not-found {
    text-align: center;
    margin-top: 3rem;
    color: var(--muted);
}

/* ===== Footer ===== */
.app-footer {
    text-align: center;
    padding: 1.2rem;
    font-size: 0.82rem;
    color: var(--muted);
    border-top: 1px solid var(--sand);
}

/* ===== Nav ===== */
.header-nav {
    max-width: 720px;
    margin: 1rem auto 0;
    display: flex;
    gap: 1.2rem;
    position: relative;
    z-index: 1;
    font-size: 0.9rem;
}

.header-nav a {
    color: rgba(255,255,255,0.85);
    text-decoration: none;
    padding-bottom: 0.2rem;
    border-bottom: 2px solid transparent;
    transition: border-color 0.15s ease;
}

.header-nav a:hover {
    border-color: var(--gold);
    color: #fff;
}

/* ===== Auth / Admin forms ===== */
.auth-page {
    display: flex;
    justify-content: center;
    margin-top: 2.5rem;
}

.auth-card {
    background: #fff;
    border-radius: var(--radius);
    box-shadow: var(--card-shadow);
    border: 1px solid var(--sand);
    padding: 2rem;
    width: 100%;
    max-width: 380px;
    text-align: center;
}

.auth-card h2 {
    margin-top: 0;
    color: var(--teal-dark);
}

.admin-page {
    margin-top: 1.6rem;
    background: #fff;
    border-radius: var(--radius);
    box-shadow: var(--card-shadow);
    border: 1px solid var(--sand);
    padding: 1.75rem;
}

.admin-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1.2rem;
    flex-wrap: wrap;
    gap: 0.5rem;
}

.admin-header h2 {
    margin: 0;
    color: var(--teal-dark);
}

.admin-user {
    font-size: 0.85rem;
    color: var(--muted);
}

.form-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 1rem;
    text-align: right;
}

.field {
    display: flex;
    flex-direction: column;
    gap: 0.35rem;
}

.field.full-width {
    grid-column: 1 / -1;
}

.field label {
    font-size: 0.85rem;
    color: var(--muted);
    font-weight: 500;
}

.text-field {
    padding: 0.6rem 0.8rem;
    border-radius: 10px;
    border: 1px solid var(--sand);
    font-family: inherit;
    font-size: 0.95rem;
    outline: none;
    background: var(--paper);
    color: var(--ink);
}

.text-field:focus {
    border-color: var(--teal);
}

.primary-btn {
    margin-top: 1.4rem;
    background: var(--teal);
    color: #fff;
    border: none;
    border-radius: 999px;
    padding: 0.7rem 1.8rem;
    font-family: inherit;
    font-size: 0.95rem;
    font-weight: 700;
    cursor: pointer;
    transition: background 0.15s ease;
}

.primary-btn:hover:not(:disabled) {
    background: var(--teal-dark);
}

.primary-btn:disabled {
    opacity: 0.6;
    cursor: not-allowed;
}

.link-btn {
    display: inline-block;
    text-decoration: none;
    margin-top: 1rem;
}

.error-text {
    color: #b3423e;
    font-size: 0.88rem;
    margin: 0.8rem 0 0;
}

.success-text {
    color: var(--teal-dark);
    font-size: 0.88rem;
    margin: 0.8rem 0 0;
    font-weight: 600;
}

@media (max-width: 520px) {
    .form-grid {
        grid-template-columns: 1fr;
    }
}
