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

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, sans-serif;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    min-height: 100vh;
    padding: 20px;
    color: #333;
}

.container {
    max-width: 1600px;
    margin: 0 auto;
}

header {
    background: white;
    padding: 30px;
    border-radius: 15px;
    box-shadow: 0 10px 30px rgba(0,0,0,0.2);
    margin-bottom: 30px;
}

header h1 {
    font-size: 2.5em;
    color: #667eea;
    margin-bottom: 20px;
    text-align: center;
    transition: all 0.3s ease;
}

header h1:hover {
    color: #764ba2;
    transform: scale(1.02);
}

.header-stats {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 20px;
    margin-bottom: 20px;
}

.stat-card {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    padding: 20px;
    border-radius: 10px;
    box-shadow: 0 4px 15px rgba(0,0,0,0.1);
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 15px;
}

.stat-content {
    text-align: left;
    flex: 1;
}

.stat-card canvas {
    opacity: 0.8;
    flex-shrink: 0;
}

.stat-value {
    font-size: 2em;
    font-weight: bold;
    margin-bottom: 5px;
}

.stat-label {
    font-size: 0.9em;
    opacity: 0.9;
}

.refresh-btn {
    display: block;
    width: 100%;
    padding: 15px;
    background: #667eea;
    color: white;
    border: none;
    border-radius: 10px;
    font-size: 1.1em;
    cursor: pointer;
    transition: all 0.3s;
    font-weight: 600;
}

.refresh-btn:hover {
    background: #764ba2;
    transform: translateY(-2px);
    box-shadow: 0 5px 15px rgba(0,0,0,0.2);
}

.loading {
    text-align: center;
    padding: 50px;
    background: white;
    border-radius: 15px;
    box-shadow: 0 10px 30px rgba(0,0,0,0.2);
}

