@import url('https://fonts.googleapis.com/css2?family=Tajawal:wght@300;400;500;700;800;900&display=swap');

:root {
    --primary: #2563eb;
    --primary-hover: #1d4ed8;
    --primary-light: rgba(37, 99, 235, 0.08);
    --primary-glow: rgba(37, 99, 235, 0.2);
    
    --accent: #8b5cf6;
    --accent-hover: #7c3aed;
    
    --success: #10b981;
    --success-bg: rgba(16, 185, 129, 0.1);
    --danger: #ef4444;
    --danger-bg: rgba(239, 68, 68, 0.1);
    --warning: #f59e0b;
    --warning-bg: rgba(245, 158, 11, 0.1);
    --info: #3b82f6;

    /* Light Theme Setup */
    --bg-dark: #f8fafc;
    --bg-darker: #f1f5f9;
    --card-dark: #ffffff;
    --card-hover: #f8fafc;
    
    --text-main: #0f172a;
    --text-secondary: #334155;
    --text-muted: #64748b;
    
    --border: #e2e8f0;
    --border-hover: #cbd5e1;
    
    --input-bg: #ffffff;
    --input-focus: #f8fafc;
    --glass-bg: rgba(255, 255, 255, 0.85);
    --glass-border: rgba(0, 0, 0, 0.05);
    --glass-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.05), 0 2px 4px -2px rgba(0, 0, 0, 0.025);

    --sidebar-w: 280px;
    --header-h: 64px;
    --radius-sm: 0.375rem;
    --radius-md: 0.5rem;
    --radius-lg: 0.75rem;
    --radius-xl: 1rem;
    --transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
    --transition-fast: all 0.1s ease;
}

/* ===== RESET & BASE ===== */
*, *::before, *::after {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

html {
    direction: rtl;
    scroll-behavior: smooth;
}

body {
    font-family: 'Tajawal', sans-serif;
    background-color: var(--bg-dark);
    color: var(--text-main);
    overflow-x: hidden;
    min-height: 100vh;
    font-size: 15px;
    line-height: 1.6;
}

a {
    text-decoration: none;
    color: inherit;
}

::selection {
    background: var(--primary);
    color: white;
}

::-webkit-scrollbar {
    width: 6px;
}

::-webkit-scrollbar-track {
    background: transparent;
}

::-webkit-scrollbar-thumb {
    background: var(--border);
    border-radius: 3px;
}

::-webkit-scrollbar-thumb:hover {
    background: rgba(255, 255, 255, 0.15);
}

/* ===== ANIMATED BACKGROUND ===== */
.bg-mesh {
    position: fixed;
    inset: 0;
    z-index: -1;
    background-color: var(--bg-dark);
    background-image: 
        radial-gradient(ellipse at top right, rgba(37, 99, 235, 0.06), transparent 50%),
        radial-gradient(ellipse at bottom left, rgba(139, 92, 246, 0.06), transparent 50%);
}

/* ===== LAYOUT ===== */
.app-container {
    display: flex;
    height: 100vh;
    overflow: hidden;
}

/* ===== SIDEBAR ===== */
.sidebar {
    width: var(--sidebar-w);
    min-width: var(--sidebar-w);
    background: var(--card-dark);
    border-left: 1px solid var(--border);
    padding: 1.5rem 1rem;
    display: flex;
    flex-direction: column;
    transition: var(--transition);
    z-index: 100;
    overflow-y: auto;
}

.sidebar-header {
    padding: 0 0.5rem;
    margin-bottom: 1.5rem;
}

.logo {
    font-size: 1.4rem;
    font-weight: 800;
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
    color: var(--text-main);
    letter-spacing: -0.5px;
}

.logo i {
    color: var(--primary);
    font-size: 1.3rem;
}

.compose-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.6rem;
    width: 100%;
    padding: 0.85rem 1.25rem;
    background: linear-gradient(135deg, var(--primary), #7c3aed);
    color: white;
    border: none;
    border-radius: var(--radius-md);
    font-family: 'Tajawal', sans-serif;
    font-size: 0.95rem;
    font-weight: 700;
    cursor: pointer;
    transition: var(--transition);
    margin-bottom: 1.5rem;
    position: relative;
    overflow: hidden;
}

.compose-btn::before {
    content: '';
    position: absolute;
    top: 0;
    left: -100%;
    width: 100%;
    height: 100%;
    background: linear-gradient(90deg, transparent, rgba(255,255,255,0.15), transparent);
    transition: left 0.6s ease;
}

.compose-btn:hover::before {
    left: 100%;
}

.compose-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 8px 25px var(--primary-glow);
}

