/* =============================================
   WhatsToot Dashboard — Premium Dark Theme
   Colors: WhatsApp Green (#25D366) + Drive Blue (#4285F4)
   ============================================= */

/* ── Reset & Base ── */
*, *::before, *::after {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

:root {
    --bg-primary: #0a0e1a;
    --bg-secondary: #111827;
    --bg-card: #1a1f35;
    --bg-card-hover: #1f2541;
    --bg-glass: rgba(26, 31, 53, 0.8);
    --bg-input: #151a2e;
    
    --text-primary: #f0f2f5;
    --text-secondary: #9ca3af;
    --text-muted: #6b7280;
    
    --green: #25D366;
    --green-soft: rgba(37, 211, 102, 0.15);
    --green-glow: rgba(37, 211, 102, 0.3);
    --blue: #4285F4;
    --blue-soft: rgba(66, 133, 244, 0.15);
    --purple: #8b5cf6;
    --purple-soft: rgba(139, 92, 246, 0.15);
    --orange: #f59e0b;
    --orange-soft: rgba(245, 158, 11, 0.15);
    --yellow: #eab308;
    --yellow-soft: rgba(234, 179, 8, 0.15);
    --red: #ef4444;
    --red-soft: rgba(239, 68, 68, 0.15);
    
    --border: rgba(255, 255, 255, 0.06);
    --border-hover: rgba(255, 255, 255, 0.12);
    --shadow: 0 4px 24px rgba(0, 0, 0, 0.3);
    --shadow-lg: 0 8px 40px rgba(0, 0, 0, 0.4);
    
    --radius: 12px;
    --radius-sm: 8px;
    --radius-lg: 16px;
    
    --font: 'Tajawal', 'Segoe UI', sans-serif;
    --transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

html {
    font-size: 15px;
    scroll-behavior: smooth;
}

body {
    font-family: var(--font);
    background: var(--bg-primary);
    color: var(--text-primary);
    min-height: 100vh;
    line-height: 1.6;
    overflow-x: hidden;
}

/* Animated background */
body::before {
    content: '';
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: 
        radial-gradient(ellipse at 20% 0%, rgba(37, 211, 102, 0.06) 0%, transparent 50%),
        radial-gradient(ellipse at 80% 100%, rgba(66, 133, 244, 0.06) 0%, transparent 50%);
    pointer-events: none;
    z-index: 0;
}

/* ── Header ── */
.header {
    position: sticky;
    top: 0;
    z-index: 100;
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    background: rgba(10, 14, 26, 0.85);
    border-bottom: 1px solid var(--border);
    padding: 0 1.5rem;
}

.header-content {
    max-width: 1400px;
    margin: 0 auto;
    display: flex;
    justify-content: space-between;
    align-items: center;
    height: 70px;
}

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

.logo-icon {
    width: 44px;
    height: 44px;
    border-radius: var(--radius);
    background: linear-gradient(135deg, var(--green), #128C7E);
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    box-shadow: 0 4px 16px var(--green-glow);
}

.logo h1 {
    font-size: 1.5rem;
    font-weight: 800;
    background: linear-gradient(135deg, var(--green), #4AE88C);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    letter-spacing: -0.5px;
}

.logo .subtitle {
    font-size: 0.75rem;
    color: var(--text-muted);
    font-weight: 500;
}

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

.bot-status {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 6px 14px;
    border-radius: 20px;
    background: var(--bg-card);
    border: 1px solid var(--border);
    font-size: 0.85rem;
    font-weight: 500;
}

.status-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: var(--red);
}

.status-dot.online {
    background: var(--green);
    box-shadow: 0 0 8px var(--green-glow);
    animation: pulse-dot 2s ease-in-out infinite;
}

.status-dot.offline {
    background: var(--red);
}

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

/* ── Buttons ── */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    padding: 8px 16px;
    border-radius: var(--radius-sm);
    border: none;
    cursor: pointer;
    font-family: var(--font);
    font-weight: 600;
    font-size: 0.85rem;
    transition: var(--transition);
}

.btn-ghost {
    background: transparent;
    color: var(--text-secondary);
    border: 1px solid var(--border);
}

.btn-ghost:hover {
    background: var(--bg-card);
    color: var(--text-primary);
    border-color: var(--border-hover);
}

.btn-sm {
    padding: 4px 10px;
    font-size: 0.8rem;
}

/* ── Main ── */
.main {
    max-width: 1400px;
    margin: 0 auto;
    padding: 1.5rem;
    position: relative;
    z-index: 1;
}

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

.stat-card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 20px;
    display: flex;
    align-items: center;
    gap: 16px;
    transition: var(--transition);
    cursor: default;
    position: relative;
    overflow: hidden;
}

.stat-card::before {
    content: '';
    position: absolute;
    top: 0;
    right: 0;
    width: 100%;
    height: 100%;
    background: linear-gradient(135deg, transparent 60%, currentColor);
    opacity: 0.03;
    pointer-events: none;
}

.stat-card:hover {
    background: var(--bg-card-hover);
    border-color: var(--border-hover);
    transform: translateY(-2px);
    box-shadow: var(--shadow);
}

.stat-icon {
    width: 48px;
    height: 48px;
    border-radius: var(--radius);
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.stat-icon.green { background: var(--green-soft); color: var(--green); }
.stat-icon.blue { background: var(--blue-soft); color: var(--blue); }
.stat-icon.purple { background: var(--purple-soft); color: var(--purple); }
.stat-icon.orange { background: var(--orange-soft); color: var(--orange); }
.stat-icon.yellow { background: var(--yellow-soft); color: var(--yellow); }
.stat-icon.red { background: var(--red-soft); color: var(--red); }

.stat-info {
    display: flex;
    flex-direction: column;
}

.stat-value {
    font-size: 1.8rem;
    font-weight: 800;
    line-height: 1.1;
    letter-spacing: -1px;
}

.stat-label {
    font-size: 0.8rem;
    color: var(--text-muted);
    font-weight: 500;
    margin-top: 2px;
}

/* Number animation */
.stat-value.counting {
    transition: color 0.3s;
}

/* ── Search Section ── */
.search-section {
    display: flex;
    gap: 16px;
    align-items: center;
    margin-bottom: 20px;
    flex-wrap: wrap;
}

.search-box {
    position: relative;
    flex: 1;
    min-width: 250px;
}

.search-icon {
    position: absolute;
    right: 14px;
    top: 50%;
    transform: translateY(-50%);
    color: var(--text-muted);
    pointer-events: none;
}

.search-box input {
    width: 100%;
    padding: 12px 44px 12px 16px;
    background: var(--bg-input);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    color: var(--text-primary);
    font-family: var(--font);
    font-size: 0.9rem;
    outline: none;
    transition: var(--transition);
}

.search-box input:focus {
    border-color: var(--green);
    box-shadow: 0 0 0 3px var(--green-soft);
}

.search-box input::placeholder {
    color: var(--text-muted);
}

.filter-tabs {
    display: flex;
    gap: 4px;
    background: var(--bg-input);
    border-radius: var(--radius);
    padding: 4px;
    border: 1px solid var(--border);
}

.tab {
    padding: 8px 16px;
    border-radius: var(--radius-sm);
    background: transparent;
    border: none;
    color: var(--text-muted);
    font-family: var(--font);
    font-size: 0.82rem;
    font-weight: 600;
    cursor: pointer;
    transition: var(--transition);
    white-space: nowrap;
}

.tab:hover {
    color: var(--text-primary);
    background: rgba(255, 255, 255, 0.05);
}

.tab.active {
    background: var(--green);
    color: white;
    box-shadow: 0 2px 8px var(--green-glow);
}

/* ── Table ── */
.table-section {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    overflow: hidden;
    margin-bottom: 24px;
}

.table-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 16px 20px;
    border-bottom: 1px solid var(--border);
}

.table-header h2 {
    font-size: 1.1rem;
    font-weight: 700;
}

.table-count {
    font-size: 0.82rem;
    color: var(--text-muted);
    background: var(--bg-input);
    padding: 4px 12px;
    border-radius: 20px;
}

.table-wrapper {
    overflow-x: auto;
}

table {
    width: 100%;
    border-collapse: collapse;
}

thead th {
    background: var(--bg-secondary);
    padding: 12px 16px;
    text-align: right;
    font-size: 0.78rem;
    font-weight: 700;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    white-space: nowrap;
    border-bottom: 1px solid var(--border);
}

tbody td {
    padding: 12px 16px;
    font-size: 0.88rem;
    border-bottom: 1px solid var(--border);
    vertical-align: middle;
}

tbody tr {
    transition: background 0.2s;
}

tbody tr:hover {
    background: rgba(255, 255, 255, 0.02);
}

tbody tr:last-child td {
    border-bottom: none;
}

.wo-number {
    font-weight: 700;
    font-family: 'Consolas', 'Courier New', monospace;
    color: var(--green);
    font-size: 0.9rem;
}

.file-name {
    font-family: 'Consolas', 'Courier New', monospace;
    font-size: 0.8rem;
    color: var(--text-secondary);
    max-width: 220px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.group-name {
    max-width: 150px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

/* Status badges */
.badge {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 3px 10px;
    border-radius: 20px;
    font-size: 0.75rem;
    font-weight: 600;
    white-space: nowrap;
}

.badge-completed {
    background: var(--green-soft);
    color: var(--green);
}

.badge-pending, .badge-waiting {
    background: var(--orange-soft);
    color: var(--orange);
}

.badge-duplicate {
    background: var(--yellow-soft);
    color: var(--yellow);
}

.badge-failed {
    background: var(--red-soft);
    color: var(--red);
}

.drive-link {
    color: var(--blue);
    text-decoration: none;
    font-weight: 600;
    font-size: 0.82rem;
    transition: var(--transition);
}

.drive-link:hover {
    color: #6ea8ff;
    text-decoration: underline;
}

.time-cell {
    font-size: 0.8rem;
    color: var(--text-muted);
    white-space: nowrap;
}

/* Empty state */
.empty-state {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 12px;
    padding: 48px 0;
    color: var(--text-muted);
}

.empty-state svg {
    opacity: 0.3;
}

.empty-state p {
    font-size: 0.9rem;
}

/* ── Logs ── */
.logs-section {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    overflow: hidden;
}

.logs-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 16px 20px;
    border-bottom: 1px solid var(--border);
}

.logs-header h2 {
    font-size: 1.1rem;
    font-weight: 700;
}

.logs-content {
    padding: 16px 20px;
    font-family: 'Consolas', 'Courier New', monospace;
    font-size: 0.78rem;
    line-height: 1.8;
    color: var(--text-secondary);
    max-height: 300px;
    overflow-y: auto;
    white-space: pre-wrap;
    word-break: break-all;
    direction: ltr;
    text-align: left;
}

.logs-content::-webkit-scrollbar {
    width: 6px;
}

.logs-content::-webkit-scrollbar-track {
    background: transparent;
}

.logs-content::-webkit-scrollbar-thumb {
    background: var(--border-hover);
    border-radius: 3px;
}

/* ── Toast Notifications ── */
.toast-container {
    position: fixed;
    bottom: 20px;
    left: 20px;
    z-index: 1000;
    display: flex;
    flex-direction: column-reverse;
    gap: 8px;
}

.toast {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 12px 20px;
    background: var(--bg-card);
    border: 1px solid var(--border-hover);
    border-radius: var(--radius);
    box-shadow: var(--shadow-lg);
    font-size: 0.88rem;
    font-weight: 500;
    color: var(--text-primary);
    animation: slideInToast 0.4s cubic-bezier(0.4, 0, 0.2, 1);
    backdrop-filter: blur(10px);
    max-width: 400px;
}

.toast.success { border-right: 3px solid var(--green); }
.toast.error { border-right: 3px solid var(--red); }
.toast.info { border-right: 3px solid var(--blue); }

.toast-exit {
    animation: slideOutToast 0.3s ease forwards;
}

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

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

/* ── Responsive ── */
@media (max-width: 768px) {
    html { font-size: 14px; }
    
    .header-content { height: 60px; }
    .logo h1 { font-size: 1.2rem; }
    .logo .subtitle { display: none; }
    
    .main { padding: 1rem; }
    
    .stats-grid { grid-template-columns: repeat(2, 1fr); gap: 10px; }
    .stat-card { padding: 14px; }
    .stat-value { font-size: 1.5rem; }
    .stat-icon { width: 40px; height: 40px; }
    
    .search-section { flex-direction: column; }
    .search-box { min-width: 100%; }
    .filter-tabs { overflow-x: auto; width: 100%; }
    
    .table-header { flex-direction: column; gap: 8px; align-items: flex-start; }
    
    thead th, tbody td { padding: 10px 12px; font-size: 0.82rem; }
}

@media (max-width: 480px) {
    .stats-grid { grid-template-columns: repeat(2, 1fr); }
}

/* ── Animations ── */
@keyframes fadeIn {
    from { opacity: 0; transform: translateY(10px); }
    to { opacity: 1; transform: translateY(0); }
}

.stat-card {
    animation: fadeIn 0.5s ease forwards;
}

.stat-card:nth-child(1) { animation-delay: 0.05s; }
.stat-card:nth-child(2) { animation-delay: 0.1s; }
.stat-card:nth-child(3) { animation-delay: 0.15s; }
.stat-card:nth-child(4) { animation-delay: 0.2s; }
.stat-card:nth-child(5) { animation-delay: 0.25s; }
.stat-card:nth-child(6) { animation-delay: 0.3s; }

/* Scrollbar */
::-webkit-scrollbar { width: 8px; height: 8px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border-hover); border-radius: 4px; }
::-webkit-scrollbar-thumb:hover { background: var(--text-muted); }
