/* ========== RESET & BASE ========== */
* { margin: 0; padding: 0; box-sizing: border-box; }
:root {
    --bg-primary: #0f172a;
    --bg-secondary: #1e293b;
    --bg-card: #1e293b;
    --bg-hover: #334155;
    --text-primary: #f1f5f9;
    --text-secondary: #94a3b8;
    --accent: #38bdf8;
    --accent-hover: #0ea5e9;
    --success: #22c55e;
    --danger: #ef4444;
    --warning: #f59e0b;
    --border: #334155;
    --radius: 12px;
}

body {
    font-family: 'Inter', 'Segoe UI', system-ui, -apple-system, sans-serif;
    background: var(--bg-primary);
    color: var(--text-primary);
    line-height: 1.6;
}

a { color: var(--accent); text-decoration: none; }
a:hover { color: var(--accent-hover); }

/* ========== LOGIN PAGE ========== */
.login-page {
    display: flex; align-items: center; justify-content: center; min-height: 100vh;
    background: linear-gradient(135deg, #0f172a 0%, #1e1b4b 100%);
}
.login-card {
    background: var(--bg-card); padding: 40px; border-radius: var(--radius);
    width: 100%; max-width: 420px; box-shadow: 0 25px 50px rgba(0,0,0,0.4);
}
.login-header { text-align: center; margin-bottom: 32px; }
.login-header h1 { font-size: 28px; color: var(--accent); margin-bottom: 4px; }
.login-header p { color: var(--text-secondary); }

/* ========== FORMS ========== */
.form-group { margin-bottom: 20px; }
.form-group label { display: block; margin-bottom: 6px; color: var(--text-secondary); font-size: 14px; font-weight: 500; }
.form-group input, .form-group select, .form-group textarea {
    width: 100%; padding: 12px 16px; background: var(--bg-primary); border: 1px solid var(--border);
    border-radius: 8px; color: var(--text-primary); font-size: 15px; transition: border-color 0.2s;
}
.form-group input:focus, .form-group select:focus {
    outline: none; border-color: var(--accent);
}
.form-row { display: flex; gap: 16px; }
.form-row .form-group { flex: 1; }

/* ========== BUTTONS ========== */
.btn {
    display: inline-flex; align-items: center; gap: 8px; padding: 10px 20px;
    border: none; border-radius: 8px; font-size: 14px; font-weight: 600;
    cursor: pointer; transition: all 0.2s;
}
.btn-primary { background: var(--accent); color: #0f172a; }
.btn-primary:hover { background: var(--accent-hover); }
.btn-danger { background: var(--danger); color: white; }
.btn-danger:hover { background: #dc2626; }
.btn-ghost { background: transparent; color: var(--text-secondary); border: 1px solid var(--border); }
.btn-ghost:hover { background: var(--bg-hover); color: var(--text-primary); }
.btn-sm { padding: 6px 12px; font-size: 12px; }
.btn-full { width: 100%; justify-content: center; padding: 14px; font-size: 16px; }

/* ========== ALERTS ========== */
.alert { padding: 12px 16px; border-radius: 8px; margin-bottom: 16px; font-size: 14px; }
.alert-error { background: rgba(239,68,68,0.15); color: #fca5a5; border: 1px solid rgba(239,68,68,0.3); }
.alert-success { background: rgba(34,197,94,0.15); color: #86efac; border: 1px solid rgba(34,197,94,0.3); }

/* ========== DASHBOARD LAYOUT ========== */
.dashboard { display: flex; min-height: 100vh; }

/* Sidebar */
.sidebar {
    width: 260px; background: var(--bg-secondary); border-right: 1px solid var(--border);
    padding: 24px 16px; display: flex; flex-direction: column; position: fixed;
    height: 100vh; overflow-y: auto;
}
.sidebar-logo { font-size: 22px; font-weight: 700; color: var(--accent); padding: 0 8px 24px; border-bottom: 1px solid var(--border); }
.sidebar-nav { margin-top: 24px; flex: 1; }
.nav-item {
    display: flex; align-items: center; gap: 12px; padding: 12px 16px;
    border-radius: 8px; color: var(--text-secondary); cursor: pointer;
    transition: all 0.2s; margin-bottom: 4px; font-size: 14px; font-weight: 500;
}
.nav-item:hover, .nav-item.active { background: var(--bg-hover); color: var(--text-primary); }
.nav-item.active { color: var(--accent); }
.nav-item svg { width: 20px; height: 20px; }

/* Main Content */
.main-content { flex: 1; margin-left: 260px; padding: 32px; }
.page-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 32px; }
.page-header h2 { font-size: 24px; font-weight: 700; }

/* ========== STAT CARDS ========== */
.stats-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 20px; margin-bottom: 32px; }
.stat-card {
    background: var(--bg-card); border: 1px solid var(--border); border-radius: var(--radius);
    padding: 24px; transition: transform 0.2s;
}
.stat-card:hover { transform: translateY(-2px); }
.stat-card .label { color: var(--text-secondary); font-size: 13px; font-weight: 500; text-transform: uppercase; letter-spacing: 0.5px; }
.stat-card .value { font-size: 32px; font-weight: 800; margin: 8px 0 4px; }
.stat-card .sub { color: var(--text-secondary); font-size: 13px; }
.stat-card.blue .value { color: var(--accent); }
.stat-card.green .value { color: var(--success); }
.stat-card.yellow .value { color: var(--warning); }
.stat-card.red .value { color: var(--danger); }

/* ========== TABLE ========== */
.table-container { background: var(--bg-card); border: 1px solid var(--border); border-radius: var(--radius); overflow: hidden; }
.table-header { display: flex; justify-content: space-between; align-items: center; padding: 20px 24px; border-bottom: 1px solid var(--border); }
.table-header h3 { font-size: 16px; }

table { width: 100%; border-collapse: collapse; }
th { text-align: left; padding: 14px 24px; font-size: 12px; font-weight: 600; text-transform: uppercase; letter-spacing: 0.5px; color: var(--text-secondary); border-bottom: 1px solid var(--border); }
td { padding: 16px 24px; border-bottom: 1px solid var(--border); font-size: 14px; }
tr:hover td { background: rgba(255,255,255,0.02); }

.url-cell { max-width: 300px; }
.url-original { color: var(--text-secondary); font-size: 12px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 280px; display: block; }
.url-short { color: var(--accent); font-weight: 600; }

.badge { display: inline-block; padding: 4px 10px; border-radius: 20px; font-size: 11px; font-weight: 600; }
.badge-active { background: rgba(34,197,94,0.15); color: #86efac; }
.badge-inactive { background: rgba(239,68,68,0.15); color: #fca5a5; }

.actions { display: flex; gap: 8px; }

/* ========== SEARCH ========== */
.search-box {
    display: flex; align-items: center; gap: 8px; background: var(--bg-primary);
    border: 1px solid var(--border); border-radius: 8px; padding: 8px 16px; width: 300px;
}
.search-box input { background: transparent; border: none; color: var(--text-primary); font-size: 14px; flex: 1; outline: none; }

/* ========== CHART ========== */
.chart-container { background: var(--bg-card); border: 1px solid var(--border); border-radius: var(--radius); padding: 24px; margin-bottom: 24px; }
.chart-container h3 { margin-bottom: 16px; font-size: 16px; }
.chart-container canvas { width: 100% !important; max-height: 300px; }

.charts-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(400px, 1fr)); gap: 24px; margin-bottom: 24px; }

/* ========== MODAL ========== */
.modal-overlay {
    position: fixed; top: 0; left: 0; right: 0; bottom: 0;
    background: rgba(0,0,0,0.7); display: flex; align-items: center; justify-content: center;
    z-index: 1000; opacity: 0; visibility: hidden; transition: all 0.3s;
}
.modal-overlay.active { opacity: 1; visibility: visible; }
.modal {
    background: var(--bg-card); border-radius: var(--radius); padding: 32px;
    width: 90%; max-width: 520px; max-height: 90vh; overflow-y: auto;
    transform: scale(0.9); transition: transform 0.3s;
}
.modal-overlay.active .modal { transform: scale(1); }
.modal-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 24px; }
.modal-header h3 { font-size: 20px; }
.modal-close { background: none; border: none; color: var(--text-secondary); font-size: 24px; cursor: pointer; }

/* ========== DETAIL/STATS PAGE ========== */
.back-link { display: inline-flex; align-items: center; gap: 8px; color: var(--text-secondary); margin-bottom: 24px; font-size: 14px; }
.back-link:hover { color: var(--accent); }

.detail-header { background: var(--bg-card); border: 1px solid var(--border); border-radius: var(--radius); padding: 24px; margin-bottom: 24px; }
.detail-header .short-url { font-size: 20px; color: var(--accent); font-weight: 700; }
.detail-header .original-url { color: var(--text-secondary); font-size: 14px; margin-top: 4px; word-break: break-all; }

.data-list { list-style: none; }
.data-list li { display: flex; justify-content: space-between; align-items: center; padding: 10px 0; border-bottom: 1px solid var(--border); font-size: 14px; }
.data-list li:last-child { border-bottom: none; }
.data-list .label { color: var(--text-secondary); }
.data-list .val { font-weight: 600; }

/* ========== PAGINATION ========== */
.pagination { display: flex; justify-content: center; gap: 8px; padding: 20px; }
.pagination button {
    padding: 8px 14px; background: var(--bg-hover); border: 1px solid var(--border);
    border-radius: 6px; color: var(--text-primary); cursor: pointer; font-size: 13px;
}
.pagination button.active { background: var(--accent); color: #0f172a; border-color: var(--accent); }
.pagination button:hover:not(.active) { background: var(--border); }

/* ========== TOAST ========== */
.toast-container { position: fixed; bottom: 24px; right: 24px; z-index: 2000; }
.toast {
    background: var(--bg-card); border: 1px solid var(--border); padding: 14px 20px;
    border-radius: 8px; margin-top: 8px; font-size: 14px;
    animation: slideIn 0.3s ease; box-shadow: 0 10px 30px rgba(0,0,0,0.3);
}
.toast.success { border-left: 4px solid var(--success); }
.toast.error { border-left: 4px solid var(--danger); }
@keyframes slideIn { from { transform: translateX(100%); opacity: 0; } to { transform: translateX(0); opacity: 1; } }

/* ========== COPY BUTTON ========== */
.copy-btn { cursor: pointer; padding: 4px 8px; border-radius: 4px; background: var(--bg-hover); border: none; color: var(--accent); font-size: 12px; }
.copy-btn:hover { background: var(--border); }

/* ========== RESPONSIVE ========== */
@media (max-width: 768px) {
    .sidebar { display: none; }
    .main-content { margin-left: 0; padding: 16px; }
    .stats-grid { grid-template-columns: repeat(2, 1fr); }
    .charts-grid { grid-template-columns: 1fr; }
    .table-container { overflow-x: auto; }
    .form-row { flex-direction: column; gap: 0; }
    .page-header { flex-direction: column; gap: 16px; align-items: flex-start; }
    .search-box { width: 100%; }
}
