/* ===== Reset & Base ===== */
*, *::before, *::after {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

:root {
    --bg-primary: #f8f9fb;
    --bg-card: #ffffff;
    --bg-hover: #f1f3f5;
    --text-primary: #1a1d21;
    --text-secondary: #6b7280;
    --text-muted: #9ca3af;
    --border-color: #e5e7eb;
    --border-light: #f0f1f3;
    --accent-blue: #3b82f6;
    --accent-blue-light: #eff6ff;
    --accent-purple: #8b5cf6;
    --accent-purple-light: #f5f3ff;
    --accent-pink: #ec4899;
    --accent-pink-light: #fdf2f8;
    --accent-green: #10b981;
    --accent-green-light: #ecfdf5;
    --accent-orange: #f59e0b;
    --accent-orange-light: #fffbeb;
    --instagram-gradient-start: #f09433;
    --instagram-gradient-mid: #e6683c;
    --instagram-gradient-end: #bc1888;
    --facebook-blue: #1877f2;
    --shadow-sm: 0 1px 2px rgba(0,0,0,0.04);
    --shadow-md: 0 4px 12px rgba(0,0,0,0.06);
    --shadow-lg: 0 8px 24px rgba(0,0,0,0.08);
    --shadow-xl: 0 12px 36px rgba(0,0,0,0.1);
    --radius-sm: 8px;
    --radius-md: 12px;
    --radius-lg: 16px;
    --radius-xl: 20px;
    --transition: all 0.25s cubic-bezier(0.4, 0, 0.2, 1);
}

html {
    font-size: 15px;
}

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
    background: var(--bg-primary);
    color: var(--text-primary);
    line-height: 1.6;
    min-height: 100vh;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

/* ===== Dashboard Container ===== */
.dashboard-container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 24px 32px 48px;
}

/* ===== Header ===== */
.dashboard-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    margin-bottom: 24px;
    padding: 28px 32px;
    background: var(--bg-card);
    border-radius: var(--radius-xl);
    box-shadow: var(--shadow-md);
    border: 1px solid var(--border-light);
}

.header-left h1 {
    font-size: 1.75rem;
    font-weight: 800;
    letter-spacing: -0.02em;
    color: var(--text-primary);
    margin-bottom: 4px;
}

.subtitle {
    font-size: 0.875rem;
    color: var(--text-secondary);
    font-weight: 400;
}

.header-right {
    display: flex;
    align-items: center;
    gap: 10px;
}

.period-label {
    font-size: 0.875rem;
    color: var(--text-secondary);
    font-weight: 500;
}

.period-select {
    appearance: none;
    padding: 10px 36px 10px 14px;
    border: 1.5px solid var(--border-color);
    border-radius: var(--radius-sm);
    font-family: inherit;
    font-size: 0.875rem;
    font-weight: 600;
    color: var(--text-primary);
    background: var(--bg-card) url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'%3E%3Cpath d='M3 4.5L6 7.5L9 4.5' stroke='%236b7280' stroke-width='1.5' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E") no-repeat right 12px center;
    cursor: pointer;
    transition: var(--transition);
    min-width: 160px;
}

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

.period-select:focus {
    outline: none;
    border-color: var(--accent-blue);
    box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.15);
}

/* ===== Tab Navigation ===== */
.tab-nav {
    display: flex;
    gap: 4px;
    margin-bottom: 24px;
    background: var(--bg-card);
    padding: 6px;
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-sm);
    border: 1px solid var(--border-light);
    width: fit-content;
}

.tab-btn {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 10px 20px;
    border: none;
    background: transparent;
    border-radius: var(--radius-md);
    font-family: inherit;
    font-size: 0.875rem;
    font-weight: 500;
    color: var(--text-secondary);
    cursor: pointer;
    transition: var(--transition);
    white-space: nowrap;
}

.tab-btn:hover {
    background: var(--bg-hover);
    color: var(--text-primary);
}

.tab-btn.active[data-tab="genel"] {
    background: var(--text-primary);
    color: #fff;
    box-shadow: var(--shadow-md);
}

.tab-btn.active[data-tab="instagram"] {
    background: linear-gradient(135deg, var(--instagram-gradient-start), var(--instagram-gradient-mid), var(--instagram-gradient-end));
    color: #fff;
    box-shadow: 0 4px 12px rgba(225, 48, 108, 0.3);
}

.tab-btn.active[data-tab="facebook"] {
    background: var(--facebook-blue);
    color: #fff;
    box-shadow: 0 4px 12px rgba(24, 119, 242, 0.3);
}

/* ===== Platform Header ===== */
.platform-header {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 20px;
}

.platform-dot {
    width: 10px;
    height: 10px;
    border-radius: 50%;
    flex-shrink: 0;
}

.platform-dot.instagram {
    background: linear-gradient(135deg, var(--instagram-gradient-start), var(--instagram-gradient-end));
}

