/* ============================================
   IUS AI — تصميم بأسلوب آبل بألوان الهوية الجامعية
   خمري داكن + كريمي دافئ + أبيض ناصع
   ============================================ */

:root {
    --maroon: #611f21;
    --maroon-dark: #4a1719;
    --maroon-light: #7a2b2d;
    --cream: #f0d3af;
    --cream-light: #faf3e7;
    --bg: #f7f5f2;
    --surface: #ffffff;
    --surface-2: #fbfaf8;
    --text-primary: #241412;
    --text-secondary: #7a6f68;
    --accent: var(--maroon);
    --accent-hover: var(--maroon-light);
    --accent-soft: #f6e9de;
    --border: #e6ded3;
    --success: #2e8b57;
    --danger: #c0392b;
    --radius-lg: 22px;
    --radius-md: 16px;
    --radius-sm: 12px;
    --shadow-sm: 0 2px 10px rgba(97,31,33,0.06);
    --shadow-md: 0 12px 40px rgba(97,31,33,0.12);
    --font: -apple-system, BlinkMacSystemFont, "SF Pro Text", "Segoe UI", "Tajawal", "Cairo", sans-serif;
}

* { box-sizing: border-box; }

html, body {
    margin: 0;
    padding: 0;
    background: var(--bg);
    color: var(--text-primary);
    font-family: var(--font);
    direction: rtl;
    -webkit-font-smoothing: antialiased;
    scroll-behavior: smooth;
}

a { color: inherit; text-decoration: none; }
img { max-width: 100%; display: block; }

/* ============ الشعار ============ */
.logo-img { width: 30px; height: 30px; border-radius: 50%; object-fit: cover; }
.logo-img-lg { width: 30px; height: 30px; border-radius: 50%; object-fit: cover; margin: 0 auto 16px; box-shadow: var(--shadow-md); }

/* ============ الحاويات العامة ============ */
.page-center {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 24px;
    background:
        radial-gradient(circle at 15% 10%, var(--cream-light) 0%, transparent 45%),
        radial-gradient(circle at 90% 90%, var(--accent-soft) 0%, transparent 40%),
        var(--bg);
}

.card {
    background: var(--surface);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-md);
    padding: 44px 40px;
    width: 100%;
    max-width: 430px;
    border: 1px solid var(--border);
}

.card h1 {
    font-size: 25px;
    font-weight: 700;
    margin: 0 0 6px;
    text-align: center;
    letter-spacing: -0.3px;
}

.card p.subtitle {
    color: var(--text-secondary);
    text-align: center;
    font-size: 14px;
    margin: 0 0 30px;
}

/* ============ الحقول ============ */
.field { margin-bottom: 17px; }

.field label {
    display: block;
    font-size: 13px;
    font-weight: 600;
    color: var(--text-secondary);
    margin-bottom: 7px;
}

.field input,
.field select,
.field textarea {
    width: 100%;
    padding: 13px 16px;
    border: 1.5px solid var(--border);
    border-radius: var(--radius-sm);
    background: var(--surface-2);
    font-size: 15px;
    font-family: var(--font);
    color: var(--text-primary);
    transition: border-color .2s, box-shadow .2s, background .2s;
}

.field input:focus,
.field select:focus,
.field textarea:focus {
    outline: none;
    border-color: var(--accent);
    background: var(--surface);
    box-shadow: 0 0 0 4px var(--accent-soft);
}

.field-hint { font-size: 12px; color: var(--text-secondary); margin-top: 6px; }

/* ============ الأزرار ============ */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 13px 24px;
    border-radius: 980px;
    border: none;
    font-size: 15px;
    font-weight: 600;
    font-family: var(--font);
    cursor: pointer;
    transition: transform .15s, background .2s, opacity .2s, box-shadow .2s;
}

.btn:active { transform: scale(0.96); }

.btn-primary {
    background: var(--accent);
    color: #fff;
    width: 100%;
    box-shadow: 0 6px 18px rgba(97,31,33,0.25);
}
.btn-primary:hover { background: var(--accent-hover); }

.btn-secondary {
    background: var(--surface-2);
    color: var(--text-primary);
    border: 1.5px solid var(--border);
}
.btn-secondary:hover { background: var(--accent-soft); border-color: var(--accent); }

