/* ============================= 
   GLOBAL STYLES & VARIABLES
   ============================= */

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

:root {
    --primary-blue: #0f172a;
    --secondary-blue: #1e293b;
    --accent-blue: #3b82f6;
    --teal: #14b8a6;
    --slate-light: #64748b;
    --slate-dark: #334155;
    --text-primary: #e2e8f0;
    --text-secondary: #94a3b8;
    --border-color: rgba(255, 255, 255, 0.1);
    --success: #10b981;
    --warning: #f59e0b;
    --error: #ef4444;
    --glass-bg: rgba(30, 41, 59, 0.8);
}

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
    background: linear-gradient(135deg, var(--primary-blue) 0%, var(--secondary-blue) 100%);
    color: var(--text-primary);
    min-height: 100vh;
    line-height: 1.6;
}

.container {
    display: flex;
    min-height: 100vh;
}

/* ============================= 
   SIDEBAR NAVIGATION
   ============================= */

.sidebar {
    width: 280px;
    background: var(--glass-bg);
    backdrop-filter: blur(20px);
    border-right: 1px solid var(--border-color);
    padding: 2rem 0;
    position: fixed;
    height: 100vh;
    overflow-y: auto;
    transition: transform 0.3s ease;
}

.sidebar.mobile-hidden {
    transform: translateX(-100%);
}

.logo {
    padding: 0 2rem 2rem;
    border-bottom: 1px solid var(--border-color);
    margin-bottom: 2rem;
}

.logo h1 {
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--accent-blue);
    margin-bottom: 0.25rem;
}

.logo p {
    font-size: 0.875rem;
    color: var(--text-secondary);
}

.nav-menu {
    list-style: none;
    padding: 0 1rem;
}

.nav-item {
    margin-bottom: 0.5rem;
}

.nav-link {
    display: flex;
    align-items: center;
    padding: 0.75rem 1rem;
    color: var(--text-secondary);
    text-decoration: none;
    border-radius: 12px;
    transition: all 0.2s ease;
    font-weight: 500;
}

.nav-link:hover, .nav-link.active {
    background: rgba(59, 130, 246, 0.1);
    color: var(--accent-blue);
    transform: translateX(4px);
}

.nav-icon {
    width: 20px;
    height: 20px;
    margin-right: 0.75rem;
    stroke-width: 2;
}

/* ============================= 
   MAIN CONTENT AREA
   ============================= */

.main-content {
    flex: 1;
    margin-left: 280px;
    padding: 2rem;
    transition: margin-left 0.3s ease;
}

.main-content.full-width {
    margin-left: 0;
}

/* ============================= 
   HEADER
   ============================= */

.header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 2rem;
    padding-bottom: 1rem;
    border-bottom: 1px solid var(--border-color);
}

.header h2 {
    font-size: 1.875rem;
    font-weight: 700;
    color: var(--text-primary);
}

.header-actions {
    display: flex;
    gap: 1rem;
    align-items: center;
}

.mobile-toggle {
    display: none;
    background: none;
    border: none;
    color: var(--text-primary);
    cursor: pointer;
    padding: 0.5rem;
    border-radius: 8px;
    transition: background 0.2s ease;
}

.mobile-toggle:hover {
    background: var(--glass-bg);
}

/* ============================= 
   CARDS & CONTAINERS
   ============================= */

.card {
    background: var(--glass-bg);
    backdrop-filter: blur(20px);
    border: 1px solid var(--border-color);
    border-radius: 16px;
    padding: 1.5rem;
    margin-bottom: 1.5rem;
    transition: all 0.2s ease;
}

.card:hover {
    border-color: rgba(59, 130, 246, 0.3);
    transform: translateY(-2px);
}

/* ============================= 
   STATS GRID
   ============================= */

.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
    gap: 1.5rem;
    margin-bottom: 2rem;
}

.stat-card {
    background: var(--glass-bg);
    backdrop-filter: blur(20px);
    border: 1px solid var(--border-color);
    border-radius: 16px;
    padding: 1.5rem;
    text-align: center;
    transition: all 0.2s ease;
}

.stat-card:hover {
    transform: translateY(-4px);
    border-color: rgba(59, 130, 246, 0.3);
}

.stat-icon {
    width: 48px;
    height: 48px;
    margin: 0 auto 1rem;
    padding: 12px;
    background: rgba(59, 130, 246, 0.1);
    border-radius: 12px;
    color: var(--accent-blue);
}

.stat-value {
    font-size: 2rem;
    font-weight: 700;
    color: var(--text-primary);
    margin-bottom: 0.5rem;
}

