/* Global Gen - AI PDF Researcher - Styles */

:root {
    --primary: #374151;
    --primary-light: #4b5563;
    --primary-dark: #1f2937;
    --primary-gradient: linear-gradient(135deg, #374151 0%, #1f2937 100%);
    --success: #22c55e;
    --success-bg: #dcfce7;
    --warning: #f59e0b;
    --warning-bg: #fef3c7;
    --error: #ef4444;
    --error-bg: #fee2e2;
    --info: #6b7280;
    --info-bg: #f3f4f6;

    --text-main: #1e293b;
    --text-light: #64748b;
    --text-muted: #94a3b8;

    --bg: #f8fafc;
    --bg-white: #ffffff;
    --border: #e2e8f0;
    --border-light: #f1f5f9;

    --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.05);
    --shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1);
    --shadow-lg: 0 10px 25px -5px rgba(0, 0, 0, 0.1);
    --shadow-glow: 0 0 40px rgba(55, 65, 81, 0.1);

    --radius: 12px;
    --radius-lg: 16px;
}

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

body {
    font-family: 'Montserrat', -apple-system, BlinkMacSystemFont, sans-serif;
    font-size: 14px;
    line-height: 1.5;
    color: var(--text-main);
    background: linear-gradient(-45deg, #f0f4f8, #e4ecf4, #edf2f7, #e8eff6, #f5f8fb, #e6edf5);
    background-size: 400% 400%;
    animation: gradientBG 4s ease infinite;
    min-height: 100vh;
    overflow-x: hidden;
}

@keyframes gradientBG {
    0% { background-position: 0% 50%; }
    20% { background-position: 40% 80%; }
    40% { background-position: 100% 50%; }
    60% { background-position: 60% 20%; }
    80% { background-position: 20% 60%; }
    100% { background-position: 0% 50%; }
}

/* App Container */
.app-container {
    display: flex;
    flex-direction: column;
    min-height: 100vh;
    max-width: 1200px;
    margin: 0 auto;
    padding: 20px;
}

/* Header styles moved to navbar.css for consistency */

/* Main Content — always 2-column layout with animation on right */
.main-content {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 20px;
    align-items: start;
    grid-auto-flow: dense;
    flex: 1;
}
.main-content .log-panel {
    grid-column: 2;
}
/* During research: logPanel takes full width (no empty left column) */
.main-content.fullwidth-animation {
    grid-template-columns: 1fr;
}
.main-content.fullwidth-animation .log-panel {
    grid-column: 1;
}
@media (max-width: 900px) {
    .main-content {
        grid-template-columns: 1fr;
    }
    .main-content .log-panel {
        grid-column: 1;
        grid-row: auto;
    }
}

/* Panels */
.panel {
    background: var(--bg-white);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-sm);
    padding: 24px;
}

.panel-title {
    font-size: 16px;
    font-weight: 600;
    color: var(--primary);
    margin-bottom: 20px;
    padding-bottom: 12px;
    border-bottom: 2px solid var(--border-light);
}

/* Form Panel */
.form-panel {
    grid-column: 1;
}

.research-form {
    display: flex;
    flex-direction: column;
    gap: 16px;
}

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

.form-group label {
    font-size: 13px;
    font-weight: 500;
    color: var(--text-light);
}

/* Query examples chips */
.query-examples {
    margin-top: 0.75rem;
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
    align-items: center;
}

.examples-label {
    font-size: 0.75rem;
    color: #9ca3af;
    margin-right: 0.25rem;
}

.example-chip {
    padding: 0.375rem 0.75rem;
    background: #fafafa;
    border: 1px solid #e5e7eb;
    border-radius: 16px;
    font-size: 0.75rem;
    color: #6b7280;
    cursor: pointer;
    transition: all 0.2s;
    font-family: inherit;
}

.example-chip:hover {
    background: #f3f4f6;
    border-color: #d1d5db;
    color: #374151;
}

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

@media (max-width: 600px) {
    .form-row {
        grid-template-columns: 1fr;
    }
}

/* Mode Cards */
.mode-cards {
    display: flex;
    gap: 10px;
}

.mode-card {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 8px;
    padding: 14px 10px;
    border: 2px solid var(--border);
    border-radius: var(--radius);
    background: var(--bg-white);
    cursor: pointer;
    transition: all 0.2s ease;
    text-align: center;
}

.mode-card:hover {
    border-color: var(--primary-light);
    background: #f8fafc;
    transform: translateY(-1px);
}

.mode-card.active {
    border-color: var(--primary);
    background: #f0f4f8;
    box-shadow: 0 0 0 3px rgba(55, 65, 81, 0.1);
}

.mode-card-icon {
    font-size: 24px;
    line-height: 1;
}

