/* Ocean AI — Dark/Light Theme with CSS Variables */

:root {
    /* Brand colors: Navy #091A2C, Gold #E7CF8F */

    /* Dark theme (default) */
    --bg-primary: #091A2C;
    --bg-secondary: #0d2238;
    --bg-tertiary: #122d47;
    --bg-hover: #163656;
    --bg-input: #0b1f33;
    --bg-card: #0d2238;

    --text-primary: #f0efe8;
    --text-secondary: #a8b8c8;
    --text-muted: #687888;
    --text-link: #E7CF8F;

    --accent: #E7CF8F;
    --accent-hover: #d4bb76;
    --accent-light: #E7CF8F;
    --accent-bg: rgba(231, 207, 143, 0.12);
    --accent-text: #091A2C;           /* dark text on gold buttons */

    --border: #1a3350;
    --border-light: #234060;

    --success: #22c55e;
    --warning: #f59e0b;
    --error: #ef4444;

    --shadow: 0 2px 8px rgba(0, 0, 0, 0.4);
    --shadow-lg: 0 4px 16px rgba(0, 0, 0, 0.5);

    --sidebar-width: 280px;
    --header-height: 56px;

    --radius: 8px;
    --radius-lg: 12px;
    --radius-xl: 16px;

    --font-sans: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    --font-mono: 'SF Mono', 'Fira Code', 'Cascadia Code', monospace;
}

[data-theme="light"] {
    --bg-primary: #ffffff;
    --bg-secondary: #f5f5f7;
    --bg-tertiary: #ebebf0;
    --bg-hover: #e0e0e8;
    --bg-input: #ffffff;
    --bg-card: #ffffff;

    --text-primary: #1a1a2e;
    --text-secondary: #555570;
    --text-muted: #888898;
    --text-link: #091A2C;

    --accent: #091A2C;
    --accent-hover: #0d2a44;
    --accent-light: #122d47;
    --accent-bg: rgba(9, 26, 44, 0.08);
    --accent-text: #ffffff;

    --border: #d8d8e0;
    --border-light: #e5e5ed;

    --shadow: 0 2px 8px rgba(0, 0, 0, 0.08);
    --shadow-lg: 0 4px 16px rgba(0, 0, 0, 0.12);
}

/* ── Reset & Base ─────────────────────────────────────────────── */

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

html, body {
    height: 100%;
    font-family: var(--font-sans);
    background: var(--bg-primary);
    color: var(--text-primary);
    font-size: 15px;
    line-height: 1.6;
    -webkit-font-smoothing: antialiased;
}

a {
    color: var(--text-link);
    text-decoration: none;
}

a:hover {
    text-decoration: underline;
}

button {
    cursor: pointer;
    font-family: inherit;
    font-size: inherit;
    border: none;
    background: none;
    color: inherit;
}

/* ── Layout ───────────────────────────────────────────────────── */

.app-layout {
    display: flex;
    height: 100vh;
    overflow: hidden;
}

/* ── Sidebar ──────────────────────────────────────────────────── */

.sidebar {
    width: var(--sidebar-width);
    background: var(--bg-secondary);
    border-right: 1px solid var(--border);
    display: flex;
    flex-direction: column;
    flex-shrink: 0;
}

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

.sidebar-logo {
    font-size: 18px;
    font-weight: 700;
    color: var(--text-primary);
}

.sidebar-logo span {
    color: var(--accent);
}

.btn-new-chat {
    background: var(--accent);
    color: var(--accent-text);
    padding: 8px 16px;
    border-radius: var(--radius);
    font-size: 13px;
    font-weight: 600;
    transition: background 0.15s;
}

.btn-new-chat:hover {
    background: var(--accent-hover);
}

.chat-list {
    flex: 1;
    overflow-y: auto;
    padding: 8px;
}

.chat-list-group {
    margin-bottom: 16px;
}

.chat-list-label {
    font-size: 11px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--text-muted);
    padding: 4px 12px;
    margin-bottom: 4px;
}

.chat-item {
    padding: 10px 12px;
    border-radius: var(--radius);
    cursor: pointer;
    font-size: 13px;
    color: var(--text-secondary);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    transition: background 0.1s;
}

.chat-item:hover {
    background: var(--bg-hover);
    color: var(--text-primary);
}

.chat-item.active {
    background: var(--accent-bg);
    color: var(--accent-light);
}

/* ── Sidebar Footer ───────────────────────────────────────────── */

