/* Admin Panel Styles */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    background-color: #f8fafc;
    color: #1e293b;
    line-height: 1.6;
}

.admin-container {
    display: flex;
    min-height: 100vh;
}

/* Sidebar */
.sidebar {
    width: 280px;
    background: #ffffff;
    border-right: 1px solid #e2e8f0;
    display: flex;
    flex-direction: column;
    position: fixed;
    height: 100vh;
    z-index: 1000;
}

.sidebar-header {
    padding: 20px;
    border-bottom: 1px solid #e2e8f0;
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.logo {
    display: flex;
    align-items: center;
    gap: 12px;
    font-weight: 700;
    font-size: 18px;
    color: #1e293b;
}

.logo-icon {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 2px;
    width: 24px;
    height: 24px;
}

.square {
    width: 10px;
    height: 10px;
    background: #3b82f6;
    border-radius: 2px;
}

.collapse-btn {
    color: #64748b;
    cursor: pointer;
    padding: 8px;
    border-radius: 6px;
    transition: all 0.2s;
}

.collapse-btn:hover {
    background: #f1f5f9;
    color: #3b82f6;
}

.sidebar-nav {
    flex: 1;
    padding: 20px 0;
}

.sidebar-nav ul {
    list-style: none;
}

.sidebar-nav li {
    margin: 4px 12px;
    border-radius: 10px;
    transition: background-color 0.25s ease, color 0.25s ease, transform 0.2s ease;
}

.sidebar-nav li a {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 20px;
    color: #64748b;
    text-decoration: none;
    transition: color 0.2s;
    cursor: pointer;
}

.sidebar-nav li:hover {
    background: #f8fafc;
    color: #3b82f6;
    transform: translateX(4px);
}

.sidebar-nav li.active {
    background: #3b82f6;
    color: white;
    position: relative;
}

.sidebar-nav li.active::after {
    content: '*';
    position: absolute;
    right: 20px;
    color: #60a5fa;
    font-weight: bold;
}

/* Main Content */
.main-content {
    flex: 1;
    margin-left: 280px;
    display: flex;
    flex-direction: column;
}

/* Header */
.header {
    background: #ffffff;
    border-bottom: 1px solid #e2e8f0;
    padding: 20px 30px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    position: sticky;
    top: 0;
    z-index: 100;
}

.search-bar {
    position: relative;
    width: 300px;
}

.search-bar i {
    position: absolute;
    left: 12px;
    top: 50%;
    transform: translateY(-50%);
    color: #64748b;
}

.search-bar input {
    width: 100%;
    padding: 10px 12px 10px 40px;
    border: 1px solid #e2e8f0;
    border-radius: 8px;
    background: #f8fafc;
    font-size: 14px;
    transition: all 0.2s;
}

.search-bar input:focus {
    outline: none;
    border-color: #3b82f6;
    background: white;
    box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.1);
}

.header-date {
    font-weight: 600;
    color: #1e293b;
}

.header-actions {
    display: flex;
    align-items: center;
    gap: 20px;
}

.notification-bell {
    font-size: 18px;
    color: #64748b;
    cursor: pointer;
    padding: 8px;
    border-radius: 6px;
    transition: all 0.2s;
}

.notification-bell:hover {
    background: #f1f5f9;
    color: #3b82f6;
}

.user-profile {
    display: flex;
    align-items: center;
    gap: 12px;
    cursor: pointer;
}

.user-info {
    display: flex;
    flex-direction: column;
    text-align: right;
}

.user-name {
    font-weight: 600;
    color: #1e293b;
    font-size: 14px;
}

.user-role {
    font-size: 12px;
    color: #64748b;
}

.user-avatar {
    width: 36px;
    height: 36px;
    background: #3b82f6;
    color: white;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 14px;
}

