/* ================================
   ATC Analytics Dashboard - Shared Styles
   ================================ */

:root {
    --primary: #0086b2;
    --primary-dark: #006a8e;
    --accent-success: #10b981;
    --accent-danger: #ef4444;
    --accent-warning: #f59e0b;
    --bg-light: #f8fafc;
    --bg-dark: #0f172a;
    --text-dark: #1e293b;
    --text-muted: #64748b;
    --border-light: #e2e8f0;
    --sidebar-width: 260px;
}

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

body {
    font-family: 'Inter', 'Noto Sans JP', sans-serif;
    background: var(--bg-light);
    color: var(--text-dark);
    line-height: 1.6;
}

/* Layout */
.app-container {
    display: flex;
    min-height: 100vh;
}

/* Sidebar */
.sidebar {
    width: var(--sidebar-width);
    background: white;
    border-right: 1px solid var(--border-light);
    padding: 24px;
    position: fixed;
    top: 0;
    left: 0;
    height: 100vh;
    display: flex;
    flex-direction: column;
    z-index: 100;
}

.sidebar-logo {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 32px;
    padding-bottom: 24px;
    border-bottom: 1px solid var(--border-light);
}

.sidebar-logo img {
    height: 32px;
    width: auto;
}

.sidebar-logo h1 {
    font-size: 14px;
    font-weight: 700;
    color: var(--text-dark);
}

.sidebar-logo span {
    font-size: 11px;
    color: var(--text-muted);
    display: block;
}

.sidebar-nav {
    flex: 1;
}

.nav-section {
    margin-bottom: 24px;
}

.nav-section-title {
    font-size: 10px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.1em;
    color: var(--text-muted);
    margin-bottom: 12px;
}

.nav-link {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px 12px;
    border-radius: 8px;
    text-decoration: none;
    color: var(--text-muted);
    font-size: 14px;
    font-weight: 500;
    transition: all 0.2s ease;
    margin-bottom: 4px;
}

.nav-link:hover {
    background: var(--bg-light);
    color: var(--primary);
}

.nav-link.active {
    background: var(--primary);
    color: white;
}

.nav-link .material-symbols-outlined {
    font-size: 20px;
}

/* Main Content */
.main-content {
    flex: 1;
    margin-left: var(--sidebar-width);
    padding: 32px;
    max-width: 1400px;
}

/* Header */
.page-header {
    margin-bottom: 32px;
}

.page-header h1 {
    font-size: 28px;
    font-weight: 800;
    color: var(--text-dark);
    margin-bottom: 4px;
}

.page-header p {
    color: var(--text-muted);
    font-size: 14px;
}

/* KPI Cards Grid */
.kpi-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 20px;
    margin-bottom: 32px;
}

.kpi-card {
    background: white;
    border-radius: 12px;
    padding: 24px;
    border: 1px solid var(--border-light);
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.04);
}

.kpi-card .label {
    font-size: 11px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--text-muted);
    margin-bottom: 8px;
}

.kpi-card .value {
    font-size: 32px;
    font-weight: 800;
    color: var(--text-dark);
    line-height: 1.1;
}

.kpi-card .change {
    font-size: 13px;
    font-weight: 600;
    margin-top: 8px;
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 4px 8px;
    border-radius: 6px;
}

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

.kpi-card .change.negative {
    background: rgba(239, 68, 68, 0.1);
    color: var(--accent-danger);
}

/* Chart Cards */
.chart-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 24px;
    margin-bottom: 32px;
}

.chart-card {
    background: white;
    border-radius: 12px;
    padding: 24px;
    border: 1px solid var(--border-light);
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.04);
}

.chart-card.full-width {
    grid-column: span 2;
}

.chart-card h3 {
    font-size: 16px;
    font-weight: 700;
    margin-bottom: 4px;
}

.chart-card .subtitle {
    font-size: 13px;
    color: var(--text-muted);
    margin-bottom: 20px;
}

.chart-container {
    position: relative;
    height: 300px;
}

/* Story Navigation */
.story-nav {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-top: 40px;
    padding-top: 24px;
    border-top: 1px solid var(--border-light);
}

.story-nav a {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 12px 24px;
    border-radius: 8px;
    text-decoration: none;
    font-weight: 600;
    font-size: 14px;
    transition: all 0.2s ease;
}

