/* ================================================
   ANALYTICS PAGE - Modern Dashboard Styling
   ================================================ */

/* ================================================
   1. ANALYTICS CONTENT & CONTAINER
   ================================================ */

.analytics-content {
    flex: 1;
    padding: 32px 24px;
    overflow-y: auto;
    background: linear-gradient(135deg, #0f1419 0%, #1a1f2e 100%);
}

.analytics-container {
    max-width: 1600px;
    margin: 0 auto;
}

.analytics-container h1 {
    font-size: 38px;
    font-weight: 700;
    color: #ffffff;
    margin-bottom: 8px;
    background: linear-gradient(135deg, #00d084 0%, #0099cc 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    letter-spacing: -0.5px;
}

.analytics-subtitle {
    color: #9ca3af;
    font-size: 16px;
    margin-bottom: 32px;
    margin-top: 0;
}

/* ================================================
   2. ANALYTICS HEADER - Controls
   ================================================ */

.analytics-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 40px;
    gap: 24px;
    flex-wrap: wrap;
}

.analytics-title-group {
    flex: 1;
    min-width: 250px;
}

.analytics-controls {
    display: flex;
    gap: 16px;
    align-items: center;
}

.date-range-select,
.export-btn {
    padding: 12px 18px;
    background: linear-gradient(135deg, #1a1f2e 0%, #2d3748 100%);
    border: 1px solid rgba(20, 184, 166, 0.2);
    border-radius: 10px;
    color: #ffffff;
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.3s ease;
    font-family: inherit;
}

.date-range-select:hover,
.export-btn:hover {
    border-color: rgba(20, 184, 166, 0.5);
    background: linear-gradient(135deg, #2d3748 0%, #374151 100%);
    box-shadow: 0 4px 12px rgba(20, 184, 166, 0.15);
}

.date-range-select {
    min-width: 160px;
    appearance: none;
    background-color: #1a1f2e;
    background-image: url("data:image/svg+xml;charset=UTF-8,%3csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%2314b8a6' stroke-width='2.5'%3e%3cpolyline points='6 9 12 15 18 9'%3e%3c/polyline%3e%3c/svg%3e");
    background-repeat: no-repeat;
    background-position: right 12px center;
    background-size: 16px;
    padding-right: 40px;
    padding-left: 18px;
}

.date-range-select:focus {
    outline: none;
    border-color: rgba(20, 184, 166, 0.6);
    background-color: #2d3748;
    box-shadow: 0 0 0 3px rgba(20, 184, 166, 0.1);
}

.date-range-select:focus-visible {
    outline: 2px solid #14b8a6;
    outline-offset: 2px;
}

.date-range-select option {
    background: #2d3748;
    color: #ffffff;
    padding: 10px 8px;
    border: none;
    font-size: 14px;
    line-height: 1.5;
}

.date-range-select option:checked {
    background: #14b8a6;
    color: #1a1f2e;
    font-weight: 600;
}

.export-btn {
    display: flex;
    align-items: center;
    gap: 8px;
    white-space: nowrap;
}

.export-btn .icon {
    width: 18px;
    height: 18px;
    stroke-width: 2;
}

/* ================================================
   3. METRICS OVERVIEW - Key Metrics Cards
   ================================================ */

.metrics-overview {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
    gap: 20px;
    margin-bottom: 40px;
}

.metric-card {
    background: linear-gradient(135deg, #1a1f2e 0%, #2d3748 100%);
    border: 1px solid rgba(20, 184, 166, 0.15);
    border-radius: 14px;
    padding: 24px;
    transition: all 0.4s cubic-bezier(0.4, 0, 0.2, 1);
    position: relative;
    overflow: hidden;
    cursor: pointer;
    box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.3);
    animation: slideInUp 0.6s cubic-bezier(0.4, 0, 0.2, 1) forwards;
    opacity: 0;
}

.metric-card:nth-child(1) {
    animation-delay: 0.1s;
}

.metric-card:nth-child(2) {
    animation-delay: 0.15s;
}

.metric-card:nth-child(3) {
    animation-delay: 0.2s;
}

.metric-card:nth-child(4) {
    animation-delay: 0.25s;
}

@keyframes slideInUp {
    from {
        opacity: 0;
        transform: translateY(24px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.metric-card::before {
    content: "";
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 3px;
    background: linear-gradient(90deg, #14b8a6, #06b6d4, #3b82f6);
    background-size: 200% 100%;
}

.metric-card::after {
    content: "";
    position: absolute;
    inset: 0;
    background: radial-gradient(600px at 50% 50%, rgba(20, 184, 166, 0.03) 0%, transparent 100%);
    pointer-events: none;
}

.metric-card:hover {
    border-color: rgba(20, 184, 166, 0.4);
    box-shadow:
        0 20px 25px -5px rgba(20, 184, 166, 0.15),
        0 10px 10px -5px rgba(0, 0, 0, 0.3);
    transform: translateY(-6px);
}

.metric-card-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    margin-bottom: 16px;
}

.metric-card-header h3 {
    font-size: 14px;
    font-weight: 600;
    color: #d1d5db;
    margin: 0;
}

.trend-badge {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 6px 12px;
    border-radius: 6px;
    font-size: 13px;
    font-weight: 600;
}

.trend-badge.positive {
    background: rgba(16, 185, 129, 0.15);
    color: #10b981;
}

.trend-badge.negative {
    background: rgba(239, 68, 68, 0.15);
    color: #ef4444;
}

.trend-badge .icon {
    width: 14px;
    height: 14px;
    stroke-width: 2.5;
}

.metric-value {
    font-size: 32px;
    font-weight: 700;
    color: #14b8a6;
    margin-bottom: 8px;
    font-variant-numeric: tabular-nums;
}

.metric-change {
    font-size: 13px;
    color: #9ca3af;
    margin-bottom: 16px;
}

.mini-chart {
    display: flex;
    align-items: flex-end;
    gap: 4px;
    height: 40px;
}

.chart-bar {
    flex: 1;
    background: linear-gradient(180deg, #14b8a6, #06b6d4);
    border-radius: 4px 4px 0 0;
    min-height: 4px;
    opacity: 0.7;
    transition: all 0.3s ease;
}

.metric-card:hover .chart-bar {
    opacity: 1;
}

/* ================================================
   4. ANALYTICS GRID - Main Content Grid
   ================================================ */

.analytics-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(350px, 1fr));
    gap: 24px;
    margin-bottom: 32px;
}

.analytics-card {
    background: linear-gradient(135deg, #1a1f2e 0%, #2d3748 100%);
    border: 1px solid rgba(20, 184, 166, 0.15);
    border-radius: 14px;
    padding: 28px;
    transition: all 0.3s ease;
    animation: fadeInScale 0.6s ease-out forwards;
    opacity: 0;
}

.analytics-card:nth-child(1) {
    grid-column: 1 / -1;
    animation-delay: 0.1s;
}

.analytics-card:nth-child(2) {
    animation-delay: 0.15s;
}

.analytics-card:nth-child(3) {
    animation-delay: 0.2s;
}

.analytics-card:nth-child(4) {
    animation-delay: 0.25s;
}

.analytics-card:nth-child(5) {
    animation-delay: 0.3s;
}

.analytics-card:nth-child(6) {
    animation-delay: 0.35s;
}

.analytics-card:nth-child(7) {
    animation-delay: 0.4s;
}

@keyframes fadeInScale {
    from {
        opacity: 0;
        transform: scale(0.95);
    }
    to {
        opacity: 1;
        transform: scale(1);
    }
}

.analytics-card:hover {
    border-color: rgba(20, 184, 166, 0.3);
    box-shadow:
        0 20px 25px -5px rgba(20, 184, 166, 0.1),
        0 10px 10px -5px rgba(0, 0, 0, 0.2);
    transform: translateY(-4px);
}

.analytics-card::before {
    content: "";
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 2px;
    background: linear-gradient(90deg, #14b8a6, #06b6d4);
    border-radius: 14px 14px 0 0;
}

.card-title {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    margin-bottom: 24px;
    gap: 16px;
}

.card-title h3 {
    font-size: 18px;
    font-weight: 600;
    color: #ffffff;
    margin: 0;
}

/* ================================================
   5. CHART LEGEND
   ================================================ */

.chart-legend {
    display: flex;
    gap: 16px;
    flex-wrap: wrap;
}

.legend-item {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 13px;
    color: #9ca3af;
}

.legend-color {
    width: 12px;
    height: 12px;
    border-radius: 3px;
}

.legend-color.twitter {
    background: #14b8a6;
}

.legend-color.email {
    background: #3b82f6;
}

.legend-color.organic {
    background: #f59e0b;
}

.legend-label {
    font-weight: 500;
}

/* ================================================
   6. CHART CONTAINER - SVG Charts
   ================================================ */

.chart-container {
    position: relative;
    width: 100%;
    height: 300px;
    margin-bottom: 16px;
}

.chart-area {
    position: absolute;
    inset: 0;
    display: flex;
    align-items: center;
    justify-content: center;
}

.line-chart {
    width: 100%;
    height: 100%;
    filter: drop-shadow(0 0 1px rgba(0, 0, 0, 0.1));
}

/* ================================================
   7. FUNNEL VISUALIZATION
   ================================================ */

.funnel-container {
    display: flex;
    flex-direction: column;
    gap: 20px;
}

.funnel-item {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.funnel-label {
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-size: 13px;
}

.funnel-name {
    font-weight: 600;
    color: #d1d5db;
}

.funnel-count {
    font-weight: 700;
    color: #14b8a6;
    font-variant-numeric: tabular-nums;
}

.funnel-bar {
    height: 24px;
    background: rgba(20, 184, 166, 0.1);
    border-radius: 4px;
    overflow: hidden;
    position: relative;
    border: 1px solid rgba(20, 184, 166, 0.2);
}

.funnel-fill {
    height: 100%;
    background: linear-gradient(90deg, #14b8a6, #06b6d4);
    border-radius: 4px;
    animation: slideRight 1.2s ease-out forwards;
    opacity: 0;
}

.funnel-item:nth-child(1) .funnel-fill {
    animation-delay: 0.1s;
}

.funnel-item:nth-child(2) .funnel-fill {
    animation-delay: 0.3s;
}

.funnel-item:nth-child(3) .funnel-fill {
    animation-delay: 0.5s;
}

.funnel-item:nth-child(4) .funnel-fill {
    animation-delay: 0.7s;
}

@keyframes slideRight {
    from {
        width: 0;
        opacity: 0;
    }
    to {
        width: 100%;
        opacity: 1;
    }
}

/* ================================================
   8. ANALYTICS TABLE
   ================================================ */

.table-container {
    overflow-x: auto;
}

.analytics-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 14px;
}

.analytics-table thead {
    border-bottom: 1px solid rgba(20, 184, 166, 0.2);
}

.analytics-table th {
    padding: 12px 0;
    text-align: left;
    font-weight: 600;
    color: #9ca3af;
    font-size: 12px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.analytics-table td {
    padding: 16px 0;
    border-bottom: 1px solid rgba(255, 255, 255, 0.05);
    color: #d1d5db;
    transition: all 0.3s ease;
}

.analytics-table tbody tr {
    transition: all 0.3s ease;
}

.analytics-table tbody tr:hover {
    background: rgba(20, 184, 166, 0.05);
}

.analytics-table tbody tr:hover td {
    color: #ffffff;
}

.page-title {
    font-weight: 600;
    color: #14b8a6;
}

/* ================================================
   9. TRAFFIC SOURCES
   ================================================ */

.sources-list {
    display: flex;
    flex-direction: column;
    gap: 16px;
}

.source-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 16px;
    background: rgba(255, 255, 255, 0.03);
    border-radius: 10px;
    border: 1px solid rgba(255, 255, 255, 0.05);
    transition: all 0.3s ease;
}

.source-item:hover {
    background: rgba(20, 184, 166, 0.08);
    border-color: rgba(20, 184, 166, 0.2);
    transform: translateX(4px);
}

.source-info {
    display: flex;
    align-items: center;
    gap: 12px;
    flex: 1;
}

.source-icon {
    width: 40px;
    height: 40px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(20, 184, 166, 0.15);
    border-radius: 8px;
    color: #14b8a6;
    font-size: 20px;
}

.source-icon.linkedin {
    background: rgba(59, 130, 246, 0.15);
    color: #3b82f6;
}

.source-icon.facebook {
    background: rgba(59, 130, 246, 0.15);
    color: #1f2937;
}

.source-icon.organic {
    background: rgba(245, 158, 11, 0.15);
    color: #f59e0b;
}

.source-icon svg {
    width: 24px;
    height: 24px;
}

.source-details {
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.source-name {
    font-weight: 600;
    color: #ffffff;
    font-size: 14px;
}

.source-percentage {
    font-size: 12px;
    color: #9ca3af;
}

.source-count {
    font-weight: 700;
    color: #14b8a6;
    font-size: 18px;
    font-variant-numeric: tabular-nums;
}

/* ================================================
   10. DEVICE BREAKDOWN
   ================================================ */

.device-breakdown {
    display: flex;
    flex-direction: column;
    gap: 24px;
}

.device-item {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.device-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-size: 14px;
    font-weight: 600;
}

.device-name {
    color: #d1d5db;
}

.device-stat {
    color: #14b8a6;
    font-size: 16px;
}

.device-bar {
    height: 20px;
    background: rgba(255, 255, 255, 0.05);
    border-radius: 10px;
    overflow: hidden;
    border: 1px solid rgba(20, 184, 166, 0.1);
}

.device-fill {
    height: 100%;
    border-radius: 10px;
    transition: all 0.6s cubic-bezier(0.4, 0, 0.2, 1);
    animation: deviceFill 1s ease-out forwards;
    animation-fill-mode: both;
}

.device-item:nth-child(1) .device-fill {
    animation-delay: 0.2s;
}

.device-item:nth-child(2) .device-fill {
    animation-delay: 0.4s;
}

.device-item:nth-child(3) .device-fill {
    animation-delay: 0.6s;
}

@keyframes deviceFill {
    from {
        width: 0 !important;
        opacity: 0;
    }
    to {
        opacity: 1;
    }
}

.device-users {
    font-size: 12px;
    color: #9ca3af;
}

/* ================================================
   11. USER ENGAGEMENT METRICS
   ================================================ */

.engagement-metrics {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
    gap: 20px;
}

.engagement-item {
    padding: 16px;
    background: rgba(20, 184, 166, 0.05);
    border-radius: 10px;
    border: 1px solid rgba(20, 184, 166, 0.15);
    display: flex;
    flex-direction: column;
    gap: 8px;
    transition: all 0.3s ease;
}

.engagement-item:hover {
    background: rgba(20, 184, 166, 0.1);
    border-color: rgba(20, 184, 166, 0.3);
    transform: translateY(-2px);
}

.engagement-label {
    font-size: 12px;
    color: #9ca3af;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.3px;
}

.engagement-value {
    font-size: 24px;
    font-weight: 700;
    color: #14b8a6;
}

.engagement-value.primary {
    color: #14b8a6;
}

.engagement-value.success {
    color: #10b981;
}

.engagement-change {
    font-size: 12px;
    color: #6b7280;
}

/* ================================================
   RESPONSIVE DESIGN
   ================================================ */

@media (max-width: 1200px) {
    .analytics-grid {
        grid-template-columns: 1fr;
    }

    .analytics-card:nth-child(1) {
        grid-column: auto;
    }
}

@media (max-width: 768px) {
    .analytics-content {
        padding: 24px 16px;
    }

    .analytics-container h1 {
        font-size: 28px;
    }

    .analytics-header {
        flex-direction: column;
        align-items: stretch;
    }

    .analytics-title-group {
        min-width: auto;
    }

    .analytics-controls {
        flex-direction: column;
    }

    .date-range-select,
    .export-btn {
        width: 100%;
    }

    .metrics-overview {
        grid-template-columns: 1fr;
    }

    .analytics-grid {
        grid-template-columns: 1fr;
    }

    .engagement-metrics {
        grid-template-columns: 1fr;
    }

    .chart-legend {
        flex-direction: column;
    }

    .card-title {
        flex-direction: column;
    }

    .table-container {
        font-size: 13px;
    }

    .analytics-table th,
    .analytics-table td {
        padding: 12px 8px;
    }
}

@media (max-width: 480px) {
    .analytics-container h1 {
        font-size: 24px;
    }

    .analytics-subtitle {
        font-size: 14px;
        margin-bottom: 24px;
    }

    .analytics-card,
    .metric-card {
        padding: 20px;
    }

    .metric-value {
        font-size: 24px;
    }

    .card-title h3 {
        font-size: 16px;
    }

    .sources-list,
    .device-breakdown {
        gap: 12px;
    }

    .source-item {
        padding: 12px;
    }

    .engagement-metrics {
        gap: 16px;
    }
}

/* ================================================
   ANIMATIONS & TRANSITIONS
   ================================================ */

@keyframes gradientShift {
    0%,
    100% {
        background-position: 0% 50%;
    }
    50% {
        background-position: 100% 50%;
    }
}

@media (prefers-reduced-motion: reduce) {
    * {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
    }
}
