/* --- Design System & CSS Variables --- */
:root {
    --bg-dark: #070a13;
    --bg-card: rgba(13, 20, 38, 0.45);
    --bg-card-hover: rgba(22, 32, 59, 0.6);
    --border-color: rgba(255, 255, 255, 0.08);
    
    --text-primary: #f1f5f9;
    --text-secondary: #94a3b8;
    --text-muted: #64748b;
    
    /* Brand Accent Colors */
    --color-blue: #3b82f6;
    --color-blue-glow: rgba(59, 130, 246, 0.15);
    --color-gold: #f59e0b;
    --color-gold-glow: rgba(245, 158, 11, 0.15);
    --color-emerald: #10b981;
    --color-emerald-glow: rgba(16, 185, 129, 0.15);
    --color-purple: #8b5cf6;
    --color-purple-glow: rgba(139, 92, 246, 0.15);
    --color-red: #ef4444;
    
    --font-heading: 'Outfit', sans-serif;
    --font-sans: 'Plus Jakarta Sans', sans-serif;
    --font-mono: 'JetBrains Mono', sans-serif;
    
    --transition-smooth: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

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

body {
    background-color: var(--bg-dark);
    color: var(--text-primary);
    font-family: var(--font-sans);
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    overflow-x: hidden;
    position: relative;
}

/* --- Background Glow Effects --- */
.glow-bg {
    position: absolute;
    width: 600px;
    height: 600px;
    border-radius: 50%;
    filter: blur(140px);
    opacity: 0.12;
    pointer-events: none;
    z-index: 0;
}

.glow-bg.bg-blue {
    background: var(--color-blue);
    top: -200px;
    left: -200px;
}

.glow-bg.bg-gold {
    background: var(--color-gold);
    bottom: -200px;
    right: -200px;
}

/* --- Header --- */
.app-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 1.25rem 2.5rem;
    border-bottom: 1px solid var(--border-color);
    background: rgba(7, 10, 19, 0.8);
    backdrop-filter: blur(12px);
    z-index: 10;
    position: relative;
}

.header-logo {
    display: flex;
    align-items: center;
    gap: 0.85rem;
}

.logo-box {
    background: linear-gradient(135deg, var(--color-blue), var(--color-gold));
    width: 38px;
    height: 38px;
    border-radius: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 0 15px rgba(59, 130, 246, 0.3);
}

.logo-text-a1 {
    font-family: var(--font-heading);
    font-weight: 800;
    font-size: 1.15rem;
    color: #fff;
    letter-spacing: -0.5px;
}

.logo-title h1 {
    font-family: var(--font-heading);
    font-size: 1.15rem;
    font-weight: 700;
    letter-spacing: -0.2px;
}

.agency-tag {
    font-size: 0.7rem;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 1px;
    font-weight: 600;
}

.nav-back-btn {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    color: var(--text-secondary);
    text-decoration: none;
    font-size: 0.85rem;
    font-weight: 600;
    transition: var(--transition-smooth);
    padding: 0.5rem 1rem;
    border-radius: 8px;
    border: 1px solid transparent;
}

.nav-back-btn:hover {
    color: #fff;
    background: rgba(255, 255, 255, 0.04);
    border-color: var(--border-color);
}

/* --- Layout Container --- */
.app-container {
    display: grid;
    grid-template-columns: 360px 1fr;
    gap: 1.5rem;
    padding: 1.5rem 2rem;
    flex: 1;
    z-index: 5;
    position: relative;
    max-height: calc(100vh - 80px);
    overflow: hidden;
}

@media (max-width: 1000px) {
    .app-container {
        grid-template-columns: 1fr;
        max-height: none;
        overflow: auto;
        padding: 1.5rem 1rem;
        gap: 1.25rem;
    }
}

@media (max-width: 600px) {
    .app-header {
        padding: 1rem;
        flex-direction: column;
        gap: 0.75rem;
        text-align: center;
    }
    .nav-back-btn {
        width: 100%;
        justify-content: center;
    }
    .pitch-header {
        flex-direction: column;
        align-items: stretch;
        gap: 0.75rem;
    }
    .pitch-header-actions {
        display: flex;
        justify-content: stretch;
    }
    .pitch-header-actions button {
        flex: 1;
    }
}

/* --- Glass Card Panels --- */
.glass-card {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: 16px;
    backdrop-filter: blur(16px);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.2);
    transition: var(--transition-smooth);
}

.panel-header {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 1.25rem;
    border-bottom: 1px solid var(--border-color);
}

.panel-icon.icon-blue { color: var(--color-blue); filter: drop-shadow(0 0 5px var(--color-blue-glow)); }
.panel-icon.icon-gold { color: var(--color-gold); filter: drop-shadow(0 0 5px var(--color-gold-glow)); }
.panel-icon.icon-purple { color: var(--color-purple); filter: drop-shadow(0 0 5px var(--color-purple-glow)); }

