/* =========================================
   YOUTUBE COMMENT ANALYZER - CSS
   ========================================= */

:root {
    --primary: #6C5CE7;
    --primary-dark: #5A4BD1;
    --primary-light: #A29BFE;
    --bg: #0F0F1A;
    --bg-card: #1A1A2E;
    --bg-card-hover: #222240;
    --bg-sidebar: #12122A;
    --text: #E8E8F0;
    --text-secondary: #9C9CB0;
    --text-muted: #6C6C8A;
    --border: #2A2A4A;
    --success: #22C55E;
    --warning: #EAB308;
    --error: #EF4444;
    --info: #3B82F6;
    --shadow: 0 4px 24px rgba(0,0,0,0.3);
    --radius: 12px;
    --radius-sm: 8px;
}

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

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
    background: var(--bg);
    color: var(--text);
    min-height: 100vh;
    line-height: 1.6;
}

/* =========================================
   AUTH PAGES
   ========================================= */

.auth-page {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 100vh;
    background: linear-gradient(135deg, var(--bg) 0%, #1A0A3E 100%);
    padding: 20px;
}

.auth-container {
    width: 100%;
    max-width: 420px;
}

.auth-card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 40px;
    box-shadow: var(--shadow);
}

.auth-header {
    text-align: center;
    margin-bottom: 32px;
}

.auth-header .logo-icon {
    font-size: 48px;
    margin-bottom: 16px;
}

.auth-header h1 {
    font-size: 22px;
    font-weight: 700;
    color: var(--text);
}

.auth-header p {
    color: var(--text-secondary);
    font-size: 14px;
    margin-top: 8px;
}

.auth-form {
    display: flex;
    flex-direction: column;
    gap: 20px;
}

.auth-footer {
    text-align: center;
    margin-top: 24px;
    padding-top: 20px;
    border-top: 1px solid var(--border);
}

.auth-footer a {
    color: var(--primary-light);
    text-decoration: none;
    font-weight: 600;
}

.auth-footer a:hover {
    text-decoration: underline;
}

/* =========================================
   FORM ELEMENTS
   ========================================= */

.form-group {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.form-group label {
    font-size: 13px;
    font-weight: 600;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.form-group input,
.form-group select,
.form-group textarea {
    background: var(--bg);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    padding: 12px 16px;
    font-size: 15px;
    color: var(--text);
    font-family: inherit;
    transition: all 0.2s;
    outline: none;
    width: 100%;
}

.form-group input:focus,
.form-group select:focus {
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(108, 92, 231, 0.15);
}

.form-group input::placeholder {
    color: var(--text-muted);
}

.form-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 16px;
}

.help-text {
    font-size: 12px;
    color: var(--text-muted);
    margin-top: 4px;
}

.input-group {
    display: flex;
    gap: 8px;
}

.input-group input {
    flex: 1;
}

.input-group .btn {
    white-space: nowrap;
}

/* =========================================
   BUTTONS
   ========================================= */

.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 10px 20px;
    border-radius: var(--radius-sm);
    font-size: 14px;
    font-weight: 600;
    font-family: inherit;
    cursor: pointer;
    border: none;
    transition: all 0.2s;
    text-decoration: none;
}

.btn-primary {
    background: var(--primary);
    color: white;
}

.btn-primary:hover {
    background: var(--primary-dark);
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(108, 92, 231, 0.4);
}

.btn-outline {
    background: transparent;
    color: var(--text);
    border: 1px solid var(--border);
}

.btn-outline:hover {
    background: var(--bg-card-hover);
    border-color: var(--primary);
}

.btn-block {
    width: 100%;
}

.btn-lg {
    padding: 14px 28px;
    font-size: 16px;
}

.btn-sm {
    padding: 6px 12px;
    font-size: 12px;
}

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

/* =========================================
   ERROR / SUCCESS MESSAGES
   ========================================= */