.platform-dot.facebook {
    background: var(--facebook-blue);
}

.platform-info h2 {
    font-size: 1.15rem;
    font-weight: 700;
    color: var(--text-primary);
}

.platform-info p {
    font-size: 0.8rem;
    color: var(--text-secondary);
    font-weight: 400;
}

/* ===== Stats Grid ===== */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(120px, 1fr));
    gap: 0px;
    margin-bottom: 28px;
    background: var(--bg-card);
    border-radius: var(--radius-lg);
    padding: 20px 24px;
    box-shadow: var(--shadow-sm);
    border: 1px solid var(--border-light);
}

.stat-item {
    text-align: left;
    padding: 0 16px;
    border-right: 1px solid var(--border-light);
}

.stat-item:first-child {
    padding-left: 0;
}

.stat-item:last-child {
    border-right: none;
}

.stat-label {
    font-size: 0.65rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: var(--text-muted);
    margin-bottom: 4px;
}

.stat-value {
    font-size: 1.5rem;
    font-weight: 800;
    color: var(--text-primary);
    letter-spacing: -0.02em;
    line-height: 1.2;
}

.stat-value.small {
    font-size: 1.2rem;
}

/* ===== Main Grid ===== */
.main-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 20px;
    margin-bottom: 24px;
}

/* ===== Cards ===== */
.card {
    background: var(--bg-card);
    border-radius: var(--radius-lg);
    padding: 24px;
    box-shadow: var(--shadow-sm);
    border: 1px solid var(--border-light);
    transition: var(--transition);
}

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

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

/* ===== Chart Toggle Buttons ===== */
.chart-toggles {
    display: flex;
    gap: 4px;
    margin-bottom: 16px;
    background: var(--bg-primary);
    padding: 3px;
    border-radius: var(--radius-sm);
    width: fit-content;
}

.chart-toggle-btn {
    padding: 6px 14px;
    border: none;
    background: transparent;
    border-radius: 6px;
    font-family: inherit;
    font-size: 0.75rem;
    font-weight: 600;
    color: var(--text-secondary);
    cursor: pointer;
    transition: var(--transition);
}

.chart-toggle-btn.active {
    background: var(--text-primary);
    color: #fff;
    box-shadow: var(--shadow-sm);
}

.chart-toggle-btn:hover:not(.active) {
    background: var(--bg-hover);
}

/* ===== Chart Container ===== */
.chart-container {
    position: relative;
    height: 260px;
    width: 100%;
}

/* ===== Best Content Section ===== */
.best-content-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 16px;
}

.sort-select {
    appearance: none;
    padding: 6px 28px 6px 10px;
    border: 1.5px solid var(--border-color);
    border-radius: 6px;
    font-family: inherit;
    font-size: 0.75rem;
    font-weight: 600;
    color: var(--text-primary);
    background: var(--bg-card) url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='10' height='10' viewBox='0 0 10 10'%3E%3Cpath d='M2.5 3.5L5 6.5L7.5 3.5' stroke='%236b7280' stroke-width='1.5' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E") no-repeat right 8px center;
    cursor: pointer;
}

/* ===== Content List ===== */
.content-list {
    list-style: none;
}

.content-item {
    display: flex;
    gap: 14px;
    padding: 14px 0;
    border-bottom: 1px solid var(--border-light);
    transition: var(--transition);
}

.content-item:last-child {
    border-bottom: none;
}

.content-rank {
    width: 28px;
    height: 28px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.75rem;
    font-weight: 700;
    flex-shrink: 0;
    margin-top: 2px;
}