.sidebar-footer {
    padding: 12px 16px;
    border-top: 1px solid var(--border);
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.sidebar-footer-links {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    font-size: 11px;
}

.sidebar-footer-links a {
    color: var(--text-muted);
}

.sidebar-footer-links a:hover {
    color: var(--text-link);
}

.sidebar-user {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 8px;
    border-radius: var(--radius);
}

.sidebar-user:hover {
    background: var(--bg-hover);
}

.user-avatar {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    background: var(--accent);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 13px;
    font-weight: 600;
    color: var(--accent-text);
}

.user-info {
    flex: 1;
    min-width: 0;
}

.user-name {
    font-size: 13px;
    font-weight: 500;
    color: var(--text-primary);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.user-email {
    font-size: 11px;
    color: var(--text-muted);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* ── Main Content ─────────────────────────────────────────────── */

.main-content {
    flex: 1;
    display: flex;
    flex-direction: column;
    min-width: 0;
}

/* ── Header ───────────────────────────────────────────────────── */

.header {
    height: var(--header-height);
    border-bottom: 1px solid var(--border);
    display: flex;
    align-items: center;
    padding: 0 20px;
    gap: 12px;
    background: var(--bg-secondary);
}

.company-selector {
    background: var(--bg-tertiary);
    border: 1px solid var(--border);
    color: var(--text-primary);
    padding: 6px 12px;
    border-radius: var(--radius);
    font-size: 13px;
    cursor: pointer;
}

.company-selector:hover {
    border-color: var(--accent);
}

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

.btn-icon {
    width: 36px;
    height: 36px;
    border-radius: var(--radius);
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--text-secondary);
    transition: background 0.1s;
}

.btn-icon:hover {
    background: var(--bg-hover);
    color: var(--text-primary);
}

.btn-feedback {
    background: var(--bg-tertiary);
    border: 1px solid var(--border);
    color: var(--text-secondary);
    padding: 6px 14px;
    border-radius: var(--radius);
    font-size: 13px;
    display: flex;
    align-items: center;
    gap: 6px;
}

.btn-feedback:hover {
    border-color: var(--accent);
    color: var(--text-primary);
}

/* ── Chat Area ────────────────────────────────────────────────── */

.chat-area {
    flex: 1;
    overflow-y: auto;
    padding: 24px 0;
}

.chat-messages {
    max-width: 780px;
    margin: 0 auto;
    padding: 0 24px;
}

.message {
    margin-bottom: 24px;
    display: flex;
    gap: 12px;
}

.message-avatar {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    flex-shrink: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 14px;
    font-weight: 600;
}

.message-avatar.user {
    background: var(--accent);
    color: var(--accent-text);
}

.message-avatar.assistant {
    background: var(--bg-tertiary);
    color: var(--accent-light);
    border: 1px solid var(--border);
}

.message-body {
    flex: 1;
    min-width: 0;
}

.message-role {
    font-size: 13px;
    font-weight: 600;
    margin-bottom: 4px;
    color: var(--text-primary);
}

.message-content {
    color: var(--text-primary);
    line-height: 1.7;
}

.message-content p {
    margin-bottom: 12px;
}

.message-content p:last-child {
    margin-bottom: 0;
}

.message-content code {
    background: var(--bg-tertiary);
    padding: 2px 6px;
    border-radius: 4px;
    font-family: var(--font-mono);
    font-size: 13px;
}

.message-content pre {
    background: var(--bg-tertiary);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 12px 16px;
    overflow-x: auto;
    margin: 12px 0;
}

.message-content pre code {
    background: none;
    padding: 0;
}

/* Citation links */
.citation {
    display: inline;
    font-size: 11px;
    font-weight: 600;
    color: var(--accent-light);
    cursor: pointer;
    vertical-align: super;
}

.citation:hover {
    text-decoration: underline;
}

/* ── Message Actions ──────────────────────────────────────────── */

.message-actions {
    display: flex;
    gap: 4px;
    margin-top: 8px;
    opacity: 0;
    transition: opacity 0.15s;
}

.message:hover .message-actions {
    opacity: 1;
}

.msg-action-btn {
    width: 28px;
    height: 28px;
    border-radius: 6px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--text-muted);
    font-size: 14px;
    transition: all 0.1s;
}

.msg-action-btn:hover {
    background: var(--bg-hover);
    color: var(--text-primary);
}

.msg-action-btn.active-up {
    color: var(--success);
}

.msg-action-btn.active-down {
    color: var(--error);
}

/* ── Input Area ───────────────────────────────────────────────── */

.input-area {
    border-top: 1px solid var(--border);
    padding: 16px 24px 20px;
    background: var(--bg-primary);
}

.input-wrapper {
    max-width: 780px;
    margin: 0 auto;
    position: relative;
}

.input-box {
    width: 100%;
    background: var(--bg-input);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: 14px 52px 14px 18px;
    color: var(--text-primary);
    font-size: 15px;
    font-family: inherit;
    line-height: 1.5;
    resize: none;
    min-height: 52px;
    max-height: 200px;
    transition: border-color 0.15s;
}

.input-box:focus {
    outline: none;
    border-color: var(--accent);
}

.input-box::placeholder {
    color: var(--text-muted);
}

.btn-send {
    position: absolute;
    right: 10px;
    bottom: 10px;
    width: 36px;
    height: 36px;
    background: var(--accent);
    border-radius: var(--radius);
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--accent-text);
    transition: background 0.15s;
}

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

