/**
 * Admin Panel - Styles
 * DKTELAS Admin Dashboard
 * @version 2.0.0
 */

:root {
    /* Primary */
    --primary: #4f46e5;
    --primary-dark: #4338ca;
    --primary-light: #6366f1;

    /* Semantic Colors */
    --success: #10b981;
    --success-dark: #059669;
    --warning: #f59e0b;
    --warning-dark: #d97706;
    --danger: #ef4444;
    --danger-dark: #dc2626;
    --info: #3b82f6;

    /* Dark Theme */
    --dark: #1e293b;
    --dark-deeper: #0f172a;
    --dark-lighter: #334155;
    --dark-surface: rgba(30, 41, 59, 0.8);

    /* Light Theme */
    --light-bg: #f1f5f9;
    --light-surface: #ffffff;

    /* Text */
    --text-primary: #1e293b;
    --text-secondary: #475569;
    --text-muted: #64748b;
    --text-light: rgba(255, 255, 255, 0.9);
    --text-light-muted: rgba(255, 255, 255, 0.6);

    /* Borders */
    --border-color: #e2e8f0;
    --border-dark: rgba(255, 255, 255, 0.1);

    /* Spacing */
    --space-xs: 4px;
    --space-sm: 8px;
    --space-md: 16px;
    --space-lg: 24px;
    --space-xl: 32px;

    /* Border Radius */
    --radius-sm: 6px;
    --radius-md: 8px;
    --radius-lg: 12px;
    --radius-xl: 16px;

    /* Shadows */
    --shadow-sm: 0 1px 3px rgba(0, 0, 0, 0.1);
    --shadow-md: 0 4px 12px rgba(0, 0, 0, 0.1);
    --shadow-lg: 0 10px 40px rgba(0, 0, 0, 0.15);

    /* Layout */
    --sidebar-width: 260px;

    /* Transitions */
    --transition-fast: 0.15s ease;
    --transition-normal: 0.2s ease;
    --transition-slow: 0.3s ease;
}

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

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    background: var(--dark-deeper);
    min-height: 100vh;
    color: var(--text-light);
}

/* ================================
   SIDEBAR
   ================================ */
.sidebar {
    position: fixed;
    left: 0;
    top: 0;
    bottom: 0;
    width: var(--sidebar-width);
    background: linear-gradient(180deg, var(--dark) 0%, var(--dark-deeper) 100%);
    color: var(--text-light);
    padding: var(--space-lg) 0;
    z-index: 1000;
    overflow-y: auto;
    transition: transform var(--transition-slow);
}

.sidebar-brand {
    padding: 20px 25px;
    border-bottom: 1px solid rgba(255,255,255,0.1);
    margin-bottom: 20px;
}

.sidebar-brand h2 {
    font-size: 1.3rem;
    font-weight: 700;
    background: linear-gradient(135deg, #60a5fa, #a78bfa);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.sidebar-brand .telegram-link {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    font-size: 0.7rem;
    color: rgba(255,255,255,0.5);
    text-decoration: none;
    margin-top: 5px;
    transition: color 0.2s;
}

.sidebar-brand .telegram-link:hover {
    color: #0088cc;
}

.sidebar-menu {
    list-style: none;
    padding: 0 15px;
}

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

.sidebar-menu a {
    display: flex;
    align-items: center;
    padding: 12px 15px;
    color: rgba(255,255,255,0.7);
    text-decoration: none;
    border-radius: 8px;
    transition: all 0.2s;
    font-size: 0.9rem;
}

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

.sidebar-menu a i {
    width: 24px;
    margin-right: 12px;
    text-align: center;
}

.sidebar-menu .badge {
    margin-left: auto;
    font-size: 0.7rem;
}

.sidebar-footer {
    position: absolute;
    bottom: 20px;
    left: 15px;
    right: 15px;
}

/* Site Selector */
.site-selector {
    background: rgba(255,255,255,0.1);
    border: 1px solid rgba(255,255,255,0.2);
    border-radius: 8px;
    padding: 10px 15px;
    margin: 0 15px 20px;
}

.site-selector select {
    width: 100%;
    background: transparent;
    border: none;
    color: white;
    font-size: 0.9rem;
    cursor: pointer;
}

.site-selector select:focus {
    outline: none;
}

.site-selector select option {
    background: var(--dark);
    color: white;
}

/* ================================
   MAIN CONTENT
   ================================ */
.main-content {
    margin-left: var(--sidebar-width);
    padding: 24px;
    min-height: 100vh;
}

/* ================================
   PAGE HEADER
   ================================ */
.page-header {
    background: var(--dark);
    border: 1px solid var(--border-dark);
    padding: var(--space-lg);
    border-radius: var(--radius-lg);
    margin-bottom: var(--space-lg);
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.page-header h1 {
    font-size: 1.5rem;
    font-weight: 600;
    color: var(--text-light);
    display: flex;
    align-items: center;
    gap: 10px;
}

.page-header h1 i {
    color: var(--primary);
}

/* ================================
   STATS CARDS
   ================================ */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    gap: 20px;
    margin-bottom: 24px;
}

.stat-card {
    background: var(--dark);
    border: 1px solid var(--border-dark);
    border-radius: var(--radius-lg);
    padding: var(--space-lg);
    position: relative;
    overflow: hidden;
    transition: transform var(--transition-normal), box-shadow var(--transition-normal);
}

.stat-card:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(0,0,0,0.1);
}

