/* YouTube Subscriber Tracer - Premium Stylesheet */

:root {
    --bg-dark: #070b15;
    --card-bg: rgba(22, 30, 49, 0.65);
    --card-border: rgba(255, 255, 255, 0.06);
    --input-bg: rgba(15, 22, 38, 0.8);
    --input-border: rgba(255, 255, 255, 0.1);
    
    --primary: #ff2a44;
    --primary-gradient: linear-gradient(135deg, #ff2a44, #d60021);
    --primary-hover: #ff475f;
    
    --blue: #3b82f6;
    --blue-gradient: linear-gradient(135deg, #3b82f6, #1d4ed8);
    
    --purple: #8b5cf6;
    --purple-gradient: linear-gradient(135deg, #8b5cf6, #6d28d9);
    
    --green: #10b981;
    
    --text-primary: #f8fafc;
    --text-secondary: #94a3b8;
    --text-muted: #64748b;
    
    --glass-shadow: 0 8px 32px 0 rgba(0, 0, 0, 0.37);
    --transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

/* Reset & Base Styles */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    background-color: var(--bg-dark);
    color: var(--text-primary);
    font-family: 'Outfit', 'Noto Sans KR', sans-serif;
    min-height: 100vh;
    overflow-x: hidden;
    position: relative;
    line-height: 1.5;
}

/* Glowing Background Blobs */
.bg-glow {
    position: fixed;
    width: 600px;
    height: 600px;
    border-radius: 50%;
    z-index: -1;
    pointer-events: none;
    filter: blur(150px);
}

.bg-glow-1 {
    top: -200px;
    left: -200px;
    background: rgba(255, 42, 68, 0.08);
}

.bg-glow-2 {
    bottom: -250px;
    right: -200px;
    background: rgba(59, 130, 246, 0.08);
}

/* Scrollbar Styling */
::-webkit-scrollbar {
    width: 8px;
    height: 8px;
}
::-webkit-scrollbar-track {
    background: rgba(0, 0, 0, 0.2);
}
::-webkit-scrollbar-thumb {
    background: rgba(255, 255, 255, 0.1);
    border-radius: 4px;
}
::-webkit-scrollbar-thumb:hover {
    background: rgba(255, 255, 255, 0.2);
}

/* Typography Helpers */
h1, h2, h3, h4, h5, h6 {
    font-weight: 600;
    letter-spacing: -0.02em;
}

span.font-semibold {
    font-weight: 600;
}

.text-center { text-align: center; }
.text-muted { color: var(--text-muted); }

/* Common UI Elements */
.hidden {
    display: none !important;
}

/* Input Fields */
.form-group {
    margin-bottom: 1.25rem;
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.form-group label {
    font-size: 0.85rem;
    font-weight: 500;
    color: var(--text-secondary);
}

.input-wrapper {
    position: relative;
    display: flex;
    align-items: center;
}

.input-icon {
    position: absolute;
    left: 1rem;
    color: var(--text-muted);
    width: 18px;
    height: 18px;
    pointer-events: none;
}

.input-wrapper input, .input-wrapper select {
    width: 100%;
    padding: 0.75rem 1rem 0.75rem 2.5rem;
    background: var(--input-bg);
    border: 1px solid var(--input-border);
    border-radius: 12px;
    color: var(--text-primary);
    font-family: inherit;
    font-size: 0.95rem;
    transition: var(--transition);
}

.input-wrapper input:focus, .input-wrapper select:focus {
    outline: none;
    border-color: rgba(255, 42, 68, 0.5);
    box-shadow: 0 0 0 4px rgba(255, 42, 68, 0.15);
}

.form-help {
    font-size: 0.75rem;
    color: var(--text-muted);
    margin-top: 0.25rem;
}

/* Buttons */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    padding: 0.75rem 1.5rem;
    border-radius: 12px;
    font-size: 0.95rem;
    font-weight: 600;
    cursor: pointer;
    transition: var(--transition);
    border: none;
    font-family: inherit;
}

.btn-primary {
    background: var(--primary-gradient);
    color: white;
    box-shadow: 0 4px 15px rgba(255, 42, 68, 0.25);
}

.btn-primary:hover {
    background: var(--primary-hover);
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(255, 42, 68, 0.35);
}

.btn-primary:active {
    transform: translateY(0);
}

.btn-outline {
    background: rgba(255, 255, 255, 0.03);
    border: 1px solid var(--card-border);
    color: var(--text-primary);
}

.btn-outline:hover {
    background: rgba(255, 255, 255, 0.08);
    border-color: rgba(255, 255, 255, 0.15);
    transform: translateY(-2px);
}

.btn-block {
    width: 100%;
}

.btn-sm {
    padding: 0.5rem 1rem;
    font-size: 0.85rem;
    border-radius: 8px;
}

/* 1. AUTH CONTAINER (Login & Setup) */
.auth-container {
    display: flex;
    justify-content: center;
    align-items: center;
    min-height: 100vh;
    padding: 2rem;
}

.auth-card {
    background: var(--card-bg);
    border: 1px solid var(--card-border);
    border-radius: 24px;
    padding: 2.5rem;
    width: 100%;
    max-width: 420px;
    box-shadow: var(--glass-shadow);
    backdrop-filter: blur(16px);
    animation: slideUp 0.6s cubic-bezier(0.16, 1, 0.3, 1) forwards;
}

.auth-header {
    text-align: center;
    margin-bottom: 2rem;
}

.youtube-logo-icon {
    width: 56px;
    height: 56px;
    background: var(--primary-gradient);
    border-radius: 16px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    margin-bottom: 1.25rem;
    box-shadow: 0 8px 24px rgba(255, 42, 68, 0.3);
}

.youtube-logo-icon i {
    color: white;
    width: 24px;
    height: 24px;
    fill: white;
    transform: translateX(2px);
}

.auth-header h2 {
    font-size: 1.5rem;
    margin-bottom: 0.5rem;
}

.auth-header p {
    font-size: 0.9rem;
    color: var(--text-secondary);
}

/* 2. MAIN CONTAINER */
.main-container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 2rem 1.5rem;
    animation: fadeIn 0.8s ease forwards;
}

/* Header */
.main-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 2.5rem;
}

.logo-area {
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.logo-icon {
    width: 40px;
    height: 40px;
    background: rgba(255, 42, 68, 0.1);
    border: 1px solid rgba(255, 42, 68, 0.2);
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--primary);
}

.logo-icon i {
    width: 20px;
    height: 20px;
}

.logo-area h1 {
    font-size: 1.5rem;
    font-weight: 700;
}

.logo-area h1 span {
    background: var(--primary-gradient);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
}

.nav-actions {
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

/* Stats Overview */
.stats-overview {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
    gap: 1.5rem;
    margin-bottom: 2.5rem;
}

.stat-card {
    background: var(--card-bg);
    border: 1px solid var(--card-border);
    border-radius: 20px;
    padding: 1.5rem;
    display: flex;
    align-items: center;
    gap: 1.25rem;
    box-shadow: var(--glass-shadow);
    backdrop-filter: blur(16px);
    transition: var(--transition);
}

.stat-card:hover {
    transform: translateY(-4px);
    border-color: rgba(255, 255, 255, 0.12);
}

.stat-icon {
    width: 52px;
    height: 52px;
    border-radius: 14px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.stat-icon i {
    width: 24px;
    height: 24px;
}

.icon-red {
    background: rgba(255, 42, 68, 0.1);
    color: var(--primary);
}

.icon-purple {
    background: rgba(139, 92, 246, 0.1);
    color: var(--purple);
}

.icon-blue {
    background: rgba(59, 130, 246, 0.1);
    color: var(--blue);
}

.stat-info h3 {
    font-size: 0.85rem;
    color: var(--text-secondary);
    font-weight: 500;
    margin-bottom: 0.25rem;
}

.stat-info p {
    font-size: 1.4rem;
    font-weight: 700;
    font-family: 'Outfit', sans-serif;
}

#btn-show-comparison {
    cursor: pointer;
}

#btn-show-comparison .stat-info p {
    font-size: 1.15rem;
    font-weight: 600;
    color: var(--blue);
}

/* Channels Section */
.channels-section {
    background: var(--card-bg);
    border: 1px solid var(--card-border);
    border-radius: 24px;
    padding: 2rem;
    box-shadow: var(--glass-shadow);
    backdrop-filter: blur(16px);
}

.section-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 2rem;
    flex-wrap: wrap;
    gap: 1rem;
}