.btn-send:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.input-footer {
    text-align: center;
    margin-top: 8px;
    font-size: 11px;
    color: var(--text-muted);
}

/* ── Modal ────────────────────────────────────────────────────── */

.modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.6);
    display: none;
    align-items: center;
    justify-content: center;
    z-index: 1000;
}

.modal-overlay.show {
    display: flex;
}

.modal {
    background: var(--bg-secondary);
    border: 1px solid var(--border);
    border-radius: var(--radius-xl);
    padding: 28px;
    width: 90%;
    max-width: 520px;
    box-shadow: var(--shadow-lg);
}

.modal-title {
    font-size: 20px;
    font-weight: 700;
    margin-bottom: 4px;
}

.modal-subtitle {
    font-size: 13px;
    color: var(--text-muted);
    margin-bottom: 20px;
}

.form-group {
    margin-bottom: 16px;
}

.form-label {
    display: block;
    font-size: 13px;
    font-weight: 600;
    margin-bottom: 6px;
    color: var(--text-primary);
}

.form-label .required {
    color: var(--error);
}

.form-select,
.form-input,
.form-textarea {
    width: 100%;
    background: var(--bg-input);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 10px 14px;
    color: var(--text-primary);
    font-size: 14px;
    font-family: inherit;
}

.form-select:focus,
.form-input:focus,
.form-textarea:focus {
    outline: none;
    border-color: var(--accent);
}

.form-textarea {
    min-height: 120px;
    resize: vertical;
}

.modal-context {
    background: var(--bg-tertiary);
    border-radius: var(--radius);
    padding: 10px 14px;
    font-size: 12px;
    color: var(--text-muted);
    margin-bottom: 16px;
}

.modal-actions {
    display: flex;
    justify-content: flex-end;
    gap: 8px;
}

.btn-cancel {
    padding: 8px 20px;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    color: var(--text-secondary);
    font-weight: 500;
}

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

.btn-submit {
    padding: 8px 20px;
    background: var(--accent);
    border-radius: var(--radius);
    color: var(--accent-text);
    font-weight: 600;
    transition: background 0.15s;
}

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

/* ── Company Form Sections (accordion) ────────────────────────── */

.form-section {
    border: 1px solid var(--border);
    border-radius: var(--radius);
    margin-bottom: 8px;
    overflow: hidden;
}

.form-section-title {
    padding: 12px 16px;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    background: var(--bg-tertiary);
    display: flex;
    justify-content: space-between;
    align-items: center;
    user-select: none;
    list-style: none;
}

.form-section-title::-webkit-details-marker {
    display: none;
}

.form-section-title::before {
    content: '\25B6';
    font-size: 10px;
    margin-right: 8px;
    transition: transform 0.15s;
}

.form-section[open] > .form-section-title::before {
    transform: rotate(90deg);
}

.form-section-count {
    font-size: 11px;
    color: var(--text-muted);
    font-weight: 400;
}

.form-section-body {
    padding: 12px 16px;
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 8px 16px;
}

.form-section-body .form-group {
    margin-bottom: 0;
}

.form-section-body .form-group:has(textarea) {
    grid-column: 1 / -1;
}

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

/* ── Theme Toggle ─────────────────────────────────────────────── */

.theme-toggle {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 13px;
    color: var(--text-muted);
    cursor: pointer;
    padding: 6px 8px;
    border-radius: var(--radius);
}

