/* style.css - Premium LIGHT theme stylesheet */

@import url('https://fonts.googleapis.com/css2?family=Cairo:wght@300;400;600;700&family=Outfit:wght@300;400;600;700&display=swap');

:root {
    --bg-color: #f0f2f7;
    --card-bg: #ffffff;
    --border-color: rgba(0, 0, 0, 0.08);
    --text-primary: #1a1c2e;
    --text-secondary: #6b7280;
    --primary-color: #6d28d9;
    --primary-glow: rgba(109, 40, 217, 0.25);
    --primary-light: #ede9fe;
    --secondary-color: #0284c7;
    --secondary-light: #e0f2fe;
    --accent-red: #dc2626;
    --accent-green: #16a34a;
    --accent-green-light: #dcfce7;
    --accent-yellow: #d97706;
    --accent-yellow-light: #fef3c7;
    --shadow-sm: 0 1px 3px rgba(0,0,0,0.08), 0 1px 2px rgba(0,0,0,0.06);
    --shadow-md: 0 4px 12px rgba(0,0,0,0.08), 0 2px 6px rgba(0,0,0,0.05);
    --shadow-lg: 0 10px 30px rgba(0,0,0,0.1);
    --font-ar: 'Cairo', sans-serif;
    --font-en: 'Outfit', sans-serif;
}

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

body {
    background-color: var(--bg-color);
    background-image:
        radial-gradient(circle at 0% 0%, rgba(109, 40, 217, 0.06) 0%, transparent 50%),
        radial-gradient(circle at 100% 100%, rgba(2, 132, 199, 0.05) 0%, transparent 50%);
    color: var(--text-primary);
    font-family: var(--font-ar);
    min-height: 100vh;
    padding: 20px;
    direction: rtl;
    line-height: 1.6;
}

.container {
    max-width: 1100px;
    margin: 0 auto;
}

/* ── Header ──────────────────────────────────────────────────────── */
header {
    text-align: center;
    margin-bottom: 32px;
    padding: 30px 20px;
    background: white;
    border-radius: 20px;
    box-shadow: var(--shadow-md);
    border: 1px solid var(--border-color);
    position: relative;
    overflow: hidden;
}