.section-header h2 {
    font-size: 1.25rem;
}

.search-bar {
    position: relative;
    display: flex;
    align-items: center;
    width: 320px;
}

.search-bar i {
    position: absolute;
    left: 1rem;
    color: var(--text-muted);
    width: 18px;
    height: 18px;
}

.search-bar input {
    width: 100%;
    padding: 0.65rem 1rem 0.65rem 2.5rem;
    background: rgba(0, 0, 0, 0.2);
    border: 1px solid var(--input-border);
    border-radius: 12px;
    color: var(--text-primary);
    font-family: inherit;
    font-size: 0.9rem;
    transition: var(--transition);
}

.search-bar input:focus {
    outline: none;
    border-color: rgba(255, 42, 68, 0.4);
}

/* Channels Grid */
.channels-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
    gap: 1.5rem;
}

.channel-card {
    background: rgba(10, 15, 28, 0.5);
    border: 1px solid var(--card-border);
    border-radius: 18px;
    padding: 1.25rem;
    display: flex;
    flex-direction: column;
    gap: 1.25rem;
    transition: var(--transition);
}

.channel-card:hover {
    transform: translateY(-3px);
    border-color: rgba(255, 255, 255, 0.1);
    box-shadow: 0 10px 25px rgba(0, 0, 0, 0.2);
}