.stat-card::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    width: 4px;
    height: 100%;
}

.stat-card.primary::before { background: var(--primary); }
.stat-card.success::before { background: var(--success); }
.stat-card.warning::before { background: var(--warning); }
.stat-card.danger::before { background: var(--danger); }
.stat-card.info::before { background: var(--info); }

.stat-card .stat-icon {
    position: absolute;
    right: 20px;
    top: 50%;
    transform: translateY(-50%);
    font-size: 2.5rem;
    opacity: 0.1;
}

.stat-card .stat-label {
    font-size: 0.75rem;
    color: var(--text-muted);
    text-transform: uppercase;
    font-weight: 600;
    margin-bottom: 8px;
    letter-spacing: 0.5px;
}

.stat-card .stat-value {
    font-size: 1.75rem;
    font-weight: 700;
    color: var(--text-light);
}

.stat-card .stat-change {
    font-size: 0.8rem;
    margin-top: 8px;
}

.stat-change.positive { color: var(--success); }
.stat-change.negative { color: var(--danger); }

/* ================================
   CARDS
   ================================ */
.card {
    background: var(--dark);
    border: 1px solid var(--border-dark);
    border-radius: var(--radius-lg);
    margin-bottom: var(--space-lg);
    color: var(--text-light);
}

.card-header {
    background: var(--dark-lighter);
    border-bottom: 1px solid var(--border-dark);
    padding: 16px 20px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 10px;
}

.card-header h5 {
    margin: 0;
    font-weight: 600;
    color: var(--text-light);
    display: flex;
    align-items: center;
    gap: 8px;
}

.card-body { 
    padding: 20px; 
}

/* ================================
   TABLES
   ================================ */
.table {
    margin-bottom: 0;
}

.table {
    color: var(--text-light);
    --bs-table-bg: transparent;
    --bs-table-striped-bg: var(--dark-lighter);
    --bs-table-hover-bg: var(--dark-lighter);
    background-color: var(--dark);
}

.table-responsive {
    background-color: var(--dark);
}

.table tbody {
    background-color: var(--dark);
}

.table tbody tr {
    background-color: var(--dark);
}

.table th {
    background: var(--dark-lighter);
    font-weight: 600;
    color: var(--text-light-muted);
    font-size: 0.75rem;
    text-transform: uppercase;
    padding: 12px 16px;
    border: none;
    white-space: nowrap;
}

.table td {
    padding: 12px 16px;
    vertical-align: middle;
    border-color: var(--border-dark);
    color: var(--text-light);
}

.table-hover tbody tr:hover {
    background-color: var(--dark-lighter);
}

/* ================================
   BADGES
   ================================ */
.badge {
    padding: 5px 10px;
    border-radius: 6px;
    font-weight: 500;
    font-size: 0.75rem;
}

.bg-purple {
    background-color: #6f42c1 !important;
    color: white;
}

/* ================================
   BUTTONS
   ================================ */
.btn {
    border-radius: var(--radius-md);
    font-weight: 500;
    transition: all var(--transition-normal);
}

.btn-primary {
    background: var(--primary);
    border-color: var(--primary);
}

.btn-primary:hover {
    background: var(--primary-dark);
    border-color: var(--primary-dark);
}

.btn-sm {
    padding: 0.35rem 0.75rem;
    font-size: 0.8rem;
}

/* Button Loading State */
.btn.loading {
    position: relative;
    pointer-events: none;
    color: transparent !important;
}