.content-rank.rank-1 {
    background: linear-gradient(135deg, #fbbf24, #f59e0b);
    color: #fff;
}

.content-rank.rank-2 {
    background: linear-gradient(135deg, #94a3b8, #64748b);
    color: #fff;
}

.content-rank.rank-3 {
    background: linear-gradient(135deg, #d97706, #b45309);
    color: #fff;
}

.content-rank:not(.rank-1):not(.rank-2):not(.rank-3) {
    background: var(--bg-primary);
    color: var(--text-secondary);
}

.content-details {
    flex: 1;
    min-width: 0;
}

.content-meta {
    font-size: 0.7rem;
    color: var(--text-muted);
    margin-bottom: 4px;
    display: flex;
    gap: 6px;
    align-items: center;
    flex-wrap: wrap;
}

.content-meta .badge {
    display: inline-block;
    padding: 1px 6px;
    border-radius: 4px;
    font-size: 0.65rem;
    font-weight: 600;
}

.badge.engagement-badge {
    background: var(--accent-green-light);
    color: var(--accent-green);
}

.badge.type-badge {
    background: var(--accent-blue-light);
    color: var(--accent-blue);
}

.content-text {
    font-size: 0.8rem;
    color: var(--text-primary);
    line-height: 1.5;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.content-text a {
    color: var(--accent-blue);
    text-decoration: none;
}

.content-text a:hover {
    text-decoration: underline;
}

.view-all-btn {
    display: block;
    width: 100%;
    padding: 12px;
    margin-top: 12px;
    border: 1.5px solid var(--border-color);
    background: transparent;
    border-radius: var(--radius-sm);
    font-family: inherit;
    font-size: 0.8rem;
    font-weight: 600;
    color: var(--text-secondary);
    cursor: pointer;
    transition: var(--transition);
}

.view-all-btn:hover {
    background: var(--bg-hover);
    border-color: var(--text-muted);
    color: var(--text-primary);
}

/* ===== Genel Tab - Combined View ===== */
.combined-stats-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 20px;
    margin-bottom: 24px;
}

.combined-stat-card {
    background: var(--bg-card);
    border-radius: var(--radius-lg);
    padding: 24px;
    box-shadow: var(--shadow-sm);
    border: 1px solid var(--border-light);
}

.combined-stat-card h3 {
    font-size: 0.75rem;
    font-weight: 700;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.08em;
    margin-bottom: 8px;
}

.combined-stat-card .big-value {
    font-size: 2rem;
    font-weight: 800;
    color: var(--text-primary);
    letter-spacing: -0.02em;
}

.combined-stat-card .breakdown {
    display: flex;
    gap: 16px;
    margin-top: 10px;
}

.breakdown-item {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 0.75rem;
    color: var(--text-secondary);
    font-weight: 500;
}

.breakdown-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    flex-shrink: 0;
}

.breakdown-dot.ig {
    background: linear-gradient(135deg, var(--instagram-gradient-start), var(--instagram-gradient-end));
}

.breakdown-dot.fb {
    background: var(--facebook-blue);
}

/* ===== Loading State ===== */
.loading {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 80px 0;
    color: var(--text-muted);
}

.spinner {
    width: 40px;
    height: 40px;
    border: 3px solid var(--border-color);
    border-top-color: var(--accent-blue);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
    margin-bottom: 16px;
}

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

/* ===== Post Type Distribution ===== */
.type-distribution {
    display: flex;
    gap: 12px;
    flex-wrap: wrap;
    margin-top: 8px;
}

.type-chip {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 6px 12px;
    background: var(--bg-primary);
    border-radius: 20px;
    font-size: 0.75rem;
    font-weight: 600;
    color: var(--text-secondary);
}

.type-chip .count {
    background: var(--text-primary);
    color: #fff;
    width: 22px;
    height: 22px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.65rem;
    font-weight: 700;
}

/* ===== Modal ===== */
.modal-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.5);
    backdrop-filter: blur(4px);
    z-index: 1000;
    align-items: center;
    justify-content: center;
    padding: 24px;
}

.modal-overlay.active {
    display: flex;
}

.modal {
    background: var(--bg-card);
    border-radius: var(--radius-xl);
    width: 100%;
    max-width: 700px;
    max-height: 80vh;
    overflow-y: auto;
    padding: 28px;
    box-shadow: var(--shadow-xl);
}

.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
}

.modal-header h2 {
    font-size: 1.15rem;
    font-weight: 700;
}

.modal-close {
    width: 32px;
    height: 32px;
    border: none;
    background: var(--bg-primary);
    border-radius: 50%;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.1rem;
    color: var(--text-secondary);
    transition: var(--transition);
}

.modal-close:hover {
    background: var(--bg-hover);
    color: var(--text-primary);
}

/* ===== Full width card ===== */
.card.full-width {
    grid-column: 1 / -1;
}

/* ===== Responsive ===== */
@media (max-width: 900px) {
    .dashboard-container {
        padding: 16px;
    }
    .dashboard-header {
        flex-direction: column;
        gap: 16px;
    }
    .main-grid {
        grid-template-columns: 1fr;
    }
    .combined-stats-grid {
        grid-template-columns: 1fr;
    }
    .stats-grid {
        grid-template-columns: repeat(3, 1fr);
        gap: 12px;
    }
    .stat-item {
        border-right: none;
        padding: 0;
    }
}

@media (max-width: 600px) {
    .tab-nav {
        width: 100%;
    }
    .tab-btn {
        flex: 1;
        justify-content: center;
        padding: 10px 12px;
        font-size: 0.8rem;
    }
    .stats-grid {
        grid-template-columns: repeat(2, 1fr);
    }
}

/* ===== Scrollbar ===== */
::-webkit-scrollbar {
    width: 6px;
}
::-webkit-scrollbar-track {
    background: transparent;
}
::-webkit-scrollbar-thumb {
    background: var(--border-color);
    border-radius: 3px;
}
::-webkit-scrollbar-thumb:hover {
    background: var(--text-muted);
}
