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

:root {
    --bg: #f7f3ea;
    --surface: #ffffff;
    --surface-2: #efe9dc;
    --text: #1c1a16;
    --text-2: #6b6457;
    --border: #e3dccb;
    --gold: #b8995e;
    --gold-soft: #e7dcc4;
    --user-bg: #1c1a16;
    --user-text: #f7f3ea;
    --bot-bg: #ffffff;
    --shadow: 0 20px 50px rgba(28, 26, 22, 0.12);
}

[data-theme="dark"] {
    --bg: #0b0b0b;
    --surface: #151515;
    --surface-2: #1d1d1d;
    --text: #f3eee3;
    --text-2: #a39c8e;
    --border: #2a2a2a;
    --gold: #d9c7a1;
    --gold-soft: #3a3125;
    --user-bg: #d9c7a1;
    --user-text: #141414;
    --bot-bg: #1a1a1a;
    --shadow: 0 20px 50px rgba(0, 0, 0, 0.55);
}

html, body {
    height: 100%;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Noto Sans Arabic", Arial, sans-serif;
    background: var(--bg);
    color: var(--text);
    transition: background 0.4s ease, color 0.4s ease;
}

a { color: var(--gold); text-decoration: none; }

h1, h2 { font-weight: 700; }

.logo {
    font-size: 30px;
    font-weight: 700;
    letter-spacing: 0.2em;
    text-transform: uppercase;
    color: var(--gold);
}

.muted { color: var(--text-2); font-size: 14px; line-height: 1.6; }
.center { text-align: center; margin-top: 18px; font-size: 14px; }

/* Shared buttons and inputs */
input {
    width: 100%;
    padding: 14px 16px;
    border: 1px solid var(--border);
    border-radius: 12px;
    background: var(--surface-2);
    color: var(--text);
    font-size: 15px;
    outline: none;
    transition: border-color 0.25s ease, box-shadow 0.25s ease;
}

input::placeholder { color: var(--text-2); }

input:focus {
    border-color: var(--gold);
    box-shadow: 0 0 0 4px rgba(217, 199, 161, 0.2);
}

.btn-primary {
    padding: 14px 22px;
    border: none;
    border-radius: 12px;
    background: var(--gold);
    color: #1c1a16;
    font-size: 15px;
    font-weight: 700;
    cursor: pointer;
    transition: transform 0.2s ease, box-shadow 0.2s ease, opacity 0.2s ease;
}

.btn-primary:hover {
    transform: translateY(-2px);
    box-shadow: 0 10px 24px rgba(184, 153, 94, 0.35);
}

.btn-primary:active {
    transform: scale(0.98);
}

.full { width: 100%; }

.flash {
    padding: 12px 14px;
    border: 1px solid var(--gold-soft);
    border-radius: 12px;
    background: var(--surface-2);
    color: var(--text);
    font-size: 14px;
    line-height: 1.5;
    animation: rise 0.4s ease both;
}

/* Login and verify pages */
.auth-page {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 24px;
    background: radial-gradient(circle at top, var(--surface-2), var(--bg) 65%);
}

.auth-card {
    width: 100%;
    max-width: 400px;
    padding: 40px 32px;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 20px;
    box-shadow: var(--shadow);
    text-align: center;
    animation: rise 0.6s ease both;
}

.auth-card h2 {
    margin: 22px 0 8px;
    font-size: 20px;
}

.auth-card form {
    display: flex;
    flex-direction: column;
    gap: 14px;
    margin-top: 24px;
    text-align: left;
}

.auth-card label {
    font-size: 13px;
    color: var(--text-2);
}

.auth-card .btn-primary { margin-top: 6px; }

.lang-switch {
    margin-top: 28px;
    padding-top: 22px;
    border-top: 1px solid var(--border);
}

/* Settings (language and theme buttons) */
.settings-form {
    display: flex;
    flex-direction: column;
    gap: 18px;
    text-align: left;
}

.setting-label {
    display: block;
    margin-bottom: 8px;
    font-size: 11px;
    font-weight: 600;
    letter-spacing: 0.12em;
    text-transform: uppercase;
    color: var(--text-2);
}

