/* ==========================================
   DESIGN SYSTEM VARIABLES & THEME RESET
   ========================================== */
:root {
    --bg-gradient: radial-gradient(circle at 50% 50%, #101430 0%, #060814 100%);
    --panel-bg: rgba(16, 20, 38, 0.65);
    --panel-border: rgba(255, 255, 255, 0.08);
    --panel-shadow: 0 12px 40px 0 rgba(0, 0, 0, 0.5);
    --glass-blur: blur(16px) saturate(180%);
    
    /* Neon Palette */
    --color-primary: #8a2be2;      /* Neon Purple */
    --color-primary-glow: rgba(138, 43, 226, 0.4);
    --color-secondary: #00f2fe;    /* Neon Cyan */
    --color-secondary-glow: rgba(0, 242, 254, 0.3);
    
    /* Semantic Colors */
    --color-success: #10b981;      /* Emerald */
    --color-success-glow: rgba(16, 185, 129, 0.2);
    --color-danger: #ef4444;       /* Ruby Red */
    --color-danger-glow: rgba(239, 68, 68, 0.25);
    
    /* Neutrals */
    --text-main: #f3f4f6;
    --text-muted: #9ca3af;
    --text-dark: #1f2937;
    --border-radius: 16px;
    --transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

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

body {
    font-family: 'Outfit', sans-serif;
    background: var(--bg-gradient);
    color: var(--text-main);
    min-height: 100vh;
    overflow-x: hidden;
    line-height: 1.5;
}

/* Custom Scrollbars */
::-webkit-scrollbar {
    width: 8px;
    height: 8px;
}
::-webkit-scrollbar-track {
    background: rgba(6, 8, 20, 0.5);
}
::-webkit-scrollbar-thumb {
    background: rgba(138, 43, 226, 0.3);
    border-radius: 4px;
}
::-webkit-scrollbar-thumb:hover {
    background: rgba(0, 242, 254, 0.5);
}

/* ==========================================
   LAYOUT STRUCTURE
   ========================================== */
.app-container {
    display: grid;
    grid-template-columns: 320px 1fr;
    min-height: 100vh;
}

/* Glassmorphism Utility */
.glass {
    background: var(--panel-bg);
    backdrop-filter: var(--glass-blur);
    -webkit-backdrop-filter: var(--glass-blur);
    border: 1px solid var(--panel-border);
    box-shadow: var(--panel-shadow);
    border-radius: var(--border-radius);
}

/* ==========================================
   SIDEBAR NAVIGATION
   ========================================== */
.sidebar {
    padding: 20px 18px;
    display: flex;
    flex-direction: column;
    justify-content: flex-start;
    gap: 16px;
    height: 100vh;
    position: sticky;
    top: 0;
    border-radius: 0;
    border-top: none;
    border-bottom: none;
    border-left: none;
    background: rgba(10, 12, 28, 0.85);
    overflow-y: auto;
}

.brand {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 8px;
}
.logo-icon {
    font-size: 2.5rem;
    color: #ff0000;
    filter: drop-shadow(0 0 10px rgba(255, 0, 0, 0.5));
}
.brand-text h1 {
    font-size: 1.5rem;
    font-weight: 800;
    letter-spacing: -0.5px;
    background: linear-gradient(135deg, #ffffff 0%, var(--text-muted) 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
}
.brand-text span {
    font-size: 0.8rem;
    color: var(--color-secondary);
    font-weight: 500;
    text-transform: uppercase;
    letter-spacing: 1px;
}

.sidebar-form {
    display: flex;
    flex-direction: column;
    gap: 12px;
    flex-grow: 1;
}

/* Form Controls */
.form-group {
    display: flex;
    flex-direction: column;
    gap: 6px;
}
.form-group label {
    font-size: 0.82rem;
    font-weight: 500;
    color: var(--text-muted);
    display: flex;
    align-items: center;
    gap: 6px;
}
.form-group label i {
    color: var(--color-secondary);
}

input[type="text"],
input[type="number"],
input[type="password"],
select {
    width: 100%;
    padding: 9px 12px;
    background: rgba(6, 8, 20, 0.6);
    border: 1px solid var(--panel-border);
    border-radius: 8px;
    color: var(--text-main);
    font-family: inherit;
    font-size: 0.9rem;
    transition: var(--transition);
}
input[type="text"]:focus,
input[type="number"]:focus,
input[type="password"]:focus,
select:focus {
    outline: none;
    border-color: var(--color-secondary);
    box-shadow: 0 0 12px var(--color-secondary-glow);
    background: rgba(6, 8, 20, 0.8);
}

.range-inputs {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 12px;
}
.range-field {
    position: relative;
}
.range-label {
    position: absolute;
    top: -6px;
    left: 8px;
    font-size: 0.7rem;
    background: #0f1225;
    padding: 0 4px;
    color: var(--text-muted);
}
.range-field input {
    padding-top: 14px;
    font-size: 0.85rem;
}

/* Buttons */
.btn {
    padding: 10px 16px;
    border: none;
    border-radius: 8px;
    font-family: inherit;
    font-size: 0.9rem;
    font-weight: 600;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    transition: var(--transition);
}
.primary-btn {
    background: linear-gradient(135deg, var(--color-primary) 0%, #a855f7 100%);
    color: #fff;
}
.primary-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 5px 15px var(--color-primary-glow);
}
.primary-btn:active {
    transform: translateY(0);
}
.btn-glow {
    position: relative;
    overflow: hidden;
}
.btn-glow::after {
    content: '';
    position: absolute;
    top: 0;
    left: -50%;
    width: 200%;
    height: 100%;
    background: linear-gradient(
        to right,
        rgba(255, 255, 255, 0) 0%,
        rgba(255, 255, 255, 0.3) 50%,
        rgba(255, 255, 255, 0) 100%
    );
    transform: skewX(-25deg);
    transition: 0.75s;
    opacity: 0;
}
.btn-glow:hover::after {
    left: 125%;
    opacity: 1;
}

.secondary-btn {
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid var(--panel-border);
    color: var(--text-main);
}
.secondary-btn:hover {
    background: rgba(255, 255, 255, 0.1);
    border-color: var(--color-secondary);
}

.sidebar-footer {
    margin-top: 10px;
}
.sidebar-footer .btn {
    width: 100%;
}

/* ==========================================
   MAIN DASHBOARD AREA
   ========================================== */
.main-content {
    padding: 30px;
    display: flex;
    flex-direction: column;
    gap: 30px;
    max-height: 100vh;
    overflow-y: auto;
}

/* Dashboard Header */
.dashboard-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 20px 30px;
}
.header-title h2 {
    font-size: 1.4rem;
    font-weight: 700;
}
.header-title p {
    font-size: 0.9rem;
    color: var(--text-muted);
}
.export-actions {
    display: flex;
    gap: 12px;
}
.export-btn {
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid var(--panel-border);
    color: var(--text-main);
    font-size: 0.85rem;
    padding: 10px 16px;
}
.export-btn:not(.disabled):hover {
    background: rgba(16, 185, 129, 0.1);
    border-color: var(--color-success);
    color: var(--color-success);
    box-shadow: 0 0 10px var(--color-success-glow);
}
.export-btn.disabled {
    opacity: 0.4;
    cursor: not-allowed;
}

/* Stats Cards */
.stats-container {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 20px;
}
.stats-card {
    display: flex;
    align-items: center;
    gap: 20px;
    padding: 20px 24px;
    transition: var(--transition);
}
.stats-card:hover {
    transform: translateY(-4px);
    border-color: rgba(255, 255, 255, 0.15);
}
.stats-icon {
    font-size: 2rem;
    width: 50px;
    height: 50px;
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(255, 255, 255, 0.03);
}
.text-cyan { color: var(--color-secondary); text-shadow: 0 0 8px var(--color-secondary-glow); }
.text-emerald { color: var(--color-success); text-shadow: 0 0 8px var(--color-success-glow); }
.text-red { color: var(--color-danger); text-shadow: 0 0 8px var(--color-danger-glow); }
.text-purple { color: #d946ef; text-shadow: 0 0 8px rgba(217, 70, 239, 0.2); }

.stats-info h3 {
    font-size: 1.6rem;
    font-weight: 800;
}
.stats-info p {
    font-size: 0.85rem;
    color: var(--text-muted);
}
.success-glow {
    box-shadow: inset 0 0 20px rgba(16, 185, 129, 0.03);
}

/* Real-Time Log Terminal */
.terminal-container {
    display: flex;
    flex-direction: column;
    height: 250px;
    background: rgba(4, 5, 12, 0.9);
    border-color: rgba(255, 255, 255, 0.05);
    overflow: hidden;
}
.terminal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 10px 20px;
    background: rgba(10, 12, 28, 0.9);
    border-bottom: 1px solid rgba(255, 255, 255, 0.05);
}
.terminal-buttons {
    display: flex;
    gap: 6px;
}
.terminal-buttons span {
    width: 10px;
    height: 10px;
    border-radius: 50%;
    display: inline-block;
}
.terminal-buttons span:nth-child(1) { background: #ff5f56; }
.terminal-buttons span:nth-child(2) { background: #ffbd2e; }
.terminal-buttons span:nth-child(3) { background: #27c93f; }

.terminal-title {
    font-family: 'JetBrains Mono', monospace;
    font-size: 0.75rem;
    color: var(--text-muted);
}
.terminal-clear-btn {
    background: transparent;
    border: none;
    color: var(--text-muted);
    cursor: pointer;
    transition: var(--transition);
}
.terminal-clear-btn:hover {
    color: var(--color-danger);
}

.terminal-body {
    padding: 16px 20px;
    font-family: 'JetBrains Mono', monospace;
    font-size: 0.85rem;
    color: #e5e7eb;
    overflow-y: auto;
    flex-grow: 1;
    display: flex;
    flex-direction: column;
    gap: 6px;
}
.log-line {
    word-break: break-all;
    line-height: 1.4;
}
.log-line.system-msg { color: var(--color-secondary); }
.log-line.error-msg { color: var(--color-danger); font-weight: 500; }
.log-line.match-msg { color: var(--color-success); font-weight: 500; }
.log-line.skip-msg { color: #6b7280; }

/* ==========================================
   RESULTS SECTION
   ========================================== */
.results-container {
    display: flex;
    flex-direction: column;
    gap: 20px;
    min-height: 300px;
}

.section-title-bar {
    display: flex;
    justify-content: space-between;
    align-items: center;
}
.section-title-bar h3 {
    font-size: 1.15rem;
    font-weight: 600;
    display: flex;
    align-items: center;
    gap: 8px;
}
.section-title-bar h3 i {
    color: var(--color-primary);
}

.view-toggles {
    display: flex;
    background: rgba(255, 255, 255, 0.03);
    border: 1px solid var(--panel-border);
    border-radius: 8px;
    padding: 3px;
}
.view-btn {
    background: transparent;
    border: none;
    color: var(--text-muted);
    padding: 6px 12px;
    cursor: pointer;
    border-radius: 6px;
    transition: var(--transition);
}
.view-btn.active {
    background: var(--color-primary);
    color: #fff;
}

/* Grid View styling */
.results-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: 20px;
}

/* Placeholder Empty View */
.no-results-placeholder {
    grid-column: 1 / -1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 60px 20px;
    text-align: center;
    color: var(--text-muted);
    background: rgba(255, 255, 255, 0.02);
    border: 1px dashed var(--panel-border);
    border-radius: var(--border-radius);
}
.placeholder-icon {
    font-size: 3rem;
    margin-bottom: 16px;
    color: rgba(255, 255, 255, 0.1);
}

/* Channel Card */
.channel-card {
    display: flex;
    flex-direction: column;
    padding: 24px;
    gap: 16px;
    transition: var(--transition);
    position: relative;
    overflow: hidden;
}
.channel-card:hover {
    transform: translateY(-6px);
    border-color: rgba(0, 242, 254, 0.3);
    box-shadow: 0 8px 30px rgba(0, 242, 254, 0.08);
}
.channel-header {
    display: flex;
    align-items: center;
    gap: 14px;
}
.channel-avatar {
    width: 50px;
    height: 50px;
    border-radius: 50%;
    border: 2px solid rgba(255, 255, 255, 0.1);
    object-fit: cover;
}
.channel-meta {
    flex-grow: 1;
    min-width: 0;
}
.channel-name {
    font-size: 1rem;
    font-weight: 600;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.channel-handle {
    font-size: 0.8rem;
    color: var(--color-secondary);
}

.channel-stats {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 10px;
    padding: 12px 0;
    border-top: 1px solid rgba(255, 255, 255, 0.05);
    border-bottom: 1px solid rgba(255, 255, 255, 0.05);
}
.c-stat {
    display: flex;
    flex-direction: column;
    align-items: center;
    text-align: center;
}
.c-stat-val {
    font-size: 0.9rem;
    font-weight: 700;
}
.c-stat-label {
    font-size: 0.7rem;
    color: var(--text-muted);
    margin-top: 2px;
}

.channel-desc {
    font-size: 0.8rem;
    color: var(--text-muted);
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
    height: 36px;
    line-height: 1.3;
}
.channel-actions {
    display: flex;
    justify-content: space-between;
    align-items: center;
}
.channel-country {
    font-size: 0.75rem;
    background: rgba(255, 255, 255, 0.05);
    padding: 4px 8px;
    border-radius: 6px;
    color: var(--text-muted);
    border: 1px solid var(--panel-border);
}
.channel-link-btn {
    font-size: 0.8rem;
    color: #ff0000;
    text-decoration: none;
    display: flex;
    align-items: center;
    gap: 4px;
    font-weight: 600;
    transition: var(--transition);
}
.channel-link-btn:hover {
    color: #ff3333;
    text-shadow: 0 0 8px rgba(255, 0, 0, 0.4);
}

/* Table View styling */
.results-table-wrapper {
    overflow-x: auto;
    border-radius: var(--border-radius);
    border: 1px solid var(--panel-border);
}
.results-table {
    width: 100%;
    border-collapse: collapse;
    text-align: left;
    background: var(--panel-bg);
}
.results-table th,
.results-table td {
    padding: 16px 20px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.05);
}
.results-table th {
    background: rgba(10, 12, 28, 0.6);
    font-size: 0.85rem;
    font-weight: 600;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.5px;
}
.results-table td {
    font-size: 0.9rem;
}
.results-table tr:hover td {
    background: rgba(255, 255, 255, 0.02);
}
.table-avatar {
    width: 32px;
    height: 32px;
    border-radius: 50%;
}
.table-channel-name {
    font-weight: 600;
}
.table-channel-handle {
    color: var(--color-secondary);
    font-size: 0.75rem;
}

/* ==========================================
   SETTINGS DIALOG MODAL
   ========================================== */
.glass-dialog {
    border: 1px solid rgba(255, 255, 255, 0.15);
    background: rgba(12, 15, 34, 0.92);
    backdrop-filter: blur(20px);
    border-radius: 16px;
    color: var(--text-main);
    width: 90%;
    max-width: 480px;
    margin: auto;
    padding: 24px;
    box-shadow: 0 20px 50px rgba(0,0,0,0.6);
}
.glass-dialog::backdrop {
    background: rgba(4, 5, 12, 0.8);
    backdrop-filter: blur(8px);
}
.dialog-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
}
.dialog-header h3 {
    font-size: 1.2rem;
    font-weight: 700;
    color: var(--text-main);
}
.dialog-close-btn {
    background: transparent;
    border: none;
    font-size: 1.8rem;
    color: var(--text-muted);
    cursor: pointer;
    transition: var(--transition);
}
.dialog-close-btn:hover {
    color: var(--color-danger);
}
.dialog-body {
    display: flex;
    flex-direction: column;
    gap: 16px;
    font-size: 0.9rem;
    color: var(--text-muted);
    line-height: 1.4;
}
.dialog-body a {
    color: var(--color-secondary);
    text-decoration: none;
}
.dialog-body a:hover {
    text-decoration: underline;
}

.input-with-icon {
    position: relative;
    display: flex;
    align-items: center;
}
.input-with-icon input {
    padding-right: 48px;
}
.key-visibility-btn {
    position: absolute;
    right: 12px;
    background: transparent;
    border: none;
    color: var(--text-muted);
    cursor: pointer;
    font-size: 1rem;
    transition: var(--transition);
}
.key-visibility-btn:hover {
    color: var(--text-main);
}

.api-help {
    background: rgba(255, 255, 255, 0.02);
    border: 1px solid var(--panel-border);
    padding: 14px 18px;
    border-radius: 10px;
}
.api-help p {
    font-weight: 600;
    color: var(--text-main);
    margin-bottom: 8px;
}
.api-help ol {
    margin-left: 20px;
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.dialog-footer {
    display: flex;
    justify-content: flex-end;
    margin-top: 24px;
}

/* ==========================================
   ANIMATIONS & PULSE STATES
   ========================================== */
@keyframes pulse {
    0% { transform: scale(1); opacity: 1; }
    50% { transform: scale(1.05); opacity: 0.7; }
    100% { transform: scale(1); opacity: 1; }
}
.scanning-indicator {
    display: inline-block;
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: var(--color-secondary);
    box-shadow: 0 0 8px var(--color-secondary);
    animation: pulse 1.5s infinite ease-in-out;
}

/* ==========================================
   RESPONSIVE MEDIA QUERIES
   ========================================== */
@media (max-width: 1024px) {
    .app-container {
        grid-template-columns: 1fr;
    }
    .sidebar {
        height: auto;
        position: relative;
        border-right: none;
        border-bottom: 1px solid var(--panel-border);
    }
    .main-content {
        max-height: none;
        overflow-y: visible;
    }
}
@media (max-width: 640px) {
    .main-content {
        padding: 16px;
    }
    .dashboard-header {
        flex-direction: column;
        align-items: flex-start;
        gap: 16px;
    }
    .export-actions {
        width: 100%;
    }
    .export-actions .btn {
        flex-grow: 1;
    }
    .stats-container {
        grid-template-columns: 1fr 1fr;
    }
}

/* Email Filter Tabs styles */
.results-filter-tabs {
    display: flex;
    gap: 12px;
    margin-bottom: 20px;
    border-bottom: 1px solid var(--panel-border);
    padding-bottom: 12px;
    flex-wrap: wrap;
}
.tab-btn {
    background: transparent;
    border: 1px solid transparent;
    color: var(--text-muted);
    padding: 8px 16px;
    cursor: pointer;
    font-family: inherit;
    font-size: 0.9rem;
    font-weight: 600;
    border-radius: 8px;
    display: flex;
    align-items: center;
    gap: 8px;
    transition: var(--transition);
}
.tab-btn:hover {
    color: var(--color-secondary);
    background: rgba(255, 255, 255, 0.03);
}
.tab-btn.active {
    background: var(--color-primary-glow);
    color: var(--color-secondary);
    border-color: rgba(0, 242, 254, 0.2);
}