.mode-card-body {
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.mode-card-title {
    font-size: 14px;
    font-weight: 600;
    color: var(--text-main);
}

.mode-card-desc {
    font-size: 11px;
    color: var(--text-light);
    line-height: 1.3;
}

.mode-card-meta {
    font-size: 10px;
    color: var(--text-muted);
    padding-top: 4px;
    border-top: 1px solid var(--border-light);
    width: 100%;
}

@media (max-width: 600px) {
    .mode-cards {
        flex-direction: column;
    }
    .mode-card {
        flex-direction: row;
        text-align: left;
        padding: 12px 14px;
        gap: 12px;
    }
    .mode-card-icon {
        font-size: 22px;
    }
    .mode-card-body {
        flex: 1;
    }
    .mode-card-meta {
        border-top: none;
        border-left: 1px solid var(--border-light);
        padding-top: 0;
        padding-left: 12px;
        width: auto;
        white-space: nowrap;
    }
}

input, textarea, select {
    font-family: inherit;
    font-size: 14px;
    padding: 12px 14px;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    background: var(--bg-white);
    color: var(--text-main);
    transition: border-color 0.2s, box-shadow 0.2s;
}

input:focus, textarea:focus, select:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(19, 68, 93, 0.1);
}

textarea {
    resize: vertical;
    min-height: 80px;
}

select {
    cursor: pointer;
}

.form-actions {
    margin-top: 8px;
}

.form-actions .btn-primary {
    width: 100%;
    justify-content: center;
    padding: 0.75rem 1rem;
    font-size: 1.05rem;
}

/* Buttons */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 12px 20px;
    font-family: inherit;
    font-size: 14px;
    font-weight: 500;
    border: none;
    border-radius: var(--radius);
    cursor: pointer;
    transition: all 0.2s;
}

.btn-icon {
    font-size: 16px;
}

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

.btn-primary:hover {
    background: var(--primary-light);
}

.btn-primary:disabled {
    background: var(--text-muted);
    cursor: not-allowed;
}

.btn-secondary {
    background: var(--bg);
    color: var(--primary);
    border: 1px solid var(--border);
}

.btn-secondary:hover {
    background: var(--border-light);
}

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

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

.btn-cancel {
    background: #6b7280;
    color: white;
}

.btn-cancel:hover {
    background: #4b5563;
}

.btn-cancel:disabled {
    background: #9ca3af;
    cursor: not-allowed;
    opacity: 0.9;
}

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

/* Progress Panel */
.progress-panel {
    grid-column: 1;
}

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

.progress-header .panel-title {
    margin-bottom: 0;
    padding-bottom: 0;
    border-bottom: none;
}

.progress-bar-container {
    height: 8px;
    background: var(--border-light);
    border-radius: 4px;
    overflow: hidden;
    margin-bottom: 8px;
}

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

.progress-text {
    font-size: 13px;
    font-weight: 600;
    color: var(--primary);
    text-align: right;
    margin-bottom: 12px;
}

.status-text {
    font-size: 14px;
    color: var(--text-light);
    padding: 12px;
    background: var(--bg);
    border-radius: var(--radius);
}

/* Plan Panel */
.plan-panel {
    grid-column: 1;
    min-height: 400px;
}

.plan-content {
    background: var(--bg);
    border-radius: var(--radius);
    padding: 16px;
    margin-bottom: 20px;
    max-height: 400px;
    overflow-y: auto;
}

.plan-title {
    font-size: 18px;
    font-weight: 600;
    color: var(--primary);
    margin-bottom: 16px;
}

.plan-section {
    margin-bottom: 16px;
}

.plan-section-title {
    font-size: 13px;
    font-weight: 600;
    color: var(--text-light);
    margin-bottom: 8px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.plan-list {
    list-style: none;
    padding: 0;
}

.plan-list li {
    padding: 8px 0;
    border-bottom: 1px solid var(--border-light);
    font-size: 14px;
}

.plan-list li:last-child {
    border-bottom: none;
}

.plan-list li::before {
    content: "•";
    color: var(--primary);
    font-weight: bold;
    margin-right: 8px;
}

.plan-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 12px;
    justify-content: flex-end;
}

.plan-actions .btn-primary {
    justify-content: center;
    padding: 0.75rem 1rem;
    font-size: 1rem;
}

/* Log Panel (Progress Workspace) */
.log-panel {
    display: block;
    min-height: 500px;
}
/* Log panel grid position is handled in .main-content rules above */

.log-workspace {
    display: grid;
    grid-template-columns: minmax(300px, 360px) minmax(0, 1fr);
    gap: 16px;
    align-items: stretch;
    min-height: 420px;
}

.log-sidebar {
    display: flex;
    flex-direction: column;
    gap: 12px;
    min-width: 0;
}

.log-animation-col {
    display: flex;
    min-width: 0;
}

@media (max-width: 1100px) {
    .log-workspace {
        grid-template-columns: 1fr;
    }
    .log-sidebar {
        order: 2;
    }
    .log-animation-col {
        order: 1;
    }
}

.log-header {
    display: flex;
    flex-direction: column;
    gap: 10px;
    margin-bottom: 0;
}

.log-header .panel-title {
    margin-bottom: 0;
    padding-bottom: 0;
    border-bottom: none;
}

.log-header-right {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 8px;
}

.timer {
    display: inline-flex;
    align-items: center;
    padding: 6px 10px;
    border: 1px solid rgba(19, 68, 93, 0.12);
    border-radius: 8px;
    background: rgba(19, 68, 93, 0.06);
    font-family: 'SF Mono', 'Monaco', 'Menlo', monospace;
    font-size: 0.88rem;
    font-weight: 600;
    font-variant-numeric: tabular-nums;
    letter-spacing: 0.01em;
    color: var(--text-main);
    margin-left: 0;
    flex: 0 0 auto;
    white-space: nowrap;
}

