/* ============================================
   HowlTicket Analytics Dashboard
   Premium/Luxury Styling
   ============================================ */

/* Page Layout */
.analytics-page {
    padding: var(--space-5);
    background: var(--surface-1);
    min-height: 100vh;
    max-width: 100%;
    overflow-x: hidden;
}

.analytics-header {
    display: flex;
    flex-wrap: wrap;
    justify-content: space-between;
    align-items: flex-start;
    gap: var(--space-4);
    margin-bottom: var(--space-5);
    padding-bottom: var(--space-4);
    border-bottom: 1px solid var(--border-subtle);
}

.analytics-title {
    flex: 1;
    min-width: 200px;
}

.analytics-title h1 {
    font-size: var(--text-2xl);
    font-weight: var(--font-bold);
    color: var(--text-strong);
    margin: 0 0 var(--space-1) 0;
}

.analytics-title p {
    font-size: var(--text-sm);
    color: var(--text-muted);
    margin: 0;
}

.analytics-controls {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: var(--space-3);
}

/* Comparison Banner */
.comparison-banner {
    display: flex;
    align-items: center;
    gap: var(--space-2);
    padding: var(--space-3) var(--space-4);
    background: var(--accent-soft);
    border-radius: var(--radius-md);
    margin-bottom: var(--space-4);
    font-size: var(--text-sm);
    color: var(--accent-strong);
    font-weight: var(--font-medium);
    flex-wrap: wrap;
}

.comparison-banner i {
    font-size: var(--text-base);
}

/* Widget Grid */
.analytics-grid {
    display: grid;
    grid-template-columns: repeat(12, 1fr);
    gap: var(--space-4);
    max-width: 100%;
}

.widget-wrapper {
    min-height: 0;
    min-width: 0;
    display: flex;
    flex-direction: column;
}

/* Widget Card - Premium Styling */
.widget-card {
    background: var(--surface-0);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-2);
    overflow: hidden;
    transition: all var(--transition-base);
    flex: 1;
    display: flex;
    flex-direction: column;
    min-width: 0;
}

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

.widget-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: var(--space-4);
    border-bottom: 1px solid var(--border-subtle);
}

.widget-title {
    font-size: var(--text-sm);
    font-weight: var(--font-semibold);
    color: var(--text-strong);
    display: flex;
    align-items: center;
    gap: var(--space-2);
}

.widget-title i {
    color: var(--text-muted);
}

.widget-menu {
    opacity: 0;
    transition: opacity var(--transition-fast);
}

.widget-card:hover .widget-menu {
    opacity: 1;
}

.widget-body {
    padding: var(--space-4);
    flex: 1;
    display: flex;
    flex-direction: column;
    min-width: 0;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
}

/* KPI Widget Styling */
.kpi-widget {
    text-align: center;
}