.btn-danger { background: var(--danger); color: #fff; }
.btn-danger:hover { opacity: .85; }

.btn-sm { padding: 9px 18px; font-size: 13px; }
.btn-lg { padding: 16px 36px; font-size: 16px; }

.link-muted {
    color: var(--text-secondary);
    text-align: center;
    display: block;
    margin-top: 22px;
    font-size: 14px;
}
.link-muted a { color: var(--accent); font-weight: 700; }

/* ============ التنبيهات ============ */
.alert {
    padding: 13px 16px;
    border-radius: var(--radius-sm);
    font-size: 14px;
    margin-bottom: 16px;
    border: 1px solid transparent;
}
.alert-error { background: #fbeae7; color: var(--danger); border-color: #f3cfc8; }
.alert-success { background: #e9f5ee; color: var(--success); border-color: #cfe9db; }

/* ============ شريط التنقل العلوي ============ */
.topbar {
    background: rgba(255,255,255,0.85);
    backdrop-filter: saturate(180%) blur(20px);
    border-bottom: 1px solid var(--border);
    padding: 14px 30px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    position: sticky;
    top: 0;
    z-index: 20;
}

.topbar .brand {
    font-weight: 800;
    font-size: 18px;
    display: flex;
    align-items: center;
    gap: 10px;
    letter-spacing: -0.3px;
}

.topbar .nav-actions { display: flex; align-items: center; gap: 12px; }

.avatar {
    width: 36px; height: 36px;
    border-radius: 50%;
    background: linear-gradient(135deg, var(--accent), var(--accent-hover));
    color: #fff;
    display: flex; align-items: center; justify-content: center;
    font-weight: 700; font-size: 14px;
}

/* ============ صفحة الهبوط ============ */
.hero {
    padding: 100px 24px 90px;
    text-align: center;
    background:
        radial-gradient(circle at 20% 20%, var(--accent-soft) 0%, transparent 50%),
        radial-gradient(circle at 85% 15%, var(--cream-light) 0%, transparent 45%),
        var(--bg);
}

.hero .badge-pill {
    display: inline-block;
    background: var(--accent-soft);
    color: var(--accent);
    padding: 7px 18px;
    border-radius: 980px;
    font-size: 13px;
    font-weight: 700;
    margin-bottom: 24px;
}

.hero h1 {
    font-size: 48px;
    font-weight: 800;
    letter-spacing: -1px;
    line-height: 1.25;
    margin: 0 0 20px;
    max-width: 760px;
    margin-inline: auto;
}
.hero h1 span { color: var(--accent); }

.hero p.lead {
    font-size: 18px;
    color: var(--text-secondary);
    max-width: 560px;
    margin: 0 auto 36px;
    line-height: 1.7;
}

.hero-actions { display: flex; gap: 14px; justify-content: center; flex-wrap: wrap; }

.section { padding: 80px 24px; max-width: 1080px; margin: 0 auto; }
.section-title { text-align: center; font-size: 32px; font-weight: 800; margin-bottom: 12px; letter-spacing: -0.5px; }
.section-subtitle { text-align: center; color: var(--text-secondary); font-size: 16px; margin-bottom: 50px; }

.features-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
    gap: 22px;
}

.feature-card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: 32px 26px;
    transition: transform .2s, box-shadow .2s;
}
.feature-card:hover { transform: translateY(-4px); box-shadow: var(--shadow-md); }
.feature-card .icon {
    width: 52px; height: 52px;
    border-radius: 16px;
    background: var(--accent-soft);
    display: flex; align-items: center; justify-content: center;
    font-size: 24px;
    margin-bottom: 18px;
}
.feature-card h3 { font-size: 17px; font-weight: 700; margin: 0 0 8px; }
.feature-card p { font-size: 14px; color: var(--text-secondary); line-height: 1.7; margin: 0; }

.cta-band {
    background: linear-gradient(135deg, var(--maroon), var(--maroon-dark));
    border-radius: var(--radius-lg);
    padding: 60px 40px;
    text-align: center;
    color: #fff;
    margin: 0 24px 90px;
}
.cta-band h2 { font-size: 28px; font-weight: 800; margin: 0 0 14px; }
.cta-band p { opacity: .85; margin: 0 0 28px; font-size: 15px; }
.cta-band .btn-primary { background: #fff; color: var(--maroon); width: auto; padding: 14px 34px; box-shadow: none; }
.cta-band .btn-primary:hover { background: var(--cream-light); }

.landing-footer {
    text-align: center;
    padding: 30px 24px;
    color: var(--text-secondary);
    font-size: 13px;
    border-top: 1px solid var(--border);
}

/* ============ واجهة الدردشة ============ */
.chat-layout { display: flex; height: calc(100vh - 63px); }

.sidebar {
    width: 280px;
    background: var(--surface);
    border-left: 1px solid var(--border);
    padding: 20px;
    overflow-y: auto;
    flex-shrink: 0;
    display: flex;
    flex-direction: column;
}

.sidebar .new-chat-btn { width: 100%; margin-bottom: 18px; }

.conv-list { flex: 1; overflow-y: auto; }

.conv-item {
    display: block;
    padding: 12px 14px;
    border-radius: var(--radius-sm);
    font-size: 14px;
    color: var(--text-primary);
    margin-bottom: 6px;
    cursor: pointer;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    transition: background .15s;
}
.conv-item:hover { background: var(--surface-2); }
.conv-item.active { background: var(--accent-soft); color: var(--accent); font-weight: 700; }

.guest-banner {
    background: var(--accent-soft);
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    padding: 16px;
    font-size: 13px;
    text-align: center;
    margin-top: 14px;
}
.guest-banner strong { color: var(--accent); display: block; margin-bottom: 6px; font-size: 14px; }
.guest-banner a { color: var(--accent); font-weight: 700; text-decoration: underline; }

.chat-main { flex: 1; display: flex; flex-direction: column; background: var(--bg); position: relative; }

.chat-messages {
    flex: 1;
    overflow-y: auto;
    padding: 36px;
    display: flex;
    flex-direction: column;
    gap: 18px;
}

.empty-state {
    text-align: center;
    color: var(--text-secondary);
    margin-top: 80px;
}
.empty-state .logo-img-lg { opacity: .9; }
.empty-state h3 { font-size: 20px; color: var(--text-primary); margin: 0 0 8px; }

.msg {
    max-width: 68%;
    padding: 14px 19px;
    border-radius: var(--radius-md);
    font-size: 15px;
    line-height: 1.65;
    white-space: pre-wrap;
}

.msg-user {
    align-self: flex-end;
    background: var(--accent);
    color: #fff;
    border-bottom-left-radius: 4px;
}

.msg-assistant {
    align-self: flex-start;
    background: var(--surface);
    color: var(--text-primary);
    box-shadow: var(--shadow-sm);
    border: 1px solid var(--border);
    border-bottom-right-radius: 4px;
}

.chat-input-bar { padding: 18px 32px 28px; background: var(--bg); }

.chat-input-wrap {
    display: flex;
    align-items: flex-end;
    gap: 10px;
    background: var(--surface);
    border: 1.5px solid var(--border);
    border-radius: var(--radius-lg);
    padding: 10px 10px 10px 18px;
    box-shadow: var(--shadow-sm);
    transition: border-color .2s;
}
.chat-input-wrap:focus-within { border-color: var(--accent); }

.chat-input-wrap textarea {
    flex: 1;
    border: none;
    outline: none;
    resize: none;
    font-family: var(--font);
    font-size: 15px;
    max-height: 140px;
    padding: 8px 0;
    background: transparent;
}

.send-btn {
    background: var(--accent);
    color: #fff;
    border: none;
    width: 42px; height: 42px;
    border-radius: 50%;
    display: flex; align-items: center; justify-content: center;
    cursor: pointer;
    flex-shrink: 0;
    transition: background .2s, transform .15s;
    font-size: 16px;
}
.send-btn:hover { background: var(--accent-hover); }
.send-btn:disabled { opacity: .4; cursor: not-allowed; }

.typing-dots span {
    display: inline-block;
    width: 6px; height: 6px;
    border-radius: 50%;
    background: var(--text-secondary);
    margin: 0 2px;
    animation: blink 1.2s infinite;
}
.typing-dots span:nth-child(2) { animation-delay: .2s; }
.typing-dots span:nth-child(3) { animation-delay: .4s; }
@keyframes blink { 0%, 80%, 100% { opacity: .2; } 40% { opacity: 1; } }

/* ============ نافذة إجبار تسجيل الدخول ============ */
.modal-overlay {
    position: fixed; inset: 0;
    background: rgba(36,20,18,0.55);
    backdrop-filter: blur(4px);
    display: flex; align-items: center; justify-content: center;
    z-index: 100;
    padding: 20px;
}
.modal-box {
    background: var(--surface);
    border-radius: var(--radius-lg);
    padding: 40px 34px;
    max-width: 400px;
    width: 100%;
    text-align: center;
    box-shadow: var(--shadow-md);
}
.modal-box .logo-img-lg { margin-bottom: 20px; }
.modal-box h3 { font-size: 20px; margin: 0 0 10px; }
.modal-box p { color: var(--text-secondary); font-size: 14px; margin: 0 0 26px; line-height: 1.7; }
.modal-box .modal-actions { display: flex; flex-direction: column; gap: 10px; }

/* ============ لوحة تحكم الأدمن ============ */
.admin-layout { display: flex; min-height: calc(100vh - 63px); }

.admin-sidebar {
    width: 240px;
    background: var(--surface);
    border-left: 1px solid var(--border);
    padding: 24px 16px;
    flex-shrink: 0;
}

.admin-sidebar a {
    display: block;
    padding: 11px 16px;
    border-radius: var(--radius-sm);
    font-size: 14px;
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: 4px;
}
.admin-sidebar a:hover { background: var(--surface-2); }
.admin-sidebar a.active { background: var(--accent-soft); color: var(--accent); }

.admin-content { flex: 1; padding: 32px; max-width: 1100px; }

.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 20px;
    margin-bottom: 32px;
}

.stat-card {
    background: var(--surface);
    border-radius: var(--radius-md);
    padding: 24px;
    box-shadow: var(--shadow-sm);
    border: 1px solid var(--border);
}
.stat-card .stat-value { font-size: 32px; font-weight: 800; margin-bottom: 4px; color: var(--accent); }
.stat-card .stat-label { color: var(--text-secondary); font-size: 13px; }

table.data-table {
    width: 100%;
    border-collapse: collapse;
    background: var(--surface);
    border-radius: var(--radius-md);
    overflow: hidden;
    box-shadow: var(--shadow-sm);
    border: 1px solid var(--border);
}
table.data-table th, table.data-table td {
    padding: 14px 18px;
    text-align: right;
    font-size: 14px;
    border-bottom: 1px solid var(--border);
}
table.data-table th { color: var(--text-secondary); font-weight: 700; background: var(--surface-2); }
table.data-table tr:last-child td { border-bottom: none; }

.badge {
    display: inline-block;
    padding: 4px 12px;
    border-radius: 980px;
    font-size: 12px;
    font-weight: 700;
}
.badge-admin { background: var(--accent-soft); color: var(--accent); }
.badge-user { background: #f0f0f2; color: var(--text-secondary); }
.badge-active { background: #e9f5ee; color: var(--success); }
.badge-banned { background: #fbeae7; color: var(--danger); }

.panel {
    background: var(--surface);
    border-radius: var(--radius-md);
    padding: 28px;
    box-shadow: var(--shadow-sm);
    border: 1px solid var(--border);
    margin-bottom: 24px;
}
.panel h2 { font-size: 18px; margin: 0 0 20px; }

.file-drop {
    border: 2px dashed var(--border);
    border-radius: var(--radius-md);
    padding: 30px;
    text-align: center;
    background: var(--surface-2);
    margin-bottom: 16px;
    cursor: pointer;
    transition: border-color .2s, background .2s;
}
.file-drop:hover { border-color: var(--accent); background: var(--accent-soft); }
.file-drop input[type=file] { display: none; }

@media (max-width: 768px) {
    .sidebar { display: none; }
    .admin-sidebar { display: none; }
    .msg { max-width: 88%; }
    .hero h1 { font-size: 32px; }
    .hero p.lead { font-size: 16px; }
}
