/* ===================================
   AgoraPush Admin - Dark Theme
   =================================== */

/* CSS Variables - Using same palette as main site */
:root {
    /* App Colors */
    --primary-dark: #4A6B7C;
    --primary: #96C2DB;
    --primary-light: #E5EDF1;
    --primary-medium: #7BA8C4;
    
    /* Text Colors */
    --text-primary: #ffffff;
    --text-secondary: rgba(255, 255, 255, 0.7);
    --text-muted: rgba(255, 255, 255, 0.5);
    
    /* Dark Theme Backgrounds */
    --bg-dark: #0a0f1a;
    --bg-darker: #060910;
    --bg-card: rgba(74, 107, 124, 0.1);
    --bg-card-hover: rgba(74, 107, 124, 0.2);
    --bg-glass: rgba(255, 255, 255, 0.03);
    --bg-sidebar: #0d1220;
    --bg-input: rgba(255, 255, 255, 0.05);
    
    /* Accent Colors */
    --accent: #96C2DB;
    --accent-glow: rgba(150, 194, 219, 0.4);
    
    /* Status Colors */
    --success: #4CAF50;
    --success-bg: rgba(76, 175, 80, 0.15);
    --danger: #D32F2F;
    --danger-bg: rgba(211, 47, 47, 0.15);
    --warning: #F57C00;
    --warning-bg: rgba(245, 124, 0, 0.15);
    --info: #2196F3;
    --info-bg: rgba(33, 150, 243, 0.15);
    
    /* Borders */
    --border-subtle: rgba(150, 194, 219, 0.1);
    --border-hover: rgba(150, 194, 219, 0.3);
    
    /* Typography */
    --font-primary: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    
    /* Transitions */
    --transition-fast: 0.15s ease;
    --transition-base: 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    
    /* Border Radius */
    --radius-sm: 6px;
    --radius-md: 10px;
    --radius-lg: 14px;
    --radius-xl: 20px;
    
    /* Shadows */
    --shadow-card: 0 4px 20px rgba(0, 0, 0, 0.3);
    --shadow-glow: 0 0 40px rgba(150, 194, 219, 0.1);
    
    /* Sidebar */
    --sidebar-width: 260px;
}

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

html {
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

body {
    font-family: var(--font-primary);
    font-size: 14px;
    line-height: 1.5;
    color: var(--text-primary);
    background-color: var(--bg-dark);
    overflow-x: hidden;
}

a {
    text-decoration: none;
    color: inherit;
}

button {
    font-family: inherit;
    cursor: pointer;
    border: none;
    background: none;
}

input, select, textarea {
    font-family: inherit;
    font-size: inherit;
}

/* ===================================
   Login Modal
   =================================== */
.login-modal {
    position: fixed;
    inset: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--bg-dark);
    z-index: 1000;
}

.login-card {
    width: 100%;
    max-width: 400px;
    background: var(--bg-card);
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-xl);
    padding: 48px 40px;
    box-shadow: var(--shadow-card);
}

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

.login-logo {
    width: 64px;
    height: 64px;
    border-radius: var(--radius-md);
    margin-bottom: 20px;
}

.login-header h1 {
    font-size: 1.5rem;
    font-weight: 700;
    margin-bottom: 8px;
}

.login-header p {
    color: var(--text-secondary);
    font-size: 0.875rem;
}

.login-form {
    display: flex;
    flex-direction: column;
    gap: 20px;
}

.login-error {
    color: var(--danger);
    font-size: 0.875rem;
    text-align: center;
    padding: 12px;
    background: var(--danger-bg);
    border-radius: var(--radius-sm);
}

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

/* Sidebar */
.sidebar {
    width: var(--sidebar-width);
    background: var(--bg-sidebar);
    border-right: 1px solid var(--border-subtle);
    display: flex;
    flex-direction: column;
    position: fixed;
    top: 0;
    left: 0;
    bottom: 0;
    z-index: 100;
}

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

.sidebar-logo {
    display: flex;
    align-items: center;
    gap: 12px;
    font-weight: 700;
    font-size: 1.125rem;
}

.sidebar-logo img {
    width: 36px;
    height: 36px;
    border-radius: var(--radius-sm);
}

.sidebar-badge {
    font-size: 0.625rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    padding: 4px 8px;
    background: var(--primary-dark);
    border-radius: var(--radius-sm);
    color: var(--text-primary);
}

.sidebar-nav {
    flex: 1;
    padding: 16px 12px;
    display: flex;
    flex-direction: column;
    gap: 4px;
    overflow-y: auto;
}

.nav-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 16px;
    border-radius: var(--radius-md);
    color: var(--text-secondary);
    transition: all var(--transition-fast);
}

.nav-item svg {
    width: 20px;
    height: 20px;
    flex-shrink: 0;
}

