:root {
    --primary-color: #0f172a;
    --primary-light: #1e293b;
    --secondary-color: #3b82f6;
    --secondary-light: #60a5fa;
    --accent-color: #f59e0b;
    --success-color: #10b981;
    --warning-color: #f59e0b;
    --danger-color: #ef4444;
    --dark-color: #0f172a;
    --light-color: #f8fafc;
    --white: #ffffff;
    --text-color: #334155;
    --text-light: #64748b;
    --border-color: #e2e8f0;
    --shadow-sm: 0 1px 2px 0 rgba(0, 0, 0, 0.05);
    --shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06);
    --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -2px rgba(0, 0, 0, 0.05);
    --shadow-xl: 0 20px 25px -5px rgba(0, 0, 0, 0.1), 0 10px 10px -5px rgba(0, 0, 0, 0.04);
}

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

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    background: linear-gradient(135deg, #f8fafc 0%, #e2e8f0 100%);
    color: var(--text-color);
    -webkit-font-smoothing: antialiased;
}

.admin-container {
    display: flex;
    min-height: 100vh;
}

.admin-sidebar {
    width: 220px;
    background: var(--dark-color);
    color: var(--white);
    position: fixed;
    height: 100vh;
    display: flex;
    flex-direction: column;
    z-index: 100;
}

.sidebar-brand {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 16px 18px;
    border-bottom: 1px solid rgba(255,255,255,0.08);
}

.brand-icon {
    width: 32px;
    height: 32px;
    background: var(--secondary-color);
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    font-size: 1rem;
}

.brand-text {
    font-weight: 600;
    font-size: 0.95rem;
    color: #fff;
}

.sidebar-nav {
    flex: 1;
    padding: 12px 10px;
    overflow-y: auto;
}

.nav-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 12px;
    color: #94a3b8;
    text-decoration: none;
    border-radius: 8px;
    font-size: 0.875rem;
    font-weight: 500;
    transition: all 0.2s ease;
    margin-bottom: 2px;
}

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

.nav-item:hover {
    background: rgba(255,255,255,0.08);
    color: #fff;
}

.nav-item.active {
    background: var(--secondary-color);
    color: #fff;
}

.nav-divider {
    height: 1px;
    background: rgba(255,255,255,0.08);
    margin: 10px 0;
}

.sidebar-footer {
    padding: 12px 10px;
    border-top: 1px solid rgba(255,255,255,0.08);
}

.footer-link {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 12px;
    color: #94a3b8;
    text-decoration: none;
    border-radius: 8px;
    font-size: 0.875rem;
    font-weight: 500;
    transition: all 0.2s ease;
}

.footer-link svg {
    width: 18px;
    height: 18px;
}

.footer-link:hover {
    background: rgba(255,255,255,0.08);
    color: #fff;
}

.footer-link.logout:hover {
    background: rgba(239, 68, 68, 0.15);
    color: #ef4444;
}

.admin-main {
    flex: 1;
    margin-left: 220px;
    padding: 24px;
}

.admin-header {
    background: var(--white);
    padding: 16px 24px;
    margin: -24px -24px 24px;
    box-shadow: var(--shadow-sm);
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-bottom: 1px solid var(--border-color);
}

.admin-header h1 {
    color: var(--primary-color);
    font-size: 1.25rem;
    font-weight: 600;
}

.admin-user-info {
    display: flex;
    align-items: center;
    gap: 15px;
}

.dashboard-stats {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
    gap: 20px;
    margin-bottom: 30px;
}

.stat-card {
    background: linear-gradient(135deg, var(--white) 0%, #f8fafc 100%);
    padding: 28px;
    border-radius: 20px;
    box-shadow: var(--shadow);
    border: 1px solid var(--border-color);
    transition: all 0.3s ease;
    position: relative;
    overflow: hidden;
}

.stat-card::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 4px;
    background: linear-gradient(90deg, var(--secondary-color), var(--accent-color));
}

.stat-card:hover {
    transform: translateY(-4px);
    box-shadow: var(--shadow-lg);
}

.stat-card-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 18px;
}

