/* Base styles for Candle Support */
*,
*::before,
*::after {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto,
        Oxygen, Ubuntu, Cantarell, "Fira Sans", "Droid Sans",
        "Helvetica Neue", sans-serif;
    line-height: 1.6;
    color: #1a1a1a;
    background-color: #f5f6f8;
    min-height: 100vh;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

.container {
    max-width: 780px;
    margin: 0 auto;
    padding: 2rem 1.5rem;
}

header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 2.5rem;
    padding-bottom: 1rem;
    border-bottom: 1px solid #e5e7eb;
}

.logo {
    font-size: 1.25rem;
    font-weight: 700;
    color: #111827;
    letter-spacing: -0.01em;
}

main {
    min-height: 60vh;
}

footer {
    margin-top: 3rem;
    padding-top: 1rem;
    border-top: 1px solid #e5e7eb;
    text-align: center;
    font-size: 0.8rem;
    color: #9ca3af;
}

/* Utility classes */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 0.5rem 1.25rem;
    font-size: 0.9rem;
    font-weight: 500;
    border: none;
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.15s ease;
    line-height: 1.4;
}

.btn-primary {
    background-color: #4f46e5;
    color: #fff;
}

.btn-primary:hover {
    background-color: #4338ca;
    box-shadow: 0 1px 2px rgba(79, 70, 229, 0.25);
}

.btn-secondary {
    background-color: #f3f4f6;
    color: #374151;
    border: 1px solid #e5e7eb;
}

.btn-secondary:hover {
    background-color: #e5e7eb;
}

input[type="text"],
input[type="password"],
textarea {
    width: 100%;
    padding: 0.6rem 0.85rem;
    font-family: inherit;
    font-size: 0.9rem;
    border: 1px solid #d1d5db;
    border-radius: 8px;
    outline: none;
    transition: border-color 0.15s ease, box-shadow 0.15s ease;
    background: #fff;
}

input[type="text"]:focus,
input[type="password"]:focus,
textarea:focus {
    border-color: #4f46e5;
    box-shadow: 0 0 0 3px rgba(79, 70, 229, 0.1);
}

.error-message {
    color: #dc2626;
    font-size: 0.85rem;
    margin-top: 0.25rem;
}

/* Login page */
.login-card {
    max-width: 380px;
    margin: 5rem auto 0;
    padding: 2rem;
    background: #fff;
    border-radius: 12px;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.06), 0 1px 2px rgba(0, 0, 0, 0.04);
}

.login-card h2 {
    font-size: 1.25rem;
    font-weight: 700;
    margin-bottom: 0.25rem;
    color: #111827;
}

.login-subtitle {
    color: #6b7280;
    font-size: 0.85rem;
    margin-bottom: 1.5rem;
}

.login-form .form-group {
    margin-bottom: 1rem;
}

.login-form label {
    display: block;
    font-size: 0.85rem;
    font-weight: 500;
    margin-bottom: 0.35rem;
    color: #374151;
}

.login-btn {
    width: 100%;
    margin-top: 0.5rem;
    padding: 0.6rem 1.25rem;
}

.login-card .error-message {
    background-color: #fef2f2;
    border: 1px solid #fecaca;
    padding: 0.5rem 0.75rem;
    border-radius: 8px;
    margin-bottom: 1rem;
}

/* Header navigation */
.header-nav {
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.nav-link {
    color: #6b7280;
    text-decoration: none;
    font-size: 0.85rem;
    font-weight: 500;
    transition: color 0.15s ease;
}

.nav-link:hover {
    color: #4f46e5;
}

.logout-form {
    display: inline;
    margin: 0;
    padding: 0;
}

.btn-sm {
    padding: 0.3rem 0.7rem;
    font-size: 0.8rem;
}

/* Search page */
.search-page {
    max-width: 100%;
}

.search-section h2 {
    font-size: 1.25rem;
    font-weight: 700;
    margin-bottom: 0.25rem;
    color: #111827;
}

.search-subtitle {
    color: #6b7280;
    font-size: 0.85rem;
    margin-bottom: 1.25rem;
}

.search-form {
    margin-bottom: 1.5rem;
}

.search-textarea-group {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.search-textarea-group textarea {
    resize: vertical;
    min-height: 4.5rem;
}

.search-textarea-group .btn {
    align-self: flex-end;
}

/* Loading indicator */
.loading-indicator {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 0.75rem;
    padding: 3rem 2rem;
    color: #6b7280;
    font-size: 0.9rem;
}

.loading-indicator #loading-message {
    transition: opacity 0.2s ease;
    text-align: center;
}

.spinner {
    width: 22px;
    height: 22px;
    border: 2.5px solid #e5e7eb;
    border-top-color: #4f46e5;
    border-radius: 50%;
    animation: spin 0.7s linear infinite;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

/* Error banner */
.error-banner {
    background-color: #fef2f2;
    border: 1px solid #fecaca;
    color: #dc2626;
    padding: 0.75rem 1rem;
    border-radius: 10px;
    font-size: 0.85rem;
    margin-bottom: 1rem;
}

/* Results panels */
.results-panel {
    background: #fff;
    border-radius: 12px;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.06), 0 1px 2px rgba(0, 0, 0, 0.04);
    padding: 1.25rem 1.5rem;
    margin-bottom: 0.75rem;
}

.panel-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 0.75rem;
    padding-bottom: 0.5rem;
    border-bottom: 1px solid #f3f4f6;
}