.timer:empty {
    display: none;
}

.log-current-panel {
    background: rgba(19, 68, 93, 0.03);
    border: 1px solid rgba(19, 68, 93, 0.08);
    border-radius: 10px;
    padding: 10px;
}

.log-current-title {
    font-size: 11px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    color: var(--text-muted);
    margin-bottom: 8px;
}

/* ==================== GENERATION ANIMATION ==================== */

.generation-animation {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    flex: 1;
    min-height: 450px;
    width: 100%;
    background: linear-gradient(180deg, #ffffff 0%, #f8fafc 100%);
    border: 1px solid #e2e8f0;
    border-radius: var(--radius);
    position: relative;
    overflow: hidden;
    padding: 2rem;
}

/* Particles Background */
.particles-container {
    position: absolute;
    inset: 0;
    overflow: hidden;
    pointer-events: none;
}

.particle {
    position: absolute;
    width: 4px;
    height: 4px;
    background: rgba(99, 102, 241, 0.3);
    border-radius: 50%;
    animation: floatParticle 6s ease-in-out infinite;
}

@keyframes floatParticle {
    0%, 100% {
        transform: translateY(0) translateX(0) scale(1);
        opacity: 0;
    }
    10% { opacity: 0.8; }
    50% {
        transform: translateY(-100px) translateX(30px) scale(0.5);
        opacity: 0.4;
    }
    90% { opacity: 0.1; }
}

/* Central Core Animation */
.animation-core {
    position: relative;
    width: 120px;
    height: 120px;
    margin-bottom: 1.5rem;
}

.core-circle {
    position: absolute;
    inset: 0;
    border-radius: 50%;
    background: #f1f5f9;
    border: 2px solid #e2e8f0;
    animation: corePulse 2s ease-in-out infinite;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.08);
}

@keyframes coreGradient {
    0%, 100% { background-position: 0% 50%; }
    50% { background-position: 100% 50%; }
}

@keyframes corePulse {
    0%, 100% { transform: scale(1); }
    50% { transform: scale(1.05); }
}

.core-pulse {
    position: absolute;
    inset: -15px;
    border-radius: 50%;
    border: 1px solid #e2e8f0;
    animation: pulseRing 2s ease-out infinite;
}

.core-pulse.delay-1 {
    animation-delay: 0.5s;
}

.core-pulse.delay-2 {
    animation-delay: 1s;
}

@keyframes pulseRing {
    0% { transform: scale(1); opacity: 0.8; }
    100% { transform: scale(2.5); opacity: 0; }
}

.core-icon {
    position: absolute;
    inset: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 2.5rem;
    animation: iconBounce 2s ease-in-out infinite;
}

/* Hide core icon when progress ring is active to avoid duplication with stages track */
.progress-ring-container.active ~ .animation-core .core-icon,
.generation-animation.running .core-icon {
    display: none;
}

@keyframes iconBounce {
    0%, 100% { transform: translateY(0); }
    50% { transform: translateY(-5px); }
}

/* Orbital Data Streams - hidden, replaced with subtle pulse */
.orbital-container {
    display: none;
}

.orbital-item {
    display: none;
}

/* Progress Ring */
.progress-ring-container {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 240px;
    height: 240px;
    display: none;
}

.progress-ring-container.active {
    display: none; /* Hidden - progress shown via stages track instead */
}

.progress-ring {
    transform: rotate(-90deg);
    width: 240px;
    height: 240px;
}

.progress-ring-bg {
    fill: none;
    stroke: #e2e8f0;
    stroke-width: 8;
}

