/**
 * Easy GA Stats - Main Stylesheet
 * Modern, professional design with light/dark theme support
 */

:root {
    /* Light theme colors */
    --bg-primary: #ffffff;
    --bg-secondary: #f8f9fa;
    --bg-tertiary: #e9ecef;
    --text-primary: #212529;
    --text-secondary: #6c757d;
    --text-muted: #868e96;
    --border-color: #dee2e6;
    --accent-primary: #0066cc;
    --accent-primary-hover: #0052a3;
    --success: #28a745;
    --warning: #ffc107;
    --danger: #dc3545;
    --info: #17a2b8;
    
    /* Layout */
    --container-max-width: 98%;
    --border-radius: 8px;
    --shadow: 0 2px 4px rgba(0,0,0,0.1);
    --shadow-lg: 0 8px 25px rgba(0,0,0,0.15);
}

/* Dark theme */
@media (prefers-color-scheme: dark) {
    :root {
        --bg-primary: #1a1a1a;
        --bg-secondary: #2d2d2d;
        --bg-tertiary: #404040;
        --text-primary: #ffffff;
        --text-secondary: #e0e0e0;
        --text-muted: #b0b0b0;
        --border-color: #404040;
        --accent-primary: #4da6ff;
        --accent-primary-hover: #3399ff;
        --shadow: 0 2px 4px rgba(0,0,0,0.3);
        --shadow-lg: 0 8px 25px rgba(0,0,0,0.4);
    }
}

/* Force dark theme when body has dark class */
body.dark-theme {
    --bg-primary: #1a1a1a;
    --bg-secondary: #2d2d2d;
    --bg-tertiary: #404040;
    --text-primary: #ffffff;
    --text-secondary: #e0e0e0;
    --text-muted: #b0b0b0;
    --border-color: #404040;
    --accent-primary: #4da6ff;
    --accent-primary-hover: #3399ff;
    --shadow: 0 2px 4px rgba(0,0,0,0.3);
    --shadow-lg: 0 8px 25px rgba(0,0,0,0.4);
}

/* Force light theme when body has light class */
body.light-theme {
    --bg-primary: #ffffff;
    --bg-secondary: #f8f9fa;
    --bg-tertiary: #e9ecef;
    --text-primary: #212529;
    --text-secondary: #6c757d;
    --text-muted: #868e96;
    --border-color: #dee2e6;
    --accent-primary: #0066cc;
    --accent-primary-hover: #0052a3;
    --shadow: 0 2px 4px rgba(0,0,0,0.1);
    --shadow-lg: 0 8px 25px rgba(0,0,0,0.15);
}

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

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, sans-serif;
    background-color: var(--bg-primary);
    color: var(--text-primary);
    line-height: 1.6;
    font-size: 16px;
    transition: background-color 0.3s ease, color 0.3s ease;
}

/* Link styles - theme aware */
a {
    color: var(--accent-primary);
    text-decoration: none;
    transition: color 0.2s ease;
}

a:hover,
a:focus {
    color: var(--accent-primary-hover);
    text-decoration: underline;
}

a:visited {
    color: var(--accent-primary);
}

/* Ensure links are visible in all contexts */
.text-muted a {
    color: var(--accent-primary);
}

.text-muted a:hover {
    color: var(--accent-primary-hover);
}

/* Container and layout */
.container {
    max-width: var(--container-max-width);
    margin: 0 auto;
    padding: 0 20px;
    width: 100%;
}

.main-content {
    min-height: calc(100vh - 140px);
    padding: 20px 0;
}

/* Header styles */
.header {
    background-color: var(--bg-secondary);
    border-bottom: 1px solid var(--border-color);
    padding: 0;
    position: sticky;
    top: 0;
    z-index: 100;
    box-shadow: var(--shadow);
}

.header-content {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 15px 0;
}

.logo-area {
    display: flex;
    align-items: center;
    gap: 15px;
}

.logo {
    width: 40px;
    height: 40px;
    background-color: var(--accent-primary);
    border-radius: var(--border-radius);
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    font-weight: bold;
    font-size: 18px;
}

.site-title {
    font-size: 24px;
    font-weight: 600;
    color: var(--text-primary);
    text-decoration: none;
}

/* Section Tabs */
.section-tabs {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 13px;
}

.section-tab {
    color: var(--text-secondary);
    text-decoration: none;
    font-weight: 500;
    padding: 2px 8px;
    border-radius: 4px;
    transition: all 0.2s ease;
}

.section-tab:hover {
    color: var(--accent-primary);
    background-color: var(--bg-tertiary);
}

