/* Training Chat - Styles */
/* Color scheme based on ICT Pro website */

:root {
    /* ICT Pro color palette */
    --bg-primary: #ffffff;
    --bg-secondary: #eceded;
    --bg-tertiary: #e0e0e0;
    --text-primary: #381a0c;
    /* Darker for readability on light/gray backgrounds */
    --text-secondary: #5b5d60;
    --accent: #ECAC00;
    --accent-hover: #c79f09;
    --accent-dark: #856100;
    --border: #c5c6c7;
    --user-bubble: #856100;
    --assistant-bubble: #eceded;
    --error: #ef4444;
    --success: #22c55e;
    --warning: #e5ae24;
    --radius: 12px;
}

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

/* Focus states for keyboard navigation */
button:focus-visible,
a:focus-visible,
input:focus-visible,
textarea:focus-visible,
.tab-btn:focus-visible,
.topic-card:focus-visible,
.history-item:focus-visible {
    outline: 2px solid var(--accent);
    outline-offset: 2px;
}

body {
    font-family: 'Plus Jakarta Sans', -apple-system, sans-serif;
    background: var(--bg-primary);
    color: var(--text-primary);
    min-height: 100vh;
    line-height: 1.6;
}

@media (prefers-contrast: more) {
    :root {
        --bg-secondary: #f1f1f1;
        --bg-tertiary: #ededed;
        --border: #a9aaab;
        --text-secondary: #3f4144;
    }
}

/* ===================
   Login Screen
   =================== */

.login-container {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 100vh;
    padding: 20px;
}

.login-box {
    background: var(--bg-secondary);
    border: 1px solid var(--border);
    border-radius: 16px;
    padding: 48px;
    width: 100%;
    max-width: 400px;
    text-align: center;
}

.login-box h1 {
    font-size: 1.75rem;
    font-weight: 600;
    margin-bottom: 8px;
}

.login-box p {
    color: var(--text-secondary);
    margin-bottom: 32px;
    font-size: 0.95rem;
}

.input-group {
    margin-bottom: 20px;
}

input[type="text"] {
    width: 100%;
    padding: 14px 18px;
    font-size: 1rem;
    font-family: 'JetBrains Mono', monospace;
    background: #ffffff;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    color: var(--text-primary);
    outline: none;
    transition: border-color 0.2s;
    text-align: center;
    letter-spacing: 0.1em;
}

input[type="text"]:focus {
    border-color: var(--accent);
}

input[type="text"]::placeholder {
    color: var(--text-secondary);
    letter-spacing: normal;
}

.btn {
    width: 100%;
    padding: 14px 24px;
    font-size: 1rem;
    font-weight: 600;
    font-family: inherit;
    background: var(--accent);
    color: var(--text-primary);
    border: none;
    border-radius: var(--radius);
    cursor: pointer;
    transition: background 0.2s, transform 0.1s;
}

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

.btn:active {
    transform: scale(0.98);
}

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

.error-message {
    color: var(--error);
    font-size: 0.875rem;
    margin-top: 16px;
    display: none;
}

.error-message.visible {
    display: block;
}

.login-hint {
    margin-top: 20px;
    font-size: 0.8rem;
    color: var(--text-secondary);
}

/* ===================
   Chat Screen
   =================== */

.chat-container {
    display: none;
    flex-direction: column;
    height: 100vh;
    max-width: 900px;
    margin: 0 auto;
}

.chat-header {
    padding: 12px 20px;
    border-bottom: 1px solid var(--border);
    display: flex;
    align-items: center;
    justify-content: space-between;
    background: var(--bg-primary);
}

.header-left {
    display: flex;
    align-items: center;
    gap: 12px;
}

.course-name {
    font-size: 0.95rem;
    font-weight: 600;
    color: var(--text-primary);
}

.chat-header h2 {
    font-size: 0.95rem;
    font-weight: 500;
    display: flex;
    align-items: center;
    gap: 10px;
}

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

/* ===================
   Inline History (in shortcuts panel)
   =================== */

.panel-section {
    padding-bottom: 16px;
}