/* Nav items */
.nav-section {
    margin-bottom: 1.5rem;
}

.nav-label {
    font-size: 0.7rem;
    font-weight: 700;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 1.5px;
    padding: 0 0.75rem;
    margin-bottom: 0.5rem;
}

.nav-item {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.7rem 0.75rem;
    border-radius: var(--radius-md);
    color: var(--text-secondary);
    font-weight: 500;
    font-size: 0.9rem;
    transition: var(--transition);
    cursor: pointer;
    position: relative;
}

.nav-item:hover {
    background: rgba(255, 255, 255, 0.04);
    color: var(--text-main);
}

.nav-item.active {
    background: var(--primary-light);
    color: var(--primary);
    font-weight: 700;
}

.nav-item.active::before {
    content: '';
    position: absolute;
    right: 0;
    top: 50%;
    transform: translateY(-50%);
    width: 3px;
    height: 60%;
    background: var(--primary);
    border-radius: 3px 0 0 3px;
}

.nav-item i {
    width: 20px;
    text-align: center;
    font-size: 0.95rem;
}

.nav-badge {
    margin-right: auto;
    background: var(--primary);
    color: white;
    font-size: 0.7rem;
    font-weight: 700;
    padding: 0.15rem 0.5rem;
    border-radius: 10px;
    min-width: 22px;
    text-align: center;
}

.nav-badge.empty {
    background: var(--text-muted);
    opacity: 0.4;
}

/* Sidebar footer - User info */
.sidebar-footer {
    margin-top: auto;
    border-top: 1px solid var(--border);
    padding-top: 1rem;
}

.user-card {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.75rem;
    border-radius: var(--radius-md);
    transition: var(--transition);
}

.user-card:hover {
    background: rgba(255, 255, 255, 0.03);
}

.user-avatar {
    width: 42px;
    height: 42px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    font-size: 1rem;
    color: white;
    flex-shrink: 0;
    position: relative;
}

.user-avatar::after {
    content: '';
    position: absolute;
    bottom: 1px;
    left: 1px;
    width: 10px;
    height: 10px;
    background: var(--success);
    border-radius: 50%;
    border: 2px solid var(--bg-dark);
}

.user-info {
    overflow: hidden;
    flex: 1;
}

.user-name {
    font-weight: 700;
    font-size: 0.85rem;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.user-email {
    font-size: 0.72rem;
    color: var(--text-muted);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    direction: ltr;
    text-align: right;
}

.logout-btn {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.5rem 0.75rem;
    margin-top: 0.5rem;
    color: var(--danger);
    font-size: 0.8rem;
    font-weight: 600;
    border-radius: var(--radius-sm);
    transition: var(--transition);
}

.logout-btn:hover {
    background: var(--danger-bg);
}

/* ===== MAIN CONTENT ===== */
.main-content {
    flex: 1;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    min-width: 0;
}

/* Header */
.header {
    height: var(--header-h);
    min-height: var(--header-h);
    border-bottom: 1px solid var(--border);
    padding: 0 1.5rem;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    background: var(--bg-dark);
}

.search-box {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    background: var(--input-bg);
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    padding: 0.5rem 1rem;
    flex: 1;
    max-width: 500px;
    transition: var(--transition);
}

.search-box:focus-within {
    border-color: var(--primary);
    background: var(--input-focus);
    box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.1);
}