.progress-ring-fill {
    fill: none;
    stroke: url(#progressGradient);
    stroke-width: 8;
    stroke-linecap: round;
    stroke-dasharray: 678.58;
    stroke-dashoffset: 678.58;
    transition: stroke-dashoffset 0.5s ease;
}

.progress-percent {
    display: none; /* Hidden - progress shown via stages track instead */
}

/* Animation Status */
.animation-status {
    color: var(--text-main);
    font-size: 1rem;
    font-weight: 500;
    text-align: center;
    margin: 1rem 0;
    min-height: 1.5rem;
    animation: fadeInOut 2s ease infinite;
}

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

/* Stages Track */
.stages-track {
    display: flex;
    align-items: center;
    gap: 0;
    margin-top: 2rem;
    padding: 0 1rem;
}

.stage {
    display: flex;
    flex-direction: column;
    align-items: center;
    position: relative;
    opacity: 0.3;
    transition: all 0.5s ease;
    padding: 0 1rem;
}

.stage-icon {
    font-size: 1.5rem;
    margin-bottom: 0.5rem;
    transition: transform 0.3s ease;
}

.stage-label {
    font-size: 0.75rem;
    color: var(--text-light);
    white-space: nowrap;
}

.stage-connector {
    position: absolute;
    top: 1rem;
    right: -1rem;
    width: 2rem;
    height: 2px;
    background: #e2e8f0;
}

.stage:last-child .stage-connector {
    display: none;
}

.stage.active {
    opacity: 1;
    transform: scale(1.1);
}

.stage.active .stage-icon {
    animation: stageIconPulse 1s ease infinite;
}

@keyframes stageIconPulse {
    0%, 100% { transform: scale(1); }
    50% { transform: scale(1.2); }
}

.stage.completed {
    opacity: 1;
}

.stage.completed .stage-icon {
    color: #4ade80;
}

.stage.completed .stage-connector {
    background: #4ade80;
}

/* Animation Counters */
.animation-counters {
    display: flex;
    gap: 3rem;
    margin-top: 2rem;
}

.counter {
    display: flex;
    flex-direction: column;
    align-items: center;
}

.counter-value {
    font-size: 2rem;
    font-weight: 700;
    color: var(--primary);
    line-height: 1;
}

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

/* Animation States */
.generation-animation.idle .animation-core {
    animation: none;
}

.generation-animation.idle .core-circle {
    animation: none;
}

.generation-animation.active .core-circle {
    animation: corePulse 1.5s ease-in-out infinite;
    border-color: var(--primary);
}

.generation-animation.completed .core-circle {
    background: #ecfdf5;
    border-color: #4ade80;
    animation: none;
}

.generation-animation.completed .core-icon {
    animation: celebrateBounce 0.5s ease;
}

@keyframes celebrateBounce {
    0%, 100% { transform: scale(1); }
    50% { transform: scale(1.3); }
}

/* Current status line */
.log-content {
    width: 100%;
    min-height: 44px;
    overflow: hidden;
    margin: 0;
    padding: 0;
    display: block;
}
.log-content:empty { display: block; }

.log-entry {
    display: grid;
    grid-template-columns: auto auto minmax(0, 1fr);
    align-items: center;
    gap: 8px;
    padding: 10px 12px;
    border-radius: 8px;
    background: rgba(99, 102, 241, 0.04);
    font-size: 12px;
    line-height: 1.4;
    animation: logFadeIn 0.3s ease;
    opacity: 1;
}

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

.log-time {
    color: var(--text-muted, #8898a4);
    font-size: 10px;
    font-variant-numeric: tabular-nums;
    flex-shrink: 0;
}
.log-icon { font-size: 10px; flex-shrink: 0; }
.log-msg {
    color: var(--text-main, #334155);
    font-size: 12px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.log-entry.log-error { background: rgba(239, 68, 68, 0.06); }
.log-entry.log-error .log-msg { color: #dc2626; }
.log-entry.log-warning { background: rgba(245, 158, 11, 0.06); }
.log-entry.log-warning .log-msg { color: #d97706; }
.log-entry.log-success { background: rgba(16, 185, 129, 0.06); }
.log-entry.log-success .log-msg { color: #059669; }

/* Results Panel */
.results-panel {
    grid-column: 1;
}

.results-summary {
    background: var(--bg);
    border-radius: var(--radius);
    padding: 20px;
    margin-bottom: 20px;
}

.results-title {
    font-size: 18px;
    font-weight: 600;
    color: var(--primary);
    margin-bottom: 12px;
}

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

.stat-item {
    text-align: center;
    padding: 12px;
    background: var(--bg-white);
    border-radius: var(--radius);
}

.stat-value {
    font-size: 24px;
    font-weight: 700;
    color: var(--primary);
}

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

.results-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 12px;
}

/* Modal */
.modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.5);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
}

.modal-content {
    background: var(--bg-white);
    border-radius: var(--radius-lg);
    width: 90%;
    max-width: 1000px;
    height: 85vh;
    display: flex;
    flex-direction: column;
    box-shadow: var(--shadow-lg);
}

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

.modal-header h3 {
    font-size: 16px;
    font-weight: 600;
    color: var(--primary);
}

.modal-close {
    background: none;
    border: none;
    font-size: 24px;
    color: var(--text-muted);
    cursor: pointer;
    padding: 4px 8px;
    border-radius: 4px;
}

.modal-close:hover {
    background: var(--bg);
    color: var(--text-main);
}

.modal-body {
    flex: 1;
    padding: 0;
    overflow: hidden;
}

.modal-body iframe {
    width: 100%;
    height: 100%;
    border: none;
}

/* Footer */
.footer {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 16px;
    font-size: 12px;
    color: var(--text-muted);
    margin-top: 20px;
}

.separator {
    color: var(--border);
}

/* Scrollbar */
::-webkit-scrollbar {
    width: 8px;
    height: 8px;
}

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

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

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

/* Loading Animation */
@keyframes pulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.5; }
}

.loading {
    animation: pulse 1.5s ease-in-out infinite;
}

/* Status Badges */
.status-badge {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 4px 10px;
    border-radius: 12px;
    font-size: 12px;
    font-weight: 500;
}

.status-badge.planning {
    background: var(--info-bg);
    color: var(--info);
}

.status-badge.researching {
    background: var(--warning-bg);
    color: var(--warning);
}

.status-badge.done {
    background: var(--success-bg);
    color: var(--success);
}

.status-badge.error {
    background: var(--error-bg);
    color: var(--error);
}

/* Mode Hint */
.mode-hint {
    font-size: 12px;
    color: var(--text-muted);
    background: var(--info-bg);
    padding: 8px 12px;
    border-radius: var(--radius);
    margin-top: 6px;
    border-left: 3px solid var(--info);
}

/* Statistics Panel */
.stats-panel {
    grid-column: 1 / -1;
}

.stats-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 16px;
}

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

.stat-card {
    background: var(--bg);
    border-radius: var(--radius);
    padding: 20px;
    text-align: center;
    border: 1px solid var(--border-light);
}

.stat-card .stat-value {
    font-size: 28px;
    font-weight: 700;
    color: var(--primary);
    margin-bottom: 4px;
}

.stat-card .stat-label {
    font-size: 13px;
    color: var(--text-muted);
    font-weight: 500;
}

/* Daily Chart */
.daily-chart-container {
    background: var(--bg);
    border-radius: 8px;
    padding: 16px;
}

.chart-title {
    font-size: 14px;
    font-weight: 600;
    color: var(--text-main);
    margin-bottom: 12px;
}

#dailyActivityChart {
    max-height: 200px;
}

