/* Reset & Design System Tokens */
* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

body {
    font-family: 'Plus Jakarta Sans', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
    background-color: #f8f9fa;
    color: #191c1d;
    height: 100vh;
    display: flex;
    justify-content: center;
    align-items: center;
    overflow: hidden;
}

/* Common Layout Utilities */
.hidden {
    display: none !important;
}

.error-msg {
    color: #ba1a1a;
    font-size: 14px;
    margin-top: 12px;
    text-align: center;
}

/* 1. Passcode Lock Screen */
.gate-container {
    background-color: #f8f9fa;
    width: 100vw;
    height: 100vh;
    display: flex;
    justify-content: center;
    align-items: center;
    position: fixed;
    z-index: 1000;
}

.gate-card {
    background: #ffffff;
    padding: 40px;
    width: 90%;
    max-width: 400px;
    border-radius: 16px; /* 1rem container radius */
    border: 1px solid #e1e3e4;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.04);
    display: flex;
    flex-direction: column;
    align-items: center;
}

.gate-icon {
    font-size: 48px;
    margin-bottom: 20px;
}

.gate-card h2 {
    font-size: 24px;
    font-weight: 700;
    margin-bottom: 8px;
    text-transform: capitalize;
}

.gate-card p {
    font-size: 14px;
    color: #575f69;
    text-align: center;
    margin-bottom: 24px;
}