.btn.loading * {
    visibility: hidden;
}

.btn.loading::after {
    content: '';
    position: absolute;
    width: 20px;
    height: 20px;
    border: 3px solid rgba(255,255,255,0.3);
    border-top-color: #fff;
    border-radius: 50%;
    animation: spin 0.7s linear infinite;
    left: 50%;
    top: 50%;
    margin-left: -10px;
    margin-top: -10px;
}

.btn-outline-primary.loading::after,
.btn-outline-secondary.loading::after,
.btn-secondary.loading::after {
    border-color: rgba(0,0,0,0.2);
    border-top-color: var(--primary);
}

/* ================================
   MODALS
   ================================ */
.modal-header {
    background: var(--dark);
    color: white;
    border-radius: 12px 12px 0 0;
    padding: 16px 20px;
}

.modal-header .btn-close-white {
    filter: brightness(0) invert(1);
}

.modal-content {
    border-radius: 12px;
    border: none;
    box-shadow: 0 20px 60px rgba(0,0,0,0.3);
    background: var(--dark);
    color: var(--text-light);
}

.modal-body {
    background: var(--dark);
    color: var(--text-light);
}

.modal-footer {
    background: var(--dark);
    border-top: 1px solid var(--border-dark);
}

.modal-title {
    font-weight: 600;
    display: flex;
    align-items: center;
    gap: 8px;
}

/* ================================
   LOGIN PAGE - Dark Minimalist Theme
   ================================ */
.login-container {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    background: linear-gradient(180deg, var(--dark) 0%, #0f172a 100%);
    position: relative;
    overflow: hidden;
}

/* Subtle grid pattern */
.login-container::before {
    content: '';
    position: absolute;
    inset: 0;
    background-image:
        linear-gradient(rgba(255,255,255,0.02) 1px, transparent 1px),
        linear-gradient(90deg, rgba(255,255,255,0.02) 1px, transparent 1px);
    background-size: 50px 50px;
    pointer-events: none;
}

/* Accent glow */
.login-container::after {
    content: '';
    position: absolute;
    width: 400px;
    height: 400px;
    background: radial-gradient(circle, rgba(79, 70, 229, 0.15) 0%, transparent 70%);
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    pointer-events: none;
}

.login-box {
    background: rgba(30, 41, 59, 0.8);
    backdrop-filter: blur(20px);
    border: 1px solid rgba(255,255,255,0.1);
    border-radius: 16px;
    padding: 48px 40px;
    width: 100%;
    max-width: 400px;
    position: relative;
    z-index: 1;
}

.login-brand {
    text-align: center;
    margin-bottom: 32px;
}

.login-brand h1 {
    font-size: 1.5rem;
    font-weight: 700;
    background: linear-gradient(135deg, #60a5fa, #a78bfa);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    margin-bottom: 8px;
}

.login-brand p {
    color: var(--text-muted);
    font-size: 0.9rem;
    margin: 0;
}

.login-box .form-label {
    color: rgba(255,255,255,0.7);
    font-size: 0.85rem;
    margin-bottom: 8px;
}

.login-box .input-group-text {
    background: rgba(255,255,255,0.05);
    border: 1px solid rgba(255,255,255,0.1);
    border-right: none;
    border-radius: 8px 0 0 8px;
    color: var(--text-muted);
}

.login-box .form-control {
    background: rgba(255,255,255,0.05);
    border: 1px solid rgba(255,255,255,0.1);
    border-left: none;
    border-radius: 0 8px 8px 0;
    color: white;
    padding: 12px 16px;
    font-size: 0.95rem;
}

.login-box .form-control::placeholder {
    color: rgba(255,255,255,0.4);
}

.login-box .form-control:focus {
    background: rgba(255,255,255,0.08);
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(79, 70, 229, 0.2);
}

.login-box .input-group:focus-within .input-group-text {
    border-color: var(--primary);
    background: rgba(255,255,255,0.08);
    color: var(--primary-light);
}

.btn-login {
    background: var(--primary);
    border: none;
    border-radius: 8px;
    font-weight: 600;
    font-size: 0.95rem;
    padding: 12px 24px;
    transition: all 0.2s ease;
    position: relative;
    color: white;
    width: 100%;
}

.btn-login:hover:not(.loading) {
    background: var(--primary-dark);
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(79, 70, 229, 0.4);
    color: white;
}

.btn-login:active:not(.loading) {
    transform: translateY(0);
}

.btn-login.loading {
    pointer-events: none;
    opacity: 0.8;
}

.btn-login.loading::before {
    content: '';
    position: absolute;
    width: 18px;
    height: 18px;
    border: 2px solid rgba(255,255,255,0.3);
    border-top-color: #fff;
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
    left: 50%;
    top: 50%;
    margin-left: -9px;
    margin-top: -9px;
}

.btn-login.loading span {
    visibility: hidden;
}

.login-box .alert-danger {
    background: rgba(239, 68, 68, 0.1);
    border: 1px solid rgba(239, 68, 68, 0.3);
    color: #fca5a5;
    border-radius: 8px;
}

/* ================================
   LOADING
   ================================ */
.loading-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0,0,0,0.5);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 9999;
    opacity: 0;
    visibility: hidden;
    transition: all 0.2s ease;
}