.kpi-value {
    font-size: var(--text-3xl);
    font-weight: var(--font-bold);
    background: linear-gradient(135deg, var(--accent) 0%, var(--accent-strong) 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    line-height: 1.2;
    margin-bottom: var(--space-2);
}

.kpi-label {
    font-size: var(--text-sm);
    color: var(--text-muted);
    margin-bottom: var(--space-3);
}

.kpi-trend {
    display: inline-flex;
    align-items: center;
    gap: var(--space-1);
    padding: var(--space-1) var(--space-2);
    border-radius: var(--radius-full);
    font-size: var(--text-xs);
    font-weight: var(--font-medium);
}

.kpi-trend.positive {
    background: var(--success-soft, rgba(16, 185, 129, 0.1));
    color: var(--success);
}

.kpi-trend.negative {
    background: var(--danger-soft, rgba(239, 68, 68, 0.1));
    color: var(--danger);
}

.kpi-trend.neutral {
    background: var(--surface-2);
    color: var(--text-muted);
}

.kpi-sparkline {
    height: 40px;
    margin-top: auto;
}

/* Chart Container */
.chart-container {
    position: relative;
    height: 280px;
    flex: 1;
    min-width: 0;
    width: 100%;
}

.chart-container.small {
    height: 200px;
}

.chart-container.large {
    height: 350px;
}

/* Heatmap Styling */
.heatmap-container {
    display: flex;
    flex-direction: column;
    gap: 2px;
    padding: var(--space-2);
}

.heatmap-row {
    display: flex;
    gap: 2px;
    align-items: center;
}

.heatmap-header {
    margin-bottom: var(--space-1);
}

.heatmap-label {
    width: 36px;
    font-size: var(--text-xs);
    color: var(--text-muted);
    text-align: right;
    padding-right: var(--space-2);
    flex-shrink: 0;
}

.heatmap-hour-label {
    flex: 1;
    font-size: 9px;
    color: var(--text-muted);
    text-align: center;
}

.heatmap-cell {
    flex: 1;
    aspect-ratio: 1;
    min-width: 16px;
    max-width: 28px;
    border-radius: var(--radius-xs);
    transition: transform var(--transition-fast);
    cursor: pointer;
}

.heatmap-cell:hover {
    transform: scale(1.15);
    z-index: 1;
}

/* Heat intensity levels using gold gradient */
.heat-0 { background: var(--surface-2); }
.heat-1 { background: rgba(232, 134, 52, 0.15); }
.heat-2 { background: rgba(232, 134, 52, 0.35); }
.heat-3 { background: rgba(232, 134, 52, 0.55); }
.heat-4 { background: rgba(232, 134, 52, 0.75); }
.heat-5 { background: var(--accent); }

/* Table Widget */
.widget-table-wrapper {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
}

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

.widget-table th {
    text-align: left;
    padding: var(--space-2) var(--space-3);
    font-size: var(--text-xs);
    font-weight: var(--font-semibold);
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.05em;
    border-bottom: 1px solid var(--border-subtle);
}

.widget-table td {
    padding: var(--space-3);
    font-size: var(--text-sm);
    color: var(--text-strong);
    border-bottom: 1px solid var(--border-subtle);
}

.widget-table tr:last-child td {
    border-bottom: none;
}

.widget-table tr:hover td {
    background: var(--surface-1);
}

.widget-table .rank {
    width: 32px;
    color: var(--text-muted);
    font-weight: var(--font-medium);
}

.widget-table .value {
    text-align: right;
    font-weight: var(--font-semibold);
}

.widget-table .trend {
    width: 60px;
    text-align: right;
}

/* Gauge Widget */
.gauge-widget {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    height: 100%;
}

.gauge-chart {
    position: relative;
    width: 140px;
    height: 90px;
}

.gauge-value {
    position: absolute;
    bottom: 0;
    left: 50%;
    transform: translateX(-50%);
    font-size: var(--text-2xl);
    font-weight: var(--font-bold);
    color: var(--text-strong);
}

.gauge-label {
    font-size: var(--text-sm);
    color: var(--text-muted);
    margin-top: var(--space-2);
}

/* Weather Context Widget */
.weather-widget {
    padding: var(--space-3);
}

.weather-summary {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: var(--space-3);
    margin-bottom: var(--space-4);
}

.weather-stat {
    text-align: center;
    padding: var(--space-2);
    background: var(--surface-1);
    border-radius: var(--radius-md);
}

.weather-stat-value {
    font-size: var(--text-xl);
    font-weight: var(--font-bold);
    color: var(--text-strong);
}

.weather-stat-label {
    font-size: var(--text-xs);
    color: var(--text-muted);
}

.weather-alerts {
    display: flex;
    flex-direction: column;
    gap: var(--space-2);
}

.weather-alert {
    display: flex;
    align-items: center;
    gap: var(--space-2);
    padding: var(--space-2) var(--space-3);
    background: var(--warning-soft, rgba(245, 158, 11, 0.1));
    border-radius: var(--radius-md);
    font-size: var(--text-sm);
    color: var(--warning);
}

.weather-alert.severe {
    background: var(--danger-soft, rgba(239, 68, 68, 0.1));
    color: var(--danger);
}

/* Filter Bar */
.filter-bar {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: var(--space-3);
    padding: var(--space-3) var(--space-4);
    background: var(--surface-0);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-1);
}