.panel-header h3 {
    font-size: 0.95rem;
    font-weight: 600;
    margin: 0;
    color: #111827;
}

.copy-btn {
    font-size: 0.75rem;
    padding: 0.2rem 0.55rem;
}

.copy-btn.copied {
    background-color: #d1fae5;
    color: #065f46;
    border-color: #a7f3d0;
}

/* Action steps */
.action-steps-list {
    padding-left: 1.25rem;
}

.action-steps-list li {
    margin-bottom: 0.4rem;
    line-height: 1.5;
    font-size: 0.9rem;
    color: #374151;
}

/* Email response */
.email-response-content {
    white-space: pre-wrap;
    font-size: 0.9rem;
    line-height: 1.65;
    color: #374151;
}

/* No results message */
.no-results-message {
    text-align: center;
    padding: 2.5rem 2rem;
    color: #6b7280;
    font-size: 0.9rem;
    background: #fff;
    border-radius: 12px;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.06), 0 1px 2px rgba(0, 0, 0, 0.04);
}

/* Sources indicator */
.sources-indicator {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    margin-bottom: 0.5rem;
    padding: 0.25rem 0;
    font-size: 0.8rem;
}

.sources-label {
    color: #9ca3af;
    font-weight: 500;
}

.sources-tags {
    display: flex;
    gap: 0.35rem;
    flex-wrap: wrap;
}

.source-tag {
    display: inline-block;
    padding: 0.125rem 0.5rem;
    border-radius: 10px;
    font-size: 0.75rem;
    font-weight: 500;
}

.source-tag.source-knowledge {
    background-color: #ede9fe;
    color: #5b21b6;
}

.source-tag.source-email {
    background-color: #dbeafe;
    color: #1e40af;
}

/* Disabled button */
.btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

/* Alert messages */
.alert {
    padding: 0.75rem 1rem;
    border-radius: 10px;
    font-size: 0.85rem;
    margin-bottom: 1rem;
}

.alert-error {
    background-color: #fef2f2;
    border: 1px solid #fecaca;
    color: #dc2626;
}

.alert-success {
    background-color: #f0fdf4;
    border: 1px solid #bbf7d0;
    color: #166534;
}

/* Admin page */
.admin-page h2 {
    font-size: 1.25rem;
    font-weight: 700;
    margin-bottom: 0.25rem;
    color: #111827;
}

.admin-subtitle {
    color: #6b7280;
    font-size: 0.85rem;
    margin-bottom: 1.5rem;
}

.admin-card {
    background: #fff;
    border-radius: 12px;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.06), 0 1px 2px rgba(0, 0, 0, 0.04);
    padding: 1.25rem 1.5rem;
    margin-bottom: 0.75rem;
}

.admin-card h3 {
    font-size: 0.95rem;
    font-weight: 600;
    margin-bottom: 0.75rem;
    color: #111827;
}

.status-row {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    margin-bottom: 1rem;
}

.status-indicator {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    display: inline-block;
}

.status-indicator.connected {
    background-color: #22c55e;
    box-shadow: 0 0 0 2px rgba(34, 197, 94, 0.2);
}

.status-indicator.disconnected {
    background-color: #ef4444;
    box-shadow: 0 0 0 2px rgba(239, 68, 68, 0.2);
}

.status-text {
    font-size: 0.9rem;
    color: #374151;
}

.help-text {
    color: #9ca3af;
    font-size: 0.8rem;
    margin-top: 0.5rem;
}

.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
    gap: 1rem;
}

.stat-item {
    display: flex;
    flex-direction: column;
    gap: 0.2rem;
}

.stat-label {
    font-size: 0.8rem;
    color: #9ca3af;
    font-weight: 500;
    text-transform: uppercase;
    letter-spacing: 0.03em;
}

.stat-value {
    font-size: 1rem;
    font-weight: 600;
    color: #111827;
}

/* Sync controls */
.sync-controls-row {
    display: flex;
    align-items: center;
    gap: 1rem;
}

.sync-progress {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    color: #6b7280;
    font-size: 0.85rem;
}
