/* YT Studio Analytics - Frontend Styles */
/* Reset & Base */
.ytsa-dashboard {
    font-family: 'Roboto', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
    max-width: 900px;
    margin: 0 auto;
    padding: 0;
    color: #0d0d0d;
    -webkit-font-smoothing: antialiased;
    position: relative;
}

.ytsa-dashboard * {
    box-sizing: border-box;
}

/* Header */
.ytsa-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 16px 0;
    border-bottom: 1px solid #e5e5e5;
    margin-bottom: 0;
}

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

.ytsa-yt-icon {
    display: flex;
    align-items: center;
}

.ytsa-header-title {
    font-size: 20px;
    font-weight: 500;
    color: #282828;
    letter-spacing: -0.3px;
}

.ytsa-channel-selector select {
    padding: 8px 32px 8px 12px;
    font-size: 14px;
    font-family: 'Roboto', sans-serif;
    border: 1px solid #d1d5db;
    border-radius: 8px;
    background: #fff;
    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='%23666' d='M6 8L1 3h10z'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 10px center;
    color: #282828;
}

.ytsa-channel-selector select:focus {
    outline: none;
    border-color: #ff0000;
    box-shadow: 0 0 0 2px rgba(255,0,0,0.1);
}

/* Channel Banner */
.ytsa-channel-banner {
    display: flex;
    align-items: center;
    gap: 16px;
    padding: 20px 0;
    border-bottom: 1px solid #e5e5e5;
}

.ytsa-channel-avatar {
    width: 56px;
    height: 56px;
    border-radius: 50%;
    overflow: hidden;
    flex-shrink: 0;
    background: #e5e5e5;
}

.ytsa-channel-avatar img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.ytsa-channel-name {
    font-size: 18px;
    font-weight: 500;
    margin: 0 0 6px;
    color: #0d0d0d;
}

.ytsa-channel-stats-row {
    display: flex;
    gap: 20px;
    font-size: 13px;
    color: #606060;
}

.ytsa-channel-stat {
    display: flex;
    align-items: center;
    gap: 4px;
}

.ytsa-channel-stat strong {
    color: #0d0d0d;
    font-weight: 500;
}

/* Tabs */
.ytsa-tabs {
    display: flex;
    border-bottom: 1px solid #e5e5e5;
    padding: 0;
    gap: 0;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
}

.ytsa-tab {
    padding: 14px 20px;
    font-size: 14px;
    font-weight: 500;
    color: #606060;
    background: none;
    border: none;
    border-bottom: 3px solid transparent;
    cursor: pointer;
    white-space: nowrap;
    font-family: 'Roboto', sans-serif;
    transition: color 0.2s, border-color 0.2s;
}

.ytsa-tab:hover {
    color: #0d0d0d;
}

.ytsa-tab.active {
    color: #0d0d0d;
    border-bottom-color: #0d0d0d;
}

/* Period Selector */
.ytsa-period-bar {
    display: flex;
    gap: 6px;
    padding: 14px 0;
}

.ytsa-period-btn {
    padding: 6px 14px;
    font-size: 13px;
    font-weight: 500;
    background: #f2f2f2;
    border: 1px solid transparent;
    border-radius: 18px;
    cursor: pointer;
    color: #606060;
    font-family: 'Roboto', sans-serif;
    transition: all 0.2s;
}

.ytsa-period-btn:hover {
    background: #e5e5e5;
}

.ytsa-period-btn.active {
    background: #0d0d0d;
    color: #fff;
}

/* Loading */
.ytsa-loading {
    display: none;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 60px 20px;
    gap: 16px;
    color: #606060;
    font-size: 14px;
}

.ytsa-loading.visible {
    display: flex;
}

.ytsa-spinner {
    width: 36px;
    height: 36px;
    border: 3px solid #e5e5e5;
    border-top-color: #ff0000;
    border-radius: 50%;
    animation: ytsa-spin 0.8s linear infinite;
}

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

/* Tab Content */
.ytsa-tab-content {
    display: none;
}

.ytsa-tab-content.active {
    display: block;
}

/* Cards / Sections */
.ytsa-card-section {
    background: #fff;
    border: 1px solid #e5e5e5;
    border-radius: 12px;
    padding: 20px 24px;
    margin-bottom: 16px;
}