.filter-group {
    display: flex;
    align-items: center;
    gap: var(--space-2);
}

.filter-label {
    font-size: var(--text-xs);
    font-weight: var(--font-medium);
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.filter-select {
    padding: var(--space-2) var(--space-3);
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-md);
    background: var(--surface-0);
    color: var(--text-strong);
    font-size: var(--text-sm);
    cursor: pointer;
    transition: border-color var(--transition-fast);
}

.filter-select:hover {
    border-color: var(--accent);
}

.filter-select:focus {
    outline: none;
    border-color: var(--accent);
    box-shadow: 0 0 0 3px var(--accent-soft);
}

.filter-divider {
    width: 1px;
    height: 24px;
    background: var(--border-subtle);
}

.filter-btn {
    display: inline-flex;
    align-items: center;
    gap: var(--space-2);
    padding: var(--space-2) var(--space-3);
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-md);
    background: var(--surface-0);
    color: var(--text-strong);
    font-size: var(--text-sm);
    cursor: pointer;
    transition: all var(--transition-fast);
}

.filter-btn:hover {
    background: var(--surface-1);
    border-color: var(--accent);
}

.filter-btn.active {
    background: var(--accent-soft);
    border-color: var(--accent);
    color: var(--accent-strong);
}

/* Date Picker */
.date-picker {
    display: flex;
    align-items: center;
    gap: var(--space-2);
}

.date-input {
    padding: var(--space-2) var(--space-3);
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-md);
    background: var(--surface-0);
    color: var(--text-strong);
    font-size: var(--text-sm);
    width: 130px;
    min-width: 0;
}

.date-input:focus {
    outline: none;
    border-color: var(--accent);
    box-shadow: 0 0 0 3px var(--accent-soft);
}

.date-presets {
    display: flex;
    gap: var(--space-1);
}

.date-preset {
    padding: var(--space-1) var(--space-2);
    border: none;
    border-radius: var(--radius-sm);
    background: transparent;
    color: var(--text-muted);
    font-size: var(--text-xs);
    cursor: pointer;
    transition: all var(--transition-fast);
}

.date-preset:hover {
    background: var(--surface-1);
    color: var(--text-strong);
}

.date-preset.active {
    background: var(--accent);
    color: white;
}

/* Widget Customizer Modal */
.widget-customizer {
    position: fixed;
    inset: 0;
    z-index: var(--z-modal);
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(0, 0, 0, 0.5);
    backdrop-filter: blur(4px);
}

.customizer-content {
    width: 90%;
    max-width: 800px;
    max-height: 80vh;
    background: var(--surface-0);
    border-radius: var(--radius-xl);
    box-shadow: var(--shadow-4);
    overflow: hidden;
    display: flex;
    flex-direction: column;
}

.customizer-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: var(--space-4);
    border-bottom: 1px solid var(--border-subtle);
}

.customizer-header h2 {
    font-size: var(--text-lg);
    font-weight: var(--font-semibold);
    color: var(--text-strong);
    margin: 0;
}

.customizer-body {
    flex: 1;
    overflow-y: auto;
    padding: var(--space-4);
}

.widget-catalog {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
    gap: var(--space-3);
}

.widget-catalog-item {
    display: flex;
    align-items: center;
    gap: var(--space-3);
    padding: var(--space-3);
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-md);
    cursor: pointer;
    transition: all var(--transition-fast);
}

.widget-catalog-item:hover {
    border-color: var(--accent);
    background: var(--surface-1);
}

.widget-catalog-item.selected {
    border-color: var(--accent);
    background: var(--accent-soft);
}

.widget-catalog-icon {
    width: 40px;
    height: 40px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--surface-1);
    border-radius: var(--radius-md);
    color: var(--text-muted);
    font-size: var(--text-lg);
}

.widget-catalog-info h4 {
    font-size: var(--text-sm);
    font-weight: var(--font-medium);
    color: var(--text-strong);
    margin: 0 0 2px 0;
}