.channel-card-top {
    display: flex;
    align-items: center;
    gap: 1rem;
}

.channel-avatar {
    width: 52px;
    height: 52px;
    border-radius: 50%;
    object-fit: cover;
    border: 2px solid rgba(255, 255, 255, 0.08);
}

.channel-avatar-sm {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    object-fit: cover;
}

.channel-main-info {
    overflow: hidden;
    display: flex;
    flex-direction: column;
    gap: 0.15rem;
}

.channel-name {
    font-size: 1rem;
    color: var(--text-primary);
    white-space: nowrap;
    text-overflow: ellipsis;
    overflow: hidden;
}

.channel-handle {
    font-size: 0.8rem;
    color: var(--text-secondary);
    font-family: 'Outfit', sans-serif;
}

.channel-card-body {
    background: rgba(0, 0, 0, 0.15);
    border-radius: 12px;
    padding: 0.85rem 1rem;
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.channel-stat-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-size: 0.85rem;
}

.stat-label {
    color: var(--text-secondary);
}

.stat-value {
    font-weight: 600;
    font-family: 'Outfit', sans-serif;
}

.channel-card-actions {
    display: grid;
    grid-template-columns: 1fr 1fr 1fr auto;
    gap: 0.4rem;
}

.btn-icon {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.25rem;
    padding: 0.5rem 0.25rem;
    border-radius: 8px;
    font-size: 0.75rem;
    font-weight: 600;
    cursor: pointer;
    border: none;
    font-family: inherit;
    transition: var(--transition);
}

.btn-icon i {
    width: 14px;
    height: 14px;
}

.btn-icon-red {
    background: rgba(255, 42, 68, 0.1);
    color: var(--primary);
}
.btn-icon-red:hover {
    background: rgba(255, 42, 68, 0.2);
}

.btn-icon-blue {
    background: rgba(59, 130, 246, 0.1);
    color: var(--blue);
}
.btn-icon-blue:hover {
    background: rgba(59, 130, 246, 0.2);
}