.nav-item:hover {
    background: var(--bg-card);
    color: var(--text-primary);
}

.nav-item.active {
    background: var(--primary-dark);
    color: var(--text-primary);
}

.sidebar-footer {
    padding: 16px 12px;
    border-top: 1px solid var(--border-subtle);
}

/* Main Content */
.main-content {
    flex: 1;
    margin-left: var(--sidebar-width);
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

.content-header {
    background: var(--bg-darker);
    border-bottom: 1px solid var(--border-subtle);
    padding: 24px 32px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    position: sticky;
    top: 0;
    z-index: 50;
}

.header-title h1 {
    font-size: 1.5rem;
    font-weight: 700;
    margin-bottom: 4px;
}

.header-title p {
    color: var(--text-muted);
    font-size: 0.875rem;
}

.server-status {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 16px;
    background: var(--bg-card);
    border-radius: var(--radius-md);
    font-size: 0.8125rem;
}

.status-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: var(--warning);
    animation: pulse 2s infinite;
}

.status-dot.online {
    background: var(--success);
}

.status-dot.offline {
    background: var(--danger);
    animation: none;
}

@keyframes pulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.5; }
}

.content-body {
    flex: 1;
    padding: 32px;
}

/* ===================================
   Cards
   =================================== */
.card {
    background: var(--bg-card);
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-lg);
    margin-bottom: 24px;
}

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

.card-header h2 {
    font-size: 1.125rem;
    font-weight: 600;
}

.card-header p {
    color: var(--text-muted);
    font-size: 0.8125rem;
    margin-top: 4px;
}

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

.card-body {
    padding: 24px;
}

/* ===================================
   Stats Grid
   =================================== */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 20px;
    margin-bottom: 24px;
}

.stat-card {
    background: var(--bg-card);
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-lg);
    padding: 24px;
    display: flex;
    align-items: center;
    gap: 16px;
}

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

.stat-icon svg {
    width: 28px;
    height: 28px;
}

.stat-icon.blue {
    background: var(--info-bg);
    color: var(--info);
}

.stat-icon.green {
    background: var(--success-bg);
    color: var(--success);
}

.stat-icon.purple {
    background: rgba(156, 39, 176, 0.15);
    color: #9C27B0;
}

.stat-icon.orange {
    background: var(--warning-bg);
    color: var(--warning);
}

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

.stat-value {
    font-size: 1.75rem;
    font-weight: 700;
    line-height: 1.2;
}

.stat-label {
    color: var(--text-muted);
    font-size: 0.8125rem;
    margin-top: 4px;
}

/* ===================================
   Buttons
   =================================== */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 10px 20px;
    font-size: 0.875rem;
    font-weight: 600;
    border-radius: var(--radius-md);
    transition: all var(--transition-fast);
    cursor: pointer;
    border: none;
}

.btn svg {
    width: 18px;
    height: 18px;
}

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

.btn-primary:hover {
    background: var(--primary-medium);
    transform: translateY(-1px);
}

.btn-secondary {
    background: var(--bg-glass);
    border: 1px solid var(--border-subtle);
    color: var(--text-primary);
}

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

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

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

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

.btn-danger:hover {
    background: #c62828;
}

.btn-success {
    background: var(--success);
    color: white;
}

.btn-success:hover {
    background: #388E3C;
}

.btn-full {
    width: 100%;
}

.btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.btn .spinner {
    width: 18px;
    height: 18px;
    animation: spin 1s linear infinite;
}

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

/* ===================================
   Form Elements
   =================================== */
.form-group {
    margin-bottom: 20px;
}

.form-group label {
    display: block;
    font-size: 0.8125rem;
    font-weight: 500;
    color: var(--text-secondary);
    margin-bottom: 8px;
}

.form-group input,
.form-group select,
.form-group textarea {
    width: 100%;
    padding: 12px 16px;
    background: var(--bg-input);
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-md);
    color: var(--text-primary);
    transition: all var(--transition-fast);
}

.form-group input:focus,
.form-group select:focus,
.form-group textarea:focus {
    outline: none;
    border-color: var(--primary);
    background: var(--bg-card);
}

.form-group input::placeholder,
.form-group textarea::placeholder {
    color: var(--text-muted);
}

.form-group small {
    display: block;
    font-size: 0.75rem;
    color: var(--text-muted);
    margin-top: 6px;
}

.form-row {
    display: flex;
    gap: 16px;
}

.form-row .form-group {
    flex: 1;
}

.flex-grow {
    flex-grow: 1;
}

.checkbox-label {
    display: flex !important;
    align-items: center;
    gap: 10px;
    cursor: pointer;
}

.checkbox-label input[type="checkbox"] {
    width: 18px;
    height: 18px;
    cursor: pointer;
}