.story-nav .prev {
    background: white;
    border: 1px solid var(--border-light);
    color: var(--text-muted);
}

.story-nav .prev:hover {
    border-color: var(--primary);
    color: var(--primary);
}

.story-nav .next {
    background: var(--primary);
    color: white;
}

.story-nav .next:hover {
    background: var(--primary-dark);
}

/* Story Slide Styles */
.story-hero {
    text-align: center;
    padding: 60px 40px;
    background: linear-gradient(135deg, var(--primary) 0%, var(--primary-dark) 100%);
    border-radius: 16px;
    color: white;
    margin-bottom: 32px;
}

.story-hero .badge {
    display: inline-block;
    background: rgba(255, 255, 255, 0.2);
    padding: 6px 16px;
    border-radius: 20px;
    font-size: 12px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.1em;
    margin-bottom: 20px;
}

.story-hero h1 {
    font-size: 48px;
    font-weight: 800;
    line-height: 1.1;
    margin-bottom: 16px;
}

.story-hero h1 span {
    color: #a7f3d0;
}

.story-hero p {
    font-size: 18px;
    opacity: 0.9;
    max-width: 600px;
    margin: 0 auto;
}

/* Insight Panel - Teal gradient for AI/insights sections */
.insight-panel {
    background: linear-gradient(135deg, #0d9488 0%, #115e59 100%);
    border-radius: 16px;
    padding: 24px;
    color: white;
}

.insight-panel h3 {
    font-size: 11px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.1em;
    opacity: 0.8;
    margin-bottom: 16px;
}

.insight-panel .insight-value {
    font-size: 48px;
    font-weight: 800;
    line-height: 1;
    margin-bottom: 8px;
}

.insight-panel .insight-label {
    font-size: 13px;
    opacity: 0.9;
}

.insight-panel .insight-list {
    margin-top: 20px;
    padding-top: 20px;
    border-top: 1px solid rgba(255, 255, 255, 0.2);
}

.insight-panel .insight-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 8px 0;
    font-size: 13px;
}

.insight-panel .insight-item .material-symbols-outlined {
    font-size: 18px;
    opacity: 0.8;
}

/* Sentiment Breakdown Bars */
.sentiment-breakdown {
    display: flex;
    flex-direction: column;
    gap: 12px;
    margin-top: 16px;
}

.sentiment-row {
    display: flex;
    align-items: center;
    gap: 12px;
}

.sentiment-row .label {
    width: 80px;
    font-size: 13px;
    color: var(--text-muted);
}

.sentiment-bar-container {
    flex: 1;
    height: 12px;
    background: var(--bg-light);
    border-radius: 6px;
    overflow: hidden;
}

.sentiment-bar {
    height: 100%;
    border-radius: 6px;
    transition: width 0.5s ease;
}

.sentiment-bar.positive {
    background: var(--accent-success);
}

.sentiment-bar.neutral {
    background: var(--accent-warning);
}

.sentiment-bar.negative {
    background: var(--accent-danger);
}

.sentiment-row .value {
    width: 50px;
    text-align: right;
    font-size: 14px;
    font-weight: 700;
}

/* Top Performing Post Cards */
.top-posts-grid {
    display: grid;
    grid-template-columns: 1fr;
    gap: 16px;
    margin-top: 20px;
}

.top-post-card {
    display: flex;
    gap: 16px;
    padding: 16px;
    background: var(--bg-light);
    border-radius: 12px;
    transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.top-post-card:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.08);
}