.loading-overlay.show {
    opacity: 1;
    visibility: visible;
}

.loading-spinner {
    background: var(--dark);
    padding: 30px 40px;
    border-radius: 12px;
    text-align: center;
    box-shadow: 0 10px 40px rgba(0,0,0,0.3);
    border: 1px solid var(--border-dark);
}

.loading-spinner .spinner {
    width: 50px;
    height: 50px;
    border: 4px solid var(--border-dark);
    border-top-color: var(--primary);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
    margin: 0 auto 15px;
}

.loading-spinner p {
    margin: 0;
    color: var(--text-light-muted);
    font-size: 0.9rem;
}

.loading {
    display: inline-block;
    width: 20px;
    height: 20px;
    border: 2px solid var(--border-color);
    border-top-color: var(--primary);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}

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

/* ================================
   UTILITIES
   ================================ */
.hidden {
    display: none !important;
}

.text-muted {
    color: var(--text-muted) !important;
}

.text-light-muted {
    color: var(--text-light-muted) !important;
}

.font-monospace {
    font-family: 'Fira Code', 'Monaco', 'Consolas', monospace;
}

/* Background utilities */
.bg-dark-gradient {
    background: linear-gradient(180deg, var(--dark) 0%, var(--dark-deeper) 100%);
}

.bg-dark-surface {
    background: var(--dark-surface);
    backdrop-filter: blur(20px);
}

/* Spacing utilities */
.gap-xs { gap: var(--space-xs); }
.gap-sm { gap: var(--space-sm); }
.gap-md { gap: var(--space-md); }
.gap-lg { gap: var(--space-lg); }

/* Border utilities */
.border-dark {
    border-color: var(--border-dark) !important;
}

/* Override Bootstrap bg-light for dark theme */
.bg-light {
    background-color: var(--dark-lighter) !important;
    color: var(--text-light) !important;
}

.bg-light .text-muted {
    color: var(--text-light-muted) !important;
}

/* Transition utilities */
.transition-fast { transition: all var(--transition-fast); }
.transition-normal { transition: all var(--transition-normal); }

/* Radius utilities */
.rounded-sm { border-radius: var(--radius-sm); }
.rounded-md { border-radius: var(--radius-md); }
.rounded-lg { border-radius: var(--radius-lg); }
.rounded-xl { border-radius: var(--radius-xl); }

/* ================================
   FORM ELEMENTS
   ================================ */
.form-control,
.form-select {
    background: var(--dark-lighter);
    border: 1px solid var(--border-dark);
    color: var(--text-light);
}

.form-control:focus,
.form-select:focus {
    background: var(--dark);
    border-color: var(--primary);
    box-shadow: 0 0 0 0.2rem rgba(79, 70, 229, 0.25);
    color: var(--text-light);
}

.form-control::placeholder {
    color: var(--text-light-muted);
}

.form-label {
    font-weight: 500;
    color: var(--text-light);
    margin-bottom: 6px;
}

.form-select option {
    background: var(--dark);
    color: var(--text-light);
}

/* ================================
   TABS
   ================================ */
.nav-tabs {
    border-bottom-color: var(--border-dark);
}

.nav-tabs .nav-link {
    color: var(--text-light-muted);
    border: none;
    padding: 10px 16px;
    font-weight: 500;
}

.nav-tabs .nav-link:hover {
    color: var(--primary-light);
    border-color: transparent;
}

.nav-tabs .nav-link.active {
    color: var(--primary-light);
    border-bottom: 2px solid var(--primary);
    background: none;
}

/* ================================
   ALERTS
   ================================ */
