/* General Body and Container Styles */
body {
    font-family: 'Inter', sans-serif;
    background-color: #f8fafc;
    color: #334155;
    margin: 0;
    padding-top: 70px; 
    transition: background-color 0.3s ease, color 0.3s ease;
}
.dark {
    background-color: #1a202c;
    color: #e2e8f0;
}

.main-content-area {
    width: 100%;
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 2rem;
    flex-grow: 1;
}

.container {
    max-width: 800px;
    width: 100%;
    padding: 0;
    display: flex;
    flex-direction: column;
    align-items: center;
    transition: max-width 0.5s ease-in-out; /* Smooth transition for width change */
}

/* NEW: Rule to expand the container when summary is visible */
.container.summary-visible {
    max-width: 1200px;
}


/* Input Card Style */
.input-card {
    background-color: #ffffff;
    border-radius: 1.5rem;
    padding: 2rem;
    box-shadow: 0 10px 25px rgba(0, 0, 0, 0.05), 0 4px 10px rgba(0, 0, 0, 0.02);
    border: 1px solid #e2e8f0;
    width: 100%;
    max-width: 500px;
    display: flex;
    flex-direction: column;
    gap: 1.5rem;
    transition: all 0.3s ease;
}
.dark .input-card {
    background-color: #2d3748;
    border-color: #4a5568;
    box-shadow: 0 10px 25px rgba(0, 0, 0, 0.2);
}

/* Input with Icon */
.input-with-icon {
    position: relative;
}
.input-icon {
    position: absolute;
    left: 0.75rem;
    top: 50%;
    transform: translateY(-50%);
    color: #94a3b8;
    width: 1.25rem;
    height: 1.25rem;
}

/* Header Styles */
header {
    background-color: #ffffff;
    box-shadow: 0 2px 4px rgba(0,0,0,0.05);
    padding: 0.5rem 1.5rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    z-index: 100;
    height: 70px;
}
.dark header {
    background-color: #2d3748;
    box-shadow: 0 2px 4px rgba(0,0,0,0.2);
}
.nav-link-button {
    background: none !important; border: none; cursor: pointer;
}

/* Form Elements & Buttons */
input, select {
    border: 1px solid #d1d9e6;
    border-radius: 10px;
    padding: 0.75rem 1rem;
    font-size: 1rem;
    background-color: #f8fafc;
    color: #334155;
    transition: all 0.2s ease-in-out;
}
input:focus, select:focus {
    border-color: #3b82f6;
    box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.25);
    outline: none;
    background-color: #ffffff;
}
.dark input, .dark select {
    background-color: #1e293b;
    border-color: #4b5563;
    color: #e2e8f0;
}
.dark input:focus, .dark select:focus {
    border-color: #60a5fa;
    box-shadow: 0 0 0 3px rgba(96, 165, 250, 0.25);
    background-color: #2d3748;
}

/* Enhanced Button Style */
#findClustersButton {
    background-image: linear-gradient(to right, #3b82f6, #60a5fa);
    color: white;
    padding: 0.85rem 1.5rem;
    border-radius: 10px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
    border: none;
    box-shadow: 0 4px 15px rgba(59, 130, 246, 0.3);
}
#findClustersButton:hover:not(:disabled) {
    transform: translateY(-3px);
    box-shadow: 0 7px 20px rgba(59, 130, 246, 0.4);
}
#findClustersButton:disabled {
    opacity: 0.6;
    cursor: not-allowed;
    background-image: none;
    background-color: #9ca3af;
}
#findClustersButton.loading {
    animation: pulse-bg 2s infinite;
}
@keyframes pulse-bg {
    0% { background-color: #3b82f6; }
    50% { background-color: #60a5fa; }
    100% { background-color: #3b82f6; }
}

/* Error Message Box */
#errorMessageBox {
    background-color: #fee2e2; border: 1px solid #fca5a5; color: #dc2626;
    padding: 0.75rem 1.25rem; border-radius: 0.5rem; margin-bottom: 1.5rem;
    text-align: center; font-weight: 500;
}
.dark #errorMessageBox {
    background-color: #450a0a; border-color: #7f1d1d; color: #f87171;
}

/* Loading Spinners */
.loading-spinner {
    border: 4px solid rgba(255, 255, 255, 0.3);
    border-top-color: #ffffff;
    border-radius: 50%;
    width: 24px;
    height: 24px;
    animation: spin 1s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* Smooth Transitions for Sections */
#clusterSelectionArea, #summaryDisplayArea {
    opacity: 0;
    transform: translateY(20px);
    transition: opacity 0.5s ease, transform 0.5s ease;
    width: 100%;
}
#clusterSelectionArea:not(.hidden), #summaryDisplayArea:not(.hidden) {
    opacity: 1;
    transform: translateY(0);
}