.panel-header h2 {
    font-family: var(--font-heading);
    font-size: 1rem;
    font-weight: 600;
}

/* --- Left Panel (Inputs) --- */
.lead-panel {
    display: flex;
    flex-direction: column;
    overflow-y: auto;
}

.form-container {
    padding: 1.25rem;
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.form-group {
    display: flex;
    flex-direction: column;
    gap: 0.4rem;
}

label {
    font-size: 0.75rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: var(--text-secondary);
}

input[type="text"], select {
    background: rgba(7, 10, 19, 0.5);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    color: var(--text-primary);
    padding: 0.75rem;
    font-family: var(--font-sans);
    font-size: 0.85rem;
    outline: none;
    transition: var(--transition-smooth);
}

input[type="text"]:focus, select:focus {
    border-color: var(--color-blue);
    box-shadow: 0 0 10px rgba(59, 130, 246, 0.15);
}

/* Toggle Buttons for Channel */
.toggle-buttons {
    display: flex;
    background: rgba(0, 0, 0, 0.2);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    padding: 2px;
}

.channel-btn {
    flex: 1;
    background: transparent;
    border: none;
    color: var(--text-secondary);
    padding: 0.6rem;
    border-radius: 6px;
    font-size: 0.8rem;
    font-weight: 600;
    cursor: pointer;
    transition: var(--transition-smooth);
    font-family: var(--font-heading);
}

.channel-btn.active {
    background: var(--color-blue);
    color: #fff;
    box-shadow: 0 2px 8px rgba(59, 130, 246, 0.3);
}

/* Button */
.btn {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    padding: 0.85rem;
    border-radius: 10px;
    border: none;
    font-family: var(--font-heading);
    font-weight: 700;
    font-size: 0.95rem;
    cursor: pointer;
    transition: var(--transition-smooth);
    color: #fff;
    width: 100%;
}

.btn-blue {
    background: linear-gradient(135deg, #3b82f6 0%, #1d4ed8 100%);
}

.btn-blue:hover {
    opacity: 0.95;
    transform: translateY(-1px);
}

.btn-glow {
    box-shadow: 0 4px 20px rgba(59, 130, 246, 0.25);
}

.btn-glow:hover {
    box-shadow: 0 6px 25px rgba(59, 130, 246, 0.4);
}

.btn:disabled {
    background: var(--text-muted);
    box-shadow: none;
    cursor: not-allowed;
    transform: none;
    opacity: 0.5;
}

/* Scraper activity logs console */
.scraper-console {
    background: #04060b;
    border-top: 1px solid var(--border-color);
    flex: 1;
    min-height: 150px;
    display: flex;
    flex-direction: column;
}

.console-title {
    font-size: 0.7rem;
    font-family: var(--font-heading);
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: var(--text-muted);
    padding: 0.5rem 1rem;
    border-bottom: 1px solid var(--border-color);
    background: rgba(0, 0, 0, 0.25);
}

.console-lines {
    flex: 1;
    overflow-y: auto;
    padding: 0.75rem 1rem;
    display: flex;
    flex-direction: column;
    gap: 0.4rem;
    font-family: var(--font-mono);
    font-size: 0.7rem;
    line-height: 1.4;
}

.log-line {
    word-break: break-all;
}

.log-line.system { color: var(--text-muted); }
.log-line.running { color: var(--color-blue); }
.log-line.finding { color: var(--color-gold); }
.log-line.done { color: var(--color-emerald); }

/* --- Right Dashboard Area --- */
.results-dashboard {
    display: grid;
    grid-template-rows: 1fr 1.1fr;
    gap: 1.5rem;
    overflow: hidden;
}

@media (max-width: 1000px) {
    .results-dashboard {
        grid-template-rows: auto auto;
        overflow: visible;
    }
}

.scorecard-panel {
    display: flex;
    flex-direction: column;
}

.scorecard-body {
    flex: 1;
    overflow-y: auto;
    padding: 1.5rem;
}

/* Placeholder state */
.dashboard-placeholder {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    text-align: center;
    color: var(--text-muted);
    margin: auto;
    max-width: 320px;
    gap: 0.75rem;
    padding: 2rem 0;
}

.muted-icon {
    opacity: 0.25;
}

.dashboard-placeholder h3 {
    font-family: var(--font-heading);
    color: var(--text-secondary);
    font-size: 1.05rem;
}

.dashboard-placeholder p {
    font-size: 0.8rem;
    line-height: 1.45;
}

.hidden {
    display: none !important;
}

/* Main Dashboard layout */
.dashboard-content {
    display: flex;
    flex-direction: column;
    gap: 1.5rem;
    animation: fadeIn 0.4s ease-out forwards;
}

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

.score-circle-row {
    display: grid;
    grid-template-columns: 140px 1fr;
    gap: 2rem;
    align-items: center;
}

@media (max-width: 600px) {
    .score-circle-row {
        grid-template-columns: 1fr;
        justify-items: center;
        text-align: center;
    }
}

/* Score Gauge SVG styling */
.score-gauge-container {
    position: relative;
    width: 130px;
    height: 130px;
}

.score-gauge {
    width: 100%;
    height: 100%;
}

.gauge-bg {
    fill: none;
    stroke: rgba(255, 255, 255, 0.05);
    stroke-width: 2.8;
}

.gauge-fill {
    fill: none;
    stroke: url(#gauge-gradient); /* Handled dynamically */
    stroke-width: 2.8;
    stroke-linecap: round;
    transition: stroke-dasharray 1s ease-in-out;
}

/* Specific SVG Gradient Fallback in CSS / JS */
#gauge-fill-val {
    stroke: var(--color-gold); /* Fallback */
}

.gauge-text {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    display: flex;
    flex-direction: column;
    align-items: center;
    text-align: center;
}

#gauge-percentage {
    font-family: var(--font-heading);
    font-size: 1.75rem;
    font-weight: 800;
    color: #fff;
}

.gauge-text .subtext {
    font-size: 0.6rem;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: var(--text-muted);
    font-weight: 700;
}

/* Metrics Grid */
.metrics-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 0.75rem;
}