.stat-card-icon {
    font-size: 2.5rem;
    background: linear-gradient(135deg, var(--secondary-color), var(--accent-color));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.stat-card-value {
    font-size: 3rem;
    font-weight: 800;
    background: linear-gradient(135deg, var(--primary-color), var(--secondary-color));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.stat-card-label {
    color: var(--text-light);
    font-size: 0.95rem;
    font-weight: 500;
}

.card {
    background: var(--white);
    border-radius: 20px;
    padding: 32px;
    box-shadow: var(--shadow);
    margin-bottom: 24px;
    border: 1px solid var(--border-color);
    transition: all 0.3s ease;
}

.card:hover {
    box-shadow: var(--shadow-lg);
}

.card h2 {
    background: linear-gradient(135deg, var(--primary-color), var(--secondary-color));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    margin-bottom: 24px;
    padding-bottom: 16px;
    border-bottom: 3px solid transparent;
    border-image: linear-gradient(90deg, var(--secondary-color), var(--accent-color)) 1;
    font-weight: 700;
    font-size: 1.5rem;
}

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

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

.table th {
    background-color: var(--light-color);
    font-weight: 600;
    color: var(--dark-color);
}

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

.btn {
    display: inline-block;
    padding: 12px 24px;
    background: linear-gradient(135deg, var(--primary-color) 0%, #1e40af 100%);
    color: var(--white);
    text-decoration: none;
    border-radius: 12px;
    border: none;
    cursor: pointer;
    font-size: 0.95rem;
    font-weight: 600;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    box-shadow: var(--shadow);
    position: relative;
    overflow: hidden;
}

.btn::before {
    content: '';
    position: absolute;
    top: 0;
    left: -100%;
    width: 100%;
    height: 100%;
    background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.2), transparent);
    transition: left 0.5s;
}

.btn:hover::before {
    left: 100%;
}

.btn:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow-lg);
}

.btn-secondary {
    background: linear-gradient(135deg, var(--secondary-color) 0%, var(--secondary-light) 100%);
}