.logout-btn {
    width: 32px;
    height: 32px;
    background: #f8fafc;
    color: #64748b;
    border: 1px solid #e2e8f0;
    border-radius: 6px;
    display: flex;
    align-items: center;
    justify-content: center;
    text-decoration: none;
    font-size: 14px;
    margin-left: 8px;
    transition: all 0.2s;
}

.logout-btn:hover {
    background: #fee2e2;
    color: #dc2626;
    border-color: #fecaca;
}

/* Dashboard Content */
.dashboard-content {
    padding: 30px;
    flex: 1;
}

/* Stats Grid */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
    gap: 24px;
    margin-bottom: 32px;
}

.stat-card {
    background: white;
    border-radius: 12px;
    padding: 24px;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
    border: 1px solid #e2e8f0;
    display: flex;
    align-items: center;
    gap: 20px;
}

.stat-icon {
    width: 48px;
    height: 48px;
    background: #f0f9ff;
    color: #3b82f6;
    border-radius: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 20px;
}

.stat-content h3 {
    font-size: 14px;
    color: #64748b;
    margin-bottom: 8px;
    font-weight: 500;
}

.stat-number {
    font-size: 32px;
    font-weight: 700;
    color: #1e293b;
    margin-bottom: 8px;
}

.stat-trend {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 12px;
    font-weight: 500;
}

.stat-trend.positive {
    color: #059669;
}

.stat-trend i {
    font-size: 10px;
}

/* Content Grid */
.content-grid {
    display: grid;
    grid-template-columns: 2fr 1fr;
    gap: 24px;
    margin-bottom: 32px;
}

/* Chart Card */
.chart-card {
    background: white;
    border-radius: 12px;
    padding: 24px;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
    border: 1px solid #e2e8f0;
}

.chart-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 24px;
}

.chart-header h3 {
    font-size: 18px;
    font-weight: 600;
    color: #1e293b;
}

.chart-legend {
    display: flex;
    gap: 16px;
}

.legend-item {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 14px;
    color: #64748b;
}

.legend-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
}

.legend-dot.active {
    background: #1e40af;
}

/* Activity Card */
.activity-card {
    background: white;
    border-radius: 12px;
    padding: 24px;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
    border: 1px solid #e2e8f0;
}

.activity-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 20px;
}

.activity-header h3 {
    font-size: 18px;
    font-weight: 600;
    color: #1e293b;
}

.activity-header i {
    color: #64748b;
    cursor: pointer;
    padding: 4px;
    border-radius: 4px;
    transition: all 0.2s;
}

.activity-header i:hover {
    background: #f1f5f9;
    color: #3b82f6;
}

.activity-list {
    display: flex;
    flex-direction: column;
    gap: 16px;
}

.activity-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 0;
    border-bottom: 1px solid #f1f5f9;
}

.activity-item:last-child {
    border-bottom: none;
}

.activity-avatar {
    width: 32px;
    height: 32px;
    background: #f0f9ff;
    color: #3b82f6;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 12px;
}

.activity-content {
    flex: 1;
}

.activity-name {
    font-weight: 500;
    color: #1e293b;
    font-size: 14px;
    margin-bottom: 4px;
}

.activity-time {
    font-size: 12px;
    color: #64748b;
}

.activity-status {
    margin-left: auto;
}

.status-badge {
    padding: 4px 8px;
    border-radius: 12px;
    font-size: 12px;
    font-weight: 500;
}

.status-badge.active {
    background: #dcfce7;
    color: #166534;
}

.see-all-link {
    display: block;
    text-align: center;
    margin-top: 16px;
    color: #3b82f6;
    text-decoration: none;
    font-size: 14px;
    font-weight: 500;
    transition: color 0.2s;
}

.see-all-link:hover {
    color: #1d4ed8;
}

/* Table Card */
.table-card {
    background: white;
    border-radius: 12px;
    padding: 24px;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
    border: 1px solid #e2e8f0;
}