.btn-icon-purple {
    background: rgba(139, 92, 246, 0.1);
    color: var(--purple);
}
.btn-icon-purple:hover {
    background: rgba(139, 92, 246, 0.2);
}

.btn-icon-delete {
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(255, 255, 255, 0.03);
    border: 1px solid var(--card-border);
    color: var(--text-muted);
    border-radius: 8px;
    padding: 0.5rem;
    cursor: pointer;
    transition: var(--transition);
}

.btn-icon-delete:hover {
    background: rgba(255, 42, 68, 0.15);
    color: var(--primary);
    border-color: transparent;
}

.btn-icon-delete i {
    width: 14px;
    height: 14px;
}

/* Empty State */
.empty-state {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 4rem 2rem;
    text-align: center;
    color: var(--text-secondary);
    gap: 1rem;
}

.empty-icon {
    width: 48px;
    height: 48px;
    color: var(--text-muted);
}

/* 3. MODALS */
.modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.6);
    backdrop-filter: blur(8px);
    z-index: 100;
    display: flex;
    justify-content: center;
    align-items: center;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.3s ease;
}

.modal.active {
    opacity: 1;
    pointer-events: auto;
}

.modal-content {
    background: #111827;
    border: 1px solid var(--card-border);
    border-radius: 20px;
    padding: 2rem;
    width: 100%;
    max-width: 480px;
    box-shadow: 0 20px 50px rgba(0, 0, 0, 0.5);
    transform: scale(0.9);
    transition: transform 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
}

.modal.active .modal-content {
    transform: scale(1);
}

.modal-lg .modal-content {
    max-width: 800px;
}

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

.modal-header h2 {
    font-size: 1.25rem;
}

.close-btn {
    background: none;
    border: none;
    color: var(--text-secondary);
    font-size: 1.5rem;
    cursor: pointer;
    transition: var(--transition);
}

.close-btn:hover {
    color: var(--text-primary);
}

.modal-footer {
    display: flex;
    justify-content: flex-end;
    gap: 0.75rem;
    margin-top: 1.5rem;
}

.modal-static-text {
    padding: 0.75rem 1rem;
    background: rgba(0, 0, 0, 0.2);
    border-radius: 12px;
    border: 1px solid var(--card-border);
    font-weight: 500;
}

/* Trend Channel Info in Modal */
.trend-channel-info {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    text-align: left;
}

.trend-channel-info h2 {
    font-size: 1.15rem;
    margin-bottom: 0.1rem;
}

.trend-channel-info p {
    font-size: 0.8rem;
    color: var(--text-secondary);
}

/* Chart Styles */
.chart-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1rem;
}

.chart-header h3 {
    font-size: 0.95rem;
    color: var(--text-secondary);
}

.chart-filters {
    display: flex;
    background: rgba(0, 0, 0, 0.2);
    padding: 0.2rem;
    border-radius: 8px;
    border: 1px solid var(--card-border);
}

.btn-filter {
    background: none;
    border: none;
    color: var(--text-secondary);
    padding: 0.35rem 0.8rem;
    font-size: 0.8rem;
    font-weight: 600;
    border-radius: 6px;
    cursor: pointer;
    transition: var(--transition);
    font-family: inherit;
}

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

.chart-container {
    background: rgba(0,0,0,0.15);
    border-radius: 16px;
    padding: 1rem;
    border: 1px solid var(--card-border);
    margin-bottom: 1.5rem;
}

.no-chart-data {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    height: 250px;
    color: var(--text-secondary);
    gap: 0.5rem;
    font-size: 0.9rem;
}

.no-chart-data i {
    width: 28px;
    height: 28px;
    color: var(--text-muted);
}

/* History Table Styles */
.log-history-section h3 {
    font-size: 0.95rem;
    color: var(--text-secondary);
    margin-bottom: 0.75rem;
}