.section-tab.active {
    color: var(--accent-primary);
    font-weight: 600;
}

.section-divider {
    color: var(--border-color);
    font-weight: 300;
}

/* Navigation */
.nav {
    display: flex;
    align-items: center;
    gap: 30px;
}

.nav-links {
    display: flex;
    gap: 20px;
    list-style: none;
}

.nav-link {
    color: var(--text-secondary);
    text-decoration: none;
    font-weight: 500;
    padding: 8px 12px;
    border-radius: var(--border-radius);
    transition: color 0.2s ease, background-color 0.2s ease;
}

.nav-link:hover,
.nav-link.active {
    color: var(--accent-primary);
    background-color: var(--bg-tertiary);
}

/* User menu */
.user-menu {
    display: flex;
    align-items: center;
    gap: 15px;
}

.theme-toggle {
    background: none;
    border: 1px solid var(--border-color);
    color: var(--text-primary);
    padding: 8px 12px;
    border-radius: var(--border-radius);
    cursor: pointer;
    transition: all 0.2s ease;
}

.theme-toggle:hover {
    background-color: var(--bg-tertiary);
}

/* Cards */
.card {
    background-color: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: var(--border-radius);
    padding: 20px;
    box-shadow: var(--shadow);
    margin-bottom: 20px;
}

.card-header {
    margin-bottom: 20px;
    padding-bottom: 15px;
    border-bottom: 1px solid var(--border-color);
}

.card-title {
    font-size: 20px;
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: 5px;
}

.card-subtitle {
    color: var(--text-secondary);
    font-size: 14px;
}

/* Tables */
.table-container {
    background-color: var(--bg-secondary);
    border-radius: var(--border-radius);
    overflow: hidden;
    box-shadow: var(--shadow);
    margin-bottom: 20px;
}

.table {
    width: 100%;
    border-collapse: collapse;
    font-size: 14px;
}

.table th,
.table td {
    padding: 15px;
    text-align: left;
    border-bottom: 1px solid var(--border-color);
}

.table th {
    background-color: var(--bg-tertiary);
    font-weight: 600;
    color: var(--text-primary);
    font-size: 13px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.table tr:hover {
    background-color: var(--bg-tertiary);
}

/* Buttons */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 10px 20px;
    border: 1px solid transparent;
    border-radius: var(--border-radius);
    font-size: 14px;
    font-weight: 500;
    text-decoration: none;
    cursor: pointer;
    transition: all 0.2s ease;
    background: none;
}

.btn-primary {
    background-color: var(--accent-primary);
    color: white !important;
    border-color: var(--accent-primary);
}

.btn-primary:hover,
.btn-primary:focus,
.btn-primary:visited {
    background-color: var(--accent-primary-hover);
    border-color: var(--accent-primary-hover);
    color: white !important;
    text-decoration: none;
}

.btn-secondary {
    background-color: var(--bg-tertiary);
    color: var(--text-primary) !important;
    border-color: var(--border-color);
}

.btn-secondary:hover,
.btn-secondary:focus,
.btn-secondary:visited {
    background-color: var(--border-color);
    color: var(--text-primary) !important;
    text-decoration: none;
}

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

.btn-success:hover,
.btn-success:focus,
.btn-success:visited {
    background-color: #218838;
    border-color: #1e7e34;
    color: white !important;
    text-decoration: none;
}

.btn-warning {
    background-color: var(--warning);
    color: #212529 !important;
    border-color: var(--warning);
}

.btn-warning:hover,
.btn-warning:focus,
.btn-warning:visited {
    background-color: #e0a800;
    border-color: #d39e00;
    color: #212529 !important;
    text-decoration: none;
}

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

.btn-danger:hover,
.btn-danger:focus,
.btn-danger:visited {
    background-color: #c82333;
    border-color: #bd2130;
    color: white !important;
    text-decoration: none;
}

.btn-sm {
    padding: 6px 12px;
    font-size: 12px;
}

.btn-full {
    width: 100%;
}

/* Forms */
.form-group {
    margin-bottom: 20px;
}

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

.form-control,
input[type="text"],
input[type="email"],
input[type="password"],
input[type="date"],
select {
    width: 100%;
    padding: 12px 16px;
    border: 1px solid var(--border-color);
    border-radius: var(--border-radius);
    font-size: 16px;
    background-color: var(--bg-primary);
    color: var(--text-primary);
    transition: border-color 0.3s ease, box-shadow 0.3s ease;
}