/* Sidebar navigation anchors */
.sidebar-nav li a {
    display: flex;
    align-items: center;
    gap: 12px;
    width: 100%;
    color: inherit;
    text-decoration: none;
}

.sidebar-nav li.active a {
    color: inherit;
}

/* Analytics Page */
.analytics-page {
    display: flex;
    flex-direction: column;
    gap: 28px;
}

.analytics-hero {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 24px;
    padding: 28px 32px;
    border-radius: 18px;
    background: linear-gradient(135deg, #2563eb, #7c3aed);
    color: white;
    position: relative;
    overflow: hidden;
}

.analytics-hero::after {
    content: '';
    position: absolute;
    inset: 0;
    background: radial-gradient(circle at top right, rgba(255, 255, 255, 0.25), transparent 55%);
    pointer-events: none;
}

.analytics-hero-text {
    position: relative;
    z-index: 1;
    max-width: 70%;
}

.analytics-hero-text h1 {
    font-size: 28px;
    font-weight: 700;
    margin-bottom: 10px;
}

.analytics-hero-text p {
    font-size: 15px;
    opacity: 0.9;
}

.analytics-hero-actions {
    position: relative;
    z-index: 1;
}

.ga-refresh-btn {
    display: inline-flex;
    align-items: center;
    gap: 10px;
    padding: 12px 20px;
    border-radius: 10px;
    border: none;
    background: white;
    color: #1d4ed8;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    box-shadow: 0 10px 30px rgba(15, 23, 42, 0.18);
    transition: transform 0.2s ease, box-shadow 0.2s ease, opacity 0.2s;
}

.ga-refresh-btn i {
    font-size: 14px;
}

.ga-refresh-btn:hover:not(:disabled) {
    transform: translateY(-2px);
    box-shadow: 0 14px 35px rgba(15, 23, 42, 0.22);
}

.ga-refresh-btn:disabled {
    opacity: 0.6;
    cursor: not-allowed;
}

.analytics-status {
    font-size: 15px;
    font-weight: 500;
    color: #475569;
}

.analytics-status[data-state="loading"] {
    color: #0ea5e9;
}

.analytics-status[data-state="success"] {
    color: #059669;
}

.analytics-status[data-state="error"] {
    color: #dc2626;
}

.analytics-status[data-state="warning"] {
    color: #d97706;
}

.analytics-metrics-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    gap: 20px;
}

.analytics-metric-card {
    position: relative;
    padding: 20px 22px;
    border-radius: 16px;
    background: linear-gradient(140deg, #f9fafb, #f1f5f9);
    border: 1px solid rgba(148, 163, 184, 0.25);
    box-shadow: 0 10px 30px rgba(15, 23, 42, 0.05);
    overflow: hidden;
}

.analytics-metric-card::after {
    content: '';
    position: absolute;
    inset: 0;
    background: radial-gradient(circle at top right, rgba(79, 70, 229, 0.12), transparent 55%);
    pointer-events: none;
}

.analytics-metric-card:nth-child(odd)::after {
    background: radial-gradient(circle at top right, rgba(14, 165, 233, 0.12), transparent 55%);
}

.analytics-metric-card .metric-label {
    font-size: 13px;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: #64748b;
}

.analytics-metric-card .metric-value {
    display: block;
    margin-top: 12px;
    font-size: 30px;
    font-weight: 700;
    color: #0f172a;
}

.analytics-metric-card .metric-change {
    margin-top: 8px;
    font-size: 13px;
    font-weight: 600;
    transition: opacity 0.2s ease;
    opacity: 0;
}

.analytics-metric-card .metric-change.positive {
    color: #0f9d58;
}

.analytics-metric-card .metric-change.negative {
    color: #dc2626;
}

.analytics-charts-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(320px, 1fr));
    gap: 24px;
}