.table-wrapper {
    max-height: 250px;
    overflow-y: auto;
    border-radius: 12px;
    border: 1px solid var(--card-border);
}

.history-table {
    width: 100%;
    border-collapse: collapse;
    text-align: left;
    font-size: 0.85rem;
}

.history-table th, .history-table td {
    padding: 0.75rem 1rem;
}

.history-table th {
    background: rgba(0, 0, 0, 0.3);
    color: var(--text-secondary);
    font-weight: 600;
    position: sticky;
    top: 0;
    z-index: 10;
}

.history-table tr {
    border-bottom: 1px solid rgba(255, 255, 255, 0.04);
}

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

.history-table tr:hover td {
    background: rgba(255, 255, 255, 0.01);
}

/* Trend status */
.change-up {
    color: var(--primary);
    display: inline-flex;
    align-items: center;
    font-weight: 500;
}
.change-up i {
    width: 12px;
    height: 12px;
    margin-right: 2px;
}

.change-down {
    color: var(--blue);
    display: inline-flex;
    align-items: center;
    font-weight: 500;
}
.change-down i {
    width: 12px;
    height: 12px;
    margin-right: 2px;
}

.change-neutral {
    color: var(--text-muted);
}

.btn-table-delete {
    background: none;
    border: none;
    color: var(--text-muted);
    cursor: pointer;
    transition: var(--transition);
    padding: 0.2rem;
    border-radius: 4px;
}

.btn-table-delete:hover {
    color: var(--primary);
    background: rgba(255, 42, 68, 0.1);
}

.btn-table-delete i {
    width: 14px;
    height: 14px;
}

/* Loading Overlay */
.loading-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(7, 11, 21, 0.85);
    backdrop-filter: blur(4px);
    z-index: 999;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    gap: 1rem;
    transition: opacity 0.3s ease;
}

.spinner {
    width: 48px;
    height: 48px;
    border: 4px solid rgba(255, 255, 255, 0.1);
    border-top: 4px solid var(--primary);
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

.loading-overlay p {
    font-size: 0.95rem;
    color: var(--text-secondary);
}

/* Toast Notifications */
.toast-container {
    position: fixed;
    bottom: 2rem;
    right: 2rem;
    z-index: 1000;
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
    pointer-events: none;
}

.toast {
    background: #111827;
    border: 1px solid var(--card-border);
    border-radius: 12px;
    padding: 1rem 1.25rem;
    display: flex;
    align-items: center;
    gap: 0.75rem;
    box-shadow: 0 10px 25px rgba(0, 0, 0, 0.3);
    min-width: 280px;
    max-width: 380px;
    pointer-events: auto;
    transform: translateX(120%);
    transition: transform 0.4s cubic-bezier(0.16, 1, 0.3, 1);
}

.toast.active {
    transform: translateX(0);
}

.toast i {
    width: 20px;
    height: 20px;
    flex-shrink: 0;
}

.toast-success {
    border-left: 4px solid var(--green);
}
.toast-success i {
    color: var(--green);
}

.toast-error {
    border-left: 4px solid var(--primary);
}
.toast-error i {
    color: var(--primary);
}

.toast-info {
    border-left: 4px solid var(--blue);
}
.toast-info i {
    color: var(--blue);
}

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

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

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

/* Responsive adjustments */
@media (max-width: 768px) {
    .main-header {
        flex-direction: column;
        align-items: flex-start;
        gap: 1rem;
    }
    
    .nav-actions {
        width: 100%;
        justify-content: space-between;
    }
    
    .section-header {
        flex-direction: column;
        align-items: flex-start;
    }
    
    .search-bar {
        width: 100%;
    }
    
    .modal-content {
        padding: 1.5rem;
        margin: 1rem;
    }
    
    .toast-container {
        left: 1.5rem;
        right: 1.5rem;
        bottom: 1.5rem;
    }
    
    .toast {
        min-width: 0;
        width: 100%;
    }
}