.panel-section-title {
    font-size: 0.8rem;
    font-weight: 600;
    color: var(--text-secondary);
    margin-bottom: 12px;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.panel-section-title .icon-btn {
    padding: 4px;
}

.panel-section-title .icon-btn svg {
    width: 14px;
    height: 14px;
}

.history-section {
    border-top: 1px solid var(--border);
    padding-top: 16px;
    margin-top: 8px;
}

/* History Bar - always visible above input */
.history-bar {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 8px 16px;
    background: var(--bg-secondary);
    border-top: 1px solid var(--border);
    transition: background 0.3s, box-shadow 0.3s;
}

.history-bar.highlight {
    background: rgba(236, 172, 0, 0.15);
    box-shadow: inset 0 0 0 2px var(--accent);
}

.history-bar-label {
    font-size: 0.75rem;
    color: var(--text-secondary);
    white-space: nowrap;
}

.history-bar-list {
    display: flex;
    gap: 6px;
    flex: 1;
    overflow-x: auto;
    padding: 4px 0;
}

.history-bar-list::-webkit-scrollbar {
    height: 4px;
}

.history-download-btn {
    flex-shrink: 0;
    width: 28px;
    height: 28px;
    padding: 4px;
}

.history-download-btn svg {
    width: 14px;
    height: 14px;
}

.history-item {
    display: inline-flex;
    align-items: center;
    padding: 4px 10px;
    background: var(--bg-tertiary);
    border: 1px solid var(--border);
    border-radius: 16px;
    cursor: pointer;
    transition: all 0.2s;
    gap: 4px;
    white-space: nowrap;
    flex-shrink: 0;
}

.history-item:hover {
    border-color: var(--accent);
}

.history-item.active {
    background: rgba(236, 172, 0, 0.2);
    border-color: var(--accent);
}

.history-item-content {
    flex: 1;
    min-width: 0;
    display: flex;
    align-items: center;
    gap: 6px;
}

.history-item-title {
    font-size: 0.8rem;
    font-weight: 500;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.history-item-date {
    font-size: 0.72rem;
    color: var(--text-secondary);
    white-space: nowrap;
}

.history-item-delete {
    width: 18px;
    height: 18px;
    padding: 0;
    background: transparent;
    border: none;
    border-radius: 50%;
    cursor: pointer;
    color: var(--text-secondary);
    opacity: 0.5;
    transition: all 0.2s;
    font-size: 14px;
    line-height: 1;
    flex-shrink: 0;
    display: flex;
    align-items: center;
    justify-content: center;
}

.history-item-delete:hover {
    opacity: 1;
    color: var(--error);
    background: rgba(239, 68, 68, 0.1);
}

.history-empty {
    color: var(--text-secondary);
    font-size: 0.8rem;
    padding: 8px 0;
}

.usage-counter {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 6px 12px;
    background: var(--bg-primary);
    border: 1px solid var(--border);
    border-radius: 8px;
    font-size: 0.9rem;
    font-family: 'JetBrains Mono', monospace;
}

.usage-counter .count {
    font-weight: 700;
    font-size: 0.9rem;
    color: var(--text-primary);
}

.usage-counter.green {
    border-left: 4px solid var(--success);
}

.usage-counter.orange {
    border-left: 4px solid var(--warning);
}

.usage-counter.red {
    border-left: 4px solid var(--error);
}

.usage-counter .label {
    color: var(--text-secondary);
    font-size: 0.75rem;
}

.usage-counter .unit {
    color: var(--text-secondary);
    font-size: 0.75rem;
}

.status-dot {
    width: 8px;
    height: 8px;
    background: var(--success);
    border-radius: 50%;
    transition: background 0.3s;
}

.status-dot.offline {
    background: var(--error);
}

.new-chat-btn {
    padding: 8px 14px;
    font-size: 0.9rem;
    font-weight: 600;
    background: var(--accent);
    border: none;
    color: var(--text-primary);
    border-radius: 8px;
    cursor: pointer;
    font-family: inherit;
    transition: all 0.2s;
}

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

.history-btn {
    padding: 8px 14px;
    font-size: 0.9rem;
    background: var(--bg-tertiary);
    border: 1px solid var(--border);
    color: var(--text-primary);
    border-radius: 8px;
    cursor: pointer;
    font-family: inherit;
    transition: all 0.2s;
}

.history-btn:hover {
    border-color: var(--accent);
    background: rgba(236, 172, 0, 0.1);
}

.logout-btn {
    margin-left: 24px;
    padding: 8px 14px;
    font-size: 0.9rem;
    background: transparent;
    border: none;
    color: var(--text-secondary);
    border-radius: 8px;
    cursor: pointer;
    font-family: inherit;
    transition: all 0.2s;
    text-decoration: underline;
    text-underline-offset: 2px;
}

.logout-btn:hover {
    color: var(--error);
    text-decoration-color: var(--error);
}

/* ===================
   Shortcuts Bar
   =================== */

.shortcuts-bar {
    background: var(--bg-tertiary);
    border-bottom: 1px solid var(--border);
    overflow: hidden;
}

.shortcuts-toggle {
    padding: 8px 20px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    cursor: pointer;
    font-size: 0.75rem;
    color: var(--text-secondary);
    transition: background 0.2s;
}

.shortcuts-toggle:hover {
    background: var(--bg-secondary);
}

.shortcuts-toggle svg {
    width: 12px;
    height: 12px;
    transition: transform 0.2s;
}

.shortcuts-toggle.open svg {
    transform: rotate(180deg);
}

.shortcuts-content {
    max-height: 0;
    overflow: hidden;
    transition: max-height 0.3s ease, padding 0.3s ease;
    padding: 0 20px;
}

.shortcuts-content.open {
    max-height: 400px;
    padding: 12px 20px;
}

.shortcuts-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
    gap: 8px;
}

.shortcut-item {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 6px 10px;
    background: var(--bg-primary);
    border-radius: 6px;
    font-size: 0.8rem;
    color: var(--text-secondary);
}

.shortcut-item svg {
    width: 14px;
    height: 14px;
    opacity: 0.7;
}

kbd {
    background: var(--bg-secondary);
    padding: 2px 5px;
    border-radius: 3px;
    font-family: 'JetBrains Mono', monospace;
    font-size: 0.75rem;
    border: 1px solid var(--border);
}

/* ===================
   Connection & Limit Banners
   =================== */

.connection-banner {
    display: none;
    padding: 10px 20px;
    background: var(--error);
    color: white;
    font-size: 0.85rem;
    text-align: center;
    align-items: center;
    justify-content: center;
    gap: 10px;
}

.connection-banner.visible {
    display: flex;
}

.limit-banner {
    display: none;
    padding: 16px 20px;
    background: var(--warning);
    color: #000;
    font-size: 0.9rem;
    text-align: center;
    font-weight: 500;
}

.limit-banner.visible {
    display: block;
}

.connection-banner button {
    padding: 4px 12px;
    background: white;
    color: var(--error);
    border: none;
    border-radius: 4px;
    cursor: pointer;
    font-size: 0.95rem;
    font-weight: 500;
}

/* ===================
   Chat Content
   =================== */

.chat-content {
    display: flex;
    flex-direction: column;
    flex: 1;
    overflow: hidden;
}

/* ===================
   Messages
   =================== */

.messages {
    flex: 1;
    overflow-y: auto;
    padding: 16px 12px;
    display: flex;
    flex-direction: column;
    gap: 16px;
}

.message {
    max-width: 92%;
    padding: 12px 16px;
    border-radius: var(--radius);
    font-size: 1.05rem;
    line-height: 1.6;
}

.message.user {
    align-self: flex-end;
    background: var(--user-bubble);
    border-bottom-right-radius: 4px;
    color: #ffffff;
}

.message.assistant {
    align-self: flex-start;
    background: var(--assistant-bubble);
    border: 1px solid var(--border);
    border-bottom-left-radius: 4px;
    max-width: 86%;
}

@media (min-width: 900px) {
    .message.assistant {
        max-width: 860px;
    }
}

.message.assistant code {
    font-family: 'JetBrains Mono', monospace;
    font-size: 0.85em;
    background: #f5f5f5;
    padding: 2px 6px;
    border-radius: 4px;
    color: #381a0c;
}

.message.assistant pre {
    background: #2d2d2d;
    color: #f8f8f2;
    padding: 12px 16px;
    border-radius: 8px;
    overflow-x: auto;
    margin: 8px 0;
}

.message.assistant pre code {
    background: none;
    padding: 0;
    color: #f8f8f2;
}

.message.assistant ol,
.message.assistant ul {
    margin: 12px 0;
    padding-left: 24px;
}

.message.assistant li {
    margin: 6px 0;
}

.message.assistant p {
    margin: 10px 0;
}

.message.assistant p:first-child {
    margin-top: 0;
}

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

.message.assistant h1,
.message.assistant h2,
.message.assistant h3 {
    margin: 16px 0 10px 0;
    font-size: 1em;
    font-weight: 600;
}

.code-block-wrapper {
    position: relative;
    margin: 8px 0;
}

.copy-btn {
    position: absolute;
    top: 8px;
    right: 8px;
    padding: 4px 10px;
    font-size: 0.85rem;
    font-family: inherit;
    background: var(--bg-tertiary);
    border: 1px solid var(--border);
    color: var(--text-secondary);
    border-radius: 6px;
    cursor: pointer;
    opacity: 0.7;
    transition: opacity 0.2s, background 0.2s;
}

.copy-btn:hover {
    opacity: 1;
    background: var(--border);
    color: var(--text-primary);
}

.copy-btn.copied {
    background: var(--success);
    border-color: var(--success);
    color: white;
}

.message-image {
    max-width: 300px;
    max-height: 200px;
    border-radius: 8px;
    margin-bottom: 8px;
    display: block;
    cursor: pointer;
}

.message.error {
    background: rgba(239, 68, 68, 0.1);
    border: 1px solid var(--error);
    color: var(--error);
}

.retry-btn {
    margin-top: 10px;
    padding: 6px 14px;
    background: var(--error);
    color: white;
    border: none;
    border-radius: 6px;
    cursor: pointer;
    font-size: 0.95rem;
    font-family: inherit;
}

.retry-btn:hover {
    background: #dc2626;
}

/* ===================
   Typing Indicator
   =================== */

.typing-indicator {
    display: none;
    align-self: flex-start;
    padding: 14px 18px;
    background: var(--assistant-bubble);
    border: 2px solid var(--accent);
    border-radius: var(--radius);
    border-bottom-left-radius: 4px;
    align-items: center;
    gap: 10px;
    margin: 10px 0;
    box-shadow: 0 2px 8px rgba(236, 172, 0, 0.15);
}

.typing-indicator.visible {
    display: flex;
}

.typing-text {
    font-size: 0.85rem;
    color: var(--accent-dark);
    font-weight: 500;
}

.typing-dots {
    display: flex;
    gap: 5px;
}

.typing-dots span {
    width: 8px;
    height: 8px;
    background: var(--accent);
    border-radius: 50%;
    animation: bounce 1.4s infinite ease-in-out;
}

.typing-dots span:nth-child(1) {
    animation-delay: 0s;
}

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

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

@keyframes bounce {

    0%,
    80%,
    100% {
        transform: translateY(0);
    }

    40% {
        transform: translateY(-4px);
    }
}

/* ===================
   Welcome Screen
   =================== */

.welcome-screen {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 30px 20px;
    text-align: center;
}

.welcome-screen h3 {
    font-size: 1.55rem;
    font-weight: 700;
    margin-bottom: 6px;
}

.welcome-screen p {
    color: var(--text-secondary);
    font-size: 1.05rem;
    font-weight: 500;
    margin-bottom: 24px;
}

.topic-cards {
    display: flex;
    flex-direction: column;
    gap: 10px;
    width: 100%;
    max-width: 520px;
}

.topic-card {
    display: flex;
    align-items: center;
    gap: 14px;
    padding: 16px 18px;
    background: var(--bg-secondary);
    border: 1px solid var(--border);
    border-radius: 10px;
    cursor: pointer;
    transition: all 0.2s;
    text-align: left;
}

.topic-card:hover {
    border-color: var(--accent);
    transform: translateX(4px);
}

.topic-card .icon {
    font-size: 1.4rem;
}

.topic-card .text {
    flex: 1;
    min-width: 0;
}

.topic-card .title-line {
    display: block;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.topic-card .title {
    font-size: 1.05rem;
    font-weight: 700;
}

.topic-card .sep {
    color: var(--text-secondary);
}

.topic-card .hint {
    font-size: 0.95rem;
    color: var(--text-secondary);
    margin-top: 0;
}

.topic-card .arrow {
    color: var(--text-secondary);
    font-size: 1rem;
    transition: transform 0.2s;
}

.topic-card:hover .arrow {
    transform: translateX(4px);
    color: var(--accent);
}

.topic-card.selected {
    border-color: var(--accent);
    background: rgba(236, 172, 0, 0.15);
}

.topic-card.selected .arrow {
    color: var(--accent);
}

/* Welcome Tips */
.welcome-tips {
    margin-top: 32px;
    padding: 20px;
    background: var(--bg-secondary);
    border: 1px solid var(--border);
    border-radius: 12px;
    text-align: left;
    max-width: 480px;
    width: 100%;
}

.tips-header {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 0.85rem;
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: 12px;
}

.tips-header svg {
    color: var(--accent-dark);
    flex-shrink: 0;
}

.tips-intro {
    font-size: 0.95rem;
    color: var(--text-secondary);
    margin-bottom: 14px;
    line-height: 1.5;
}

.tips-examples {
    display: flex;
    flex-direction: column;
    gap: 8px;
    margin-bottom: 14px;
}

.tip-row {
    display: flex;
    align-items: center;
    gap: 10px;
    font-size: 0.95rem;
    padding: 8px 10px;
    background: var(--bg-tertiary);
    border-radius: 8px;
}

.tip-bad {
    color: var(--text-secondary);
    text-decoration: none;
    opacity: 1;
    flex: 1;
    min-width: 0;
}

.tip-arrow {
    color: var(--text-secondary);
    flex-shrink: 0;
    font-weight: 500;
}

.tip-good {
    color: var(--text-primary);
    font-weight: 600;
    flex: 2;
    min-width: 0;
}


/* ===================
   Topic Badge
   =================== */

.topic-badge {
    display: none;
    align-items: center;
    gap: 6px;
    margin-bottom: 6px;
    padding: 6px 10px;
    background: rgba(236, 172, 0, 0.2);
    border: 1px solid var(--accent);
    border-radius: 8px;
    font-size: 0.78rem;
}

.topic-badge.visible {
    display: inline-flex;
}

.topic-badge .badge-icon {
    font-size: 0.95rem;
}

.topic-badge .badge-text {
    color: var(--text-primary);
}

.topic-badge .badge-close {
    background: none;
    border: none;
    color: var(--text-secondary);
    cursor: pointer;
    padding: 2px 6px;
    font-size: 1.05rem;
    line-height: 1;
    border-radius: 4px;
    transition: all 0.2s;
}

.topic-badge .badge-close:hover {
    background: rgba(255, 255, 255, 0.1);
    color: var(--text-primary);
}

/* ===================
   Input Options (Docs Link Checkbox)
   =================== */

.input-options {
    display: flex;
    align-items: center;
    gap: 16px;
    margin-bottom: 8px;
}

.docs-link-option {
    display: flex;
    align-items: center;
    gap: 8px;
    cursor: pointer;
    font-size: 0.85rem;
    color: var(--text-secondary);
    user-select: none;
    transition: color 0.2s;
}

.docs-link-option:hover {
    color: var(--text-primary);
}

.docs-link-option input[type="checkbox"] {
    width: 16px;
    height: 16px;
    accent-color: var(--accent);
    cursor: pointer;
}

.docs-link-option span {
    line-height: 1;
}

/* ===================
   Input Area
   =================== */

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

.input-wrapper {
    display: flex;
    gap: 10px;
    align-items: flex-end;
}

.upload-btn {
    padding: 12px;
    background: var(--bg-tertiary);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    cursor: pointer;
    color: var(--text-secondary);
    transition: all 0.2s;
    display: flex;
    align-items: center;
    justify-content: center;
}

.upload-btn:hover {
    border-color: var(--accent);
    color: var(--accent-dark);
}

.upload-btn svg {
    width: 20px;
    height: 20px;
}

textarea {
    flex: 1;
    padding: 12px 16px;
    font-size: 1.05rem;
    font-family: inherit;
    background: #ffffff;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    color: var(--text-primary);
    outline: none;
    resize: none;
    min-height: 52px;
    max-height: 200px;
    line-height: 1.5;
    transition: border-color 0.2s;
}

textarea:focus {
    border-color: var(--accent);
}

textarea::placeholder {
    color: var(--text-secondary);
}

.send-btn {
    padding: 12px 20px;
    font-size: 1rem;
    font-weight: 600;
    font-family: inherit;
    background: var(--accent);
    color: var(--text-primary);
    border: none;
    border-radius: var(--radius);
    cursor: pointer;
    transition: background 0.2s;
    white-space: nowrap;
}

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

.send-btn:disabled {
    opacity: 0.6;
    cursor: not-allowed;
    background: var(--text-secondary);
}

.download-dropdown {
    position: relative;
    flex-shrink: 0;
}

.download-btn {
    width: 44px;
    height: 44px;
    padding: 10px;
    background: var(--bg-tertiary);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    cursor: pointer;
    color: var(--text-secondary);
    transition: all 0.2s;
}

.download-btn:hover {
    border-color: var(--accent);
    color: var(--accent);
}

.download-btn svg {
    width: 100%;
    height: 100%;
}

.download-menu {
    display: none;
    position: absolute;
    bottom: 100%;
    right: 0;
    margin-bottom: 4px;
    background: var(--bg-primary);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
    overflow: hidden;
    z-index: 100;
}

.download-menu.visible {
    display: flex;
    flex-direction: column;
}

.download-menu button {
    padding: 10px 20px;
    background: none;
    border: none;
    cursor: pointer;
    font-size: 0.875rem;
    font-weight: 500;
    color: var(--text-primary);
    text-align: left;
    transition: background 0.15s;
    white-space: nowrap;
}

.download-menu button:hover {
    background: var(--bg-tertiary);
}

.download-menu button:not(:last-child) {
    border-bottom: 1px solid var(--border);
}

.image-preview {
    margin-top: 12px;
    position: relative;
    display: inline-block;
}

.image-preview img {
    max-height: 100px;
    max-width: 180px;
    border-radius: 8px;
    border: 1px solid var(--border);
}

.remove-image-btn {
    position: absolute;
    top: -8px;
    right: -8px;
    width: 22px;
    height: 22px;
    background: var(--error);
    color: white;
    border: none;
    border-radius: 50%;
    cursor: pointer;
    font-size: 14px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.remove-image-btn:hover {
    background: #dc2626;
}

/* ===================
   Drop Overlay
   =================== */

.drop-overlay {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(236, 172, 0, 0.15);
    border: 3px dashed var(--accent);
    z-index: 1000;
    align-items: center;
    justify-content: center;
}

.drop-overlay.visible {
    display: flex;
}

.drop-overlay-content {
    background: var(--bg-secondary);
    padding: 40px 60px;
    border-radius: 16px;
    text-align: center;
}

.drop-overlay-content svg {
    width: 48px;
    height: 48px;
    color: var(--accent);
    margin-bottom: 16px;
}

.drop-overlay-content p {
    font-size: 1.1rem;
}

/* ===================
   Onboarding Modal
   =================== */

.onboarding-modal {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.8);
    z-index: 2000;
    align-items: center;
    justify-content: center;
    padding: 20px;
}

.onboarding-modal.visible {
    display: flex;
}

.onboarding-content {
    background: var(--bg-secondary);
    border-radius: 16px;
    padding: 32px;
    max-width: 500px;
    width: 100%;
    text-align: center;
}

.onboarding-content h3 {
    font-size: 1.3rem;
    margin-bottom: 8px;
}

.onboarding-content>p {
    color: var(--text-secondary);
    margin-bottom: 24px;
    font-size: 0.9rem;
}

.onboarding-steps {
    text-align: left;
    margin-bottom: 24px;
}

.onboarding-step {
    display: flex;
    align-items: flex-start;
    gap: 14px;
    padding: 14px;
    background: var(--bg-tertiary);
    border-radius: 10px;
    margin-bottom: 10px;
}

.step-number {
    width: 28px;
    height: 28px;
    background: var(--accent);
    color: var(--text-primary);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 600;
    font-size: 0.85rem;
    flex-shrink: 0;
}

.step-content {
    flex: 1;
}

.step-content strong {
    display: block;
    margin-bottom: 4px;
    font-size: 0.9rem;
}

.step-content span {
    font-size: 0.8rem;
    color: var(--text-secondary);
}

.onboarding-close {
    padding: 12px 32px;
    background: var(--accent);
    color: var(--text-primary);
    border: none;
    border-radius: 8px;
    cursor: pointer;
    font-size: 0.95rem;
    font-family: inherit;
    font-weight: 500;
}

.onboarding-close:hover {
    background: var(--accent-hover);
}

.onboarding-skip {
    display: block;
    margin-top: 12px;
    color: var(--text-secondary);
    font-size: 0.8rem;
    cursor: pointer;
    background: none;
    border: none;
}

.onboarding-skip:hover {
    color: var(--text-primary);
}

/* ===================
   Lightbox
   =================== */

.lightbox {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.9);
    z-index: 3000;
    align-items: center;
    justify-content: center;
    cursor: zoom-out;
}

.lightbox.visible {
    display: flex;
}

.lightbox img {
    max-width: 90%;
    max-height: 90%;
    border-radius: 8px;
}

/* ===================
   Tab Navigation
   =================== */

.tab-nav {
    display: flex;
    background: var(--bg-primary);
    border-top: 1px solid var(--border);
    border-bottom: 1px solid var(--border);
}

.tab-btn {
    flex: 1;
    padding: 12px 20px;
    font-size: 1rem;
    font-weight: 600;
    font-family: inherit;
    background: transparent;
    border: none;
    color: var(--text-primary);
    cursor: pointer;
    transition: all 0.2s;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
}

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

.tab-btn.active {
    background: var(--bg-secondary);
    color: var(--text-primary);
    border-bottom: 3px solid var(--accent);
}

.tab-btn.active svg {
    color: var(--accent-dark);
}

.tab-btn svg {
    width: 20px;
    height: 20px;
    flex: 0 0 auto;
}

.tab-btn .tab-content {
    display: flex;
    flex-direction: row;
    align-items: center;
    justify-content: center;
    gap: 0;
    line-height: 1.1;
}

.tab-btn .tab-content>span {
    font-weight: 700;
}

/* ===================
   Files Section
   =================== */

.files-container {
    display: none;
    flex-direction: column;
    flex: 1;
    overflow: hidden;
}

.files-container.visible {
    display: flex;
}

.files-section {
    flex: 1;
    overflow-y: auto;
    padding: 20px;
}

.files-section-title {
    font-size: 0.85rem;
    font-weight: 600;
    color: var(--text-secondary);
    margin-bottom: 12px;
    display: flex;
    align-items: center;
    gap: 8px;
}

.files-section-title svg {
    width: 16px;
    height: 16px;
}

.files-grid {
    display: flex;
    flex-direction: column;
    gap: 8px;
    margin-bottom: 24px;
}

.file-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 16px;
    background: var(--bg-secondary);
    border: 1px solid var(--border);
    border-radius: 10px;
    transition: all 0.2s;
}