.analytics-chart-card {
    background: white;
    border-radius: 18px;
    padding: 24px 26px;
    border: 1px solid rgba(148, 163, 184, 0.2);
    box-shadow: 0 18px 40px rgba(15, 23, 42, 0.08);
    display: flex;
    flex-direction: column;
    gap: 18px;
    min-height: 340px;
}

.analytics-map-card {
    min-height: 420px;
}

.analytics-chart-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
}

.analytics-chart-header h2 {
    font-size: 20px;
    font-weight: 600;
    color: #0f172a;
}

.chart-subtitle {
    display: block;
    font-size: 13px;
    font-weight: 500;
    color: #94a3b8;
    margin-top: 6px;
}

.chart-legend {
    display: flex;
    align-items: center;
    gap: 16px;
    font-size: 13px;
    color: #64748b;
}

.chart-legend .legend-dot {
    display: inline-flex;
    width: 10px;
    height: 10px;
    border-radius: 9999px;
    margin-right: 6px;
}

.chart-legend .legend-dot.sessions {
    background: #2563eb;
}

.chart-legend .legend-dot.users {
    background: #0ea5e9;
}

.analytics-chart-body {
    flex: 1;
    position: relative;
}

.analytics-chart-body canvas {
    width: 100% !important;
    height: 100% !important;
}

.analytics-map-body {
    position: relative;
    height: 320px;
    border-radius: 16px;
    overflow: hidden;
    background: #e2e8f0;
}

#gaCountriesMap {
    width: 100%;
    height: 100%;
}

.analytics-map-marker {
    transition: opacity 0.2s ease;
}

.analytics-top-countries {
    list-style: none;
    display: flex;
    flex-direction: column;
    gap: 14px;
    margin-top: auto;
}

.analytics-top-country-item {
    display: grid;
    grid-template-columns: 36px 1fr auto;
    gap: 14px;
    align-items: center;
    padding: 12px 14px;
    border-radius: 12px;
    background: #f8fafc;
    border: 1px solid rgba(148, 163, 184, 0.2);
}

.analytics-top-country-rank {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 28px;
    height: 28px;
    border-radius: 50%;
    background: rgba(2, 132, 199, 0.15);
    color: #0284c7;
    font-weight: 600;
    font-size: 13px;
}

.analytics-top-country-name {
    font-size: 14px;
    font-weight: 600;
    color: #0f172a;
}

.analytics-top-country-value {
    font-size: 13px;
    font-weight: 600;
    color: #0ea5e9;
    white-space: nowrap;
}

.analytics-top-country-empty {
    padding: 18px;
    text-align: center;
    color: #94a3b8;
    font-size: 14px;
    border-radius: 12px;
    background: #f8fafc;
}

.leaflet-control-attribution {
    font-size: 10px !important;
    color: #475569 !important;
}

.analytics-quality-card {
    min-height: 360px;
}

.analytics-quality-grid {
    display: grid;
    grid-template-columns: 220px 1fr;
    gap: 24px;
    align-items: center;
}

.quality-chart {
    position: relative;
    width: 100%;
    max-width: 220px;
    margin: 0 auto;
}

.quality-insights {
    display: flex;
    flex-direction: column;
    gap: 16px;
}

.quality-item span {
    display: block;
    font-size: 13px;
    color: #64748b;
    margin-bottom: 6px;
}

.quality-item strong {
    font-size: 20px;
    font-weight: 700;
    color: #0f172a;
}

.quality-tip {
    font-size: 13px;
    line-height: 1.6;
    color: #475569;
    background: #f8fafc;
    padding: 12px 14px;
    border-radius: 10px;
    border: 1px solid rgba(148, 163, 184, 0.2);
}

.table-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 20px;
    flex-wrap: wrap;
    gap: 16px;
}

.table-header h3 {
    font-size: 18px;
    font-weight: 600;
    color: #1e293b;
}

.table-controls {
    display: flex;
    align-items: center;
    gap: 16px;
    flex-wrap: wrap;
}