.theme-toggle:hover {
    background: var(--bg-hover);
    color: var(--text-primary);
}

/* ── Scrollbar ────────────────────────────────────────────────── */

::-webkit-scrollbar {
    width: 6px;
}

::-webkit-scrollbar-track {
    background: transparent;
}

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

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

/* ── Multi-Tab Warning Banner ────────────────────────────────── */

.multi-tab-banner {
    display: flex;
    align-items: flex-start;
    gap: 12px;
    max-width: 780px;
    margin: 12px auto 0;
    padding: 14px 18px;
    background: var(--bg-tertiary);
    border: 1px solid var(--warning);
    border-radius: var(--radius-lg);
    animation: bannerSlideIn 0.25s ease-out;
}

.multi-tab-banner-icon {
    font-size: 22px;
    color: var(--warning);
    line-height: 1;
    flex-shrink: 0;
    margin-top: 2px;
}

.multi-tab-banner-text {
    flex: 1;
    min-width: 0;
}

.multi-tab-banner-title {
    font-size: 14px;
    font-weight: 700;
    color: var(--warning);
    margin-bottom: 4px;
}

.multi-tab-banner-subtitle {
    font-size: 13px;
    color: var(--text-secondary);
    line-height: 1.5;
}

.multi-tab-banner-close {
    width: 28px;
    height: 28px;
    border-radius: 6px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--text-muted);
    font-size: 18px;
    flex-shrink: 0;
    cursor: pointer;
    background: none;
    border: none;
    transition: background 0.1s, color 0.1s;
}

.multi-tab-banner-close:hover {
    background: var(--bg-hover);
    color: var(--text-primary);
}

@keyframes bannerSlideIn {
    from { opacity: 0; transform: translateY(-8px); }
    to   { opacity: 1; transform: translateY(0); }
}

/* ── Empty State ──────────────────────────────────────────────── */

.empty-state {
    text-align: center;
    padding: 80px 24px;
    color: var(--text-muted);
}

.empty-state h2 {
    font-size: 24px;
    font-weight: 700;
    color: var(--text-primary);
    margin-bottom: 8px;
}

.empty-state p {
    font-size: 15px;
    max-width: 400px;
    margin: 0 auto;
}

/* ── Loading Dots ─────────────────────────────────────────────── */

.typing-indicator {
    display: inline-flex;
    gap: 4px;
    padding: 4px 0;
}

.typing-indicator span {
    width: 6px;
    height: 6px;
    background: var(--text-muted);
    border-radius: 50%;
    animation: typing 1.4s ease-in-out infinite;
}

.typing-indicator span:nth-child(2) {
    animation-delay: 0.2s;
}

.typing-indicator span:nth-child(3) {
    animation-delay: 0.4s;
}

@keyframes typing {
    0%, 60%, 100% { opacity: 0.3; transform: scale(0.8); }
    30% { opacity: 1; transform: scale(1); }
}

/* ── Responsive ───────────────────────────────────────────────── */

/* ── Chat Item with Delete ─────────────────────────────────────── */

.chat-item {
    display: flex;
    align-items: center;
    gap: 4px;
}

.chat-item-title {
    flex: 1;
    min-width: 0;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    cursor: pointer;
}

.chat-item-delete {
    display: none;
    width: 22px;
    height: 22px;
    border-radius: 4px;
    align-items: center;
    justify-content: center;
    font-size: 16px;
    color: var(--text-muted);
    flex-shrink: 0;
    background: none;
    border: none;
    cursor: pointer;
}

.chat-item:hover .chat-item-delete {
    display: flex;
}

.chat-item-delete:hover {
    background: var(--bg-hover);
    color: var(--error);
}

/* ── Sidebar Toggle (all screens) ─────────────────────────────── */

.sidebar {
    transition: margin-left 0.2s, transform 0.2s;
}

.sidebar.collapsed {
    margin-left: calc(-1 * var(--sidebar-width));
}

/* ── Sidebar Overlay (mobile) ─────────────────────────────────── */

@media (max-width: 768px) {
    .sidebar {
        position: fixed;
        left: 0;
        top: 0;
        bottom: 0;
        z-index: 100;
        transform: translateX(-100%);
        transition: transform 0.2s;
    }

    .sidebar.open {
        transform: translateX(0);
    }

    .header {
        padding: 0 12px;
    }

    .chat-messages {
        padding: 0 12px;
    }

    .input-area {
        padding: 12px;
    }
}