.spinner {
    border: 4px solid #f3f3f3;
    border-top: 4px solid #667eea;
    border-radius: 50%;
    width: 50px;
    height: 50px;
    animation: spin 1s linear infinite;
    margin: 0 auto 20px;
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

.error {
    background: #ff4757;
    color: white;
    padding: 20px;
    border-radius: 10px;
    margin-bottom: 20px;
    box-shadow: 0 4px 15px rgba(0,0,0,0.2);
}

.sort-controls {
    background: white;
    padding: 20px;
    border-radius: 15px;
    box-shadow: 0 10px 30px rgba(0,0,0,0.2);
    margin-bottom: 30px;
    display: flex;
    align-items: center;
    gap: 15px;
}

.sort-controls label {
    font-weight: 600;
    color: #667eea;
    font-size: 1.1em;
}

.sort-controls select {
    flex: 1;
    padding: 12px 20px;
    border: 2px solid #667eea;
    border-radius: 10px;
    font-size: 1em;
    background: white;
    color: #333;
    cursor: pointer;
    transition: all 0.3s;
    font-weight: 500;
}

.sort-controls select:hover {
    border-color: #764ba2;
    box-shadow: 0 0 0 3px rgba(102, 126, 234, 0.1);
}

.sort-controls select:focus {
    outline: none;
    border-color: #764ba2;
    box-shadow: 0 0 0 3px rgba(102, 126, 234, 0.2);
}

.channels-grid {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 30px;
    position: relative;
    overflow: visible;
    /* Enable automatic grid row alignment */
    grid-auto-rows: auto;
    align-items: start;
}

/* Channel row wrapper */
.channel-row {
    grid-column: 1 / -1;
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 30px;
    position: relative;
    overflow: visible;
}

/* Master row toggle */
.row-master-toggle {
    grid-column: 1 / -1;
    margin-bottom: 10px;
    display: flex;
    justify-content: flex-end;
}

.master-toggle-btn {
    background: linear-gradient(135deg, #f59e0b 0%, #d97706 100%);
    color: white;
    border: none;
    padding: 12px 24px;
    border-radius: 8px;
    font-size: 0.95em;
    font-weight: 600;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 10px;
    transition: all 0.3s;
    box-shadow: 0 4px 12px rgba(245, 158, 11, 0.3);
}

.master-toggle-btn:hover {
    background: linear-gradient(135deg, #d97706 0%, #b45309 100%);
    transform: translateY(-2px);
    box-shadow: 0 6px 16px rgba(245, 158, 11, 0.4);
}

.master-toggle-icon {
    font-size: 0.9em;
    transition: transform 0.3s;
}

@media (max-width: 1400px) {
    .channels-grid {
        grid-template-columns: repeat(2, 1fr);
    }
}

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

.channel-card {
    background: white;
    border-radius: 15px;
    box-shadow: 0 10px 30px rgba(0,0,0,0.2);
    overflow: hidden;
    transition: transform 0.3s;
    /* Use flexbox for internal structure */
    display: flex;
    flex-direction: column;
    /* Force equal widths */
    min-width: 0;
    max-width: 100%;
    width: 100%;
}

.channel-card:hover {
    transform: translateY(-5px);
}

.channel-header {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    padding: 20px;
    display: flex;
    align-items: center;
    gap: 15px;
}

.channel-thumbnail {
    width: 80px;
    height: 80px;
    border-radius: 50%;
    border: 3px solid white;
}

.channel-info h2 {
    font-size: 1.5em;
    margin-bottom: 5px;
}

.channel-info p {
    opacity: 0.9;
    font-size: 0.9em;
}

.channel-email {
    font-size: 0.85em;
    margin-top: 5px;
    opacity: 0.8;
}

.channel-description {
    font-size: 1.05em;
    margin-top: 8px;
    margin-bottom: 5px;
    color: #ffffff;
    line-height: 1.5;
    font-weight: 500;
    text-shadow: 0 1px 2px rgba(0,0,0,0.2);
}

.channel-stats {
    padding: 20px;
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 15px;
    border-bottom: 2px solid #f0f0f0;
}

.channel-stat {
    text-align: center;
}

.channel-stat-value {
    font-size: 1.5em;
    font-weight: bold;
    color: #667eea;
    margin-bottom: 5px;
}

.channel-stat-label {
    font-size: 0.85em;
    color: #666;
}

.videos-section {
    padding: 20px;
}

.videos-section h3 {
    margin-bottom: 15px;
    color: #333;
    font-size: 1.2em;
}

.videos-list {
    max-height: 400px;
    overflow-y: auto;
}

.video-item {
    display: flex;
    gap: 15px;
    padding: 15px;
    border-bottom: 1px solid #f0f0f0;
    transition: background 0.3s;
}

.video-item:hover {
    background: #f8f9fa;
}

.video-thumbnail {
    width: 120px;
    height: 90px;
    object-fit: cover;
    border-radius: 8px;
    flex-shrink: 0;
    transition: opacity 0.2s ease, transform 0.2s ease;
}

.video-thumbnail:hover {
    opacity: 0.8;
    transform: scale(1.02);
}

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

.video-title {
    font-weight: 600;
    margin-bottom: 8px;
    overflow: hidden;
    text-overflow: ellipsis;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    color: #333;
}

.video-link {
    color: #333;
    text-decoration: none;
    transition: color 0.2s ease;
}

.video-link:hover {
    color: #FF0000;
    text-decoration: underline;
}

.video-link:visited {
    color: #551A8B;
}

.video-stats {
    display: flex;
    gap: 15px;
    font-size: 0.85em;
    color: #666;
}

.video-stat {
    display: flex;
    align-items: center;
    gap: 5px;
}

.video-date {
    font-size: 0.8em;
    color: #999;
    margin-top: 5px;
}

.top-videos {
    margin-top: 30px;
    background: white;
    border-radius: 15px;
    padding: 30px;
    box-shadow: 0 10px 30px rgba(0,0,0,0.2);
}

.top-videos h2 {
    color: #667eea;
    margin-bottom: 20px;
    font-size: 1.8em;
}

.top-video-item {
    display: flex;
    gap: 20px;
    padding: 20px;
    border-bottom: 2px solid #f0f0f0;
    align-items: center;
}

.top-video-rank {
    font-size: 2em;
    font-weight: bold;
    color: #667eea;
    min-width: 50px;
}

.channel-error {
    background: #fff3cd;
    color: #856404;
    padding: 20px;
    border-radius: 10px;
    margin: 20px;
}

/* Scrollbar styling */
.videos-list::-webkit-scrollbar {
    width: 8px;
}

.videos-list::-webkit-scrollbar-track {
    background: #f1f1f1;
    border-radius: 10px;
}

.videos-list::-webkit-scrollbar-thumb {
    background: #667eea;
    border-radius: 10px;
}

.videos-list::-webkit-scrollbar-thumb:hover {
    background: #764ba2;
}

/* Analytics Section */
.analytics-section {
    padding: 20px;
    background: #f8f9fa;
    border-top: 2px solid #f0f0f0;
}

.analytics-section h3 {
    color: #667eea;
    margin-bottom: 20px;
    font-size: 1.3em;
}

.analytics-subsection {
    background: white;
    padding: 20px;
    border-radius: 10px;
    margin-bottom: 20px;
    box-shadow: 0 2px 8px rgba(0,0,0,0.05);
}

.analytics-subsection h4 {
    color: #333;
    margin-bottom: 15px;
    font-size: 1.1em;
}

/* Traffic Sources */
.traffic-source-item {
    margin-bottom: 15px;
}

.traffic-source-name {
    font-weight: 600;
    color: #333;
    margin-bottom: 5px;
    font-size: 0.95em;
}

.traffic-source-bar {
    background: #e9ecef;
    height: 25px;
    border-radius: 12px;
    overflow: hidden;
    margin-bottom: 5px;
}

.traffic-source-fill {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    height: 100%;
    transition: width 0.5s ease;
    display: flex;
    align-items: center;
    justify-content: flex-end;
    padding-right: 10px;
    color: white;
    font-size: 0.85em;
    font-weight: bold;
}

.traffic-source-stats {
    display: flex;
    justify-content: space-between;
    font-size: 0.85em;
    color: #666;
}

/* Engagement Metrics */
.engagement-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(120px, 1fr));
    gap: 15px;
    align-items: stretch;
}

.engagement-metric {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    padding: 15px;
    border-radius: 10px;
    text-align: center;
    box-shadow: 0 4px 10px rgba(0,0,0,0.1);
    transition: transform 0.3s;
    display: flex;
    flex-direction: column;
    justify-content: center;
    min-height: 120px;
}

.engagement-metric:hover {
    transform: translateY(-3px);
    box-shadow: 0 6px 15px rgba(0,0,0,0.15);
}

.engagement-icon {
    font-size: 2em;
    margin-bottom: 8px;
}

.engagement-value {
    font-size: 1.5em;
    font-weight: bold;
    margin-bottom: 5px;
}

.engagement-label {
    font-size: 0.85em;
    opacity: 0.9;
}

/* Responsive design */
@media (max-width: 768px) {
    .channels-grid {
        grid-template-columns: 1fr;
    }

    .header-stats {
        grid-template-columns: repeat(2, 1fr);
    }

    header h1 {
        font-size: 1.8em;
    }

    .video-thumbnail {
        width: 80px;
        height: 60px;
    }

    .engagement-grid {
        grid-template-columns: repeat(2, 1fr);
    }

    .sort-controls {
        flex-direction: column;
        align-items: stretch;
    }

    .sort-controls label {
        text-align: center;
    }
}

/* Activity feed styles for detailed page */
.activity-feed, .activity-feed-detailed {
    display: flex;
    flex-direction: column;
    gap: 15px;
    max-height: 600px;
    overflow-y: auto;
}

.activity-item {
    display: flex;
    gap: 12px;
    padding: 12px;
    background: white;
    border-radius: 8px;
    border-left: 3px solid #667eea;
    transition: all 0.2s;
}

.activity-item:hover {
    transform: translateX(5px);
    box-shadow: 0 2px 8px rgba(0,0,0,0.1);
}

.activity-icon {
    font-size: 1.5em;
    line-height: 1;
}

.activity-content {
    flex: 1;
    font-size: 0.9em;
}

.activity-time {
    font-size: 0.8em;
    color: #999;
    margin-top: 5px;
}

/* Growth Chart Section */
.growth-chart-section {
    padding: 15px 20px;
    background: linear-gradient(135deg, #f5f7fa 0%, #c3cfe2 100%);
    border-radius: 10px;
    margin: 15px 0;
}

.growth-chart-section h3 {
    margin: 0 0 15px 0;
    font-size: 1.1em;
    color: #333;
}

.growth-chart-section canvas {
    max-width: 100%;
    height: 150px !important;
}

/* Comment Management Modal */
.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.7);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
    animation: fadeIn 0.2s ease;
}

@keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

.modal-content {
    background: white;
    border-radius: 15px;
    width: 90%;
    max-width: 800px;
    max-height: 90vh;
    overflow-y: auto;
    box-shadow: 0 20px 60px rgba(0,0,0,0.3);
    animation: slideUp 0.3s ease;
}

@keyframes slideUp {
    from {
        transform: translateY(50px);
        opacity: 0;
    }
    to {
        transform: translateY(0);
        opacity: 1;
    }
}

.modal-header {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    padding: 25px 30px;
    border-radius: 15px 15px 0 0;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.modal-header h2 {
    margin: 0;
    font-size: 1.5em;
}

.modal-close {
    background: rgba(255,255,255,0.2);
    border: none;
    color: white;
    font-size: 1.5em;
    cursor: pointer;
    width: 35px;
    height: 35px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.3s;
}

.modal-close:hover {
    background: rgba(255,255,255,0.3);
    transform: rotate(90deg);
}

.modal-body {
    padding: 30px;
}

.modal-actions {
    display: flex;
    gap: 15px;
    margin-bottom: 25px;
}

.btn {
    padding: 12px 24px;
    border: none;
    border-radius: 8px;
    font-size: 1em;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s;
    display: flex;
    align-items: center;
    gap: 8px;
}

.btn-primary {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
}

.btn-primary:hover {
    transform: translateY(-2px);
    box-shadow: 0 5px 15px rgba(102, 126, 234, 0.3);
}

.btn-secondary {
    background: #6c757d;
    color: white;
    transition: all 0.3s ease;
}

.btn-secondary:hover:not(:disabled) {
    background: #5a6268;
    transform: translateY(-2px);
}

.btn-secondary:disabled {
    background: #adb5bd;
    cursor: not-allowed;
    opacity: 0.6;
}

.btn-danger {
    background: #ef4444;
    color: white;
}

.btn-danger:hover {
    background: #dc2626;
}

.btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
    transform: none !important;
}