.stat-label {
    font-size: 0.875rem;
    color: var(--text-secondary);
    font-weight: 500;
}

/* ============================= 
   BUTTONS
   ============================= */

.btn {
    display: inline-flex;
    align-items: center;
    padding: 0.75rem 1.5rem;
    border: none;
    border-radius: 12px;
    font-weight: 600;
    text-decoration: none;
    cursor: pointer;
    transition: all 0.2s ease;
    font-size: 0.875rem;
}

.btn-primary {
    background: var(--accent-blue);
    color: white;
}

.btn-primary:hover {
    background: #2563eb;
    transform: translateY(-2px);
}

.btn-secondary {
    background: var(--glass-bg);
    color: var(--text-primary);
    border: 1px solid var(--border-color);
}

.btn-secondary:hover {
    background: rgba(59, 130, 246, 0.1);
    border-color: var(--accent-blue);
}

.btn-danger {
    background: var(--error);
    color: white;
}

.btn-danger:hover {
    background: #dc2626;
}

/* ============================= 
   FORMS
   ============================= */

.form-group {
    margin-bottom: 1.5rem;
}

.form-label {
    display: block;
    margin-bottom: 0.5rem;
    font-weight: 600;
    color: var(--text-primary);
}

.form-input, .form-textarea {
    width: 100%;
    padding: 0.75rem 1rem;
    background: rgba(15, 23, 42, 0.5);
    border: 1px solid var(--border-color);
    border-radius: 12px;
    color: var(--text-primary);
    font-size: 0.875rem;
    transition: all 0.2s ease;
}

.form-input:focus, .form-textarea:focus {
    outline: none;
    border-color: var(--accent-blue);
    box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.1);
}

.form-textarea {
    min-height: 120px;
    resize: vertical;
}

/* ============================= 
   TABLES
   ============================= */

.table-container {
    background: var(--glass-bg);
    backdrop-filter: blur(20px);
    border: 1px solid var(--border-color);
    border-radius: 16px;
    overflow: hidden;
}

.table {
    width: 100%;
    border-collapse: collapse;
}

.table th {
    background: rgba(59, 130, 246, 0.1);
    padding: 1rem;
    text-align: left;
    font-weight: 600;
    color: var(--text-primary);
    border-bottom: 1px solid var(--border-color);
}

.table td {
    padding: 1rem;
    border-bottom: 1px solid var(--border-color);
    color: var(--text-secondary);
}

.table tr:hover {
    background: rgba(59, 130, 246, 0.05);
}

/* ============================= 
   STATUS BADGES
   ============================= */

.status-badge {
    display: inline-block;
    padding: 0.25rem 0.75rem;
    border-radius: 20px;
    font-size: 0.75rem;
    font-weight: 600;
    text-transform: uppercase;
}

.status-active {
    background: rgba(16, 185, 129, 0.2);
    color: var(--success);
}

.status-unsubscribed {
    background: rgba(239, 68, 68, 0.2);
    color: var(--error);
}

/* ============================= 
   LOADING & ANIMATIONS
   ============================= */

.loading {
    display: inline-block;
    width: 20px;
    height: 20px;
    border: 2px solid var(--border-color);
    border-radius: 50%;
    border-top-color: var(--accent-blue);
    animation: spin 1s ease-in-out infinite;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

/* ============================= 
   TOAST NOTIFICATIONS
   ============================= */

.toast {
    position: fixed;
    top: 2rem;
    right: 2rem;
    background: var(--glass-bg);
    backdrop-filter: blur(20px);
    border: 1px solid var(--border-color);
    border-radius: 12px;
    padding: 1rem 1.5rem;
    color: var(--text-primary);
    z-index: 1000;
    transform: translateX(400px);
    transition: transform 0.3s ease;
}

.toast.show {
    transform: translateX(0);
}

.toast.success {
    border-color: var(--success);
    background: rgba(16, 185, 129, 0.1);
}

.toast.error {
    border-color: var(--error);
    background: rgba(239, 68, 68, 0.1);
}

/* ============================= 
   MODALS
   ============================= */

.modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.8);
    backdrop-filter: blur(8px);
    display: none;
    align-items: center;
    justify-content: center;
    z-index: 1000;
}

.modal.show {
    display: flex;
}

.modal-content {
    background: var(--secondary-blue);
    border: 1px solid var(--border-color);
    border-radius: 16px;
    padding: 2rem;
    max-width: 500px;
    width: 90%;
    max-height: 80vh;
    overflow-y: auto;
}

.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1.5rem;
    padding-bottom: 1rem;
    border-bottom: 1px solid var(--border-color);
}