.ytsa-card-section h3 {
    font-size: 16px;
    font-weight: 500;
    margin: 0 0 4px;
    color: #0d0d0d;
}

.ytsa-section-subtitle {
    font-size: 12px;
    color: #909090;
    margin: 0 0 16px;
}

/* Overview Stats Cards */
.ytsa-overview-stats {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 12px;
    margin-bottom: 16px;
}

.ytsa-stat-card {
    background: #fff;
    border: 1px solid #e5e5e5;
    border-radius: 12px;
    padding: 20px;
    text-align: left;
}

.ytsa-stat-label {
    font-size: 12px;
    color: #606060;
    margin-bottom: 8px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    font-weight: 500;
}

.ytsa-stat-value {
    font-size: 28px;
    font-weight: 500;
    color: #0d0d0d;
    letter-spacing: -0.5px;
}

.ytsa-stat-card:nth-child(1) {
    border-left: 3px solid #ff0000;
}

.ytsa-stat-card:nth-child(2) {
    border-left: 3px solid #065fd4;
}

.ytsa-stat-card:nth-child(3) {
    border-left: 3px solid #2ba640;
}

/* Views Chart */
.ytsa-chart-container {
    position: relative;
    height: 260px;
    margin-bottom: 12px;
}

.ytsa-views-total {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 14px;
    padding-top: 12px;
    border-top: 1px solid #f2f2f2;
}

.ytsa-views-total .ytsa-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: #065fd4;
}

.ytsa-views-total strong {
    font-weight: 500;
}

/* Top Content */
.ytsa-top-content {
    display: flex;
    flex-direction: column;
    gap: 0;
}

.ytsa-video-item {
    display: flex;
    align-items: center;
    gap: 14px;
    padding: 12px 0;
    border-bottom: 1px solid #f2f2f2;
    text-decoration: none;
    color: inherit;
    transition: background 0.15s;
}

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

.ytsa-video-item:hover {
    background: #fafafa;
    margin: 0 -24px;
    padding-left: 24px;
    padding-right: 24px;
}

.ytsa-video-thumb {
    width: 56px;
    height: 56px;
    border-radius: 8px;
    overflow: hidden;
    flex-shrink: 0;
    background: #f2f2f2;
}

.ytsa-video-thumb img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.ytsa-video-info {
    flex: 1;
    min-width: 0;
}

.ytsa-video-title {
    font-size: 14px;
    font-weight: 400;
    color: #0d0d0d;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    margin-bottom: 4px;
}

.ytsa-video-meta {
    color: #606060;
    font-size: 12px;
    margin: -1px 0 6px;
}

.ytsa-video-views-bar {
    width: 100%;
    height: 3px;
    background: #e5e5e5;
    border-radius: 2px;
    overflow: hidden;
}

.ytsa-video-views-bar-fill {
    height: 100%;
    background: #065fd4;
    border-radius: 2px;
    transition: width 0.6s ease;
}

.ytsa-video-views-count {
    font-size: 14px;
    font-weight: 500;
    color: #0d0d0d;
    white-space: nowrap;
    text-align: right;
    min-width: 60px;
}

/* Demographics Bars */
.ytsa-demographics {
    display: flex;
    flex-direction: column;
    gap: 0;
}

.ytsa-demo-item {
    display: flex;
    align-items: center;
    padding: 14px 0;
    border-bottom: 1px solid #f2f2f2;
}

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

.ytsa-demo-label {
    font-size: 14px;
    font-weight: 400;
    color: #0d0d0d;
    width: 130px;
    flex-shrink: 0;
}

.ytsa-demo-bar-container {
    flex: 1;
    margin: 0 16px;
}

.ytsa-demo-bar {
    width: 100%;
    height: 4px;
    background: #e5e5e5;
    border-radius: 2px;
    overflow: hidden;
}

.ytsa-demo-bar-fill {
    height: 100%;
    border-radius: 2px;
    transition: width 0.8s cubic-bezier(0.25, 0.46, 0.45, 0.94);
    width: 0;
}

