@import url('https://fonts.googleapis.com/css2?family=Noto+Sans+Arabic:wght@300;400;500;600;700&display=swap');

:root {
    --wa-green: #25D366;
    --wa-dark: #075E54;
    --wa-light: #DCF8C6;
    --wa-teal: #128C7E;
    --bg: #f0f2f5;
    --card: #ffffff;
    --text: #1a1a2e;
    --text-muted: #8696a0;
    --border: #e9edef;
    --danger: #ef4444;
    --warning: #f59e0b;
    --radius: 12px;
}

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

body {
    font-family: 'Noto Sans Arabic', sans-serif;
    background: var(--bg);
    color: var(--text);
    direction: rtl;
    min-height: 100vh;
}

/* Login Page */
.login-wrapper {
    display: flex;
    justify-content: center;
    align-items: center;
    min-height: 100vh;
    background: linear-gradient(135deg, var(--wa-dark) 0%, var(--wa-teal) 50%, var(--wa-green) 100%);
}

.login-card {
    background: var(--card);
    border-radius: 20px;
    padding: 48px 40px;
    width: 400px;
    box-shadow: 0 20px 60px rgba(0,0,0,0.3);
    text-align: center;
}

.login-card .logo { font-size: 3em; margin-bottom: 8px; }
.login-card h1 { font-size: 1.5em; margin-bottom: 4px; color: var(--wa-dark); }
.login-card p { color: var(--text-muted); margin-bottom: 28px; font-size: 0.9em; }

.form-group {
    margin-bottom: 18px;
    text-align: right;
}

.form-group label {
    display: block;
    margin-bottom: 6px;
    font-size: 0.85em;
    font-weight: 500;
    color: var(--text-muted);
}

.form-group input {
    width: 100%;
    padding: 12px 16px;
    border: 2px solid var(--border);
    border-radius: 10px;
    font-size: 1em;
    font-family: inherit;
    direction: rtl;
    transition: border-color 0.2s;
}

.form-group input:focus {
    outline: none;
    border-color: var(--wa-green);
}

.btn {
    padding: 12px 28px;
    border: none;
    border-radius: 10px;
    font-size: 1em;
    font-family: inherit;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
    display: inline-flex;
    align-items: center;
    gap: 8px;
}

.btn-primary {
    background: var(--wa-green);
    color: white;
    width: 100%;
    justify-content: center;
}

.btn-primary:hover { background: var(--wa-teal); }

.btn-danger { background: var(--danger); color: white; }
.btn-danger:hover { opacity: 0.9; }

.btn-outline {
    background: transparent;
    border: 2px solid var(--border);
    color: var(--text);
}

.btn-outline:hover { border-color: var(--wa-green); color: var(--wa-green); }

.btn-sm { padding: 8px 16px; font-size: 0.85em; }

.error-msg {
    background: #fef2f2;
    color: var(--danger);
    padding: 10px;
    border-radius: 8px;
    margin-bottom: 16px;
    font-size: 0.9em;
    display: none;
}

/* Dashboard Layout */
.dashboard {
    display: flex;
    min-height: 100vh;
}

.sidebar {
    width: 260px;
    background: var(--wa-dark);
    color: white;
    padding: 24px 0;
    display: flex;
    flex-direction: column;
    position: fixed;
    top: 0;
    right: 0;
    bottom: 0;
    z-index: 10;
}

.sidebar-brand {
    padding: 0 24px 24px;
    border-bottom: 1px solid rgba(255,255,255,0.1);
    text-align: center;
}

.sidebar-brand h2 { font-size: 1.2em; margin-top: 8px; }
.sidebar-brand small { color: rgba(255,255,255,0.5); font-size: 0.75em; }

.sidebar-nav {
    flex: 1;
    padding: 16px 12px;
    list-style: none;
}

.sidebar-nav li {
    margin-bottom: 4px;
}

.sidebar-nav a {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 12px 16px;
    color: rgba(255,255,255,0.7);
    text-decoration: none;
    border-radius: 10px;
    font-size: 0.9em;
    transition: all 0.2s;
}

.sidebar-nav a:hover,
.sidebar-nav a.active {
    background: rgba(255,255,255,0.1);
    color: white;
}

.sidebar-nav a.active { background: var(--wa-green); }

.sidebar-footer {
    padding: 16px 24px;
    border-top: 1px solid rgba(255,255,255,0.1);
}

.main-content {
    flex: 1;
    margin-right: 260px;
    padding: 24px 32px;
}

.page-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 24px;
}

.page-header h1 { font-size: 1.5em; }

/* Status Cards */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 16px;
    margin-bottom: 24px;
}

.stat-card {
    background: var(--card);
    border-radius: var(--radius);
    padding: 20px;
    box-shadow: 0 1px 3px rgba(0,0,0,0.08);
}

.stat-card .stat-icon {
    width: 44px;
    height: 44px;
    border-radius: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.3em;
    margin-bottom: 12px;
}

.stat-card .stat-value { font-size: 1.6em; font-weight: 700; }
.stat-card .stat-label { color: var(--text-muted); font-size: 0.85em; margin-top: 2px; }