.form-control:focus,
input[type="text"]:focus,
input[type="email"]:focus,
input[type="password"]:focus,
input[type="date"]:focus,
select:focus {
    outline: none;
    border-color: var(--accent-primary);
    box-shadow: 0 0 0 3px rgba(0, 102, 204, 0.1);
}

.form-control:hover,
input[type="text"]:hover,
input[type="email"]:hover,
input[type="password"]:hover,
input[type="date"]:hover,
select:hover {
    border-color: var(--accent-primary);
}

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

select.form-control {
    appearance: none;
    background-image: url("data:image/svg+xml,%3csvg xmlns='http://www.w3.org/2000/svg' fill='none' viewBox='0 0 20 20'%3e%3cpath stroke='%236b7280' stroke-linecap='round' stroke-linejoin='round' stroke-width='1.5' d='m6 8 4 4 4-4'/%3e%3c/svg%3e");
    background-position: right 12px center;
    background-repeat: no-repeat;
    background-size: 16px 12px;
    padding-right: 40px;
}

/* Authentication pages */
.auth-container {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: calc(100vh - 140px);
    padding: 20px;
}

.auth-card {
    background-color: var(--bg-secondary);
    padding: 40px;
    border-radius: var(--border-radius);
    box-shadow: var(--shadow-lg);
    width: 100%;
    max-width: 400px;
    border: 1px solid var(--border-color);
}

.auth-header {
    text-align: center;
    margin-bottom: 30px;
}

.auth-header h1 {
    font-size: 28px;
    font-weight: 700;
    margin-bottom: 8px;
    color: var(--text-primary);
}

.auth-header p {
    color: var(--text-secondary);
}

/* Messages */
.error-message,
.success-message,
.info-message {
    padding: 12px 15px;
    border-radius: var(--border-radius);
    margin-bottom: 20px;
    font-size: 14px;
}

.error-message {
    background-color: rgba(220, 53, 69, 0.1);
    border: 1px solid var(--danger);
    color: var(--danger);
}

.success-message {
    background-color: rgba(40, 167, 69, 0.1);
    border: 1px solid var(--success);
    color: var(--success);
}

.info-message {
    background-color: rgba(23, 162, 184, 0.1);
    border: 1px solid var(--info);
    color: var(--info);
}

/* Status indicators */
.status-badge {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 4px 10px;
    border-radius: 20px;
    font-size: 12px;
    font-weight: 500;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.status-success {
    background-color: rgba(40, 167, 69, 0.1);
    color: var(--success);
}

.status-warning {
    background-color: rgba(255, 193, 7, 0.1);
    color: var(--warning);
}

.status-error {
    background-color: rgba(220, 53, 69, 0.1);
    color: var(--danger);
}

/* Chart containers */
.chart-container {
    position: relative;
    height: 300px;
    margin: 20px 0;
}

/* Footer */
.footer {
    background-color: var(--bg-secondary);
    border-top: 1px solid var(--border-color);
    padding: 20px 0;
    margin-top: auto;
    text-align: center;
    color: var(--text-muted);
    font-size: 14px;
}

.footer a {
    color: var(--text-primary);
    font-weight: 600;
    text-decoration: underline;
}

.footer a:hover,
.footer a:focus {
    color: var(--accent-primary);
    text-decoration: underline;
}

/* Responsive design */
@media (max-width: 768px) {
    .container {
        padding: 0 15px;
    }
    
    .header-content {
        flex-direction: column;
        gap: 15px;
    }
    
    .nav {
        flex-direction: column;
        gap: 15px;
    }
    
    .nav-links {
        flex-wrap: wrap;
        justify-content: center;
    }
    
    .table-container {
        overflow-x: auto;
    }
    
    .auth-card {
        padding: 30px 20px;
    }
}

/* Loading states */
.loading {
    opacity: 0.6;
    pointer-events: none;
}

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

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

/* Utilities */
.text-center { text-align: center; }
.text-right { text-align: right; }
.text-muted { color: var(--text-muted); }
.text-primary { color: var(--accent-primary); }
.text-success { color: var(--success); }
.text-warning { color: var(--warning); }
.text-danger { color: var(--danger); }

.d-flex { display: flex; }
.align-items-center { align-items: center; }
.justify-content-between { justify-content: space-between; }
.gap-2 { gap: 10px; }
.gap-3 { gap: 15px; }

.mb-0 { margin-bottom: 0; }
.mb-2 { margin-bottom: 10px; }
.mb-3 { margin-bottom: 15px; }
.mb-4 { margin-bottom: 20px; }

.mt-2 { margin-top: 10px; }
.mt-3 { margin-top: 15px; }
.mt-4 { margin-top: 20px; }