.widget-catalog-info p {
    font-size: var(--text-xs);
    color: var(--text-muted);
    margin: 0;
}

.customizer-footer {
    display: flex;
    justify-content: flex-end;
    gap: var(--space-3);
    padding: var(--space-4);
    border-top: 1px solid var(--border-subtle);
}

/* Loading State */
.widget-loading {
    display: flex;
    align-items: center;
    justify-content: center;
    height: 100%;
    min-height: 200px;
}

.loading-spinner {
    width: 32px;
    height: 32px;
    border: 3px solid var(--surface-2);
    border-top-color: var(--accent);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}

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

/* Skeleton Loading */
.skeleton {
    background: linear-gradient(
        90deg,
        var(--surface-2) 25%,
        var(--surface-1) 50%,
        var(--surface-2) 75%
    );
    background-size: 200% 100%;
    animation: shimmer 1.5s infinite;
    border-radius: var(--radius-md);
}

@keyframes shimmer {
    0% { background-position: 200% 0; }
    100% { background-position: -200% 0; }
}

/* Responsive Design */
@media (max-width: 1200px) {
    .analytics-grid {
        grid-template-columns: repeat(6, 1fr);
    }

    .widget-wrapper[style*="span 3"] {
        grid-column: span 3 !important;
    }

    .widget-wrapper[style*="span 4"] {
        grid-column: span 3 !important;
    }

    .widget-wrapper[style*="span 6"] {
        grid-column: span 6 !important;
    }

    .widget-wrapper[style*="span 8"],
    .widget-wrapper[style*="span 12"] {
        grid-column: span 6 !important;
    }
}

@media (max-width: 992px) {
    .analytics-page {
        padding: var(--space-4);
    }

    .analytics-grid {
        grid-template-columns: repeat(4, 1fr);
    }

    .widget-wrapper[style*="span 3"] {
        grid-column: span 2 !important;
    }

    .widget-wrapper[style*="span 4"],
    .widget-wrapper[style*="span 6"] {
        grid-column: span 4 !important;
    }

    .widget-wrapper[style*="span 8"],
    .widget-wrapper[style*="span 12"] {
        grid-column: span 4 !important;
    }

    .analytics-section {
        grid-column: span 4 !important;
    }
}

@media (max-width: 768px) {
    .analytics-page {
        padding: var(--space-3);
    }

    .analytics-header {
        flex-direction: column;
    }

    .analytics-grid {
        grid-template-columns: 1fr;
    }

    .widget-wrapper {
        grid-column: span 1 !important;
    }

    .analytics-section {
        grid-column: span 1 !important;
    }

    /* Section headers: better touch targets */
    .section-header {
        padding: var(--space-4) var(--space-3);
        min-height: 56px;
    }

    .section-header h2 {
        font-size: var(--text-base);
        gap: var(--space-2);
    }

    /* Heatmap: horizontal scroll on small screens */
    .heatmap-container {
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
    }

    .heatmap-row {
        min-width: 320px;
    }

    /* Filter bar */
    .filter-bar {
        flex-direction: column;
        align-items: stretch;
        padding: var(--space-3);
    }

    .filter-group {
        width: 100%;
        justify-content: space-between;
    }

    .filter-group[style*="margin-left"] {
        margin-left: 0 !important;
    }

    .filter-divider {
        display: none;
    }

    .date-picker {
        flex-direction: column;
    }

    .date-input {
        width: 100%;
    }

    .date-presets {
        flex-wrap: wrap;
        gap: var(--space-2);
    }

    .date-preset {
        padding: var(--space-2) var(--space-3);
        font-size: var(--text-sm);
        min-height: 36px;
    }

    /* Tables: scrollable on mobile */
    .widget-table-wrapper {
        margin: 0 calc(-1 * var(--space-2));
        padding: 0 var(--space-2);
    }

    .widget-table {
        font-size: var(--text-xs);
        min-width: 280px;
    }

    .widget-table th,
    .widget-table td {
        padding: var(--space-2);
        white-space: nowrap;
    }

    .widget-table .rank {
        width: 24px;
    }

    .widget-table .trend {
        width: 48px;
    }

    /* Notes */
    .notes-hint {
        flex-direction: column;
        text-align: center;
        gap: var(--space-2);
    }

    /* Comparison banner */
    .comparison-banner {
        font-size: var(--text-xs);
        padding: var(--space-2) var(--space-3);
        flex-wrap: wrap;
    }

    /* Scrollable nav tabs */
    .analytics-page .nav-tabs,
    .nav-tabs {
        flex-wrap: nowrap;
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
        scrollbar-width: none;
        -ms-overflow-style: none;
    }

    .analytics-page .nav-tabs::-webkit-scrollbar,
    .nav-tabs::-webkit-scrollbar {
        display: none;
    }

    .nav-tabs .nav-item {
        flex-shrink: 0;
    }

    .nav-tabs .nav-link {
        white-space: nowrap;
        padding: var(--space-2) var(--space-3);
        font-size: var(--text-sm);
    }
}