.metric-box {
    background: rgba(0, 0, 0, 0.15);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    padding: 0.65rem 0.85rem;
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
}

.metric-box .label {
    font-size: 0.65rem;
    color: var(--text-muted);
    font-weight: 700;
    text-transform: uppercase;
}

.metric-box .val {
    font-size: 0.9rem;
    font-weight: 700;
    color: var(--color-emerald);
}

.metric-box .val.bad {
    color: var(--color-red);
}

.metric-box .val.warn {
    color: var(--color-gold);
}

/* Audit Findings List */
.audit-details-list h3 {
    font-family: var(--font-heading);
    font-size: 0.85rem;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: var(--text-secondary);
    margin-bottom: 0.75rem;
}

.findings-list {
    list-style: none;
    display: flex;
    flex-direction: column;
    gap: 0.65rem;
}

.finding {
    display: flex;
    align-items: flex-start;
    gap: 0.75rem;
    background: rgba(255, 255, 255, 0.02);
    border: 1px solid var(--border-color);
    padding: 0.75rem 1rem;
    border-radius: 8px;
    font-size: 0.8rem;
    line-height: 1.45;
}

.finding-icon {
    flex-shrink: 0;
    margin-top: 2px;
}

.finding.bad {
    border-color: rgba(239, 68, 68, 0.15);
    background: rgba(239, 68, 68, 0.02);
}

.finding.bad .finding-icon {
    color: var(--color-red);
}

.finding.good {
    border-color: rgba(16, 185, 129, 0.15);
    background: rgba(16, 185, 129, 0.02);
}

.finding.good .finding-icon {
    color: var(--color-emerald);
}

/* --- Pitch Panel (AI Composer) --- */
.pitch-panel {
    display: flex;
    flex-direction: column;
}

.pitch-body {
    flex: 1;
    overflow-y: auto;
    padding: 1.25rem;
    display: flex;
    flex-direction: column;
}

.copy-btn {
    margin-left: auto;
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid var(--border-color);
    color: var(--text-secondary);
    padding: 0.4rem 0.75rem;
    border-radius: 6px;
    font-size: 0.75rem;
    font-weight: 600;
    cursor: pointer;
    transition: var(--transition-smooth);
    display: flex;
    align-items: center;
    gap: 0.35rem;
    font-family: var(--font-heading);
}

.copy-btn:hover:not(:disabled) {
    color: #fff;
    background: rgba(255, 255, 255, 0.1);
    border-color: rgba(255, 255, 255, 0.2);
}

.copy-btn:disabled {
    opacity: 0.4;
    cursor: not-allowed;
}

.pitch-content {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
    animation: fadeIn 0.4s ease-out forwards;
}

.email-metadata {
    background: rgba(0, 0, 0, 0.15);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    padding: 0.65rem 0.85rem;
    font-size: 0.75rem;
    line-height: 1.5;
    color: var(--text-secondary);
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
}

.email-metadata strong {
    color: var(--text-primary);
    width: 60px;
    display: inline-block;
}

.pitch-text-box {
    flex: 1;
    display: flex;
}

#pitch-text {
    flex: 1;
    background: rgba(0, 0, 0, 0.25);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    color: var(--text-primary);
    font-family: var(--font-sans);
    font-size: 0.85rem;
    line-height: 1.5;
    padding: 1rem;
    resize: none;
    outline: none;
    min-height: 150px;
}

/* --- Footer --- */
.app-footer {
    text-align: center;
    padding: 1rem;
    font-size: 0.75rem;
    color: var(--text-muted);
    border-top: 1px solid var(--border-color);
    background: rgba(7, 10, 19, 0.9);
    z-index: 10;
    position: relative;
}

/* Height-based Responsiveness for Short Screens */
@media (max-height: 768px) {
    .app-container {
        max-height: none;
        overflow: visible;
    }
}