.btn-thinking {
    background: #9ca3af !important;
    color: #6b7280 !important;
    cursor: not-allowed !important;
    opacity: 0.6 !important;
    pointer-events: none !important;
}

.unit-cost-warning {
    background: #fff3cd;
    border: 2px solid #ffc107;
    border-radius: 8px;
    padding: 15px 20px;
    margin-bottom: 20px;
    color: #856404;
    display: flex;
    align-items: center;
    gap: 10px;
    font-weight: 600;
}

.unit-cost-warning .icon {
    font-size: 1.5em;
}

.comments-list {
    display: flex;
    flex-direction: column;
    gap: 20px;
}

.comment-item {
    background: #f8f9fa;
    border-radius: 10px;
    padding: 20px;
    border-left: 4px solid #667eea;
    transition: all 0.3s;
}

.comment-item:hover {
    box-shadow: 0 4px 12px rgba(0,0,0,0.1);
    transform: translateX(5px);
}

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

.comment-author {
    font-weight: 700;
    color: #333;
    font-size: 1.1em;
}

.comment-video {
    font-size: 0.85em;
    color: #666;
    font-style: italic;
}

.comment-text {
    color: #333;
    line-height: 1.6;
    margin: 15px 0;
    font-size: 0.95em;
}

.comment-date {
    font-size: 0.8em;
    color: #999;
    margin-bottom: 15px;
}

