:root {
    --primary: #4f46e5;
    --primary-hover: #4338ca;
    --primary-light: #e0e7ff;
    --accent: #059669;
    --accent-light: #dcfce7;
    --warning: #d97706;
    --warning-light: #fef3c7;
    --danger: #dc2626;
    --danger-light: #fee2e2;
    --bg-main: #f8fafc;
    --card-bg: #ffffff;
    --text-dark: #0f172a;
    --text-muted: #64748b;
    --border: #e2e8f0;
    --shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.05), 0 2px 4px -1px rgba(0, 0, 0, 0.03);
    --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.07), 0 4px 6px -2px rgba(0, 0, 0, 0.04);
    --radius: 12px;
}

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

body {
    font-family: 'Prompt', 'Sarabun', sans-serif;
    background-color: var(--bg-main);
    color: var(--text-dark);
    line-height: 1.7;
    padding: 24px;
}

.app-container {
    max-width: 1280px;
    margin: 0 auto;
}

/* Navbar / App Header */
.app-header {
    background: linear-gradient(135deg, #1e1b4b 0%, #3730a3 50%, #0284c7 100%);
    color: #ffffff;
    padding: 32px 36px;
    border-radius: var(--radius);
    box-shadow: var(--shadow-lg);
    margin-bottom: 28px;
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.header-brand h1 {
    font-size: 2rem;
    font-weight: 700;
    line-height: 1.2;
}

.header-brand p {
    font-size: 1rem;
    opacity: 0.88;
    margin-top: 4px;
}

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

/* Input Workspace View */
.workspace-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 24px;
    margin-bottom: 32px;
}

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

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

.card-title {
    font-size: 1.25rem;
    font-weight: 700;
    margin-bottom: 16px;
    display: flex;
    align-items: center;
    gap: 8px;
}

.card-title span {
    width: 6px;
    height: 22px;
    background: var(--primary);
    border-radius: 4px;
    display: inline-block;
}

.preset-btn-group {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    margin-bottom: 18px;
}

.btn-preset {
    background: #f1f5f9;
    color: var(--text-dark);
    border: 1px solid var(--border);
    padding: 8px 14px;
    border-radius: 8px;
    font-size: 0.88rem;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s ease;
    font-family: inherit;
}

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

.prompt-textarea {
    width: 100%;
    height: 380px;
    padding: 16px;
    border-radius: 8px;
    border: 1px solid var(--border);
    font-family: 'Courier New', Courier, monospace;
    font-size: 0.88rem;
    line-height: 1.6;
    resize: vertical;
    outline: none;
    background: #fafafa;
    color: #1e293b;
    margin-bottom: 16px;
}

.prompt-textarea:focus {
    border-color: var(--primary);
    background: #ffffff;
    box-shadow: 0 0 0 3px rgba(79, 70, 229, 0.1);
}

.btn-primary {
    background: var(--primary);
    color: #ffffff;
    padding: 14px 28px;
    border-radius: 8px;
    font-weight: 600;
    font-size: 1rem;
    border: none;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    width: 100%;
    font-family: inherit;
    transition: all 0.3s ease;
}

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

/* Dynamic Ready State Glow & Highlight */
.btn-highlight-ready {
    background: linear-gradient(135deg, #059669 0%, #10b981 100%) !important;
    color: #ffffff !important;
    font-size: 1.06rem !important;
    font-weight: 700 !important;
    border: 2px solid #a7f3d0 !important;
    box-shadow: 0 0 25px rgba(16, 185, 129, 0.65), 0 6px 20px rgba(5, 150, 105, 0.4) !important;
    animation: pulseButtonGlow 1.4s infinite alternate !important;
}

@keyframes pulseButtonGlow {
    0% {
        box-shadow: 0 0 15px rgba(16, 185, 129, 0.5), 0 0 0 0 rgba(16, 185, 129, 0.4);
        transform: scale(1.00);
    }
    100% {
        box-shadow: 0 0 30px rgba(16, 185, 129, 0.85), 0 0 0 10px rgba(16, 185, 129, 0);
        transform: scale(1.025);
    }
}

.btn-success {
    background: var(--accent);
    color: #ffffff;
    padding: 10px 20px;
    border-radius: 8px;
    font-weight: 600;
    border: none;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    gap: 8px;
    font-family: inherit;
    transition: background 0.2s ease;
}

.btn-success:hover {
    background: #047857;
}

/* Feature Bullet Cards */
.feature-list {
    display: flex;
    flex-direction: column;
    gap: 16px;
}

.feature-item {
    background: #f8fafc;
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 16px;
}

.feature-item h4 {
    font-size: 0.98rem;
    color: var(--primary-hover);
    margin-bottom: 4px;
}

.feature-item p {
    font-size: 0.88rem;
    color: var(--text-muted);
}

/* Results & Dashboard Section */
.results-section {
    display: none; /* hidden until user clicks analyze */
}

.kpi-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
    gap: 20px;
    margin-bottom: 32px;
}

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

.kpi-title {
    font-size: 0.85rem;
    color: var(--text-muted);
    font-weight: 600;
    text-transform: uppercase;
    margin-bottom: 6px;
}

.kpi-value {
    font-size: 2.2rem;
    font-weight: 700;
    margin-bottom: 4px;
}

.kpi-sub {
    font-size: 0.84rem;
    color: var(--text-muted);
}

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

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

.chart-container {
    position: relative;
    width: 100%;
    min-height: 320px;
    margin-bottom: 16px;
}

.annotation-box {
    background: #f8fafc;
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 14px 18px;
    font-size: 0.9rem;
    margin-top: 12px;
}

.recommend-box {
    background: #f0fdf4;
    border-left: 4px solid var(--accent);
    border-radius: 0 8px 8px 0;
    padding: 14px 18px;
    font-size: 0.9rem;
    color: #14532d;
    margin-top: 10px;
}

.badge-risk {
    display: inline-block;
    padding: 4px 10px;
    border-radius: 20px;
    font-size: 0.78rem;
    font-weight: 600;
}
.risk-dream { background: #fee2e2; color: #991b1b; }
.risk-target { background: #fef3c7; color: #92400e; }
.risk-likely { background: #dbeafe; color: #1e40af; }
.risk-safety { background: #dcfce7; color: #166534; }

.table-responsive {
    width: 100%;
    overflow-x: auto;
    border-radius: 8px;
    border: 1px solid var(--border);
}

table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.9rem;
}

th {
    background-color: #f8fafc;
    padding: 12px 16px;
    font-weight: 600;
    border-bottom: 2px solid var(--border);
    text-align: left;
}

td {
    padding: 12px 16px;
    border-bottom: 1px solid var(--border);
    color: var(--text-muted);
}

tr:hover {
    background-color: #f1f5f9;
}

footer {
    text-align: center;
    padding: 24px;
    color: var(--text-muted);
    font-size: 0.88rem;
    border-top: 1px solid var(--border);
    margin-top: 40px;
}