.ytsa-demo-bar-fill.age-bar,
.ytsa-demo-bar-fill.gender-bar {
    background: linear-gradient(90deg, #7c3aed, #a855f7);
}

.ytsa-demo-bar-fill.geo-bar {
    background: linear-gradient(90deg, #0d0d0d, #404040);
}

.ytsa-demo-percentage {
    font-size: 14px;
    font-weight: 500;
    color: #0d0d0d;
    min-width: 50px;
    text-align: right;
}

/* Content Type Stats */
.ytsa-content-types {
    display: flex;
    flex-direction: column;
    gap: 0;
}

.ytsa-content-type-item {
    display: flex;
    align-items: center;
    padding: 14px 0;
    border-bottom: 1px solid #f2f2f2;
}

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

.ytsa-content-type-label {
    font-size: 14px;
    color: #0d0d0d;
    width: 130px;
    flex-shrink: 0;
}

.ytsa-content-type-bar-container {
    flex: 1;
    margin: 0 16px;
}

.ytsa-content-type-bar {
    width: 100%;
    height: 4px;
    background: #e5e5e5;
    border-radius: 2px;
    overflow: hidden;
}

.ytsa-content-type-bar-fill {
    height: 100%;
    background: linear-gradient(90deg, #065fd4, #4a9eff);
    border-radius: 2px;
    transition: width 0.8s cubic-bezier(0.25, 0.46, 0.45, 0.94);
    width: 0;
}

.ytsa-content-type-views {
    font-size: 14px;
    font-weight: 500;
    color: #0d0d0d;
    min-width: 80px;
    text-align: right;
}

/* Notice */
.ytsa-notice {
    background: #fff3cd;
    border: 1px solid #ffc107;
    padding: 16px 20px;
    border-radius: 8px;
    color: #856404;
    font-size: 14px;
}

.ytsa-error-msg {
    background: #f8d7da;
    border: 1px solid #f5c6cb;
    padding: 12px 16px;
    border-radius: 8px;
    color: #721c24;
    font-size: 13px;
    margin-top: 8px;
}

/* Responsive */
@media (max-width: 768px) {
    .ytsa-dashboard {
        padding: 0 12px;
    }

    .ytsa-overview-stats {
        grid-template-columns: 1fr;
    }

    .ytsa-stat-value {
        font-size: 22px;
    }

    .ytsa-demo-label,
    .ytsa-content-type-label {
        width: 100px;
        font-size: 13px;
    }

    .ytsa-header-title {
        font-size: 16px;
    }

    .ytsa-channel-banner {
        gap: 12px;
    }

    .ytsa-channel-avatar {
        width: 44px;
        height: 44px;
    }

    .ytsa-channel-name {
        font-size: 16px;
    }

    .ytsa-video-item {
        gap: 10px;
    }

    .ytsa-video-thumb {
        width: 44px;
        height: 44px;
    }

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

@media (max-width: 480px) {
    .ytsa-tabs {
        gap: 0;
    }

    .ytsa-tab {
        padding: 12px 14px;
        font-size: 13px;
    }
}

.ytsa-pro-upsell {
    background: linear-gradient(135deg, #f9f9f9 0%, #f0f0f0 100%);
    border: 1px solid #e5e5e5;
    padding: 20px;
    text-align: center;
    border-radius: 8px;
    color: #606060;
    font-size: 14px;
    margin: 10px 0;
}

.ytsa-pro-upsell .ytsa-pro-title {
    font-size: 16px;
    font-weight: 500;
    color: #0d0d0d;
    margin-bottom: 6px;
}

.ytsa-pro-upsell p {
    margin: 0 0 16px 0;
    font-size: 13px;
    line-height: 1.4;
}

.ytsa-pro-upsell-btn {
    background: #0d0d0d;
    color: #fff;
    border-radius: 18px;
    padding: 8px 16px;
    font-weight: 500;
    text-decoration: none;
    transition: background 0.2s;
    font-size: 13px;
    display: inline-block;
}

.ytsa-pro-upsell-btn:hover {
    background: #ff0000;
}

.ytsa-plugin-link {
    margin-top: 14px;
    text-align: right;
    font-size: 12px;
    color: #606060;
}

.ytsa-plugin-link a {
    color: #606060;
    text-decoration: underline;
    text-underline-offset: 2px;
}

.ytsa-plugin-link a:hover {
    color: #0d0d0d;
}