/* History Panel */
.history-panel {
    grid-column: 1 / -1;
}

.history-table-container {
    overflow-x: auto;
}

.history-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 14px;
}

.history-table thead {
    background: var(--bg);
}

.history-table th {
    text-align: left;
    padding: 12px 16px;
    font-weight: 600;
    color: var(--text-light);
    border-bottom: 2px solid var(--border);
    font-size: 12px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.history-table td {
    padding: 12px 16px;
    border-bottom: 1px solid var(--border-light);
    color: var(--text-main);
}

.history-row {
    cursor: pointer;
    transition: background 0.2s;
}

.history-row:hover {
    background: var(--border-light);
}

.history-query {
    max-width: 300px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.history-status {
    width: 60px;
    text-align: center;
}

.history-date {
    width: 80px;
    color: var(--text-muted);
}

.history-author {
    max-width: 100px;
    color: var(--text-muted);
    font-size: 0.85em;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.history-card-author {
    color: var(--text-muted);
    font-size: 0.8em;
}

.history-cost {
    width: 80px;
    font-weight: 500;
    color: var(--primary);
}

/* Status Icons */
.status-icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 24px;
    height: 24px;
    border-radius: 50%;
    font-size: 14px;
}

.status-completed {
    background: var(--success-bg);
    color: var(--success);
}

.status-error {
    background: var(--error-bg);
    color: var(--error);
}

.status-cancelled {
    background: var(--warning-bg);
    color: var(--warning);
}

.status-running {
    background: var(--info-bg);
    color: var(--info);
}

.status-pending {
    background: var(--border-light);
    color: var(--text-muted);
}

/* Success Animation Overlay */
.success-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.45);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 2000;
    opacity: 0;
    transition: opacity 0.3s ease;
}

.success-overlay.active {
    opacity: 1;
}

.success-popup {
    background: var(--bg-white);
    border-radius: var(--radius-lg);
    padding: 48px;
    text-align: center;
    max-width: 400px;
    transform: scale(0.8);
    transition: transform 0.3s ease;
    box-shadow: var(--shadow-lg);
}

.success-overlay.active .success-popup {
    transform: scale(1);
}

.success-icon {
    width: 80px;
    height: 80px;
    margin: 0 auto 24px;
}

.checkmark {
    width: 80px;
    height: 80px;
}

.checkmark-circle {
    stroke: var(--success);
    stroke-width: 2;
    stroke-dasharray: 166;
    stroke-dashoffset: 166;
    animation: checkmark-circle 0.6s ease-in-out forwards;
}

.checkmark-check {
    stroke: var(--success);
    stroke-width: 3;
    stroke-linecap: round;
    stroke-linejoin: round;
    stroke-dasharray: 48;
    stroke-dashoffset: 48;
    animation: checkmark-check 0.3s 0.4s ease-in-out forwards;
}

@keyframes checkmark-circle {
    to {
        stroke-dashoffset: 0;
    }
}

@keyframes checkmark-check {
    to {
        stroke-dashoffset: 0;
    }
}

.success-title {
    font-size: 24px;
    font-weight: 700;
    color: var(--primary);
    margin-bottom: 8px;
}

.success-subtitle {
    font-size: 14px;
    color: var(--text-muted);
    margin-bottom: 24px;
}

.success-btn {
    background: var(--success);
    color: white;
    border: none;
    padding: 12px 32px;
    border-radius: var(--radius);
    font-size: 16px;
    font-weight: 600;
    cursor: pointer;
    transition: background 0.2s, transform 0.2s;
}

.success-btn:hover {
    background: #16a34a;
    transform: scale(1.05);
}

/* Confetti Animation */
.confetti {
    position: fixed;
    width: 10px;
    height: 10px;
    top: -10px;
    opacity: 0;
    animation: confetti-fall 3s ease-in-out forwards;
    z-index: 2001;
    pointer-events: none;
}

@keyframes confetti-fall {
    0% {
        transform: translateY(0) rotate(0deg);
        opacity: 1;
    }
    100% {
        transform: translateY(100vh) rotate(720deg);
        opacity: 0;
    }
}

/* Loading Spinner - 3 pulsing dots */
@keyframes dotPulse {
    0%, 80%, 100% { transform: scale(0.6); opacity: 0.5; }
    40% { transform: scale(1); opacity: 1; }
}