.btn-row {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}

.opt {
    flex: 1 1 40%;
    padding: 10px;
    border: 1px solid var(--border);
    border-radius: 10px;
    background: var(--surface);
    color: var(--text);
    font-size: 13px;
    cursor: pointer;
    transition: all 0.2s ease;
}

.opt:hover {
    border-color: var(--gold);
    transform: translateY(-1px);
}

.opt.active {
    background: var(--gold);
    border-color: var(--gold);
    color: #1c1a16;
    font-weight: 700;
}

/* Chat layout */
.app {
    display: flex;
    height: 100vh;
}

.sidebar {
    width: 280px;
    padding: 28px 22px;
    background: var(--surface);
    border-inline-end: 1px solid var(--border);
    display: flex;
    flex-direction: column;
    gap: 26px;
    overflow-y: auto;
}

.sidebar .logo {
    font-size: 20px;
    letter-spacing: 0.18em;
}

.logout {
    margin-top: auto;
    padding: 10px;
    border-radius: 10px;
    text-align: center;
    font-size: 14px;
    color: var(--text-2);
    transition: color 0.2s ease, background 0.2s ease;
}

.logout:hover {
    color: var(--gold);
    background: var(--surface-2);
}

.main {
    flex: 1;
    min-width: 0;
    display: flex;
    flex-direction: column;
    background: var(--bg);
}

.chat-header {
    padding: 22px 28px;
    border-bottom: 1px solid var(--border);
    background: var(--surface);
}

.chat-header h1 {
    font-size: 22px;
    letter-spacing: 0.04em;
}

.chat-header .muted { margin-top: 4px; }

.messages {
    flex: 1;
    overflow-y: auto;
    padding: 28px;
    display: flex;
    flex-direction: column;
    gap: 14px;
}

.welcome {
    margin: auto;
    text-align: center;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 12px;
    animation: rise 0.6s ease both;
}

.welcome-icon {
    font-size: 56px;
    animation: float 3s ease-in-out infinite;
}

.welcome .logo { font-size: 24px; }

.message { display: flex; animation: rise 0.35s ease both; }
.message.user { justify-content: flex-end; }
.message.bot { justify-content: flex-start; }

.bubble {
    max-width: 70%;
    padding: 13px 17px;
    border-radius: 18px;
    font-size: 15px;
    line-height: 1.6;
    white-space: pre-wrap;
    word-wrap: break-word;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.08);
}

.message.user .bubble {
    background: var(--user-bg);
    color: var(--user-text);
    border-end-end-radius: 4px;
}

.message.bot .bubble {
    background: var(--bot-bg);
    color: var(--text);
    border: 1px solid var(--border);
    border-end-start-radius: 4px;
}

.input-bar {
    display: flex;
    gap: 12px;
    padding: 18px 28px;
    border-top: 1px solid var(--border);
    background: var(--surface);
}

.input-bar input {
    flex: 1;
    padding: 14px 20px;
    border-radius: 999px;
}

.input-bar .btn-primary {
    min-width: 100px;
    border-radius: 999px;
}

.disclaimer {
    padding: 0 0 14px;
    text-align: center;
    font-size: 12px;
    color: var(--text-2);
    background: var(--surface);
}

/* Animations */
@keyframes rise {
    from { opacity: 0; transform: translateY(14px); }
    to { opacity: 1; transform: translateY(0); }
}

@keyframes float {
    0%, 100% { transform: translateY(0); }
    50% { transform: translateY(-10px); }
}

/* Phones */
@media (max-width: 768px) {
    .app {
        flex-direction: column;
        height: auto;
        min-height: 100vh;
    }

    .sidebar {
        width: 100%;
        border-inline-end: none;
        border-bottom: 1px solid var(--border);
    }

    .logout { margin-top: 0; }
    .messages { padding: 18px; }
    .chat-header { padding: 18px; }
    .input-bar { padding: 14px 16px; }
    .bubble { max-width: 85%; }
    .auth-card { padding: 30px 22px; }
}

/* Respect users who turn off motion in their device settings */
@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after {
        animation: none !important;
        transition: none !important;
    }
}