.modal-title {
    font-size: 1.25rem;
    font-weight: 700;
    color: var(--text-primary);
}

.modal-close {
    background: none;
    border: none;
    color: var(--text-secondary);
    cursor: pointer;
    padding: 0.5rem;
    border-radius: 8px;
    transition: all 0.2s ease;
}

.modal-close:hover {
    background: var(--glass-bg);
    color: var(--text-primary);
}

/* ============================= 
   SEARCH
   ============================= */

.search-container {
    position: relative;
    margin-bottom: 1.5rem;
}

.search-input {
    width: 100%;
    padding: 0.75rem 1rem 0.75rem 3rem;
    background: rgba(15, 23, 42, 0.5);
    border: 1px solid var(--border-color);
    border-radius: 12px;
    color: var(--text-primary);
    font-size: 0.875rem;
}

.search-icon {
    position: absolute;
    left: 1rem;
    top: 50%;
    transform: translateY(-50%);
    width: 16px;
    height: 16px;
    color: var(--text-secondary);
}

/* ============================= 
   EMPTY STATE
   ============================= */

.empty-state {
    text-align: center;
    padding: 3rem 1rem;
    color: var(--text-secondary);
}

.empty-state-icon {
    width: 64px;
    height: 64px;
    margin: 0 auto 1rem;
    color: var(--slate-light);
}

/* ============================= 
   ACTION BUTTONS
   ============================= */

.action-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 0.5rem;
    border: 1px solid var(--border-color);
    border-radius: 8px;
    background: rgba(59, 130, 246, 0.1);
    color: var(--accent-blue);
    cursor: pointer;
    transition: all 0.2s ease;
    margin-right: 0.5rem;
}

.action-btn:hover {
    background: var(--accent-blue);
    color: white;
    transform: translateY(-2px);
}

.action-btn.danger {
    background: rgba(239, 68, 68, 0.1);
    color: var(--error);
    border-color: rgba(239, 68, 68, 0.3);
}

.action-btn.danger:hover {
    background: var(--error);
    color: white;
}

.action-btn svg {
    width: 14px;
    height: 14px;
}

/* ============================= 
   PAGINATION
   ============================= */

.pagination {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 0.5rem;
    margin-top: 1.5rem;
    padding-top: 1.5rem;
    border-top: 1px solid var(--border-color);
}

.pagination-btn {
    padding: 0.5rem 1rem;
    border: 1px solid var(--border-color);
    border-radius: 8px;
    background: var(--glass-bg);
    color: var(--text-primary);
    cursor: pointer;
    transition: all 0.2s ease;
    font-weight: 500;
    font-size: 0.875rem;
}

.pagination-btn:hover:not(:disabled) {
    background: rgba(59, 130, 246, 0.1);
    border-color: var(--accent-blue);
    color: var(--accent-blue);
}

.pagination-btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.pagination-btn.active {
    background: var(--accent-blue);
    color: white;
    border-color: var(--accent-blue);
}

.pagination-info {
    color: var(--text-secondary);
    font-size: 0.875rem;
}

/* ============================= 
   SECTIONS
   ============================= */

.section {
    display: none;
}

.section.active {
    display: block;
}

/* ============================= 
   SYSTEM STATUS
   ============================= */

.system-status {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-size: 0.875rem;
}

.status-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: var(--success);
}

.status-dot.offline {
    background: var(--error);
}

/* ============================= 
   PROGRESS BAR
   ============================= */

.progress-bar {
    width: 100%;
    height: 8px;
    background: rgba(255, 255, 255, 0.1);
    border-radius: 4px;
    overflow: hidden;
    margin-top: 0.5rem;
}

.progress-fill {
    height: 100%;
    background: var(--accent-blue);
    transition: width 0.3s ease;
}

.progress-fill.warning {
    background: var(--warning);
}

.progress-fill.danger {
    background: var(--error);
}

/* ============================= 
   LOGIN SCREEN
   ============================= */

#loginScreen {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: linear-gradient(135deg, #0f172a 0%, #1e293b 100%);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 2000;
}

/* ============================= 
   RESPONSIVE DESIGN
   ============================= */

@media (max-width: 768px) {
    .sidebar {
        transform: translateX(-100%);
    }

    .sidebar.mobile-visible {
        transform: translateX(0);
    }

    .main-content {
        margin-left: 0;
        padding: 1rem;
    }

    .mobile-toggle {
        display: block;
    }

    .stats-grid {
        grid-template-columns: 1fr;
    }

    .header {
        flex-direction: column;
        align-items: flex-start;
        gap: 1rem;
    }

    .header-actions {
        width: 100%;
        justify-content: flex-start;
    }
}