.spinner-dots {
    display: inline-flex;
    gap: 4px;
    margin-left: 8px;
    vertical-align: middle;
}

.spinner-dots span {
    width: 6px;
    height: 6px;
    background: var(--primary);
    border-radius: 50%;
    animation: dotPulse 1.4s infinite ease-in-out;
}

.spinner-dots span:nth-child(2) { animation-delay: 0.2s; }
.spinner-dots span:nth-child(3) { animation-delay: 0.4s; }

/* Progress Bar Shimmer Effect */
@keyframes shimmer {
    from { transform: translateX(-100%); }
    to { transform: translateX(200%); }
}

.progress-bar {
    position: relative;
    overflow: hidden;
}

.progress-bar.active::after {
    content: '';
    position: absolute;
    inset: 0;
    background: linear-gradient(90deg, transparent, rgba(255,255,255,0.4), transparent);
    animation: shimmer 1.5s infinite;
}


/* Running Status Indicator - spinning icon */
@keyframes spin {
    to { transform: rotate(360deg); }
}

.status-running svg,
.status-running.spinning {
    animation: spin 1s linear infinite;
}

/* ==========================================
   MOBILE OPTIMIZATION
   ========================================== */

/* Desktop/Mobile visibility */
.desktop-only {
    display: flex;
}
.mobile-only {
    display: none !important;
}

@media (max-width: 768px) {
    .desktop-only {
        display: none !important;
    }
    .mobile-only {
        display: flex !important;
    }
}

/* Header and mobile menu styles moved to navbar.css */

/* Log Panel Toggle Button */
.log-toggle {
    display: none;
    width: 100%;
    text-align: center;
    padding: 10px;
    background: var(--bg);
    border: none;
    border-top: 1px solid var(--border-light);
    color: var(--primary);
    font-size: 13px;
    font-weight: 500;
    cursor: pointer;
    margin-top: 12px;
    border-radius: 0 0 var(--radius) var(--radius);
}

.log-toggle:hover {
    background: var(--border-light);
}

/* History Cards (Mobile) */
.history-cards {
    display: none;
}

.history-card {
    background: var(--bg);
    border-radius: var(--radius);
    padding: 14px;
    margin-bottom: 12px;
    border: 1px solid var(--border-light);
}

.history-card:last-child {
    margin-bottom: 0;
}

.history-card-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    margin-bottom: 8px;
}

.history-card-query {
    font-size: 14px;
    font-weight: 500;
    color: var(--text-main);
    flex: 1;
    margin-right: 12px;
    word-break: break-word;
}

.history-card-footer {
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-size: 12px;
    color: var(--text-muted);
}

.history-card-cost {
    font-weight: 600;
    color: var(--primary);
}

.history-card {
    cursor: pointer;
    transition: all 0.2s ease;
}

.history-card:hover {
    border-color: var(--primary);
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.08);
}

/* History action buttons (desktop table) */
.history-actions {
    display: flex;
    gap: 6px;
    justify-content: center;
}

.history-action-btn {
    width: 32px;
    height: 32px;
    border: 1px solid var(--border);
    border-radius: 6px;
    background: var(--bg-white);
    color: var(--text-light);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s ease;
}

.history-action-btn:hover {
    border-color: var(--primary);
    color: var(--primary);
    background: var(--border-light);
}

/* History card action buttons (mobile) */
.history-card-actions {
    display: flex;
    gap: 8px;
    margin-top: 10px;
    padding-top: 10px;
    border-top: 1px solid var(--border-light);
}

.history-card-btn {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    padding: 10px 12px;
    border: 1px solid var(--border);
    border-radius: 6px;
    background: var(--bg-white);
    color: var(--text-light);
    font-size: 12px;
    font-weight: 500;
    font-family: inherit;
    cursor: pointer;
    transition: all 0.2s ease;
}

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

/* ==================== GLOBAL MOBILE UTILITIES ==================== */

/* Hide/Show utilities */
.hide-mobile { display: block; }
.show-mobile { display: none !important; }

@media (max-width: 768px) {
    .hide-mobile { display: none !important; }
    .show-mobile { display: block !important; }

    /* Prevent horizontal scroll globally */
    body {
        overflow-x: hidden;
    }

    /* Touch-friendly buttons - minimum tap target */
    .btn {
        min-height: 44px;
        min-width: 44px;
    }

    /* Fullscreen modals on mobile */
    .modal-content.modal-fullscreen-mobile {
        max-width: 100%;
        max-height: 100vh;
        border-radius: 0;
        margin: 0;
    }
}

@media (max-width: 480px) {
    /* Extra small screen container adjustments */
    .container,
    .main {
        padding-left: 12px;
        padding-right: 12px;
    }

    /* Modal forms - reduce padding */
    .modal-content form {
        padding: 1rem;
    }

    .modal-content .form-group {
        margin-bottom: 0.875rem;
    }

    /* Form inputs - larger touch targets */
    .modal-content .form-group input[type="text"],
    .modal-content .form-group input[type="email"],
    .modal-content .form-group input[type="password"],
    .modal-content .form-group select,
    .modal-content .form-group textarea {
        padding: 0.875rem;
        font-size: 16px; /* Prevents iOS zoom on focus */
    }
}