.top-post-card .post-thumbnail {
    width: 60px;
    height: 60px;
    background: linear-gradient(135deg, #e2e8f0 0%, #cbd5e1 100%);
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.top-post-card .post-thumbnail .material-symbols-outlined {
    font-size: 24px;
    color: var(--text-muted);
}

.top-post-card .post-content {
    flex: 1;
    min-width: 0;
}

.top-post-card .post-title {
    font-size: 14px;
    font-weight: 600;
    margin-bottom: 4px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.top-post-card .post-platform {
    font-size: 11px;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.05em;
    margin-bottom: 8px;
}

.top-post-card .post-metrics {
    display: flex;
    gap: 16px;
}

.top-post-card .metric {
    display: flex;
    align-items: center;
    gap: 4px;
    font-size: 12px;
    color: var(--text-muted);
}

.top-post-card .metric .material-symbols-outlined {
    font-size: 14px;
}

.top-post-card .metric .value {
    font-weight: 600;
    color: var(--text-dark);
}

/* Benchmark Table */
.benchmark-table {
    width: 100%;
    margin-top: 16px;
}

.benchmark-table .benchmark-row {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 0;
    border-bottom: 1px solid var(--border-light);
}

.benchmark-table .benchmark-row:last-child {
    border-bottom: none;
}

.benchmark-table .benchmark-name {
    flex: 1;
    font-size: 14px;
    font-weight: 500;
}

.benchmark-table .benchmark-bar-container {
    width: 120px;
    height: 8px;
    background: var(--bg-light);
    border-radius: 4px;
    overflow: hidden;
}

.benchmark-table .benchmark-bar {
    height: 100%;
    background: var(--primary);
    border-radius: 4px;
}

.benchmark-table .benchmark-row.highlight .benchmark-bar {
    background: var(--accent-success);
}

.benchmark-table .benchmark-value {
    width: 40px;
    text-align: right;
    font-size: 14px;
    font-weight: 700;
}

/* Peak Performance Indicator */
.peak-indicator {
    display: flex;
    align-items: center;
    gap: 16px;
    padding: 16px 24px;
    background: linear-gradient(135deg, #fef3c7 0%, #fde68a 100%);
    border-radius: 12px;
    margin-bottom: 24px;
}

.peak-indicator .peak-icon {
    width: 48px;
    height: 48px;
    background: #f59e0b;
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.peak-indicator .peak-icon .material-symbols-outlined {
    font-size: 24px;
    color: white;
}

.peak-indicator .peak-content {
    flex: 1;
}

.peak-indicator .peak-label {
    font-size: 11px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.1em;
    color: #92400e;
    margin-bottom: 4px;
}

.peak-indicator .peak-value {
    font-size: 16px;
    font-weight: 700;
    color: #78350f;
}

/* Keyword Tags */
.keyword-tags {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-top: 12px;
}

.keyword-tag {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 6px 12px;
    background: rgba(255, 255, 255, 0.15);
    border-radius: 20px;
    font-size: 12px;
    font-weight: 500;
}

.keyword-tag .count {
    opacity: 0.7;
    font-size: 11px;
}

/* Referral Source Table */
.referral-table {
    margin-top: 16px;
}

.referral-row {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 0;
    border-bottom: 1px solid var(--border-light);
}

.referral-row:last-child {
    border-bottom: none;
}

.referral-row .source-icon {
    width: 32px;
    height: 32px;
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 18px;
    font-weight: 700;
    color: white;
}

.referral-row .source-icon.google {
    background: #4285F4;
}

.referral-row .source-icon.maps {
    background: #34A853;
}

.referral-row .source-icon.facebook {
    background: #1877F2;
}

.referral-row .source-icon.direct {
    background: #64748b;
}

.referral-row .source-name {
    flex: 1;
    font-size: 14px;
    font-weight: 500;
}

.referral-row .source-volume {
    font-size: 14px;
    font-weight: 700;
    min-width: 60px;
    text-align: right;
}

.referral-row .source-conv {
    font-size: 13px;
    color: var(--accent-success);
    font-weight: 600;
    min-width: 50px;
    text-align: right;
}

/* Story Progress */
.story-progress {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    margin-top: 32px;
}

.story-dot {
    width: 10px;
    height: 10px;
    border-radius: 50%;
    background: var(--border-light);
    transition: all 0.2s ease;
}

.story-dot.active {
    width: 32px;
    border-radius: 5px;
    background: var(--primary);
}

/* Platform Badges */
.platform-badge {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 4px 8px;
    border-radius: 4px;
    font-size: 10px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.platform-badge.google-maps {
    background: rgba(52, 168, 83, 0.1);
    color: #34A853;
}

.platform-badge.instagram {
    background: rgba(225, 48, 108, 0.1);
    color: #E1306C;
}

/* Filter Bar */
.filter-bar {
    display: flex;
    align-items: center;
    gap: 16px;
    padding: 16px 0;
    margin-bottom: 24px;
    border-bottom: 1px solid var(--border-light);
    flex-wrap: wrap;
}

.filter-group {
    display: flex;
    align-items: center;
    gap: 8px;
}

.filter-label {
    font-size: 11px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.1em;
    color: var(--text-muted);
}

.filter-select {
    padding: 8px 32px 8px 12px;
    border: 1px solid var(--border-light);
    border-radius: 8px;
    font-size: 13px;
    font-weight: 600;
    color: var(--text-dark);
    background: white;
    cursor: pointer;
    appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'%3E%3Cpath fill='%2364748b' d='M3 4.5L6 7.5L9 4.5'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 10px center;
    transition: border-color 0.2s ease, box-shadow 0.2s ease;
}

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

.filter-select:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(0, 134, 178, 0.1);
}

.filter-btn {
    padding: 8px 20px;
    background: var(--primary);
    color: white;
    border: none;
    border-radius: 8px;
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
    transition: background 0.2s ease;
    display: inline-flex;
    align-items: center;
    gap: 6px;
}

.filter-btn:hover {
    background: var(--primary-dark);
}

.filter-reset {
    padding: 8px 16px;
    background: transparent;
    color: var(--text-muted);
    border: 1px solid var(--border-light);
    border-radius: 8px;
    font-size: 13px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s ease;
}

.filter-reset:hover {
    background: var(--bg-light);
    color: var(--text-dark);
}

/* Clickable KPI Cards */
.kpi-card.clickable {
    cursor: pointer;
    transition: all 0.2s ease;
}

.kpi-card.clickable:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
    border-color: var(--primary);
}

.kpi-card.active {
    border: 2px solid var(--primary);
    background: rgba(0, 134, 178, 0.02);
}

/* Correlation Insights Panel */
.correlation-panel {
    background: linear-gradient(135deg, #1e293b 0%, #334155 100%);
    border-radius: 16px;
    padding: 24px;
    color: white;
    margin-bottom: 24px;
}

.correlation-panel h3 {
    font-size: 14px;
    font-weight: 700;
    margin-bottom: 16px;
    display: flex;
    align-items: center;
    gap: 8px;
}

.correlation-panel h3 .material-symbols-outlined {
    font-size: 20px;
    color: #a7f3d0;
}

.correlation-list {
    display: flex;
    flex-wrap: wrap;
    gap: 12px;
}

.correlation-item {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 10px 16px;
    background: rgba(255, 255, 255, 0.1);
    border-radius: 8px;
    font-size: 13px;
    font-weight: 500;
    transition: background 0.2s ease;
    cursor: pointer;
}

.correlation-item:hover {
    background: rgba(255, 255, 255, 0.2);
}

.correlation-item .material-symbols-outlined {
    font-size: 18px;
}

.correlation-item.positive {
    border-left: 3px solid var(--accent-success);
}

.correlation-item.negative {
    border-left: 3px solid var(--accent-danger);
}

/* Chart Container Sizes */
.chart-container.tall {
    height: 400px;
}

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

/* Event Annotation */
.event-annotation {
    position: absolute;
    top: -24px;
    background: var(--primary);
    color: white;
    padding: 4px 8px;
    border-radius: 4px;
    font-size: 10px;
    font-weight: 700;
    white-space: nowrap;
}

/* Stats Grid for detailed breakdown */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
    gap: 16px;
    margin-top: 16px;
}

.stat-item {
    text-align: center;
    padding: 16px;
    background: var(--bg-light);
    border-radius: 8px;
}

.stat-item .stat-value {
    font-size: 24px;
    font-weight: 800;
    color: var(--text-dark);
}

.stat-item .stat-label {
    font-size: 11px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--text-muted);
    margin-top: 4px;
}

/* Utilities */
.text-success {
    color: var(--accent-success);
}

.text-danger {
    color: var(--accent-danger);
}

.text-warning {
    color: var(--accent-warning);
}

@media (max-width: 1024px) {
    .chart-grid {
        grid-template-columns: 1fr;
    }

    .chart-card.full-width {
        grid-column: span 1;
    }
}

@media (max-width: 768px) {
    .sidebar {
        transform: translateX(-100%);
    }

    .main-content {
        margin-left: 0;
    }
}