.search-input {
    padding: 10px 16px;
    background: var(--bg-input);
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-md);
    color: var(--text-primary);
    font-size: 0.875rem;
    min-width: 200px;
}

.search-input:focus {
    outline: none;
    border-color: var(--primary);
}

/* ===================================
   Tables
   =================================== */
.table-container {
    overflow-x: auto;
}

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

.data-table th,
.data-table td {
    padding: 14px 16px;
    text-align: left;
    border-bottom: 1px solid var(--border-subtle);
}

.data-table th {
    font-size: 0.75rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--text-muted);
    background: var(--bg-glass);
}

.data-table tbody tr:hover {
    background: var(--bg-card-hover);
}

.data-table .loading {
    text-align: center;
    color: var(--text-muted);
    padding: 40px;
}

.data-table .badge {
    display: inline-block;
    padding: 4px 10px;
    font-size: 0.75rem;
    font-weight: 500;
    border-radius: var(--radius-sm);
}

.badge.success {
    background: var(--success-bg);
    color: var(--success);
}

.badge.warning {
    background: var(--warning-bg);
    color: var(--warning);
}

.badge.danger {
    background: var(--danger-bg);
    color: var(--danger);
}

.badge.info {
    background: var(--info-bg);
    color: var(--info);
}

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

.table-actions button {
    padding: 6px 10px;
    font-size: 0.75rem;
}

/* Pagination */
.pagination {
    display: flex;
    justify-content: center;
    gap: 8px;
    margin-top: 24px;
}

.pagination button {
    padding: 8px 14px;
    background: var(--bg-glass);
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-sm);
    color: var(--text-secondary);
    font-size: 0.8125rem;
    transition: all var(--transition-fast);
}

.pagination button:hover:not(:disabled) {
    background: var(--bg-card-hover);
    color: var(--text-primary);
}

.pagination button.active {
    background: var(--primary-dark);
    border-color: var(--primary-dark);
    color: var(--text-primary);
}

.pagination button:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

/* ===================================
   Action Groups
   =================================== */
.action-group {
    margin-bottom: 24px;
}

.action-group h3 {
    font-size: 1rem;
    font-weight: 600;
    margin-bottom: 8px;
}

.action-group p {
    color: var(--text-muted);
    font-size: 0.875rem;
    margin-bottom: 16px;
}

.divider {
    height: 1px;
    background: var(--border-subtle);
    margin: 32px 0;
}

.warning-box {
    display: flex;
    gap: 16px;
    padding: 16px 20px;
    background: var(--warning-bg);
    border: 1px solid rgba(245, 124, 0, 0.2);
    border-radius: var(--radius-md);
    margin-bottom: 20px;
}

.warning-box svg {
    width: 24px;
    height: 24px;
    color: var(--warning);
    flex-shrink: 0;
}

.warning-box strong {
    display: block;
    color: var(--warning);
    margin-bottom: 4px;
}

.warning-box p {
    color: var(--text-secondary);
    font-size: 0.875rem;
    margin: 0;
}

/* Quick Actions */
.quick-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 16px;
}

/* ===================================
   Database Section
   =================================== */
.db-tables-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 16px;
}

.db-table-card {
    background: var(--bg-glass);
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-md);
    padding: 20px;
    text-align: center;
}

.db-table-card h3 {
    font-size: 0.875rem;
    font-weight: 600;
    font-family: monospace;
    color: var(--accent);
    margin-bottom: 4px;
}

.db-table-card p {
    color: var(--text-muted);
    font-size: 0.75rem;
    margin-bottom: 12px;
}

.db-count {
    font-size: 1.25rem;
    font-weight: 700;
}

/* ===================================
   Maintenance Section
   =================================== */
.maintenance-status {
    padding: 20px;
    background: var(--bg-glass);
    border-radius: var(--radius-md);
    margin-bottom: 24px;
}

.status-indicator {
    display: flex;
    align-items: center;
    gap: 16px;
}

.status-badge {
    padding: 6px 12px;
    font-size: 0.75rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    border-radius: var(--radius-sm);
}

.status-badge.active {
    background: var(--danger-bg);
    color: var(--danger);
}

.status-badge.inactive {
    background: var(--success-bg);
    color: var(--success);
}

/* ===================================
   Modals
   =================================== */
.modal {
    position: fixed;
    inset: 0;
    z-index: 1000;
    display: flex;
    align-items: center;
    justify-content: center;
}

.modal-overlay {
    position: absolute;
    inset: 0;
    background: rgba(0, 0, 0, 0.7);
    backdrop-filter: blur(4px);
}

.modal-content {
    position: relative;
    width: 100%;
    max-width: 640px;
    max-height: 90vh;
    background: var(--bg-darker);
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-xl);
    overflow: hidden;
    display: flex;
    flex-direction: column;
}

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