header::before {
    content: '';
    position: absolute;
    top: 0; left: 0; right: 0;
    height: 4px;
    background: linear-gradient(90deg, #6d28d9, #0284c7, #6d28d9);
    background-size: 200%;
    animation: gradient-flow 3s ease infinite;
}

@keyframes gradient-flow {
    0% { background-position: 0%; }
    100% { background-position: 200%; }
}

header h1 {
    font-size: 2.2rem;
    font-weight: 700;
    background: linear-gradient(135deg, #6d28d9, #0284c7);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    margin-bottom: 8px;
}

header p {
    color: var(--text-secondary);
    font-size: 1.05rem;
    font-weight: 400;
}

/* ── Cards ───────────────────────────────────────────────────────── */
.card {
    background: var(--card-bg);
    border: 1px solid var(--border-color);
    border-radius: 16px;
    padding: 24px;
    margin-bottom: 20px;
    box-shadow: var(--shadow-md);
    transition: box-shadow 0.3s ease;
}

.card:hover {
    box-shadow: var(--shadow-lg);
}

.card-title {
    font-size: 1.2rem;
    font-weight: 700;
    margin-bottom: 20px;
    color: var(--text-primary);
    border-bottom: 2px solid var(--bg-color);
    padding-bottom: 12px;
    display: flex;
    align-items: center;
    gap: 10px;
}

.card-title .icon {
    width: 36px; height: 36px;
    border-radius: 10px;
    background: var(--primary-light);
    display: flex; align-items: center; justify-content: center;
    font-size: 1.1rem;
}

/* ── Section dividers ─────────────────────────────────────────────── */
.section-label {
    font-size: 0.85rem;
    font-weight: 700;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-bottom: 12px;
    margin-top: 20px;
    display: flex;
    align-items: center;
    gap: 8px;
}

.section-label::after {
    content: '';
    flex: 1;
    height: 1px;
    background: var(--border-color);
}

/* ── Forms ───────────────────────────────────────────────────────── */
.form-group {
    margin-bottom: 18px;
}

label {
    display: block;
    margin-bottom: 6px;
    color: var(--text-secondary);
    font-size: 0.9rem;
    font-weight: 600;
}

input[type="text"],
input[type="password"],
input[type="number"],
input[type="file"],
select,
textarea {
    width: 100%;
    padding: 11px 14px;
    background: #f9fafb;
    border: 1.5px solid #e5e7eb;
    border-radius: 10px;
    color: var(--text-primary);
    font-family: var(--font-ar);
    font-size: 0.97rem;
    transition: all 0.25s ease;
}

input:focus, select:focus, textarea:focus {
    outline: none;
    border-color: var(--primary-color);
    box-shadow: 0 0 0 3px var(--primary-glow);
    background: #fff;
}

.form-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 16px;
}

@media (max-width: 768px) {
    .form-row { grid-template-columns: 1fr; }
    header h1 { font-size: 1.7rem; }
}

/* ── Buttons ──────────────────────────────────────────────────────── */
.btn {
    background: var(--primary-color);
    color: #fff;
    border: none;
    border-radius: 10px;
    padding: 12px 22px;
    font-family: var(--font-ar);
    font-size: 1rem;
    font-weight: 700;
    cursor: pointer;
    transition: all 0.25s ease;
    box-shadow: 0 2px 8px rgba(109,40,217,0.3);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
}

.btn:hover {
    background: #5b21b6;
    transform: translateY(-2px);
    box-shadow: 0 5px 18px rgba(109,40,217,0.4);
}

.btn:active { transform: translateY(0); }

.btn:disabled {
    background: #d1d5db;
    color: #9ca3af;
    cursor: not-allowed;
    transform: none;
    box-shadow: none;
}

.btn-secondary {
    background: white;
    color: var(--text-primary);
    border: 1.5px solid #e5e7eb;
    box-shadow: var(--shadow-sm);
}

.btn-secondary:hover {
    background: #f3f4f6;
    border-color: #d1d5db;
    box-shadow: var(--shadow-md);
}

.btn-danger {
    background: var(--accent-red);
    box-shadow: 0 2px 8px rgba(220, 38, 38, 0.3);
}

.btn-danger:hover {
    background: #b91c1c;
    box-shadow: 0 5px 18px rgba(220, 38, 38, 0.4);
}

.btn-success {
    background: var(--accent-green);
    box-shadow: 0 2px 8px rgba(22, 163, 74, 0.3);
}

.btn-success:hover {
    background: #15803d;
    box-shadow: 0 5px 18px rgba(22, 163, 74, 0.4);
}

/* ── Progress ─────────────────────────────────────────────────────── */
.progress-container {
    margin-top: 20px;
}

.progress-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 8px;
    font-size: 0.92rem;
    font-weight: 600;
}

.progress-bar-bg {
    width: 100%;
    height: 10px;
    background: #e5e7eb;
    border-radius: 6px;
    overflow: hidden;
}

.progress-bar-fill {
    height: 100%;
    width: 0%;
    background: linear-gradient(90deg, var(--primary-color), var(--secondary-color));
    border-radius: 6px;
    transition: width 0.5s ease;
    position: relative;
}

.progress-bar-fill.animated::after {
    content: '';
    position: absolute;
    top: 0; left: 0; right: 0; bottom: 0;
    background: linear-gradient(90deg, transparent, rgba(255,255,255,0.35), transparent);
    animation: shimmer 1.5s infinite;
}

@keyframes shimmer {
    0% { transform: translateX(-100%); }
    100% { transform: translateX(100%); }
}

/* ── Console / Log box ───────────────────────────────────────────── */
.console-box {
    margin-top: 16px;
    background: #0f1117;
    border: 1px solid #e5e7eb;
    border-radius: 10px;
    padding: 14px 16px;
    font-family: 'Courier New', Courier, monospace;
    font-size: 0.85rem;
    height: 220px;
    overflow-y: auto;
    color: #a5f3fc;
    text-align: left;
    direction: ltr;
}

.console-box p {
    margin-bottom: 5px;
    white-space: pre-wrap;
    word-break: break-all;
}