.search-box i {
    color: var(--text-muted);
    font-size: 0.9rem;
}

.search-box input {
    border: none;
    background: transparent;
    padding: 0.3rem 0;
    color: var(--text-main);
    font-family: 'Tajawal', sans-serif;
    font-size: 0.9rem;
    width: 100%;
    outline: none;
}

.search-box input::placeholder {
    color: var(--text-muted);
}

.header-actions {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.header-icon-btn {
    width: 38px;
    height: 38px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--text-muted);
    cursor: pointer;
    transition: var(--transition);
    background: transparent;
    border: none;
    font-size: 1rem;
    position: relative;
}

.header-icon-btn:hover {
    background: rgba(255, 255, 255, 0.06);
    color: var(--text-main);
}

.header-icon-btn .notif-dot {
    position: absolute;
    top: 8px;
    left: 8px;
    width: 7px;
    height: 7px;
    background: var(--danger);
    border-radius: 50%;
}

/* Mobile menu toggle */
.mobile-menu-btn {
    display: none;
    width: 38px;
    height: 38px;
    border-radius: 50%;
    align-items: center;
    justify-content: center;
    color: var(--text-muted);
    cursor: pointer;
    background: transparent;
    border: none;
    font-size: 1.1rem;
}

/* ===== CONTENT AREA ===== */
.content-area {
    flex: 1;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
}

/* Mail list header */
.mail-list-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 1rem 1.5rem;
    border-bottom: 1px solid var(--border);
    background: var(--card-dark);
}

.mail-list-title {
    font-weight: 700;
    font-size: 1.1rem;
}

.mail-list-count {
    font-size: 0.8rem;
    color: var(--text-muted);
}