.comment-reply-box {
    margin-top: 15px;
}

.comment-reply-box textarea {
    width: 100%;
    min-height: 80px;
    padding: 12px;
    border: 2px solid #ddd;
    border-radius: 8px;
    font-family: inherit;
    font-size: 0.95em;
    resize: vertical;
    transition: border-color 0.3s;
}

.comment-reply-box textarea:focus {
    outline: none;
    border-color: #667eea;
}

.comment-reply-box button {
    margin-top: 10px;
}

.no-comments {
    text-align: center;
    padding: 50px;
    color: #999;
}

.no-comments .icon {
    font-size: 4em;
    margin-bottom: 15px;
    opacity: 0.3;
}

.loading-comments {
    text-align: center;
    padding: 40px;
    color: #667eea;
}

.loading-comments .spinner {
    margin: 0 auto 15px;
}

/* Unreplied comment badge */
.unreplied-badge {
    background: #ef4444;
    color: white;
    font-size: 0.75em;
    font-weight: 700;
    padding: 4px 10px;
    border-radius: 12px;
    margin-left: 10px;
    display: inline-flex;
    align-items: center;
    gap: 5px;
    animation: pulse 2s infinite;
}

@keyframes pulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.7; }
}

.channel-header-actions {
    display: flex;
    gap: 10px;
    margin-top: 10px;
}

.btn-comment-reply {
    background: #667eea;
    color: white;
    border: none;
    padding: 8px 16px;
    border-radius: 6px;
    font-size: 0.85em;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s;
    display: flex;
    align-items: center;
    gap: 6px;
}

.btn-comment-reply:hover {
    background: #764ba2;
    transform: translateY(-2px);
}

/* Emoji picker buttons */
.emoji-btn {
    background: #f0f0f0;
    border: 1px solid #ddd;
    border-radius: 5px;
    padding: 5px 8px;
    font-size: 1.2em;
    cursor: pointer;
    transition: all 0.2s;
    line-height: 1;
}

.emoji-btn:hover {
    background: #667eea;
    transform: scale(1.15);
    box-shadow: 0 2px 8px rgba(102, 126, 234, 0.3);
}

.emoji-btn:active {
    transform: scale(1.05);
}

/* Collapsible sections */
.collapsible-section {
    margin-bottom: 10px;
}

/* Row-level fold toggle (left side) */
.row-fold-toggle {
    position: absolute;
    left: -30px;
    top: 50%;
    transform: translateY(-50%);
    width: 25px;
    height: 60px;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    border: none;
    border-radius: 5px 0 0 5px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.2em;
    font-weight: bold;
    transition: all 0.3s;
    box-shadow: -2px 0 8px rgba(102, 126, 234, 0.3);
    z-index: 10;
}