.filter-select {
    padding: 8px 12px;
    border: 1px solid #e2e8f0;
    border-radius: 6px;
    background: white;
    font-size: 14px;
    color: #1e293b;
}

.view-toggle {
    display: flex;
    background: #f1f5f9;
    border-radius: 6px;
    padding: 2px;
}

.view-option {
    padding: 6px 12px;
    font-size: 14px;
    cursor: pointer;
    border-radius: 4px;
    transition: all 0.2s;
    color: #64748b;
}

.view-option.active {
    background: white;
    color: #3b82f6;
    font-weight: 500;
}

.btn-secondary {
    padding: 8px 16px;
    background: #f8fafc;
    border: 1px solid #e2e8f0;
    border-radius: 6px;
    color: #1e293b;
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s;
}

.btn-secondary:hover {
    background: #f1f5f9;
    border-color: #cbd5e1;
}

/* Table */
.table-content {
    overflow-x: auto;
}

.subscribers-table {
    width: 100%;
    border-collapse: collapse;
}

.subscribers-table th {
    text-align: left;
    padding: 12px 16px;
    font-weight: 600;
    color: #64748b;
    font-size: 14px;
    border-bottom: 1px solid #e2e8f0;
    white-space: nowrap;
}

.subscribers-table td {
    padding: 16px;
    border-bottom: 1px solid #f1f5f9;
    font-size: 14px;
}

.email-cell {
    display: flex;
    align-items: center;
    gap: 12px;
}

.email-avatar {
    width: 32px;
    height: 32px;
    background: #f0f9ff;
    color: #3b82f6;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 12px;
}

.action-buttons {
    display: flex;
    gap: 8px;
}

.btn-icon {
    width: 32px;
    height: 32px;
    border: 1px solid #e2e8f0;
    background: white;
    border-radius: 6px;
    color: #64748b;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s;
}

.btn-icon:hover {
    background: #f8fafc;
    border-color: #cbd5e1;
    color: #3b82f6;
}

/* Pagination */
.pagination {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-top: 20px;
    padding-top: 20px;
    border-top: 1px solid #e2e8f0;
}

.pagination-btn {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 16px;
    background: #f8fafc;
    border: 1px solid #e2e8f0;
    border-radius: 6px;
    color: #1e293b;
    text-decoration: none;
    font-size: 14px;
    font-weight: 500;
    transition: all 0.2s;
}

.pagination-btn:hover {
    background: #f1f5f9;
    border-color: #cbd5e1;
    color: #3b82f6;
}

.pagination-info {
    font-size: 14px;
    color: #64748b;
    font-weight: 500;
}

/* Status badges */
.status-badge.inactive {
    background: #fef3c7;
    color: #92400e;
}

.status-badge.unsubscribed {
    background: #fee2e2;
    color: #991b1b;
}

/* Responsive */
@media (max-width: 1024px) {
    .content-grid {
        grid-template-columns: 1fr;
    }
    
    .stats-grid {
        grid-template-columns: 1fr;
    }

    .analytics-charts-grid {
        grid-template-columns: 1fr;
    }
}

@media (max-width: 768px) {
    .sidebar {
        transform: translateX(-100%);
        transition: transform 0.3s;
    }
    
    .sidebar.open {
        transform: translateX(0);
    }
    
    .main-content {
        margin-left: 0;
    }
    
    .header {
        padding: 16px 20px;
    }
    
    .search-bar {
        width: 200px;
    }
    
    .dashboard-content {
        padding: 20px;
    }
    
    .table-controls {
        flex-direction: column;
        align-items: flex-start;
    }
    
    .pagination {
        flex-direction: column;
        gap: 12px;
    }

    .analytics-hero {
        flex-direction: column;
        gap: 20px;
    }

    .analytics-hero-text {
        max-width: 100%;
    }

    .analytics-quality-grid {
        grid-template-columns: 1fr;
    }
}