.file-item:hover {
    border-color: var(--accent);
}

.file-icon {
    width: 36px;
    height: 36px;
    background: var(--bg-tertiary);
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.2rem;
}

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

.file-name {
    font-size: 0.9rem;
    font-weight: 500;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.file-meta {
    font-size: 0.75rem;
    color: var(--text-secondary);
}

.file-actions {
    display: flex;
    gap: 6px;
}

/* Materials Section Labels */
.materials-section-label {
    font-size: 0.75rem;
    font-weight: 600;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin: 16px 0 8px 0;
    padding-left: 4px;
}

.materials-section-label:first-child {
    margin-top: 0;
}

.file-item.clickable {
    cursor: pointer;
}

.file-item.clickable:hover {
    background: var(--bg-tertiary);
    border-color: var(--accent);
}

.link-item .file-icon {
    color: var(--accent);
}

.file-action-icon {
    color: var(--text-secondary);
    width: 20px;
    height: 20px;
    flex-shrink: 0;
}

.file-action-icon svg {
    width: 20px;
    height: 20px;
}

.file-item.clickable:hover .file-action-icon {
    color: var(--accent);
}

/* Icon Buttons */
.icon-btn {
    width: 32px;
    height: 32px;
    padding: 6px;
    background: var(--bg-tertiary);
    border: 1px solid var(--border);
    border-radius: 6px;
    cursor: pointer;
    color: var(--text-secondary);
    transition: all 0.2s;
    display: flex;
    align-items: center;
    justify-content: center;
}

.icon-btn svg {
    width: 16px;
    height: 16px;
}

.icon-btn:hover {
    border-color: var(--accent);
    color: var(--accent-dark);
    background: rgba(236, 172, 0, 0.15);
}

.icon-btn.delete:hover {
    border-color: var(--error);
    color: var(--error);
    background: rgba(239, 68, 68, 0.1);
}

.upload-icon-btn {
    margin-left: auto;
    background: var(--accent);
    border-color: var(--accent);
    color: var(--text-primary);
}

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

.file-action-btn {
    padding: 6px 10px;
    font-size: 0.75rem;
    font-family: inherit;
    background: var(--bg-tertiary);
    border: 1px solid var(--border);
    color: var(--text-secondary);
    border-radius: 6px;
    cursor: pointer;
    transition: all 0.2s;
}

.file-action-btn:hover {
    border-color: var(--accent);
    color: var(--accent-dark);
}

.file-action-btn.delete:hover {
    border-color: var(--error);
    color: var(--error);
}

.files-empty {
    text-align: center;
    padding: 20px;
    color: var(--text-secondary);
}

.files-empty p {
    font-size: 0.85rem;
    margin: 0;
}

.files-empty .hint {
    font-size: 0.75rem;
    margin-top: 4px;
    opacity: 0.7;
}

/* ===================
   Upload Dropzone
   =================== */

.upload-dropzone {
    border: 2px dashed var(--border);
    border-radius: 10px;
    padding: 16px;
    text-align: center;
    transition: all 0.2s;
    cursor: pointer;
    margin-top: 16px;
}

.upload-dropzone:hover,
.upload-dropzone.dragover {
    border-color: var(--accent);
    background: rgba(236, 172, 0, 0.1);
}

.upload-dropzone svg {
    width: 24px;
    height: 24px;
    color: var(--text-secondary);
    margin-bottom: 6px;
}

.upload-dropzone p {
    font-size: 0.8rem;
    color: var(--text-secondary);
    margin: 0;
}

.upload-dropzone .hint {
    font-size: 0.7rem;
    margin-top: 4px;
    opacity: 0.7;
}

/* ===================
   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-secondary);
}

/* ===================
   Responsive
   =================== */

@media (max-width: 640px) {
    .login-box {
        padding: 32px 24px;
    }

    .messages {
        padding: 16px;
    }

    .message {
        max-width: 95%;
    }

    .input-area {
        padding: 12px;
    }

    .topic-cards {
        max-width: 100%;
    }

    .shortcuts-grid {
        grid-template-columns: 1fr;
    }

    .chat-header {
        padding: 12px;
    }

    .header-buttons {
        gap: 10px;
        flex-wrap: wrap;
    }

    .usage-counter {
        font-size: 0.95rem;
        padding: 8px 12px;
    }

    .usage-counter .label,
    .usage-counter .unit {
        font-size: 0.85rem;
    }

    .new-chat-btn,
    .history-btn,
    .logout-btn {
        padding: 10px 14px;
        font-size: 0.95rem;
    }

    .tab-btn {
        padding: 14px 12px;
    }

    .tab-btn svg {
        width: 20px;
        height: 20px;
    }

    .tab-btn .tab-hint {
        font-size: 0.85rem;
    }

    .shortcuts-toggle {
        padding: 10px 12px;
        font-size: 0.95rem;
    }

    .shortcut-item {
        font-size: 0.9rem;
        padding: 10px 12px;
    }

    kbd {
        font-size: 0.8rem;
        padding: 3px 6px;
    }

    .history-bar {
        padding: 10px 12px;
    }

    .history-bar-label {
        font-size: 0.9rem;
    }

    .history-item {
        padding: 8px 12px;
    }

    .history-item-delete {
        width: 28px;
        height: 28px;
        font-size: 16px;
    }

    .icon-btn {
        width: 40px;
        height: 40px;
        padding: 10px;
    }

    textarea {
        font-size: 1rem;
        min-height: 52px;
    }

    .send-btn {
        font-size: 1rem;
        padding: 12px 16px;
    }

    /* Welcome Tips - Mobile */
    .welcome-tips {
        margin-top: 24px;
        padding: 16px;
    }

    .tips-header {
        font-size: 0.8rem;
    }

    .tip-row {
        flex-wrap: wrap;
        gap: 6px;
    }

    .tip-bad,
    .tip-good {
        flex: 1 1 100%;
    }

    .tip-arrow {
        display: none;
    }

    .tip-good::before {
        content: "→ ";
    }
}

/* ===================
   History Panel
   =================== */

.history-panel {
    display: none;
    padding: 12px 20px;
    background: var(--bg-secondary);
    border-bottom: 1px solid var(--border);
}

.history-panel.visible {
    display: block;
}

.history-panel-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 10px;
}

.history-panel-title {
    font-size: 0.9rem;
    font-weight: 600;
    color: var(--text-primary);
}

.history-download-btn {
    width: 32px;
    height: 32px;
    padding: 6px;
    background: var(--bg-tertiary);
    border: 1px solid var(--border);
    border-radius: 6px;
    cursor: pointer;
    color: var(--text-secondary);
    transition: all 0.2s;
}

.history-download-btn:hover {
    border-color: var(--accent);
    color: var(--accent);
}

.history-download-btn svg {
    width: 100%;
    height: 100%;
}

.history-panel-list {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.history-panel-item {
    text-align: left;
    width: 100%;
    padding: 10px 12px;
    border-radius: 10px;
    border: 1px solid var(--border);
    background: var(--bg-tertiary);
    cursor: pointer;
    transition: all 0.2s;
    color: var(--text-primary);
}

.history-panel-item:hover {
    border-color: var(--accent);
}

.history-panel-item.active {
    background: rgba(236, 172, 0, 0.2);
    border-color: var(--accent);
}

.history-panel-item-title {
    display: block;
    font-size: 0.95rem;
    font-weight: 600;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}