.modal-header h2 {
    font-size: 1.125rem;
    font-weight: 600;
}

.modal-close {
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.5rem;
    color: var(--text-muted);
    background: transparent;
    border: none;
    cursor: pointer;
    border-radius: var(--radius-sm);
    transition: all var(--transition-fast);
}

.modal-close:hover {
    background: var(--bg-card);
    color: var(--text-primary);
}

.modal-body {
    padding: 24px;
    overflow-y: auto;
    flex: 1;
}

.modal-footer {
    padding: 16px 24px;
    border-top: 1px solid var(--border-subtle);
    display: flex;
    justify-content: flex-end;
    gap: 12px;
}

/* Task Modal */
.task-modal {
    max-width: 500px;
}

.task-progress {
    margin-bottom: 20px;
}

.progress-bar {
    height: 8px;
    background: var(--bg-glass);
    border-radius: 4px;
    overflow: hidden;
    margin-bottom: 12px;
}

.progress-fill {
    height: 100%;
    background: linear-gradient(90deg, var(--primary-dark), var(--primary));
    border-radius: 4px;
    transition: width 0.3s ease;
}

.task-status {
    font-size: 0.875rem;
    color: var(--text-secondary);
    text-align: center;
}

.task-log {
    max-height: 200px;
    overflow-y: auto;
    font-family: monospace;
    font-size: 0.75rem;
    background: var(--bg-dark);
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-md);
    padding: 16px;
}

.task-log .log-line {
    color: var(--text-muted);
    margin-bottom: 4px;
}

.task-log .log-line.success {
    color: var(--success);
}

.task-log .log-line.error {
    color: var(--danger);
}

.task-log .log-line.info {
    color: var(--info);
}

/* ===================================
   Toast Notifications
   =================================== */
.toast-container {
    position: fixed;
    bottom: 24px;
    right: 24px;
    z-index: 2000;
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.toast {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 16px 20px;
    background: var(--bg-darker);
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-card);
    animation: slideIn 0.3s ease;
    min-width: 300px;
    max-width: 400px;
}

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

.toast svg {
    width: 20px;
    height: 20px;
    flex-shrink: 0;
}

.toast.success {
    border-color: var(--success);
}

.toast.success svg {
    color: var(--success);
}

.toast.error {
    border-color: var(--danger);
}

.toast.error svg {
    color: var(--danger);
}

.toast.warning {
    border-color: var(--warning);
}

.toast.warning svg {
    color: var(--warning);
}

.toast.info {
    border-color: var(--info);
}

.toast.info svg {
    color: var(--info);
}

.toast-content {
    flex: 1;
}

.toast-title {
    font-weight: 600;
    margin-bottom: 2px;
}

.toast-message {
    font-size: 0.8125rem;
    color: var(--text-secondary);
}

.toast-close {
    padding: 4px;
    color: var(--text-muted);
    cursor: pointer;
    transition: color var(--transition-fast);
}

.toast-close:hover {
    color: var(--text-primary);
}

/* ===================================
   Utility Classes
   =================================== */
.muted {
    color: var(--text-muted);
}

.loading {
    color: var(--text-muted);
    font-style: italic;
}

.truncate {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    max-width: 300px;
}

/* ===================================
   Responsive
   =================================== */
@media (max-width: 1200px) {
    .stats-grid {
        grid-template-columns: repeat(2, 1fr);
    }
    
    .db-tables-grid {
        grid-template-columns: repeat(2, 1fr);
    }
}

@media (max-width: 1024px) {
    :root {
        --sidebar-width: 80px;
    }
    
    .sidebar-logo span,
    .sidebar-badge,
    .nav-item span,
    .sidebar-footer span {
        display: none;
    }
    
    .sidebar-header {
        justify-content: center;
    }
    
    .nav-item {
        justify-content: center;
        padding: 14px;
    }
    
    .sidebar-footer button {
        justify-content: center;
        padding: 14px;
    }
}

@media (max-width: 768px) {
    .sidebar {
        display: none;
    }
    
    .main-content {
        margin-left: 0;
    }
    
    .content-header {
        padding: 20px;
    }
    
    .content-body {
        padding: 20px;
    }
    
    .stats-grid {
        grid-template-columns: 1fr;
    }
    
    .form-row {
        flex-direction: column;
    }
    
    .db-tables-grid {
        grid-template-columns: 1fr;
    }
    
    .quick-actions {
        flex-direction: column;
    }
    
    .quick-actions .btn {
        width: 100%;
    }
}

@media (max-width: 480px) {
    .login-card {
        margin: 20px;
        padding: 32px 24px;
    }
    
    .modal-content {
        margin: 16px;
        max-height: calc(100vh - 32px);
    }
}