/* Collapsible Sections */
.analytics-section {
    margin-top: var(--space-4);
}

.section-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    width: 100%;
    padding: var(--space-4);
    background: var(--surface-0);
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-lg);
    cursor: pointer;
    transition: all var(--transition-fast);
}

.section-header:hover {
    background: var(--surface-1);
    border-color: var(--accent);
}

.section-header h2 {
    display: flex;
    align-items: center;
    gap: var(--space-3);
    font-size: var(--text-lg);
    font-weight: var(--font-semibold);
    color: var(--text-strong);
    margin: 0;
}

.section-header h2 i {
    color: var(--accent);
    font-size: var(--text-xl);
}

.section-header > i {
    color: var(--text-muted);
    font-size: var(--text-lg);
    transition: transform var(--transition-fast);
}

.section-content {
    margin-top: var(--space-4);
}

.section-content .analytics-grid {
    padding: 0;
}

/* ============================================
   Analytics Notes Panel
   ============================================ */

.notes-hint {
    display: flex;
    align-items: center;
    gap: var(--space-2);
    padding: var(--space-3);
    margin-bottom: var(--space-4);
    background: var(--surface-2);
    border-radius: var(--radius-lg);
    border: 1px dashed var(--border-subtle);
}

.notes-hint .btn-link {
    font-weight: var(--font-medium);
    text-decoration: none;
    color: var(--accent);
}

.notes-hint .hint-text {
    color: var(--text-muted);
    font-size: var(--text-sm);
}

.notes-panel {
    background: var(--surface-2);
    border-radius: var(--radius-lg);
    border: 1px solid var(--border-subtle);
    padding: var(--space-4);
    margin-bottom: var(--space-4);
}

.notes-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: var(--space-3);
}

.notes-header h3 {
    display: flex;
    align-items: center;
    gap: var(--space-2);
    font-size: var(--text-base);
    font-weight: var(--font-semibold);
    color: var(--text-strong);
    margin: 0;
}

.notes-header h3 i {
    color: var(--accent);
}

/* Note Form */
.note-form {
    background: var(--surface-1);
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-md);
    padding: var(--space-4);
    margin-bottom: var(--space-4);
}

.note-form-row {
    display: flex;
    gap: var(--space-4);
    margin-bottom: var(--space-3);
}

.note-form-row .form-group {
    flex: 1;
}

.note-form .form-group {
    margin-bottom: var(--space-3);
}

.note-form .form-group label {
    display: block;
    font-size: var(--text-sm);
    font-weight: var(--font-medium);
    color: var(--text-muted);
    margin-bottom: var(--space-1);
}

.note-form .form-control {
    width: 100%;
    padding: var(--space-2) var(--space-3);
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-md);
    background: var(--surface-1);
    color: var(--text-default);
    font-size: var(--text-sm);
}

.note-form .form-control:focus {
    outline: none;
    border-color: var(--accent);
    box-shadow: 0 0 0 2px rgba(232, 134, 52, 0.1);
}

.note-form textarea.form-control {
    resize: vertical;
    min-height: 60px;
}