.row-fold-toggle:hover {
    background: linear-gradient(135deg, #764ba2 0%, #667eea 100%);
    box-shadow: -4px 0 12px rgba(102, 126, 234, 0.5);
}

.row-fold-icon {
    transition: transform 0.3s;
}

.row-fold-icon.collapsed {
    transform: rotate(180deg);
}

/* Channel header */
.channel-main-header {
    background: linear-gradient(135deg, #4c5fd5 0%, #5a3a7d 100%);
    color: white;
    padding: 15px 20px;
    border-radius: 10px;
    margin-bottom: 15px;
    box-shadow: 0 4px 12px rgba(76, 95, 213, 0.4);
    /* Force consistent height across all cards */
    min-height: 68px;
    height: 68px;
}

.channel-title-text {
    font-size: 1.3em;
    font-weight: 700;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* Channel stats panel - always visible */
.channel-stats-panel {
    background: white;
    border-radius: 10px;
    padding: 20px;
    margin-top: 15px;
    box-shadow: 0 2px 10px rgba(0,0,0,0.1);
}

/* Collapsible content (hidden when row is folded) */
.channel-collapsible-content {
    display: block;
    transition: all 0.3s ease;
}

/* SUB-SECTIONS - nested folds */
.sub-section {
    margin-bottom: 12px;
}

.sub-header {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 12px 18px;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    border-radius: 8px;
    user-select: none;
    font-weight: 600;
    font-size: 1em;
    box-shadow: 0 2px 8px rgba(102, 126, 234, 0.3);
}

.sub-content {
    max-height: 3000px;
    overflow: hidden;
    transition: max-height 0.4s ease, opacity 0.3s ease;
    opacity: 1;
    margin-top: 10px;
}

.sub-content.collapsed {
    max-height: 0;
    opacity: 0;
    margin-top: 0;
}

.toggle-icon {
    font-size: 0.8em;
    transition: transform 0.3s;
    display: inline-block;
    min-width: 15px;
}

.section-title {
    flex: 1;
}

.section-content {
    padding: 15px 0 0 0;
    transition: all 0.3s;
}

/* Remove default margins from sections inside collapsible content */
.section-content .channel-header,
.section-content .channel-stats,
.section-content .growth-chart-section,
.section-content .analytics-section,
.section-content .videos-section {
    margin-top: 0;
}

.section-content .growth-chart-section h3,
.section-content .videos-section h3 {
    display: none; /* Hide duplicate headings since they're in toggle */
}

/* Toggle Switch for AI Settings */
.toggle-switch {
    position: relative;
    display: inline-block;
    width: 50px;
    height: 26px;
}

.toggle-switch input {
    opacity: 0;
    width: 0;
    height: 0;
}

.toggle-slider {
    position: absolute;
    cursor: pointer;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-color: #ccc;
    transition: .4s;
    border-radius: 34px;
}

.toggle-slider:before {
    position: absolute;
    content: "";
    height: 18px;
    width: 18px;
    left: 4px;
    bottom: 4px;
    background-color: white;
    transition: .4s;
    border-radius: 50%;
}

.toggle-switch input:checked + .toggle-slider {
    background-color: #4caf50;
}

.toggle-switch input:checked + .toggle-slider:before {
    transform: translateX(24px);
}

/* AI Generation Section */
.ai-generation-section {
    background: linear-gradient(135deg, #667eea22 0%, #764ba211 100%);
    border: 2px solid #667eea;
    border-radius: 12px;
    padding: 20px;
    margin-top: 15px;
}

.ai-generation-disabled {
    opacity: 0.5;
    pointer-events: none;
}

.personality-selector {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 10px;
    margin: 15px 0;
}

.personality-btn {
    padding: 12px;
    border: 2px solid #ddd;
    border-radius: 8px;
    background: white;
    cursor: pointer;
    transition: all 0.3s;
    font-weight: 600;
    text-align: center;
}

.personality-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(0,0,0,0.15);
}

.personality-btn.active {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    border-color: #667eea;
}

.generation-history {
    max-height: 200px;
    overflow-y: auto;
    background: white;
    border-radius: 8px;
    padding: 10px;
}

.history-item {
    padding: 10px;
    border-bottom: 1px solid #eee;
    cursor: pointer;
    transition: background 0.2s;
    font-size: 0.9em;
}

.history-item:hover {
    background: #f8f9fa;
}

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

/* Channel Section Headers (Foldable) */
.channel-section-header {
    transition: all 0.2s ease;
    margin-bottom: 1px;
}

.channel-section-header:hover {
    opacity: 0.9;
    transform: translateX(3px);
}

.section-toggle-icon {
    font-size: 0.8em;
    display: inline-block;
    transition: transform 0.3s ease;
}

.main-toggle-icon {
    font-size: 1em;
    display: inline-block;
    transition: transform 0.3s ease;
    font-weight: bold;
}

.channel-main-header:hover {
    opacity: 0.95;
}

.channel-section-content {
    transition: height 0.3s ease, opacity 0.3s ease;
    opacity: 1;
    overflow: hidden;
}

.main-channel-content {
    transition: height 0.3s ease, opacity 0.3s ease;
    opacity: 1;
    overflow: hidden;
}

/* Improve channel stats grid alignment */
.channel-stats {
    background: white;
}

/* Audience Insights Styles */
.audience-insights-container {
    display: flex;
    flex-direction: column;
    gap: 25px;
}

.audience-section {
    background: #f8fafc;
    padding: 15px;
    border-radius: 10px;
    border: 1px solid #e2e8f0;
}

/* Countries List */
.countries-list {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.country-item {
    display: grid;
    grid-template-columns: 140px 1fr 100px;
    align-items: center;
    gap: 12px;
}

.country-info {
    display: flex;
    align-items: center;
    gap: 8px;
}

.country-flag {
    font-size: 1.3em;
}

.country-name {
    font-size: 0.9em;
    font-weight: 500;
    color: #333;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.country-bar-container {
    height: 8px;
    background: #e2e8f0;
    border-radius: 4px;
    overflow: hidden;
}

.country-bar {
    height: 100%;
    background: linear-gradient(90deg, #667eea 0%, #764ba2 100%);
    border-radius: 4px;
    transition: width 0.5s ease;
}

.country-stats {
    display: flex;
    gap: 10px;
    justify-content: flex-end;
    font-size: 0.85em;
}

.country-views {
    color: #333;
    font-weight: 600;
}

.country-percentage {
    color: #667eea;
    font-weight: 600;
}

/* Age Breakdown */
.age-breakdown {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.age-row {
    display: grid;
    grid-template-columns: 50px 1fr 50px;
    align-items: center;
    gap: 10px;
}

.age-label {
    font-size: 0.85em;
    font-weight: 500;
    color: #666;
}

.age-bar-container {
    display: flex;
    height: 16px;
    background: #e2e8f0;
    border-radius: 8px;
    overflow: hidden;
}

.age-bar {
    height: 100%;
    transition: width 0.5s ease;
}

.age-bar.male {
    background: linear-gradient(90deg, #3b82f6 0%, #1d4ed8 100%);
}

.age-bar.female {
    background: linear-gradient(90deg, #ec4899 0%, #be185d 100%);
}

.age-total {
    font-size: 0.85em;
    font-weight: 600;
    color: #333;
    text-align: right;
}

/* Devices Grid */
.devices-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(80px, 1fr));
    gap: 10px;
}

.device-item {
    background: white;
    padding: 12px 8px;
    border-radius: 10px;
    text-align: center;
    box-shadow: 0 2px 8px rgba(0,0,0,0.08);
    transition: transform 0.2s, box-shadow 0.2s;
}

.device-item:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(0,0,0,0.12);
}

.device-icon {
    font-size: 1.8em;
    margin-bottom: 6px;
}

.device-name {
    font-size: 0.75em;
    color: #666;
    margin-bottom: 4px;
}

.device-percentage {
    font-size: 1em;
    font-weight: 700;
    color: #667eea;
}

/* Peak Hours */
.peak-hours {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 10px;
}

.peak-hour-item {
    padding: 12px;
    border-radius: 10px;
    color: white;
    text-align: center;
}

.peak-hour-time {
    font-size: 1.2em;
    font-weight: 700;
    margin-bottom: 4px;
}

.peak-hour-views {
    font-size: 0.8em;
    opacity: 0.9;
}

.hourly-bar:hover {
    opacity: 0.8;
}

/* Responsive adjustments for audience insights */
@media (max-width: 768px) {
    .country-item {
        grid-template-columns: 120px 1fr 80px;
    }

    .peak-hours {
        grid-template-columns: 1fr;
    }

    .devices-grid {
        grid-template-columns: repeat(3, 1fr);
    }
}