.mail-list-actions {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.toolbar-btn {
    width: 34px;
    height: 34px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: var(--radius-sm);
    color: var(--text-muted);
    cursor: pointer;
    transition: var(--transition);
    background: transparent;
    border: none;
    font-size: 0.85rem;
}

.toolbar-btn:hover {
    background: rgba(255, 255, 255, 0.06);
    color: var(--text-main);
}

/* ===== EMAIL LIST ===== */
.email-list {
    flex: 1;
    overflow-y: auto;
}

.email-row {
    display: flex;
    align-items: center;
    padding: 0.85rem 1.5rem;
    border-bottom: 1px solid var(--border);
    cursor: pointer;
    transition: var(--transition-fast);
    gap: 0.75rem;
    position: relative;
}

.email-row:hover {
    background: var(--card-dark);
}

.email-row.unread {
    background: var(--primary-light);
    border-left: 3px solid var(--primary); /* highlight left instead of absolute bar */
}

.email-row.unread::after {
    display: none;
}

.email-row.unread .email-sender,
.email-row.unread .email-subject {
    font-weight: 700;
    color: var(--text-main);
}

.email-checkbox {
    width: 18px;
    height: 18px;
    cursor: pointer;
    accent-color: var(--primary);
    flex-shrink: 0;
}

.email-star {
    color: var(--text-muted);
    cursor: pointer;
    transition: var(--transition-fast);
    font-size: 0.9rem;
    flex-shrink: 0;
}

.email-star:hover,
.email-star.starred {
    color: var(--warning);
}

.email-sender {
    width: 180px;
    min-width: 120px;
    font-weight: 400;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    color: var(--text-secondary);
    font-size: 0.9rem;
}

.email-content {
    flex: 1;
    display: flex;
    align-items: baseline;
    gap: 0.5rem;
    overflow: hidden;
    min-width: 0;
}

.email-subject {
    font-weight: 400;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    color: var(--text-secondary);
    font-size: 0.9rem;
}

.email-preview {
    color: var(--text-muted);
    font-size: 0.82rem;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    flex-shrink: 10;
}

.email-meta {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    flex-shrink: 0;
}

.email-date {
    font-size: 0.78rem;
    color: var(--text-muted);
    white-space: nowrap;
    min-width: 55px;
    text-align: left;
}

.email-attachment {
    color: var(--text-muted);
    font-size: 0.8rem;
}

/* ===== EMAIL VIEW ===== */
.email-view {
    padding: 2rem;
    max-width: 900px;
    margin: 0 auto;
    width: 100%;
}

.email-view-header {
    margin-bottom: 2rem;
}

.email-view-subject {
    font-size: 1.5rem;
    font-weight: 800;
    margin-bottom: 1.5rem;
    line-height: 1.4;
}

.email-view-info {
    display: flex;
    align-items: flex-start;
    gap: 1rem;
    padding-bottom: 1.5rem;
    border-bottom: 1px solid var(--border);
}

.email-view-avatar {
    width: 48px;
    height: 48px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    font-size: 1.1rem;
    color: white;
    flex-shrink: 0;
}

.email-view-sender-info {
    flex: 1;
}

.email-view-sender-name {
    font-weight: 700;
    font-size: 1rem;
}

.email-view-sender-email {
    font-size: 0.82rem;
    color: var(--text-muted);
    direction: ltr;
    text-align: right;
}

.email-view-date {
    font-size: 0.8rem;
    color: var(--text-muted);
    margin-top: 0.25rem;
}

.email-view-actions {
    display: flex;
    gap: 0.5rem;
    flex-shrink: 0;
}

.email-view-body {
    padding: 1.5rem 0;
    line-height: 1.8;
    font-size: 0.95rem;
    color: var(--text-secondary);
    word-wrap: break-word;
    overflow-wrap: break-word;
}

.email-view-body img {
    max-width: 100%;
    border-radius: var(--radius-md);
}

.email-view-attachments {
    border-top: 1px solid var(--border);
    padding-top: 1.5rem;
    margin-top: 1rem;
}

.attachment-label {
    font-size: 0.85rem;
    color: var(--text-muted);
    margin-bottom: 0.75rem;
    font-weight: 600;
}

.attachment-item {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.5rem 1rem;
    background: var(--input-bg);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    font-size: 0.82rem;
    color: var(--text-secondary);
    margin-left: 0.5rem;
    margin-bottom: 0.5rem;
    transition: var(--transition-fast);
}

.attachment-item:hover {
    border-color: var(--primary);
    color: var(--primary);
}

/* ===== COMPOSE ===== */
.compose-area {
    padding: 2rem;
    max-width: 850px;
    margin: 0 auto;
    width: 100%;
}

.compose-card {
    background: var(--card-dark);
    backdrop-filter: blur(12px);
    border: 1px solid var(--glass-border);
    border-radius: var(--radius-xl);
    overflow: hidden;
}

.compose-header {
    padding: 1.25rem 1.5rem;
    border-bottom: 1px solid var(--border);
    font-weight: 700;
    font-size: 1.05rem;
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.compose-body {
    padding: 1.5rem;
}

.compose-field {
    display: flex;
    align-items: center;
    border-bottom: 1px solid var(--border);
    padding: 0.6rem 0;
}

.compose-field-label {
    font-size: 0.85rem;
    color: var(--text-muted);
    font-weight: 600;
    min-width: 60px;
}

.compose-field input {
    border: none;
    background: transparent;
    padding: 0.4rem 0.5rem;
    font-size: 0.9rem;
    outline: none;
}

.compose-field input:focus {
    border: none;
    box-shadow: none;
}

.compose-editor {
    min-height: 300px;
    padding: 1rem 0;
}

.compose-editor textarea {
    width: 100%;
    min-height: 300px;
    border: none;
    background: transparent;
    color: var(--text-main);
    font-family: 'Tajawal', sans-serif;
    font-size: 0.95rem;
    line-height: 1.8;
    resize: vertical;
    outline: none;
}

.compose-footer {
    padding: 1rem 1.5rem;
    border-top: 1px solid var(--border);
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.compose-actions-right {
    display: flex;
    gap: 0.5rem;
}

/* ===== CARDS ===== */
.card {
    background: var(--card-dark);
    border: 1px solid var(--border);
    padding: 1.5rem;
    border-radius: var(--radius-lg);
    box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.05), 0 2px 4px -1px rgba(0, 0, 0, 0.03);
}

/* ===== BUTTONS ===== */
.btn {
    padding: 0.7rem 1.25rem;
    border-radius: var(--radius-md);
    border: none;
    cursor: pointer;
    font-family: 'Tajawal', sans-serif;
    font-weight: 600;
    font-size: 0.9rem;
    transition: var(--transition);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    white-space: nowrap;
}

.btn-primary {
    background: linear-gradient(135deg, var(--primary), #7c3aed);
    color: white;
}

.btn-primary:hover {
    transform: translateY(-1px);
    box-shadow: 0 6px 20px var(--primary-glow);
}

.btn-secondary {
    background: var(--bg-darker);
    color: var(--text-secondary);
    border: 1px solid var(--border);
}

.btn-secondary:hover {
    background: var(--border);
    color: var(--text-main);
    border-color: var(--border-hover);
}

.btn-ghost {
    background: transparent;
    color: var(--text-muted);
    padding: 0.5rem 0.8rem;
}

.btn-ghost:hover {
    background: var(--primary-light);
    color: var(--primary);
}

.btn-danger {
    background: var(--danger-bg);
    color: var(--danger);
    border: 1px solid rgba(239, 68, 68, 0.2);
}

.btn-danger:hover {
    background: rgba(239, 68, 68, 0.2);
}

.btn-sm {
    padding: 0.45rem 0.85rem;
    font-size: 0.82rem;
}

.btn-icon {
    width: 36px;
    height: 36px;
    padding: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: var(--radius-sm);
    background: transparent;
    color: var(--text-muted);
    border: 1px solid var(--border);
    cursor: pointer;
    transition: var(--transition-fast);
    font-size: 0.9rem;
}

.btn-icon:hover {
    background: rgba(255, 255, 255, 0.06);
    color: var(--text-main);
    border-color: var(--border-hover);
}

/* ===== FORMS ===== */
.input-group {
    margin-bottom: 1.25rem;
}

.input-group label {
    display: block;
    margin-bottom: 0.4rem;
    color: var(--text-muted);
    font-size: 0.82rem;
    font-weight: 600;
}

input, select, textarea {
    width: 100%;
    padding: 0.8rem 1rem;
    background: var(--input-bg);
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    color: var(--text-main);
    font-family: 'Tajawal', sans-serif;
    font-size: 0.95rem;
    outline: none;
    transition: var(--transition);
    box-shadow: 0 1px 2px 0 rgba(0, 0, 0, 0.05);
}

input:focus, select:focus, textarea:focus {
    border-color: var(--primary);
    background: var(--input-focus);
    box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.1);
}

input::placeholder, textarea::placeholder {
    color: var(--text-muted);
}

textarea {
    resize: vertical;
    line-height: 1.7;
}

/* ===== ALERTS ===== */
.alert {
    padding: 0.85rem 1.15rem;
    border-radius: var(--radius-md);
    margin-bottom: 1.25rem;
    display: flex;
    align-items: center;
    gap: 0.75rem;
    font-size: 0.9rem;
    font-weight: 500;
    animation: alertIn 0.35s ease;
}

@keyframes alertIn {
    from { opacity: 0; transform: translateY(-8px); }
    to { opacity: 1; transform: translateY(0); }
}

.alert-error {
    background: var(--danger-bg);
    border: 1px solid rgba(239, 68, 68, 0.25);
    color: #fca5a5;
}

.alert-success {
    background: var(--success-bg);
    border: 1px solid rgba(16, 185, 129, 0.25);
    color: #6ee7b7;
}

.alert-info {
    background: rgba(59, 130, 246, 0.1);
    border: 1px solid rgba(59, 130, 246, 0.25);
    color: #93c5fd;
}

/* ===== AUTH PAGES ===== */
.auth-wrapper {
    display: flex;
    min-height: 100vh;
    background: var(--bg-dark);
}

.auth-sidebar {
    display: none;
    flex: 1;
    background: linear-gradient(135deg, var(--card-dark), var(--bg-darker));
    border-left: 1px solid var(--border);
    padding: 3rem;
    flex-direction: column;
    justify-content: center;
    position: relative;
    overflow: hidden;
}

@media (min-width: 900px) {
    .auth-sidebar {
        display: flex;
    }
}

.auth-sidebar-content {
    position: relative;
    z-index: 2;
    max-width: 450px;
}

.auth-sidebar-title {
    font-size: 2.5rem;
    font-weight: 800;
    margin-bottom: 1.5rem;
    color: var(--text-main);
    line-height: 1.3;
}

.auth-sidebar-text {
    font-size: 1.1rem;
    color: var(--text-muted);
    line-height: 1.7;
    margin-bottom: 2rem;
}

.auth-main {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 2rem;
    position: relative;
}

.auth-card {
    width: 100%;
    max-width: 440px;
    background: var(--card-dark);
    border: 1px solid var(--border);
    border-radius: var(--radius-xl);
    padding: 2.5rem;
    box-shadow: var(--glass-shadow);
    animation: fadeIn 0.4s ease;
}

.auth-logo {
    margin-bottom: 2.5rem;
}

.auth-logo .logo {
    justify-content: flex-start;
    font-size: 1.8rem;
    margin-bottom: 0.5rem;
}

.auth-logo p {
    color: var(--text-muted);
    font-size: 1rem;
}

.auth-footer {
    text-align: right;
    margin-top: 2rem;
    color: var(--text-muted);
    font-size: 0.9rem;
}

.auth-footer {
    text-align: center;
    margin-top: 1.75rem;
    color: var(--text-muted);
    font-size: 0.85rem;
}

.auth-footer a {
    color: var(--primary);
    font-weight: 600;
    transition: var(--transition-fast);
}

.auth-footer a:hover {
    color: var(--accent);
}

.email-preview-badge {
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
    background: var(--primary-light);
    color: var(--primary);
    padding: 0.4rem 0.8rem;
    border-radius: var(--radius-sm);
    font-size: 0.82rem;
    font-weight: 600;
    margin-top: 0.5rem;
    direction: ltr;
}

/* ===== SETTINGS PAGE ===== */
.settings-container {
    padding: 2rem;
    max-width: 800px;
    margin: 0 auto;
    width: 100%;
}

.settings-section {
    margin-bottom: 2rem;
}

.settings-section-title {
    font-size: 1.1rem;
    font-weight: 700;
    margin-bottom: 1rem;
    padding-bottom: 0.75rem;
    border-bottom: 1px solid var(--border);
}

.settings-row {
    display: flex;
    align-items: center;
    gap: 1rem;
    padding: 0.75rem 0;
}

.settings-row label {
    min-width: 120px;
    font-size: 0.85rem;
    color: var(--text-muted);
    font-weight: 600;
}

.settings-row input,
.settings-row textarea,
.settings-row select {
    flex: 1;
}

/* Color picker */
.color-options {
    display: flex;
    gap: 0.5rem;
    flex-wrap: wrap;
}

.color-option {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    cursor: pointer;
    border: 2px solid transparent;
    transition: var(--transition-fast);
}

.color-option:hover,
.color-option.selected {
    border-color: white;
    transform: scale(1.15);
}

/* ===== CONTACTS PAGE ===== */
.contacts-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: 1rem;
    padding: 1.5rem;
}

.contact-card {
    background: var(--card-dark);
    border: 1px solid var(--glass-border);
    border-radius: var(--radius-lg);
    padding: 1.25rem;
    display: flex;
    align-items: center;
    gap: 1rem;
    transition: var(--transition);
    cursor: pointer;
}

.contact-card:hover {
    border-color: var(--border-hover);
    background: var(--card-hover);
    transform: translateY(-2px);
}

.contact-avatar {
    width: 48px;
    height: 48px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    color: white;
    flex-shrink: 0;
    font-size: 1.1rem;
}

.contact-info {
    flex: 1;
    overflow: hidden;
}

.contact-name {
    font-weight: 700;
    font-size: 0.95rem;
    margin-bottom: 0.15rem;
}

.contact-email {
    font-size: 0.8rem;
    color: var(--text-muted);
    direction: ltr;
    text-align: right;
}

.contact-actions {
    display: flex;
    gap: 0.35rem;
}

/* ===== EMPTY STATE ===== */
.empty-state {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 4rem 2rem;
    text-align: center;
}

.empty-state i {
    font-size: 3.5rem;
    color: var(--text-muted);
    opacity: 0.25;
    margin-bottom: 1rem;
}

.empty-state h3 {
    font-size: 1.1rem;
    font-weight: 700;
    margin-bottom: 0.5rem;
    color: var(--text-secondary);
}

.empty-state p {
    color: var(--text-muted);
    font-size: 0.9rem;
    max-width: 300px;
}

/* ===== MODAL / DIALOG ===== */
.modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.6);
    backdrop-filter: blur(4px);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
    animation: fadeIn 0.2s ease;
    padding: 1rem;
}