.error-message {
    background: rgba(239, 68, 68, 0.1);
    border: 1px solid rgba(239, 68, 68, 0.3);
    color: #FCA5A5;
    padding: 12px 16px;
    border-radius: var(--radius-sm);
    font-size: 14px;
}

.success-message {
    background: rgba(34, 197, 94, 0.1);
    border: 1px solid rgba(34, 197, 94, 0.3);
    color: #86EFAC;
    padding: 12px 16px;
    border-radius: var(--radius-sm);
    font-size: 14px;
}

/* =========================================
   APP LAYOUT
   ========================================= */

.app-layout {
    display: flex;
    min-height: 100vh;
}

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

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

.sidebar-header .logo-icon {
    font-size: 28px;
}

.sidebar-header h2 {
    font-size: 18px;
    font-weight: 700;
    color: var(--text);
}

.sidebar-nav {
    flex: 1;
    padding: 16px 12px;
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.nav-section {
    font-size: 10px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 1px;
    color: var(--text-muted);
    padding: 16px 12px 8px;
}

.nav-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px 12px;
    border-radius: var(--radius-sm);
    color: var(--text-secondary);
    text-decoration: none;
    font-size: 14px;
    font-weight: 500;
    transition: all 0.2s;
}

.nav-item:hover {
    background: var(--bg-card-hover);
    color: var(--text);
}

.nav-item.active {
    background: rgba(108, 92, 231, 0.15);
    color: var(--primary-light);
}

.nav-icon {
    font-size: 18px;
    width: 24px;
    text-align: center;
}

.sidebar-footer {
    padding: 16px 20px;
    border-top: 1px solid var(--border);
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.user-info {
    display: flex;
    align-items: center;
    gap: 10px;
}

.user-avatar {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    background: var(--primary);
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    font-size: 16px;
    color: white;
}

.user-avatar-sm {
    width: 28px;
    height: 28px;
    border-radius: 50%;
    background: var(--primary);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    font-size: 12px;
    color: white;
    margin-right: 8px;
}

.user-details {
    display: flex;
    flex-direction: column;
}

.user-name {
    font-size: 14px;
    font-weight: 600;
    color: var(--text);
}

.user-role {
    font-size: 11px;
    color: var(--text-muted);
    text-transform: capitalize;
}

.btn-logout {
    color: var(--text-muted);
    text-decoration: none;
    font-size: 18px;
    transition: color 0.2s;
}

.btn-logout:hover {
    color: var(--error);
}

/* =========================================
   MAIN CONTENT
   ========================================= */

.main-content {
    flex: 1;
    margin-left: 260px;
    padding: 0;
    min-height: 100vh;
}

.content-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 24px 32px;
    border-bottom: 1px solid var(--border);
    background: var(--bg-card);
    position: sticky;
    top: 0;
    z-index: 50;
}

.content-header h1 {
    font-size: 24px;
    font-weight: 700;
}

.content-body {
    padding: 32px;
}

/* =========================================
   CARDS
   ========================================= */

.card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    margin-bottom: 24px;
    overflow: hidden;
}

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

.card-header h3 {
    font-size: 16px;
    font-weight: 600;
}

.card-body {
    padding: 20px;
}

.badge {
    background: rgba(108, 92, 231, 0.15);
    color: var(--primary-light);
    padding: 4px 12px;
    border-radius: 20px;
    font-size: 12px;
    font-weight: 600;
}

/* =========================================
   TABLES
   ========================================= */

.table-responsive {
    overflow-x: auto;
}

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

.table th,
.table td {
    padding: 12px 16px;
    text-align: left;
    border-bottom: 1px solid var(--border);
    font-size: 14px;
}

.table th {
    font-size: 11px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: var(--text-muted);
    background: rgba(0,0,0,0.2);
}

.table tr:hover td {
    background: var(--bg-card-hover);
}

.video-link {
    color: var(--primary-light);
    text-decoration: none;
    font-weight: 500;
}

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