.gate-card form {
    width: 100%;
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.gate-card input[type="password"] {
    width: 100%;
    padding: 14px 16px;
    font-size: 18px;
    border: 1px solid #e1e3e4;
    border-radius: 8px; /* 0.5rem radius */
    text-align: center;
    letter-spacing: 4px;
    outline: none;
    transition: border-color 0.2s;
    background: #f8f9fa;
}

.gate-card input[type="password"]:focus {
    border-color: #861F41;
    background: #ffffff;
}

/* Buttons and Controls */
.primary-btn {
    background-color: #861F41;
    color: #ffffff;
    border: none;
    padding: 14px 16px;
    font-size: 16px;
    font-weight: 600;
    border-radius: 8px;
    cursor: pointer;
    transition: background-color 0.2s;
    width: 100%;
}

.primary-btn:hover {
    background-color: #6e1735;
}

/* Google OAuth & Whitelist Auth UI */
.google-signin-wrapper {
    width: 100%;
    display: flex;
    flex-direction: column;
    align-items: center;
    margin-bottom: 14px;
}

.auth-divider {
    display: flex;
    align-items: center;
    width: 100%;
    margin: 18px 0 6px 0;
    color: #8b929c;
    font-size: 12px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.auth-divider::before,
.auth-divider::after {
    content: "";
    flex: 1;
    border-bottom: 1px solid #e1e3e4;
}

.auth-divider span {
    padding: 0 10px;
}

.user-badge {
    display: flex;
    align-items: center;
    gap: 8px;
    background: #f1f3f4;
    padding: 6px 12px;
    border-radius: 20px;
    font-size: 12px;
    color: #3c4043;
    font-weight: 500;
    max-width: 220px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.user-avatar {
    width: 20px;
    height: 20px;
    border-radius: 50%;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: 14px;
}

.user-avatar img {
    width: 100%;
    height: 100%;
    border-radius: 50%;
    object-fit: cover;
}

.user-email {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

/* 2. Main Chat App Layout */
.app-container {
    background-color: #ffffff;
    width: 100vw;
    height: 100vh;
    max-width: 800px;
    max-height: 900px;
    border-radius: 16px;
    border: 1px solid #e1e3e4;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.03);
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

@media (max-width: 800px) {
    .app-container {
        border-radius: 0;
        border: none;
        max-height: 100%;
    }
}

.app-header {
    background-color: #ffffff;
    padding: 16px 24px;
    border-bottom: 1px solid #e1e3e4;
    display: flex;
    align-items: center;
    gap: 16px;
    position: relative;
}

.header-logo {
    font-size: 32px;
}

.header-info {
    flex-grow: 1;
}

.header-info h1 {
    font-size: 18px;
    font-weight: 700;
}

.header-info p {
    font-size: 12px;
    color: #575f69;
}

.status-online {
    display: flex;
    align-items: center;
    gap: 6px;
    font-weight: 500;
}

.status-online .dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background-color: #2e7d32;
    display: inline-block;
}

.logout-btn {
    background: none;
    border: 1px solid #e1e3e4;
    color: #575f69;
    padding: 8px 16px;
    font-size: 13px;
    font-weight: 600;
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.2s;
}

.logout-btn:hover {
    background-color: #f8f9fa;
    color: #191c1d;
    border-color: #575f69;
}

/* Chat Message Logs */
.chat-log {
    flex-grow: 1;
    padding: 24px;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 16px;
    background-color: #f8f9fa;
}

.message {
    max-width: 80%;
    display: flex;
    flex-direction: column;
}

.message.user-msg {
    align-self: flex-end;
}

.message.bot-msg {
    align-self: flex-start;
}

.message.system-msg {
    align-self: center;
    max-width: 90%;
}

.message-content {
    padding: 12px 18px;
    border-radius: 16px; /* 1rem radius */
    font-size: 15px;
    line-height: 1.5;
    word-break: break-word;
}

.user-msg .message-content {
    background-color: #E5751F;
    color: #ffffff;
    border-bottom-right-radius: 4px;
}

.bot-msg .message-content {
    background-color: #fcf3f5;
    color: #191c1d;
    border-bottom-left-radius: 4px;
    border: 1px solid #f4d2db;
}

.system-msg .message-content {
    background-color: #ffffff;
    color: #575f69;
    border: 1px solid #e1e3e4;
    font-size: 14px;
    text-align: center;
}

.message-content table {
    width: 100%;
    border-collapse: collapse;
    margin: 12px 0;
    font-size: 14px;
}

.message-content th, 
.message-content td {
    padding: 8px 10px;
    text-align: left;
    border-bottom: 1px solid #f4d2db;
}

.user-msg .message-content a {
    color: #ffffff;
    text-decoration: underline;
    font-weight: 500;
}

.bot-msg .message-content a {
    color: #861F41;
    text-decoration: none;
    font-weight: 600;
}

.bot-msg .message-content a:hover {
    color: #E5751F;
    text-decoration: underline;
}

/* JetBrains Mono styling for tabular calculations */
.bot-msg .message-content strong,
.bot-msg .message-content code {
    font-family: 'JetBrains Mono', monospace;
    font-size: 14px;
    background-color: rgba(134, 31, 65, 0.08);
    color: #861F41;
    padding: 2px 4px;
    border-radius: 4px;
}

/* Chat Helper Suggestions Chips */
.suggestions-bar {
    padding: 12px 24px;
    background-color: #ffffff;
    border-top: 1px solid #e1e3e4;
    display: flex;
    gap: 8px;
    overflow-x: auto;
    scrollbar-width: none; /* Hide scrollbar for clean HUD */
}

.suggestions-bar::-webkit-scrollbar {
    display: none;
}

.chip-btn {
    background-color: #fff3eb;
    color: #E5751F;
    border: 1px solid #ffd4bc;
    padding: 8px 16px;
    font-size: 13px;
    font-weight: 600;
    border-radius: 20px; /* Pill shape */
    cursor: pointer;
    white-space: nowrap;
    transition: all 0.2s;
}

.chip-btn:hover {
    background-color: #E5751F;
    color: #ffffff;
    border-color: #E5751F;
}

/* App Input Footer */
.app-footer {
    background-color: #ffffff;
    padding: 16px 24px;
    border-top: 1px solid #e1e3e4;
}

.app-footer form {
    display: flex;
    gap: 12px;
}

.app-footer input[type="text"] {
    flex-grow: 1;
    padding: 12px 18px;
    font-size: 15px;
    border: 1px solid #e1e3e4;
    border-radius: 8px;
    outline: none;
    transition: border-color 0.2s;
}

.app-footer input[type="text"]:focus {
    border-color: #861F41;
}

.send-btn {
    background-color: #861F41;
    color: #ffffff;
    border: none;
    padding: 12px 24px;
    font-size: 15px;
    font-weight: 600;
    border-radius: 8px;
    cursor: pointer;
    transition: background-color 0.2s;
}

.send-btn:hover {
    background-color: #6e1735;
}

/* Thinking Indicator Dots */
.thinking-container {
    padding: 16px 24px;
    display: flex;
    align-items: center;
    gap: 6px;
    background-color: #f8f9fa;
}

.thinking-text {
    font-size: 13px;
    color: #575f69;
    margin-left: 8px;
}

.thinking-dot {
    width: 6px;
    height: 6px;
    background-color: #861F41;
    border-radius: 50%;
    display: inline-block;
    animation: bounce 1.4s infinite ease-in-out both;
}

.thinking-dot:nth-child(1) { animation-delay: -0.32s; }
.thinking-dot:nth-child(2) { animation-delay: -0.16s; }

@keyframes bounce {
    0%, 80%, 100% { transform: scale(0); }
    40% { transform: scale(1.0); }
}

.header-actions {
    display: flex;
    gap: 8px;
    align-items: center;
}

.dashboard-btn {
    text-decoration: none;
    background-color: #861F41;
    color: #ffffff;
    padding: 8px 16px;
    font-size: 13px;
    font-weight: 600;
    border-radius: 8px;
    transition: background-color 0.2s;
    display: inline-flex;
    align-items: center;
    gap: 6px;
    border: none;
    cursor: pointer;
}

.dashboard-btn:hover {
    background-color: #6e1735;
}

/* Styled Collapsible Thought/Thinking Details Block */
.thought-container {
    background-color: #faf6f7;
    border-left: 3px solid #861F41;
    border-radius: 6px;
    margin: 8px 0 12px 0;
    padding: 10px 14px;
    font-size: 13px;
    color: #575f69;
}
.thought-header {
    font-weight: 700;
    color: #861F41;
    cursor: pointer;
    outline: none;
    user-select: none;
    font-family: 'Plus Jakarta Sans', sans-serif;
}
.thought-header::-webkit-details-marker {
    color: #E5751F;
}
.thought-content {
    margin-top: 8px;
    font-style: italic;
    line-height: 1.5;
    white-space: pre-wrap;
    font-family: 'Plus Jakarta Sans', sans-serif;
}

/* Upload Button */
.upload-btn {
    background-color: #f8f9fa;
    border: 1px solid #e1e3e4;
    font-size: 18px;
    padding: 0 14px;
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.2s;
    display: flex;
    align-items: center;
    justify-content: center;
}

.upload-btn:hover {
    background-color: #fff3eb;
    border-color: #E5751F;
}

/* Drag & Drop Overlay */
.drop-overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(134, 31, 65, 0.88);
    backdrop-filter: blur(4px);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 500;
    pointer-events: none;
    transition: opacity 0.2s ease;
}

.drop-card {
    background: #ffffff;
    padding: 32px 40px;
    border-radius: 16px;
    border: 2px dashed #861F41;
    text-align: center;
    box-shadow: 0 12px 32px rgba(0,0,0,0.15);
    max-width: 90%;
}

.drop-icon {
    font-size: 48px;
    margin-bottom: 12px;
}

.drop-card h3 {
    font-size: 20px;
    font-weight: 700;
    color: #861F41;
    margin-bottom: 6px;
}

.drop-card p {
    font-size: 14px;
    color: #575f69;
}

/* Modal Popup for Upload Settings */
.modal-container {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    background: rgba(0, 0, 0, 0.45);
    backdrop-filter: blur(2px);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 600;
}

.modal-card {
    background: #ffffff;
    padding: 28px 32px;
    width: 90%;
    max-width: 440px;
    border-radius: 16px;
    box-shadow: 0 16px 40px rgba(0, 0, 0, 0.12);
    border: 1px solid #e1e3e4;
}

.modal-header {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-bottom: 8px;
}

.modal-icon {
    font-size: 24px;
}

.modal-header h3 {
    font-size: 18px;
    font-weight: 700;
    color: #191c1d;
}

.upload-preview-text {
    font-size: 13px;
    color: #861F41;
    font-family: 'JetBrains Mono', monospace;
    margin-bottom: 20px;
    word-break: break-all;
    background: #faf6f7;
    padding: 6px 10px;
    border-radius: 6px;
    border: 1px solid #f4d2db;
}

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

.form-group label {
    font-size: 13px;
    font-weight: 600;
    color: #575f69;
}

.form-group input {
    padding: 10px 14px;
    font-size: 14px;
    border: 1px solid #e1e3e4;
    border-radius: 8px;
    outline: none;
    transition: border-color 0.2s;
}

.form-group input:focus {
    border-color: #861F41;
}

.modal-actions {
    display: flex;
    gap: 10px;
    margin-top: 24px;
}

.secondary-btn {
    background: #f8f9fa;
    color: #575f69;
    border: 1px solid #e1e3e4;
    padding: 12px 18px;
    font-size: 14px;
    font-weight: 600;
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.2s;
    flex: 1;
}

.secondary-btn:hover {
    background: #e1e3e4;
    color: #191c1d;
}

.modal-actions .primary-btn {
    flex: 1;
    padding: 12px 18px;
    font-size: 14px;
}

/* Ingested Receipt Result Card */
.receipt-result-badge {
    display: inline-block;
    padding: 3px 8px;
    border-radius: 6px;
    font-size: 12px;
    font-weight: 700;
    text-transform: uppercase;
}

.badge-approved {
    background-color: #e8f5e9;
    color: #2e7d32;
    border: 1px solid #c8e6c9;
}

.badge-review {
    background-color: #fff8e1;
    color: #f57f17;
    border: 1px solid #ffe082;
}

.badge-rejected {
    background-color: #ffebee;
    color: #c62828;
    border: 1px solid #ffcdd2;
}