@media (max-width: 360px) {
    /* Very small screens (iPhone SE, older Android) */
    html {
        font-size: 14px;
    }

    .container,
    .main {
        padding-left: 8px;
        padding-right: 8px;
    }
}

/* Touch-Friendly Buttons */
.btn {
    min-height: 44px;
}

/* Safe Area for iPhone X+ (notch support) */
@supports (padding: env(safe-area-inset-top)) {
    .footer {
        padding-bottom: calc(16px + env(safe-area-inset-bottom));
        padding-left: calc(16px + env(safe-area-inset-left));
        padding-right: calc(16px + env(safe-area-inset-right));
    }

    .app-container {
        padding-left: calc(20px + env(safe-area-inset-left));
        padding-right: calc(20px + env(safe-area-inset-right));
    }
}

/* ==========================================
   TABLET BREAKPOINT (max-width: 768px)
   ========================================== */
@media (max-width: 768px) {
    /* Header styles in navbar.css */

    /* Stats grid 2 columns on tablet */
    .stats-grid {
        grid-template-columns: repeat(2, 1fr);
    }
}

/* ==========================================
   MOBILE BREAKPOINT (max-width: 600px)
   ========================================== */
@media (max-width: 600px) {
    /* Container padding */
    .app-container {
        padding: 12px;
    }

    /* Header styles in navbar.css */

    /* Panels */
    .panel {
        padding: 16px;
    }

    /* Form actions - stack buttons */
    .form-actions {
        display: flex;
        flex-direction: column;
    }

    .form-actions .btn {
        width: 100%;
    }

    /* Plan actions - stack buttons */
    .plan-actions {
        flex-direction: column;
    }

    .plan-actions .btn {
        width: 100%;
    }

    /* Results actions - wrap buttons */
    .results-actions {
        flex-direction: row;
        flex-wrap: wrap;
        justify-content: center;
    }

    .results-actions .btn {
        flex: 1 1 auto;
        min-width: 140px;
    }

    /* History - cards instead of table */
    .history-table-container {
        display: none;
    }

    .history-cards {
        display: block;
    }

    /* Modal fullscreen on mobile */
    .modal-content {
        width: 100%;
        height: 100%;
        max-width: none;
        border-radius: 0;
    }

    .modal-header {
        position: sticky;
        top: 0;
        z-index: 10;
        background: var(--bg-white);
    }

    .modal-close {
        min-width: 44px;
        min-height: 44px;
        display: flex;
        align-items: center;
        justify-content: center;
    }

    /* Success popup smaller padding */
    .success-popup {
        padding: 32px 24px;
        margin: 16px;
        max-width: calc(100% - 32px);
    }
}

/* ==========================================
   SMALL MOBILE BREAKPOINT (max-width: 480px)
   ========================================== */
@media (max-width: 480px) {
    /* Stats grid 1 column */
    .stats-grid {
        grid-template-columns: 1fr;
    }

    .stat-card {
        padding: 14px;
    }

    .stat-card .stat-value {
        font-size: 24px;
    }

    /* Smaller panel titles */
    .panel-title {
        font-size: 15px;
    }

    /* Header adjustments in navbar.css */

    /* Results stats smaller */
    .results-stats {
        grid-template-columns: repeat(2, 1fr);
        gap: 8px;
    }

    .stat-item {
        padding: 8px;
    }

    .stat-item .stat-value {
        font-size: 18px;
    }

    .stat-item .stat-label {
        font-size: 11px;
    }
}

/* === Session Tabs === */
.session-tabs-bar {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 20px;
    background: rgba(19, 68, 93, 0.05);
    border-bottom: 1px solid rgba(19, 68, 93, 0.1);
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
}

.session-tabs {
    display: flex;
    gap: 6px;
    flex: 1;
    overflow-x: auto;
    scrollbar-width: none;
}

.session-tabs::-webkit-scrollbar { display: none; }

.session-tab {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 6px 12px;
    background: rgba(255,255,255,0.7);
    border: 1px solid rgba(19, 68, 93, 0.15);
    border-radius: 8px;
    cursor: pointer;
    white-space: nowrap;
    font-size: 0.85em;
    transition: all 0.2s;
    min-width: 0;
}

.session-tab:hover {
    background: rgba(255,255,255,0.9);
    border-color: #2563eb;
}

.session-tab.active {
    background: #fff;
    border-color: #2563eb;
    box-shadow: 0 1px 4px rgba(37, 99, 235, 0.15);
}

.session-tab-icon { font-size: 1em; }
.session-tab-title {
    max-width: 120px;
    overflow: hidden;
    text-overflow: ellipsis;
    color: #13445d;
    font-weight: 500;
}
.session-tab-status { font-size: 0.9em; }

.session-tab-add {
    width: 32px;
    height: 32px;
    border-radius: 8px;
    border: 1px dashed rgba(19, 68, 93, 0.3);
    background: transparent;
    color: #13445d;
    font-size: 1.2em;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s;
    flex-shrink: 0;
}

.session-tab-add:hover {
    background: rgba(37, 99, 235, 0.1);
    border-color: #2563eb;
    color: #2563eb;
}