.user-cell {
    display: flex;
    align-items: center;
}

/* =========================================
   STATUS BADGES
   ========================================= */

.status-badge {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 3px 10px;
    border-radius: 20px;
    font-size: 12px;
    font-weight: 600;
}

.status-badge.success {
    background: rgba(34, 197, 94, 0.15);
    color: #86EFAC;
}

.status-badge.warning {
    background: rgba(234, 179, 8, 0.15);
    color: #FDE68A;
}

.status-badge.error {
    background: rgba(239, 68, 68, 0.15);
    color: #FCA5A5;
}

.role-badge {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 2px 10px;
    border-radius: 20px;
    font-size: 12px;
    font-weight: 600;
}

.role-badge.admin {
    background: rgba(239, 68, 68, 0.15);
    color: #FCA5A5;
}

.role-badge.user {
    background: rgba(59, 130, 246, 0.15);
    color: #93C5FD;
}

/* =========================================
   SENTIMENT BAR
   ========================================= */

.sentiment-bar {
    display: flex;
    height: 8px;
    border-radius: 4px;
    overflow: hidden;
    width: 120px;
    background: var(--bg);
}

.sent-pos {
    background: var(--success);
    height: 100%;
}

.sent-neu {
    background: var(--warning);
    height: 100%;
}

.sent-neg {
    background: var(--error);
    height: 100%;
}

/* =========================================
   EMPTY STATE
   ========================================= */

.empty-state {
    text-align: center;
    padding: 60px 20px;
}

.empty-icon {
    font-size: 64px;
    margin-bottom: 20px;
    opacity: 0.5;
}

.empty-state h2 {
    font-size: 24px;
    margin-bottom: 12px;
}

.empty-state p {
    color: var(--text-secondary);
    margin-bottom: 24px;
}

.empty-text {
    color: var(--text-muted);
    text-align: center;
    padding: 20px;
}

/* =========================================
   ANALYSIS FORM
   ========================================= */

.analysis-form {
    max-width: 800px;
}

.loading-state {
    text-align: center;
    padding: 40px;
    margin-top: 20px;
}

.spinner {
    width: 48px;
    height: 48px;
    border: 4px solid var(--border);
    border-top-color: var(--primary);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
    margin: 0 auto 20px;
}

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

.loading-state h3 {
    margin-bottom: 8px;
}

.loading-state p {
    color: var(--text-secondary);
    margin-bottom: 20px;
}

.progress-bar {
    width: 100%;
    max-width: 400px;
    height: 8px;
    background: var(--border);
    border-radius: 4px;
    overflow: hidden;
    margin: 0 auto;
}

.progress-fill {
    height: 100%;
    background: linear-gradient(90deg, var(--primary), var(--primary-light));
    border-radius: 4px;
    transition: width 0.3s;
    width: 0%;
}

/* =========================================
   RESULTS
   ========================================= */

.result-header {
    margin-bottom: 24px;
}

.result-header h2 {
    font-size: 22px;
    margin-bottom: 8px;
}

.result-meta {
    display: flex;
    gap: 16px;
    color: var(--text-secondary);
    font-size: 14px;
    flex-wrap: wrap;
}

.result-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 24px;
    margin-bottom: 32px;
}

.result-header-card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 24px;
    margin-bottom: 24px;
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
}

.result-title h2 {
    font-size: 20px;
    margin-bottom: 8px;
}

.result-title p {
    color: var(--text-secondary);
    font-size: 14px;
}

.result-date {
    color: var(--text-muted) !important;
    font-size: 12px !important;
    margin-top: 4px;
}

.error-card {
    text-align: center;
    padding: 40px;
    background: var(--bg-card);
    border: 1px solid rgba(239, 68, 68, 0.3);
    border-radius: var(--radius);
    margin-top: 24px;
}

.error-icon {
    font-size: 48px;
    margin-bottom: 16px;
}