.alert {
    border-radius: 8px;
    border: 1px solid var(--border-dark);
}

.alert-light {
    background: var(--dark-lighter);
    color: var(--text-light);
}

.alert-info {
    background: rgba(59, 130, 246, 0.15);
    border-color: rgba(59, 130, 246, 0.3);
    color: #93c5fd;
}

.alert-warning {
    background: rgba(245, 158, 11, 0.15);
    border-color: rgba(245, 158, 11, 0.3);
    color: #fcd34d;
}

/* ================================
   RESPONSIVE
   ================================ */
@media (max-width: 992px) {
    .sidebar {
        transform: translateX(-100%);
    }
    
    .sidebar.show {
        transform: translateX(0);
    }
    
    .main-content {
        margin-left: 0;
    }
    
    .page-header {
        flex-direction: column;
        align-items: flex-start;
        gap: 15px;
    }
}

@media (max-width: 768px) {
    .stats-grid {
        grid-template-columns: 1fr;
    }
    
    .card-header {
        flex-direction: column;
        align-items: flex-start;
    }
    
    .login-box {
        margin: 16px;
        padding: 32px 24px;
        border-radius: 12px;
    }

    .login-brand h1 {
        font-size: 1.3rem;
    }
}

/* ================================
   SCROLLBAR
   ================================ */
::-webkit-scrollbar {
    width: 8px;
    height: 8px;
}

::-webkit-scrollbar-track {
    background: var(--dark-deeper);
}

::-webkit-scrollbar-thumb {
    background: var(--dark-lighter);
    border-radius: 4px;
}

::-webkit-scrollbar-thumb:hover {
    background: var(--text-muted);
}

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

.page-content {
    animation: fadeIn 0.3s ease;
}

/* ================================
   TOAST NOTIFICATIONS
   ================================ */
.toast-container {
    position: fixed;
    top: 20px;
    right: 20px;
    z-index: 10000;
}

.toast {
    background: var(--dark);
    color: var(--text-light);
    border-radius: 8px;
    box-shadow: 0 4px 20px rgba(0,0,0,0.3);
    padding: 16px 20px;
    margin-bottom: 10px;
    display: flex;
    align-items: center;
    gap: 12px;
    animation: slideIn 0.3s ease;
    min-width: 300px;
    border: 1px solid var(--border-dark);
}

.toast.success { border-left: 4px solid var(--success); }
.toast.error { border-left: 4px solid var(--danger); }
.toast.warning { border-left: 4px solid var(--warning); }
.toast.info { border-left: 4px solid var(--info); }

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

/* ================================
   EVENT CARDS
   ================================ */
.event-card {
    transition: transform 0.2s, box-shadow 0.2s;
    border-left-width: 4px !important;
}

.event-card:hover {
    transform: translateY(-3px);
    box-shadow: 0 8px 25px rgba(0,0,0,0.1);
}

.event-card .badge {
    font-size: 0.8rem;
    padding: 6px 10px;
}

.event-card code {
    background: var(--dark-lighter);
    padding: 3px 8px;
    border-radius: 4px;
    color: var(--text-light);
}

.event-card .card-body {
    display: flex;
    flex-direction: column;
}

/* Cores específicas por tipo de evento */
.event-card.border-success {
    border-left-color: var(--success) !important;
}

.event-card.border-warning {
    border-left-color: var(--warning) !important;
}

.event-card.border-danger {
    border-left-color: var(--danger) !important;
}

.event-card.border-info {
    border-left-color: var(--info) !important;
}

.event-card.border-primary {
    border-left-color: var(--primary) !important;
}

/* Grid responsivo para cards */
#events-cards-container {
    max-height: 70vh;
    overflow-y: auto;
    padding-right: 5px;
}

/* ================================
   EVENT STATS CARDS (Contadores)
   ================================ */
.stat-card-clickable {
    transition: transform 0.2s, box-shadow 0.2s, border-color 0.2s;
    border-width: 2px !important;
}

.stat-card-clickable:hover {
    transform: translateY(-5px);
    box-shadow: 0 10px 30px rgba(0,0,0,0.15);
}

.stat-card-clickable:active {
    transform: translateY(-2px);
}

#events-stats-container .card {
    min-height: 130px;
}

#events-stats-container .card-body {
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
}

#events-stats-container .card i {
    opacity: 0.85;
}

#events-stats-container .card:hover i {
    opacity: 1;
    transform: scale(1.1);
    transition: transform 0.2s;
}