/* Quick restart button */
.btn-start-next {
    background: linear-gradient(135deg, #2563eb, #1e40af) !important;
    font-weight: 600;
}

.btn-start-next:hover {
    background: linear-gradient(135deg, #1e40af, #1e3a5f) !important;
}

/* Panel title row with help link */
.panel-title-row {
    display: flex;
    align-items: center;
    gap: 12px;
}

.help-link {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 24px;
    height: 24px;
    border-radius: 50%;
    background: rgba(19, 68, 93, 0.08);
    color: #13445d;
    font-size: 0.85em;
    font-weight: 600;
    text-decoration: none;
    transition: all 0.2s;
}

.help-link:hover {
    background: #2563eb;
    color: #fff;
}

/* === Research Info Bar (plan + mode during research) === */
.log-header-right {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 8px;
}

.research-mode-badge {
    display: inline-flex;
    align-items: center;
    padding: 3px 10px;
    border-radius: 12px;
    font-size: 0.8em;
    font-weight: 600;
    white-space: nowrap;
}

.research-mode-badge.mode-marketing {
    background: rgba(234, 179, 8, 0.15);
    color: #b45309;
}

.research-mode-badge.mode-customer {
    background: rgba(37, 99, 235, 0.12);
    color: #1e40af;
}

.research-mode-badge.mode-product {
    background: rgba(16, 185, 129, 0.12);
    color: #065f46;
}

.research-mode-badge.mode-custom {
    background: rgba(139, 92, 246, 0.12);
    color: #5b21b6;
}

.research-info-bar {
    background: rgba(19, 68, 93, 0.04);
    border: 1px solid rgba(19, 68, 93, 0.08);
    border-radius: 10px;
    padding: 10px 14px;
    margin-bottom: 14px;
}

.info-plan-title {
    font-weight: 600;
    font-size: 0.9em;
    color: #13445d;
    margin-bottom: 6px;
}

.info-plan-items {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
}

.info-plan-item {
    display: inline-block;
    padding: 2px 8px;
    background: rgba(37, 99, 235, 0.08);
    border-radius: 6px;
    font-size: 0.78em;
    color: #374151;
}

.log-panel-actions {
    display: flex;
    justify-content: flex-start;
    padding: 10px 0 0;
    border-top: 1px solid rgba(19, 68, 93, 0.08);
    margin-top: auto;
}

.btn-sm {
    padding: 6px 14px;
    font-size: 0.82em;
}

/* === History Header with Tabs === */
.history-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 14px;
}

.history-tabs {
    display: flex;
    gap: 4px;
    background: rgba(19, 68, 93, 0.06);
    border-radius: 8px;
    padding: 3px;
}

.history-tab {
    padding: 5px 14px;
    border: none;
    background: transparent;
    border-radius: 6px;
    font-size: 0.82em;
    font-weight: 500;
    color: #6b7280;
    cursor: pointer;
    transition: all 0.2s;
}

.history-tab:hover {
    color: #13445d;
}

.history-tab.active {
    background: #fff;
    color: #13445d;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.08);
}

/* === History Icon Buttons === */
.history-icon-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 30px;
    height: 30px;
    border: 1px solid rgba(19, 68, 93, 0.12);
    border-radius: 6px;
    background: transparent;
    color: #6b7280;
    cursor: pointer;
    transition: all 0.15s;
}

.history-icon-btn:hover {
    background: rgba(37, 99, 235, 0.08);
    border-color: #2563eb;
    color: #2563eb;
}

.history-icon-btn-danger:hover {
    background: rgba(239, 68, 68, 0.08);
    border-color: #ef4444;
    color: #ef4444;
}

.history-actions {
    display: flex;
    gap: 4px;
    align-items: center;
}

.history-mode {
    text-align: center;
    font-size: 1.1em;
}

/* Mobile: history card actions */
.history-card-actions {
    display: flex;
    gap: 4px;
    align-items: center;
}

.history-card-footer {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.history-card-mode {
    font-size: 1em;
    margin-right: 6px;
}

/* Mobile: session tabs scroll */
@media (max-width: 768px) {
    .session-tabs-bar { padding: 6px 12px; }
    .session-tab { padding: 4px 8px; font-size: 0.8em; }
    .session-tab-title { max-width: 80px; }
    .history-header { flex-direction: column; gap: 8px; align-items: flex-start; }
    .research-info-bar { padding: 8px 10px; }
    .info-plan-item { font-size: 0.72em; }
    .log-workspace { grid-template-columns: 1fr; }
    .log-sidebar { order: 2; }
    .log-animation-col { order: 1; }
    .generation-animation { min-height: 360px; padding: 1.25rem; }
    .stages-track { margin-top: 1.25rem; padding: 0 0.25rem; }
    .stage { padding: 0 0.35rem; }
    .stage-label { font-size: 0.66rem; }
    .stage-connector { right: -0.45rem; width: 0.9rem; }
    .animation-counters { margin-top: 1.1rem; gap: 1.2rem; }
    .counter-value { font-size: 1.55rem; }
    .log-header-right { width: 100%; justify-content: flex-start; }
    .timer { width: 100%; font-size: 0.82rem; white-space: normal; line-height: 1.35; }
    .log-msg { white-space: normal; overflow: visible; text-overflow: clip; }
}