.btn-success {
    background: linear-gradient(135deg, var(--success-color) 0%, #34d399 100%);
}

.btn-danger {
    background: linear-gradient(135deg, var(--danger-color) 0%, #f87171 100%);
}

.btn-sm {
    padding: 8px 16px;
    font-size: 0.875rem;
}

.badge {
    display: inline-block;
    padding: 5px 10px;
    border-radius: 20px;
    font-size: 0.85rem;
    font-weight: 600;
}

.badge-success {
    background-color: #d1fae5;
    color: #065f46;
}

.badge-warning {
    background-color: #fed7aa;
    color: #92400e;
}

.badge-danger {
    background-color: #fee2e2;
    color: #991b1b;
}

.badge-info {
    background-color: #dbeafe;
    color: #1e40af;
}

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

.form-group label {
    display: block;
    margin-bottom: 5px;
    font-weight: 600;
    color: var(--dark-color);
}

.form-group input,
.form-group select,
.form-group textarea {
    width: 100%;
    padding: 10px;
    border: 1px solid var(--border-color);
    border-radius: 5px;
    font-size: 1rem;
    font-family: inherit;
}

.form-group textarea {
    min-height: 150px;
    resize: vertical;
}

.alert {
    padding: 15px 20px;
    border-radius: 5px;
    margin-bottom: 20px;
}

.alert-success {
    background-color: #d1fae5;
    color: #065f46;
    border-left: 4px solid var(--success-color);
}

.alert-error {
    background-color: #fee2e2;
    color: #991b1b;
    border-left: 4px solid var(--accent-color);
}

.login-container {
    display: flex;
    justify-content: center;
    align-items: center;
    min-height: 100vh;
    background: linear-gradient(135deg, #0f172a 0%, #1e3a8a 50%, #3b82f6 100%);
    position: relative;
    overflow: hidden;
}

.login-container::before {
    content: '';
    position: absolute;
    width: 100%;
    height: 100%;
    background: url('data:image/svg+xml,<svg width="100" height="100" xmlns="http://www.w3.org/2000/svg"><defs><pattern id="grid" width="100" height="100" patternUnits="userSpaceOnUse"><path d="M 100 0 L 0 0 0 100" fill="none" stroke="rgba(255,255,255,0.05)" stroke-width="1"/></pattern></defs><rect width="100%" height="100%" fill="url(%23grid)"/></svg>');
}

.login-card {
    background: rgba(255, 255, 255, 0.95);
    backdrop-filter: blur(20px);
    padding: 48px;
    border-radius: 24px;
    box-shadow: var(--shadow-xl);
    width: 100%;
    max-width: 440px;
    border: 1px solid rgba(255, 255, 255, 0.2);
    position: relative;
    z-index: 1;
    animation: fadeInUp 0.6s ease;
}

.login-card h1 {
    text-align: center;
    background: linear-gradient(135deg, var(--primary-color), var(--secondary-color));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    margin-bottom: 36px;
    font-weight: 800;
    font-size: 2rem;
}

.actions {
    display: flex;
    gap: 10px;
    margin-top: 20px;
}

/* Dashboard amélioré */
.stat-card {
    position: relative;
    overflow: hidden;
}

.stat-card-content {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
}

.stat-card-info {
    flex: 1;
}

.stat-card-icon-wrapper {
    width: 60px;
    height: 60px;
    border-radius: 16px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.8rem;
}

.stat-card-icon-wrapper.primary {
    background: linear-gradient(135deg, rgba(59, 130, 246, 0.15) 0%, rgba(59, 130, 246, 0.05) 100%);
}

.stat-card-icon-wrapper.success {
    background: linear-gradient(135deg, rgba(16, 185, 129, 0.15) 0%, rgba(16, 185, 129, 0.05) 100%);
}

.stat-card-icon-wrapper.warning {
    background: linear-gradient(135deg, rgba(245, 158, 11, 0.15) 0%, rgba(245, 158, 11, 0.05) 100%);
}

.stat-card-icon-wrapper.info {
    background: linear-gradient(135deg, rgba(99, 102, 241, 0.15) 0%, rgba(99, 102, 241, 0.05) 100%);
}

.stat-card-trend {
    font-size: 0.85rem;
    color: var(--text-light);
    margin-top: 8px;
}

.stat-card-trend span {
    font-weight: 600;
}

.stat-card-trend.trend-up span {
    color: var(--success-color);
}

.stat-card-trend.trend-success span {
    color: var(--success-color);
}

.stat-card-footer {
    margin-top: 16px;
    padding-top: 16px;
    border-top: 1px solid var(--border-color);
}

.stat-card-footer a {
    color: var(--secondary-color);
    text-decoration: none;
    font-size: 0.9rem;
    font-weight: 500;
    transition: all 0.3s ease;
}

.stat-card-footer a:hover {
    color: var(--primary-color);
}

.stat-card-progress {
    margin-top: 16px;
    height: 6px;
    background: var(--border-color);
    border-radius: 10px;
    overflow: hidden;
}

.stat-card-progress .progress-bar {
    height: 100%;
    background: linear-gradient(90deg, var(--success-color), #34d399);
    border-radius: 10px;
    transition: width 1s ease;
}

.stat-card-primary::before { background: linear-gradient(90deg, #3b82f6, #60a5fa); }
.stat-card-success::before { background: linear-gradient(90deg, #10b981, #34d399); }
.stat-card-warning::before { background: linear-gradient(90deg, #f59e0b, #fbbf24); }
.stat-card-info::before { background: linear-gradient(90deg, #6366f1, #818cf8); }

/* Mini stats */
.dashboard-stats-secondary {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 16px;
    margin-bottom: 30px;
}

.mini-stat-card {
    background: var(--white);
    padding: 20px;
    border-radius: 16px;
    display: flex;
    align-items: center;
    gap: 16px;
    box-shadow: var(--shadow-sm);
    border: 1px solid var(--border-color);
    transition: all 0.3s ease;
}

.mini-stat-card:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow);
}

.mini-stat-icon {
    font-size: 2rem;
}

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

.mini-stat-value {
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--primary-color);
}

.mini-stat-label {
    font-size: 0.85rem;
    color: var(--text-light);
}

/* Charts */
.dashboard-charts {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 24px;
    margin-bottom: 30px;
}

.chart-card {
    background: var(--white);
    padding: 24px;
    border-radius: 20px;
    box-shadow: var(--shadow);
    border: 1px solid var(--border-color);
}

.chart-card h3 {
    font-size: 1.1rem;
    color: var(--primary-color);
    margin-bottom: 20px;
    padding-bottom: 12px;
    border-bottom: 2px solid var(--border-color);
}

.chart-content {
    min-height: 200px;
}

/* Horizontal bars */
.horizontal-bars {
    display: flex;
    flex-direction: column;
    gap: 16px;
}

.bar-item {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.bar-label {
    display: flex;
    justify-content: space-between;
    font-size: 0.9rem;
}

.bar-label span:first-child {
    color: var(--text-color);
    font-weight: 500;
}

.bar-value {
    color: var(--text-light);
    font-weight: 600;
}

.bar-track {
    height: 10px;
    background: var(--light-color);
    border-radius: 10px;
    overflow: hidden;
}

.bar-fill {
    height: 100%;
    border-radius: 10px;
    transition: width 1s ease;
}

/* Priority grid */
.priority-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 16px;
}

.priority-item {
    background: var(--light-color);
    padding: 16px;
    border-radius: 12px;
    display: flex;
    align-items: center;
    gap: 12px;
}

.priority-icon {
    font-size: 1.5rem;
}

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

.priority-count {
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--primary-color);
}

.priority-label {
    font-size: 0.85rem;
    color: var(--text-light);
}

.no-data {
    text-align: center;
    color: var(--text-light);
    padding: 40px;
    font-style: italic;
}

/* Animations */
@keyframes fadeInUp {
    from {
        opacity: 0;
        transform: translateY(20px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.stat-card {
    animation: fadeInUp 0.5s ease forwards;
}

.stat-card:nth-child(1) { animation-delay: 0.1s; }
.stat-card:nth-child(2) { animation-delay: 0.2s; }
.stat-card:nth-child(3) { animation-delay: 0.3s; }
.stat-card:nth-child(4) { animation-delay: 0.4s; }

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

@media (max-width: 768px) {
    .admin-sidebar {
        width: 200px;
    }
    
    .admin-main {
        margin-left: 200px;
    }
    
    .dashboard-stats {
        grid-template-columns: 1fr;
    }
    
    .dashboard-stats-secondary {
        grid-template-columns: 1fr 1fr;
    }
    
    .priority-grid {
        grid-template-columns: 1fr;
    }
}

/* Dashboard Grid */
.dashboard-grid-2 {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 24px;
    margin-bottom: 24px;
}

/* Device Grid */
.device-grid {
    display: flex;
    flex-direction: column;
    gap: 16px;
}

.device-item {
    display: flex;
    align-items: center;
    gap: 16px;
    padding: 16px;
    background: var(--light-color);
    border-radius: 12px;
}

.device-icon {
    font-size: 2rem;
}

.device-info {
    flex: 1;
}

.device-name {
    font-weight: 600;
    color: var(--primary-color);
}

.device-stats {
    font-size: 0.9rem;
    color: var(--text-light);
}

.device-count {
    font-weight: 700;
    color: var(--primary-color);
}

.device-bar {
    width: 80px;
    height: 8px;
    background: var(--border-color);
    border-radius: 10px;
    overflow: hidden;
}

.device-bar-fill {
    height: 100%;
    border-radius: 10px;
    transition: width 1s ease;
}

/* Top Pages */
.top-pages-list, .top-articles-list {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.top-page-item, .top-article-item {
    display: flex;
    align-items: center;
    gap: 16px;
    padding: 14px 16px;
    background: var(--light-color);
    border-radius: 12px;
    transition: all 0.3s ease;
}

.top-page-item:hover, .top-article-item:hover {
    background: #e2e8f0;
    transform: translateX(4px);
}

.page-rank, .article-rank {
    width: 32px;
    height: 32px;
    background: linear-gradient(135deg, var(--secondary-color), var(--secondary-light));
    color: white;
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    font-size: 0.9rem;
}

.page-url {
    flex: 1;
    font-size: 0.9rem;
    color: var(--text-color);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.page-views, .article-views {
    font-weight: 600;
    color: var(--secondary-color);
    font-size: 0.9rem;
    white-space: nowrap;
}

.article-info {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 4px;
    overflow: hidden;
}

.article-title {
    font-weight: 500;
    color: var(--text-color);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.article-date {
    font-size: 0.8rem;
    color: var(--text-light);
}

/* Card Footer */
.card-footer {
    margin-top: 20px;
    padding-top: 16px;
    border-top: 1px solid var(--border-color);
    text-align: center;
}

/* Chart Cards */
.chart-card-wide, .chart-card-full {
    grid-column: span 2;
}

/* Analytics Header */
.analytics-header {
    margin-bottom: 30px;
}

.analytics-header h2 {
    font-size: 1.8rem;
    background: linear-gradient(135deg, var(--primary-color), var(--secondary-color));
    -webkit-background-clip: text;
    background-clip: text;
    -webkit-text-fill-color: transparent;
    margin-bottom: 8px;
}

.analytics-header p {
    color: var(--text-light);
}

/* Referrers List */
.referrers-list {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.referrer-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 12px 16px;
    background: var(--light-color);
    border-radius: 10px;
}

.referrer-url {
    font-size: 0.9rem;
    color: var(--text-color);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    flex: 1;
    margin-right: 16px;
}

.referrer-count {
    font-weight: 700;
    color: var(--secondary-color);
}

/* Inline Progress */
.inline-progress {
    display: flex;
    align-items: center;
    gap: 10px;
}

.inline-progress-bar {
    height: 8px;
    background: linear-gradient(90deg, var(--secondary-color), var(--secondary-light));
    border-radius: 10px;
    min-width: 20px;
}

.inline-progress span {
    font-size: 0.85rem;
    color: var(--text-light);
    min-width: 45px;
}

/* Responsive Grid */
@media (max-width: 1200px) {
    .dashboard-grid-2 {
        grid-template-columns: 1fr;
    }
    
    .chart-card-wide, .chart-card-full {
        grid-column: span 1;
    }
}