.note-form-actions {
    display: flex;
    justify-content: flex-end;
}

/* Notes List */
.notes-list {
    display: flex;
    flex-direction: column;
    gap: var(--space-3);
}

.note-item {
    display: grid;
    grid-template-columns: 120px 1fr auto;
    gap: var(--space-3);
    align-items: center;
    padding: var(--space-3);
    background: var(--surface-1);
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-md);
}

.note-date {
    display: flex;
    flex-direction: column;
    gap: var(--space-1);
}

.note-date .date {
    font-weight: var(--font-semibold);
    color: var(--text-strong);
}

.note-date .category-badge {
    display: inline-block;
    font-size: 10px;
    font-weight: var(--font-medium);
    padding: 2px 6px;
    border-radius: var(--radius-sm);
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

/* Category Badge Colors */
.category-marketing { background: #dbeafe; color: #1e40af; }
.category-weather { background: #fef3c7; color: #92400e; }
.category-holiday { background: #fce7f3; color: #9d174d; }
.category-staffing { background: #d1fae5; color: #065f46; }
.category-event { background: #e0e7ff; color: #3730a3; }
.category-promotion { background: #fed7aa; color: #c2410c; }
.category-competitor { background: #fecaca; color: #991b1b; }
.category-other { background: #f3f4f6; color: #374151; }

/* Dark mode category badges */
[data-theme="dark"] .category-marketing { background: rgba(59, 130, 246, 0.2); color: #93c5fd; }
[data-theme="dark"] .category-weather { background: rgba(251, 191, 36, 0.2); color: #fcd34d; }
[data-theme="dark"] .category-holiday { background: rgba(236, 72, 153, 0.2); color: #f9a8d4; }
[data-theme="dark"] .category-staffing { background: rgba(16, 185, 129, 0.2); color: #6ee7b7; }
[data-theme="dark"] .category-event { background: rgba(99, 102, 241, 0.2); color: #a5b4fc; }
[data-theme="dark"] .category-promotion { background: rgba(232, 134, 52, 0.2); color: #f9a872; }
[data-theme="dark"] .category-competitor { background: rgba(239, 68, 68, 0.2); color: #fca5a5; }
[data-theme="dark"] .category-other { background: rgba(156, 163, 175, 0.15); color: #d1d5db; }

.note-content {
    color: var(--text-default);
    font-size: var(--text-sm);
    line-height: 1.5;
}

.note-meta {
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    gap: var(--space-1);
}

.note-meta .author {
    font-size: var(--text-xs);
    color: var(--text-muted);
}

.note-meta .btn-link {
    padding: 0;
    opacity: 0.5;
    transition: opacity var(--transition-fast);
}

.note-item:hover .note-meta .btn-link {
    opacity: 1;
}

/* Responsive adjustments */
@media (max-width: 768px) {
    .note-form-row {
        flex-direction: column;
        gap: var(--space-3);
    }

    .note-item {
        grid-template-columns: 1fr;
        gap: var(--space-2);
    }

    .note-date {
        flex-direction: row;
        align-items: center;
        gap: var(--space-2);
    }

    .note-meta {
        flex-direction: row;
        justify-content: space-between;
        align-items: center;
        width: 100%;
    }
}

/* Date Mode Toggle */
.date-mode-toggle {
    display: flex;
    gap: 0;
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-md);
    overflow: hidden;
}

.date-mode-btn {
    display: inline-flex;
    align-items: center;
    gap: var(--space-1);
    padding: var(--space-1) var(--space-3);
    border: none;
    background: var(--surface-0);
    color: var(--text-muted);
    font-size: var(--text-xs);
    cursor: pointer;
    transition: all var(--transition-fast);
    white-space: nowrap;
}

.date-mode-btn:not(:last-child) {
    border-right: 1px solid var(--border-subtle);
}

.date-mode-btn:hover {
    background: var(--surface-1);
    color: var(--text-strong);
}

.date-mode-btn.active {
    background: var(--accent);
    color: white;
}

/* Comparison Presets */
.comparison-group {
    flex-wrap: wrap;
    gap: var(--space-2);
}

.comparison-presets {
    display: flex;
    gap: var(--space-1);
}

.date-preset.small {
    padding: var(--space-1) var(--space-2);
    font-size: 11px;
}

.comparison-label {
    font-size: var(--text-sm);
    color: var(--text-strong);
    padding: var(--space-1) var(--space-2);
    background: var(--surface-1);
    border-radius: var(--radius-sm);
    white-space: nowrap;
}

/* Event Deep Dive Section */
.deep-dive-event-selector {
    display: flex;
    align-items: center;
    gap: var(--space-3);
    padding: var(--space-3) var(--space-4);
    background: var(--surface-1);
    border-radius: var(--radius-md);
    margin-bottom: var(--space-4);
}

.deep-dive-event-selector label {
    font-size: var(--text-sm);
    font-weight: var(--font-medium);
    color: var(--text-strong);
    white-space: nowrap;
}

.deep-dive-event-selector select {
    flex: 1;
    max-width: 400px;
    padding: var(--space-2) var(--space-3);
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-md);
    background: var(--surface-0);
    color: var(--text-strong);
    font-size: var(--text-sm);
}

.deep-dive-loading {
    text-align: center;
    padding: var(--space-8);
    color: var(--text-muted);
}

/* Mobile: Filter bar & new elements */
@media (max-width: 768px) {
    .date-mode-toggle {
        width: 100%;
    }

    .date-mode-btn {
        flex: 1;
        justify-content: center;
        padding: var(--space-2) var(--space-2);
    }

    .comparison-group {
        flex-direction: column;
        align-items: stretch;
    }

    .comparison-presets {
        flex-wrap: wrap;
    }

    .comparison-label {
        text-align: center;
    }

    .deep-dive-event-selector {
        flex-direction: column;
        align-items: stretch;
    }

    .deep-dive-event-selector select {
        max-width: none;
    }

    /* Better touch targets for filter buttons */
    .filter-btn {
        min-height: 40px;
        padding: var(--space-2) var(--space-3);
    }

    .filter-select {
        min-height: 40px;
    }
}

/* Mobile: Additional small screen fixes */
@media (max-width: 480px) {
    .analytics-page {
        padding: var(--space-2);
    }

    .analytics-title h1 {
        font-size: var(--text-xl);
    }

    .widget-card {
        padding: 0;
    }

    .kpi-value {
        font-size: var(--text-xl);
    }

    .widget-header {
        padding: var(--space-3);
    }

    .widget-body {
        padding: var(--space-3);
    }

    .comparison-banner {
        flex-direction: column;
        align-items: flex-start;
        gap: var(--space-1);
    }

    .filter-bar {
        padding: var(--space-2);
        gap: var(--space-2);
    }

    .section-header {
        padding: var(--space-3) var(--space-2);
    }

    .section-header h2 {
        font-size: var(--text-sm);
    }

    .heatmap-row {
        min-width: 280px;
    }

    .customizer-content {
        width: 100%;
        max-width: none;
        max-height: 90vh;
        border-radius: var(--radius-md);
        margin: var(--space-2);
    }
}

/* Disable hover transforms on touch devices */
@media (hover: none) {
    .widget-card:hover {
        transform: none;
        box-shadow: var(--shadow-2);
    }
}

/* Ensure chart containers don't overflow */
.chart-container canvas {
    max-width: 100%;
}

/* Print Styles */
@media print {
    .analytics-page {
        background: white;
        padding: 0;
    }

    .widget-card {
        box-shadow: none;
        border: 1px solid #e5e7eb;
        break-inside: avoid;
    }

    .widget-card:hover {
        transform: none;
    }

    .filter-bar,
    .widget-menu,
    .customizer-content {
        display: none !important;
    }

    .section-header {
        border: 1px solid #e5e7eb;
    }

    .notes-panel {
        border: 1px solid #e5e7eb;
    }

    .note-form,
    .notes-hint,
    .note-meta .btn-link {
        display: none !important;
    }
}