.error-card h3 {
    margin-bottom: 8px;
    color: #FCA5A5;
}

.error-card p {
    color: var(--text-secondary);
    margin-bottom: 20px;
}

/* =========================================
   WORD CLOUD
   ========================================= */

.word-cloud {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    justify-content: center;
    align-items: center;
    padding: 20px;
    min-height: 150px;
}

.cloud-word {
    display: inline-block;
    padding: 4px 8px;
    border-radius: 4px;
    color: var(--primary-light);
    font-weight: 500;
    transition: all 0.2s;
    cursor: default;
    line-height: 1.4;
}

.cloud-word:hover {
    background: rgba(108, 92, 231, 0.15);
    transform: scale(1.1);
}

/* =========================================
   LISTS
   ========================================= */

.questions-list,
.patterns-list {
    list-style: none;
    padding: 0;
}

.questions-list li,
.patterns-list li {
    padding: 10px 14px;
    border-bottom: 1px solid var(--border);
    font-size: 14px;
    color: var(--text);
}

.questions-list li:last-child,
.patterns-list li:last-child {
    border-bottom: none;
}

.questions-list li::before {
    content: "❓ ";
}

.patterns-list li::before {
    content: "💬 ";
}

.empty-item {
    color: var(--text-muted) !important;
    font-style: italic;
}

.empty-item::before {
    content: "" !important;
}

/* =========================================
   ACTION BAR
   ========================================= */

.action-bar {
    display: flex;
    gap: 12px;
    justify-content: center;
    margin-top: 24px;
}

/* =========================================
   STATS GRID
   ========================================= */

.stats-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 20px;
    margin-bottom: 32px;
}

.stat-card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 24px;
    display: flex;
    align-items: center;
    gap: 16px;
}

.stat-icon {
    font-size: 36px;
    width: 56px;
    height: 56px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(108, 92, 231, 0.1);
    border-radius: 12px;
}

.stat-info {
    display: flex;
    flex-direction: column;
}

.stat-value {
    font-size: 28px;
    font-weight: 800;
    color: var(--text);
    line-height: 1.2;
}

.stat-label {
    font-size: 13px;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

/* =========================================
   RESPONSIVE
   ========================================= */

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

@media (max-width: 768px) {
    .sidebar {
        width: 60px;
    }
    .sidebar-header h2,
    .sidebar-nav .nav-item span,
    .nav-section,
    .user-details,
    .sidebar-footer .btn-logout {
        display: none;
    }
    .sidebar-header {
        justify-content: center;
        padding: 16px 8px;
    }
    .sidebar-nav {
        padding: 8px 4px;
    }
    .nav-item {
        justify-content: center;
        padding: 10px;
    }
    .sidebar-footer {
        justify-content: center;
        padding: 12px 8px;
    }
    .main-content {
        margin-left: 60px;
    }
    .content-header {
        padding: 16px;
        flex-direction: column;
        gap: 12px;
    }
    .content-body {
        padding: 16px;
    }
    .stats-grid {
        grid-template-columns: 1fr;
    }
    .form-row {
        grid-template-columns: 1fr;
    }
    .input-group {
        flex-direction: column;
    }
    .result-meta {
        flex-direction: column;
        gap: 4px;
    }
    .result-header-card {
        flex-direction: column;
        gap: 12px;
    }
}

/* =========================================
   SCROLLBAR
   ========================================= */

::-webkit-scrollbar {
    width: 8px;
    height: 8px;
}

::-webkit-scrollbar-track {
    background: var(--bg);
}

::-webkit-scrollbar-thumb {
    background: var(--border);
    border-radius: 4px;
}

::-webkit-scrollbar-thumb:hover {
    background: var(--text-muted);
}

/* =========================================
   CANVAS (Chart.js)
   ========================================= */

canvas {
    max-height: 280px;
    max-width: 100%;
}