.stat-card.green .stat-icon { background: #d1fae5; }
.stat-card.yellow .stat-icon { background: #fef3c7; }
.stat-card.red .stat-icon { background: #fee2e2; }
.stat-card.blue .stat-icon { background: #dbeafe; }

/* Cards */
.card {
    background: var(--card);
    border-radius: var(--radius);
    box-shadow: 0 1px 3px rgba(0,0,0,0.08);
    margin-bottom: 20px;
}

.card-header {
    padding: 18px 24px;
    border-bottom: 1px solid var(--border);
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-weight: 600;
}

.card-body { padding: 24px; }

/* QR Section */
.qr-container {
    text-align: center;
    padding: 40px 20px;
}

.qr-container img {
    width: 280px;
    height: 280px;
    border-radius: 16px;
    border: 3px solid var(--border);
}

.qr-container .qr-instructions {
    margin-top: 20px;
    color: var(--text-muted);
    font-size: 0.9em;
    line-height: 1.8;
}

.qr-container .qr-instructions ol {
    text-align: right;
    display: inline-block;
}

.connected-badge {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    background: #d1fae5;
    color: #065f46;
    padding: 12px 24px;
    border-radius: 50px;
    font-size: 1.1em;
    font-weight: 600;
}

/* Send Form */
.send-form {
    max-width: 600px;
}

.send-form .form-group { margin-bottom: 20px; }

.send-form textarea,
.send-form input[type="text"],
.send-form input[type="url"] {
    width: 100%;
    padding: 12px 16px;
    border: 2px solid var(--border);
    border-radius: 10px;
    font-size: 0.95em;
    font-family: inherit;
    direction: rtl;
    resize: vertical;
    transition: border-color 0.2s;
}

.send-form textarea:focus,
.send-form input:focus {
    outline: none;
    border-color: var(--wa-green);
}

.send-form textarea { min-height: 100px; }

/* Logs */
.log-list {
    max-height: 400px;
    overflow-y: auto;
}

.log-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 12px 16px;
    border-bottom: 1px solid var(--border);
    font-size: 0.9em;
}

.log-item:last-child { border-bottom: none; }

.log-item .log-phone { font-weight: 600; }
.log-item .log-time { color: var(--text-muted); font-size: 0.8em; }

.badge {
    display: inline-block;
    padding: 3px 10px;
    border-radius: 20px;
    font-size: 0.75em;
    font-weight: 600;
}

.badge-success { background: #d1fae5; color: #065f46; }
.badge-error { background: #fee2e2; color: #991b1b; }
.badge-warning { background: #fef3c7; color: #92400e; }

/* Settings */
.settings-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 20px;
}

.toggle-switch {
    display: flex;
    align-items: center;
    gap: 12px;
}

.toggle-switch input[type="checkbox"] {
    width: 48px;
    height: 26px;
    appearance: none;
    background: #ccc;
    border-radius: 13px;
    position: relative;
    cursor: pointer;
    transition: background 0.2s;
}

.toggle-switch input[type="checkbox"]:checked { background: var(--wa-green); }

.toggle-switch input[type="checkbox"]::after {
    content: '';
    width: 22px;
    height: 22px;
    background: white;
    border-radius: 50%;
    position: absolute;
    top: 2px;
    right: 2px;
    transition: transform 0.2s;
}

.toggle-switch input[type="checkbox"]:checked::after { transform: translateX(-22px); }

/* Pages */
.page { display: none; }
.page.active { display: block; }

/* Toast */
.toast-container {
    position: fixed;
    top: 20px;
    left: 20px;
    z-index: 1000;
}

.toast {
    background: var(--card);
    border-radius: 10px;
    padding: 14px 20px;
    margin-bottom: 8px;
    box-shadow: 0 4px 20px rgba(0,0,0,0.15);
    display: flex;
    align-items: center;
    gap: 10px;
    font-size: 0.9em;
    animation: slideIn 0.3s ease;
    min-width: 280px;
}

.toast.success { border-right: 4px solid var(--wa-green); }
.toast.error { border-right: 4px solid var(--danger); }

@keyframes slideIn {
    from { transform: translateX(-100%); opacity: 0; }
    to { transform: translateX(0); opacity: 1; }
}

/* Loading */
.spinner {
    width: 40px;
    height: 40px;
    border: 4px solid var(--border);
    border-top-color: var(--wa-green);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
    margin: 20px auto;
}

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

/* Empty State */
.empty-state {
    text-align: center;
    padding: 40px;
    color: var(--text-muted);
}

.empty-state .icon { font-size: 3em; margin-bottom: 12px; }

/* Responsive */
@media (max-width: 768px) {
    .sidebar { width: 100%; position: relative; }
    .main-content { margin-right: 0; }
    .dashboard { flex-direction: column; }
    .stats-grid { grid-template-columns: 1fr 1fr; }
    .settings-grid { grid-template-columns: 1fr; }
    .login-card { width: 90%; padding: 32px 24px; }
}