.modal {
    background: var(--bg-dark);
    border: 1px solid var(--border);
    border-radius: var(--radius-xl);
    width: 100%;
    max-width: 500px;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.5);
    animation: modalIn 0.3s ease;
}

@keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

@keyframes modalIn {
    from { opacity: 0; transform: scale(0.95) translateY(10px); }
    to { opacity: 1; transform: scale(1) translateY(0); }
}

.modal-header {
    padding: 1.25rem 1.5rem;
    border-bottom: 1px solid var(--border);
    display: flex;
    align-items: center;
    justify-content: space-between;
    font-weight: 700;
}

.modal-body {
    padding: 1.5rem;
}

.modal-footer {
    padding: 1rem 1.5rem;
    border-top: 1px solid var(--border);
    display: flex;
    justify-content: flex-start;
    gap: 0.75rem;
}

/* ===== SPINNER ===== */
.spinner {
    width: 20px;
    height: 20px;
    border: 2px solid var(--border);
    border-top-color: var(--primary);
    border-radius: 50%;
    animation: spin 0.7s linear infinite;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

.loading-center {
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 3rem;
}

/* ===== TOOLTIP ===== */
[data-tooltip] {
    position: relative;
}

[data-tooltip]::after {
    content: attr(data-tooltip);
    position: absolute;
    bottom: calc(100% + 8px);
    left: 50%;
    transform: translateX(-50%);
    background: var(--bg-darker);
    color: var(--text-main);
    border: 1px solid var(--border);
    padding: 0.35rem 0.7rem;
    border-radius: var(--radius-sm);
    font-size: 0.75rem;
    white-space: nowrap;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.2s ease;
    z-index: 999;
}

[data-tooltip]:hover::after {
    opacity: 1;
}

/* ===== INSTALL PAGE ===== */
.install-box {
    max-width: 600px;
    margin: 4rem auto;
    padding: 2.5rem;
}

.step-indicator {
    display: flex;
    justify-content: center;
    gap: 1rem;
    margin-bottom: 2rem;
}

.step-dot {
    width: 35px;
    height: 35px;
    border-radius: 50%;
    border: 2px solid var(--border);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.8rem;
    font-weight: 700;
    color: var(--text-muted);
    transition: var(--transition);
}

.step-dot.active {
    border-color: var(--primary);
    background: var(--primary);
    color: white;
    box-shadow: 0 0 15px var(--primary-glow);
}

.step-dot.done {
    border-color: var(--success);
    background: var(--success);
    color: white;
}

.req-item {
    display: flex;
    justify-content: space-between;
    padding: 0.75rem 0;
    border-bottom: 1px solid var(--border);
}

.status-ok { color: var(--success); }
.status-fail { color: var(--danger); }

/* ===== RESPONSIVE ===== */
@media (max-width: 900px) {
    .sidebar {
        position: fixed;
        right: 0;
        top: 0;
        bottom: 0;
        transform: translateX(100%);
        z-index: 200;
        box-shadow: -10px 0 30px rgba(0, 0, 0, 0.3);
    }

    .sidebar.open {
        transform: translateX(0);
    }

    .mobile-menu-btn {
        display: flex;
    }

    .sidebar-overlay {
        display: none;
        position: fixed;
        inset: 0;
        background: rgba(0, 0, 0, 0.5);
        z-index: 150;
    }

    .sidebar-overlay.active {
        display: block;
    }

    .email-sender {
        width: 100px;
        min-width: 80px;
    }

    .email-preview {
        display: none;
    }
}

@media (max-width: 600px) {
    .auth-main {
        padding: 1rem;
    }
    
    .auth-card {
        padding: 1.5rem;
        border-radius: var(--radius-lg);
    }

    .header {
        padding: 0 1rem;
    }

    .search-box {
        max-width: none;
    }

    /* تحسين شكل صف الرسالة في الموبايل ليصبح عمودي */
    .email-row {
        padding: 1rem;
        flex-wrap: wrap;
        position: relative;
    }

    .email-star {
        position: absolute;
        top: 1rem;
        right: 1rem; /* RTL: star on the right */
        width: 1.5rem;
    }

    .email-sender {
        width: auto;
        flex: 1 1 100%;
        margin-right: 2.5rem; /* Space for the star */
        margin-bottom: 0.25rem;
        font-size: 1rem;
    }

    .email-content {
        width: auto;
        flex: 1 1 100%;
        margin-right: 2.5rem;
    }

    .email-subject {
        font-size: 0.9rem;
    }

    .email-meta {
        position: absolute;
        left: 1rem; /* RTL: date on the left */
        top: 1rem;
    }

    .email-date {
        font-size: 0.75rem;
    }

    .content-area {
        padding: 0;
    }

    .compose-area,
    .email-view,
    .settings-container,
    .mail-list-header {
        padding: 1rem;
    }

    .contacts-grid {
        grid-template-columns: 1fr;
        padding: 1rem;
    }

    /* تحسين الإعدادات وتفاصيل الحساب */
    .settings-container {
        padding: 1rem 0.5rem;
    }
    
    .card {
        padding: 1rem;
    }
    
    .settings-section-title {
        font-size: 0.95rem;
    }

    .btn {
        width: 100%;
        margin-bottom: 0.5rem;
    }
    
    .btn-sm {
        width: auto;
    }

    /* تحسين عرض الإيميل نفسه (View Mail) */
    .email-view-info {
        flex-direction: column;
        gap: 0.5rem;
    }

    .email-view-actions {
        width: 100%;
        justify-content: space-between;
        margin-top: 0.5rem;
    }
}

/* إصلاح جداول الإدارة للموبايل */
@media (max-width: 768px) {
    .admin-table th, .admin-table td {
        white-space: nowrap;
        font-size: 0.85rem;
        padding: 0.5rem;
    }
}

/* ===== UTILITY ===== */
.text-center { text-align: center; }
.text-muted { color: var(--text-muted); }
.mt-1 { margin-top: 0.5rem; }
.mt-2 { margin-top: 1rem; }
.mt-3 { margin-top: 1.5rem; }
.mb-1 { margin-bottom: 0.5rem; }
.mb-2 { margin-bottom: 1rem; }
.mb-3 { margin-bottom: 1.5rem; }
.gap-1 { gap: 0.5rem; }
.gap-2 { gap: 1rem; }
.flex { display: flex; }
.flex-col { flex-direction: column; }
.items-center { align-items: center; }
.justify-between { justify-content: space-between; }
.w-full { width: 100%; }
.hidden { display: none !important; }

/* ===== PAGE TRANSITION ===== */
.page-enter {
    animation: pageIn 0.4s ease;
}

@keyframes pageIn {
    from { opacity: 0; transform: translateY(15px); }
    to { opacity: 1; transform: translateY(0); }
}