/* Enhanced Cluster Cards */
.cluster-card {
    background-color: #ffffff;
    padding: 1.5rem;
    border-radius: 1rem;
    box-shadow: 0 4px 10px rgba(0, 0, 0, 0.05);
    cursor: pointer;
    transition: all 0.2s ease-in-out;
    border: 1px solid #e2e8f0;
}
.cluster-card:hover {
    box-shadow: 0 8px 20px rgba(0, 0, 0, 0.08);
    transform: translateY(-4px);
    border-color: #93c5fd;
}
.dark .cluster-card {
    background-color: #2d3748;
    border-color: #4b5563;
}
.dark .cluster-card:hover { border-color: #60a5fa; }
.cluster-card-header {
    display: flex;
    align-items: flex-start;
    gap: 1rem;
    margin-bottom: 1rem;
}
.cluster-card-icon {
    flex-shrink: 0;
    color: #3b82f6;
    background-color: #dbeafe;
    border-radius: 50%;
    padding: 0.75rem;
}
.dark .cluster-card-icon {
    color: #93c5fd;
    background-color: #1e3a8a;
}
.cluster-card h3 {
    font-weight: 700; color: #1e3a8a; font-size: 1.125rem; margin-bottom: 0.25rem;
}
.dark .cluster-card h3 { color: #93c5fd; }
.cluster-card p {
    font-size: 0.9rem; color: #475569; margin-bottom: 0.5rem;
}
.dark .cluster-card p { color: #cbd5e0; }
.cluster-card-links {
    font-size: 0.8rem;
    color: #64748b;
    border-top: 1px solid #e2e8f0;
    padding-top: 0.75rem;
    margin-top: 0.75rem;
}
.dark .cluster-card-links {
    border-top-color: #4b5563;
    color: #a0aec0;
}
.cluster-card-links ul { list-style-type: disc; padding-left: 1.25rem; }
.cluster-card-links a { color: #3b82f6; text-decoration: none; word-break: break-all; }
.cluster-card-links a:hover { text-decoration: underline; }
.dark .cluster-card-links a { color: #60a5fa; }

/* Friendlier Empty/Error State */
.empty-state {
    text-align: center;
    padding: 3rem 1rem;
    border: 2px dashed #d1d5db;
    border-radius: 1rem;
    background-color: #f9fafb;
}
.dark .empty-state {
    border-color: #4b5563;
    background-color: #1f2937;
}
.empty-state-icon {
    color: #9ca3af;
    width: 4rem;
    height: 4rem;
    margin: 0 auto 1rem;
}
.dark .empty-state-icon { color: #6b7280; }

/* Result Box & Summary Typography */
.result-box {
    background-color: #f1f5f9;
    padding: 2rem;
    border-radius: 1rem;
    line-height: 1.7;
    color: #334155;
    text-align: justify;
}
.dark .result-box {
    background-color: #334155;
    color: #e2e8f0;
}
.result-box h2 {
    font-size: 1.5rem; font-weight: 700; margin-top: 1.5rem; margin-bottom: 0.75rem;
    color: #1e3a8a;
}
.dark .result-box h2 { color: #93c5fd; }
.result-box h3 {
    font-size: 1.25rem; font-weight: 600; margin-top: 1.25rem; margin-bottom: 0.5rem;
    color: #1d4ed8;
}
.dark .result-box h3 { color: #bfdbfe; }

/* RESTORED: Original Sentiment Bar Styles */
.sentiment-bar-chart {
    display: flex;
    width: 100%;
    height: 20px;
    border-radius: 10px;
    overflow: hidden;
    margin-bottom: 0.5rem;
    box-shadow: inset 0 1px 3px rgba(0,0,0,0.1);
}
.sentiment-bar-positive { background-color: #22c55e; }
.sentiment-bar-neutral { background-color: #facc15; }
.sentiment-bar-negative { background-color: #ef4444; }
.sentiment-labels {
    display: flex;
    justify-content: space-between;
    width: 100%;
    margin-top: 0.2rem;
    font-size: 0.8em;
    color: #64748b;
}

/* Dark Mode Toggle Button */
#darkModeToggle {
    background: #e2e8f0; color: #475569;
    border-radius: 9999px; padding: 0.5rem 1rem;
    font-size: 0.875rem; font-weight: 600;
    position: fixed; bottom: 2rem; right: 1.5rem;
    cursor: pointer; transition: all 0.3s ease;
    box-shadow: 0 2px 5px rgba(0,0,0,0.1);
    z-index: 1000;
}
#darkModeToggle:hover { background-color: #cbd5e1; }
.dark #darkModeToggle { background: #4a5568; color: #e2e8f0; }
.dark #darkModeToggle:hover { background-color: #2d3748; }


.modal-sentiment-bar-chart {
    display: flex;
    width: 100%;
    height: 20px;
    border-radius: 5px;
    overflow: hidden;
    margin-top: 1rem;
}

.modal-sentiment-bar-positive {
    background-color: #10b981; /* Emerald 500 */
}

.modal-sentiment-bar-neutral {
    background-color: #fbbf24; /* Amber 400 */
}

.modal-sentiment-bar-negative {
    background-color: #ef4444; /* Red 500 */
}

.modal-sentiment-labels {
    display: flex;
    justify-content: space-between;
    width: 100%;
    margin-top: 0.5rem;
    font-size: 0.8em;
    color: #64748b;
}

.dark .modal-sentiment-labels {
    color: #94a3b8;
}