.console-box p.error { color: #f87171; }
.console-box p.success { color: #86efac; }
.console-box p.warning { color: #fde68a; }

/* ── Alert Boxes ─────────────────────────────────────────────────── */
.alert {
    padding: 12px 16px;
    border-radius: 10px;
    margin-bottom: 16px;
    font-size: 0.93rem;
    display: flex;
    align-items: flex-start;
    gap: 10px;
    line-height: 1.5;
}

.alert-info {
    background: var(--secondary-light);
    border: 1px solid rgba(2, 132, 199, 0.3);
    color: #0369a1;
}

.alert-success {
    background: var(--accent-green-light);
    border: 1px solid rgba(22, 163, 74, 0.3);
    color: #15803d;
}

.alert-warning {
    background: var(--accent-yellow-light);
    border: 1px solid rgba(217, 119, 6, 0.3);
    color: #92400e;
}

.alert-danger {
    background: #fee2e2;
    border: 1px solid rgba(220, 38, 38, 0.3);
    color: #991b1b;
}

/* ── Book Cards (grid) ───────────────────────────────────────────── */
.books-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
    gap: 14px;
    margin-top: 14px;
}

.book-card {
    background: #f9fafb;
    border: 2px solid #e5e7eb;
    border-radius: 14px;
    padding: 18px 14px;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 8px;
    text-align: center;
    transition: all 0.25s ease;
    cursor: pointer;
}

.book-card:hover {
    background: var(--primary-light);
    border-color: var(--primary-color);
    transform: translateY(-3px);
    box-shadow: var(--shadow-md);
}

.book-card.selected {
    background: var(--primary-light);
    border-color: var(--primary-color);
    box-shadow: 0 0 0 3px rgba(109, 40, 217, 0.15);
}

.book-card-icon { font-size: 2.2rem; line-height: 1; }
.book-card-title {
    font-size: 0.88rem;
    font-weight: 700;
    color: var(--text-primary);
    line-height: 1.4;
}
.book-card-meta {
    font-size: 0.76rem;
    color: var(--text-secondary);
}
.book-select-btn {
    margin-top: 6px;
    padding: 7px 14px;
    font-size: 0.82rem;
    width: 100%;
}

/* ── Job Tracker card ─────────────────────────────────────────────── */
.tracker-card {
    background: var(--card-bg);
    border: 2px solid var(--border-color);
    border-radius: 16px;
    padding: 22px;
    margin-bottom: 20px;
    box-shadow: var(--shadow-md);
}

.tracker-card.active-job {
    border-color: var(--primary-color);
    box-shadow: 0 0 0 3px rgba(109,40,217,0.1), var(--shadow-md);
}

.tracker-status-badge {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 4px 12px;
    border-radius: 20px;
    font-size: 0.82rem;
    font-weight: 700;
}

.badge-running {
    background: #dbeafe;
    color: #1d4ed8;
}

.badge-pending {
    background: var(--accent-yellow-light);
    color: var(--accent-yellow);
}

.badge-finished {
    background: var(--accent-green-light);
    color: var(--accent-green);
}

.badge-failed {
    background: #fee2e2;
    color: var(--accent-red);
}

.pulse-dot {
    width: 8px; height: 8px;
    border-radius: 50%;
    background: currentColor;
    animation: pulse-anim 1.5s ease-in-out infinite;
}

@keyframes pulse-anim {
    0%, 100% { opacity: 1; transform: scale(1); }
    50% { opacity: 0.4; transform: scale(0.7); }
}

.stat-row {
    display: flex;
    gap: 16px;
    flex-wrap: wrap;
    margin: 14px 0;
}

.stat-box {
    flex: 1;
    min-width: 100px;
    background: #f9fafb;
    border: 1px solid #e5e7eb;
    border-radius: 10px;
    padding: 12px 14px;
    text-align: center;
}

.stat-box .stat-val {
    font-size: 1.6rem;
    font-weight: 700;
    color: var(--primary-color);
    line-height: 1;
    margin-bottom: 4px;
}

.stat-box .stat-lbl {
    font-size: 0.78rem;
    color: var(--text-secondary);
}

/* ── Tables ───────────────────────────────────────────────────────── */
.table-responsive { overflow-x: auto; margin-top: 14px; }

table {
    width: 100%;
    border-collapse: collapse;
    text-align: right;
    font-size: 0.93rem;
}

th, td {
    padding: 12px 14px;
    border-bottom: 1px solid #f0f2f7;
}

th {
    color: var(--text-secondary);
    font-weight: 700;
    font-size: 0.85rem;
    background: #f9fafb;
    text-transform: uppercase;
    letter-spacing: 0.3px;
}

tr:hover td { background: #f9fafb; }

/* ── API Keys ─────────────────────────────────────────────────────── */
.key-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    background: #f9fafb;
    border: 1px solid #e5e7eb;
    border-radius: 10px;
    padding: 12px 16px;
    margin-bottom: 10px;
}

.key-text {
    font-family: monospace;
    font-size: 0.95rem;
    color: var(--text-primary);
}

/* ── Dividers ─────────────────────────────────────────────────────── */
.divider {
    border: none;
    border-top: 1px solid var(--border-color);
    margin: 20px 0;
}

/* ── Spinner ─────────────────────────────────────────────────────── */
.spinner {
    width: 20px; height: 20px;
    border: 2.5px solid #e5e7eb;
    border-top-color: var(--primary-color);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
    display: inline-block;
}

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

/* Admin link button */
.admin-link {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    color: var(--text-secondary);
    font-size: 0.88rem;
    text-decoration: none;
    padding: 6px 14px;
    border: 1px solid #e5e7eb;
    border-radius: 8px;
    background: white;
    transition: all 0.2s;
    margin-top: 12px;
}

.admin-link:hover {
    color: var(--primary-color);
    border-color: var(--primary-color);
    background: var(--primary-light);
}

/* ── Custom Select Dropdown ────────────────────────────────────────── */
.custom-select-container {
    position: relative;
    width: 100%;
}

.custom-select-trigger {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 12px 16px;
    background: #f9fafb;
    border: 1.5px solid #e5e7eb;
    border-radius: 12px;
    cursor: pointer;
    font-size: 0.97rem;
    color: var(--text-primary);
    transition: all 0.25s ease;
    user-select: none;
}

.custom-select-trigger:hover {
    border-color: var(--primary-color);
    background: #fff;
}

.custom-select-container.open .custom-select-trigger {
    border-color: var(--primary-color);
    box-shadow: 0 0 0 3px var(--primary-glow);
    background: #fff;
}

.custom-select-arrow {
    font-size: 0.75rem;
    transition: transform 0.25s ease;
    color: var(--text-secondary);
}

.custom-select-container.open .custom-select-arrow {
    transform: rotate(180deg);
}

.custom-select-dropdown {
    position: absolute;
    top: calc(100% + 6px);
    left: 0;
    right: 0;
    background: #ffffff;
    border: 1px solid var(--border-color);
    border-radius: 12px;
    box-shadow: var(--shadow-lg);
    z-index: 1000;
    overflow: hidden;
    animation: fadeInDropdown 0.2s ease;
}

@keyframes fadeInDropdown {
    from { opacity: 0; transform: translateY(-8px); }
    to { opacity: 1; transform: translateY(0); }
}

.custom-select-search-box {
    padding: 10px;
    background: #f9fafb;
    border-bottom: 1px solid var(--border-color);
}

.custom-select-search-box input {
    width: 100%;
    padding: 8px 12px;
    border: 1.5px solid #e5e7eb;
    border-radius: 8px;
    font-family: var(--font-ar);
    font-size: 0.9rem;
}

.custom-select-search-box input:focus {
    outline: none;
    border-color: var(--primary-color);
    background: #fff;
}

.custom-select-options {
    max-height: 260px;
    overflow-y: auto;
}

.custom-select-option {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 12px 16px;
    cursor: pointer;
    transition: background 0.2s ease;
    border-bottom: 1px solid #f9fafb;
    font-size: 0.95rem;
}

.custom-select-option:last-child {
    border-bottom: none;
}

.custom-select-option:hover {
    background: var(--primary-light);
    color: var(--primary-color);
}

.custom-select-option.selected {
    background: var(--primary-color);
    color: #ffffff;
}

.custom-select-option-meta {
    font-size: 0.78rem;
    color: var(--text-secondary);
}

.custom-select-option.selected .custom-select-option-meta {
    color: rgba(255, 255, 255, 0.8);
}
