/* ==========================================================================
   RESET & BASE
   ========================================================================== */
* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
    background-color: #f1f5f9; /* slate-100 */
    color: #1e293b;
    height: 100vh;
    overflow: hidden;
}

button {
    font-family: inherit;
    cursor: pointer;
}

input, textarea {
    font-family: inherit;
}

/* Icons */
.icon {
    width: 20px;
    height: 20px;
    flex-shrink: 0;
}
.icon-sm {
    width: 14px;
    height: 14px;
}
.icon-amber {
    color: #fbbf24; /* amber-400 */
}

/* ==========================================================================
   APP SHELL
   ========================================================================== */
.app-container {
    position: relative;
    display: flex;
    height: 100vh;
    background-color: #f1f5f9;
    overflow: hidden;
}

.sidebar-backdrop {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.4);
    z-index: 30;
}
.sidebar-backdrop.visible {
    display: block;
}

/* ==========================================================================
   SIDEBAR
   ========================================================================== */
.sidebar {
    position: fixed;
    top: 0;
    bottom: 0;
    left: 0;
    z-index: 40;
    width: 288px;
    flex-shrink: 0;
    background-color: #0f172a; /* slate-900 */
    color: #e2e8f0; /* slate-200 */
    display: flex;
    flex-direction: column;
    transform: translateX(-100%);
    transition: transform 0.2s ease-out;
}
.sidebar.open {
    transform: translateX(0);
}

@media (min-width: 768px) {
    .sidebar {
        position: static;
        transform: translateX(0);
    }
    .sidebar-backdrop {
        display: none !important;
    }
}

.sidebar-top {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 12px 16px;
    border-bottom: 1px solid #334155; /* slate-700 */
}

.sidebar-brand {
    display: flex;
    align-items: center;
    gap: 8px;
    font-family: "Courier New", monospace;
    font-size: 0.85rem;
    letter-spacing: 0.5px;
}

.icon-btn {
    background: transparent;
    border: none;
    color: #94a3b8; /* slate-400 */
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 4px;
}
.icon-btn:hover {
    color: #ffffff;
}

.sidebar-open {
    color: #cbd5e1;
}

@media (min-width: 768px) {
    .sidebar-close,
    .sidebar-open {
        display: none;
    }
}

.sidebar-new-chat-wrap {
    padding: 12px 12px 0;
}

.new-chat-btn {
    width: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    border: 1px solid #475569; /* slate-600 */
    border-radius: 8px;
    background: transparent;
    color: #e2e8f0;
    font-size: 0.85rem;
    padding: 8px 12px;
    transition: background-color 0.15s ease;
}
.new-chat-btn:hover {
    background-color: #1e293b; /* slate-800 */
}

.sidebar-stats {
    display: flex;
    gap: 8px;
    padding: 12px;
}

.stat-chip {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 4px;
    font-family: "Courier New", monospace;
    font-size: 0.75rem;
    padding: 6px 8px;
    border-radius: 8px;
}
.stat-chip-amber {
    background-color: #fbbf24;
    color: #451a03;
}
.stat-chip-slate {
    background-color: #334155;
    color: #e2e8f0;
}

.sidebar-offline-note {
    font-size: 0.72rem;
    color: rgba(251, 191, 36, 0.8);
    padding: 0 16px 8px;
    margin-top: -4px;
}

.sidebar-section-label {
    padding: 8px 16px 4px;
    font-size: 0.72rem;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: #64748b; /* slate-500 */
}

.thread-list {
    flex: 1;
    overflow-y: auto;
    padding: 0 8px 12px;
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.thread-item {
    width: 100%;
    text-align: left;
    background: transparent;
    border: none;
    border-left: 4px solid transparent;
    border-radius: 8px;
    padding: 8px 12px;
    display: flex;
    gap: 8px;
    align-items: flex-start;
    transition: background-color 0.15s ease;
}
.thread-item:hover {
    background-color: rgba(30, 41, 59, 0.6);
}
.thread-item.active {
    background-color: #1e293b;
    border-left-color: #f59e0b; /* amber-500 */
}
.thread-item .icon {
    color: #94a3b8;
    margin-top: 2px;
}
.thread-item-text {
    min-width: 0;
    display: flex;
    flex-direction: column;
}
.thread-item-title {
    display: block;
    font-size: 0.85rem;
    color: #f1f5f9;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.thread-item-preview {
    display: block;
    font-size: 0.72rem;
    color: #64748b;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* ==========================================================================
   MAIN COLUMN
   ========================================================================== */
.main-col {
    flex: 1;
    display: flex;
    flex-direction: column;
    min-width: 0;
}

.main-header {
    background-color: #0f172a;
    color: #ffffff;
    padding: 12px 16px;
    display: flex;
    align-items: center;
    gap: 12px;
    border-bottom: 4px solid #f59e0b; /* amber-500 */
    flex-shrink: 0;
}

@media (min-width: 768px) {
    .sidebar-open {
        display: none;
    }
}

.main-header-text {
    min-width: 0;
}
.main-header-title {
    font-family: "Courier New", monospace;
    font-size: 0.85rem;
    letter-spacing: 0.5px;
    line-height: 1.3;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.main-header-subtitle {
    font-size: 0.72rem;
    color: #94a3b8;
    line-height: 1.3;
}

/* ==========================================================================
   CHAT LOG
   ========================================================================== */
.chat-log {
    flex: 1;
    overflow-y: auto;
    padding: 16px;
    max-width: 672px;
    width: 100%;
    margin: 0 auto;
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.msg-row {
    display: flex;
}
.msg-row.user {
    justify-content: flex-end;
}
.msg-row.bot {
    justify-content: flex-start;
}

.msg-avatar {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    background-color: #0f172a;
    color: #fbbf24;
    display: flex;
    align-items: center;
    justify-content: center;
    margin-right: 8px;
    flex-shrink: 0;
}

.bubble {
    border-radius: 8px;
    padding: 8px 12px;
    font-size: 0.85rem;
    max-width: 20rem;
}
.bubble.user {
    background-color: #4f46e5; /* indigo-600 */
    color: #ffffff;
}
.bubble.bot {
    background-color: #ffffff;
    border-left: 4px solid #f59e0b;
    color: #1e293b;
    box-shadow: 0 1px 2px rgba(0,0,0,0.05);
    max-width: 24rem;
}

.bubble.typing {
    color: #94a3b8;
}

/* ==========================================================================
   CATEGORY CHIPS
   ========================================================================== */
.category-bar-wrap {
    max-width: 672px;
    width: 100%;
    margin: 0 auto;
    padding: 0 16px;
    flex-shrink: 0;
}

.category-bar {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    padding-bottom: 8px;
}

.category-chip {
    display: flex;
    align-items: center;
    gap: 4px;
    border: 1px solid #cbd5e1; /* slate-300 */
    background-color: #ffffff;
    border-radius: 999px;
    padding: 4px 12px;
    font-size: 0.75rem;
    color: #334155; /* slate-700 */
    transition: background-color 0.15s ease;
}
.category-chip:hover {
    background-color: #f8fafc;
}
.category-chip:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

/* ==========================================================================
   INPUT BAR
   ========================================================================== */
.input-bar {
    border-top: 1px solid #e2e8f0; /* slate-200 */
    background-color: #ffffff;
    padding: 12px 16px;
    flex-shrink: 0;
}

.input-bar-inner {
    max-width: 672px;
    width: 100%;
    margin: 0 auto;
    display: flex;
    gap: 8px;
}

.chat-input {
    flex: 1;
    border: 1px solid #cbd5e1;
    border-radius: 8px;
    padding: 8px 12px;
    font-size: 0.85rem;
    outline: none;
    transition: box-shadow 0.15s ease, border-color 0.15s ease;
}
.chat-input:focus {
    border-color: #6366f1; /* indigo-500 */
    box-shadow: 0 0 0 2px rgba(99, 102, 241, 0.4);
}
.chat-input:disabled {
    background-color: #f8fafc;
}

.send-btn {
    background-color: #4f46e5;
    color: #ffffff;
    border: none;
    border-radius: 8px;
    padding: 8px 16px;
    font-size: 0.85rem;
    display: flex;
    align-items: center;
    gap: 4px;
    transition: background-color 0.15s ease;
}
.send-btn:hover {
    background-color: #4338ca;
}
.send-btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

/* ==========================================================================
   MODAL
   ========================================================================== */
.modal-overlay {
    position: absolute;
    inset: 0;
    z-index: 50;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(0, 0, 0, 0.4);
    padding: 0 16px;
}
.modal-overlay[hidden] {
    display: none;
}

.modal-card {
    background-color: #ffffff;
    border-radius: 12px;
    box-shadow: 0 20px 40px rgba(0,0,0,0.2);
    width: 100%;
    max-width: 384px;
    overflow: hidden;
}

.modal-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 12px 16px;
    border-bottom: 1px solid #e2e8f0;
    background-color: #0f172a;
}
.modal-header-title {
    display: flex;
    align-items: center;
    gap: 8px;
    color: #ffffff;
    font-family: "Courier New", monospace;
    font-size: 0.85rem;
}
.modal-header .icon-btn {
    color: #94a3b8;
}
.modal-header .icon-btn:hover {
    color: #ffffff;
}

.modal-body {
    padding: 16px;
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.modal-copy {
    font-size: 0.85rem;
    color: #475569; /* slate-600 */
}

.form-field label {
    display: block;
    font-size: 0.72rem;
    font-weight: 500;
    color: #475569;
    margin-bottom: 4px;
}

.form-field input,
.form-field textarea {
    width: 100%;
    border: 1px solid #cbd5e1;
    border-radius: 8px;
    padding: 8px 12px;
    font-size: 0.85rem;
    outline: none;
    transition: box-shadow 0.15s ease, border-color 0.15s ease;
}
.form-field textarea {
    resize: none;
}
.form-field input:focus,
.form-field textarea:focus {
    border-color: #6366f1;
    box-shadow: 0 0 0 2px rgba(99, 102, 241, 0.4);
}
.form-field input:disabled,
.form-field textarea:disabled {
    background-color: #f8fafc;
}

.input-with-icon {
    position: relative;
}
.input-with-icon .input-icon {
    position: absolute;
    left: 10px;
    top: 50%;
    transform: translateY(-50%);
    color: #94a3b8;
}
.input-with-icon input {
    padding-left: 32px;
}

.form-error {
    font-size: 0.72rem;
    color: #dc2626; /* red-600 */
    margin-top: 4px;
}
.form-error[hidden] {
    display: none;
}

.modal-footer {
    display: flex;
    gap: 8px;
    padding: 12px 16px;
    border-top: 1px solid #e2e8f0;
}

.modal-btn {
    flex: 1;
    border-radius: 8px;
    padding: 8px 12px;
    font-size: 0.85rem;
    transition: background-color 0.15s ease;
}
.modal-btn-secondary {
    border: 1px solid #cbd5e1;
    background-color: #ffffff;
    color: #334155;
}
.modal-btn-secondary:hover {
    background-color: #f8fafc;
}
.modal-btn-primary {
    border: none;
    background-color: #4f46e5;
    color: #ffffff;
}
.modal-btn-primary:hover {
    background-color: #4338ca;
}
.modal-btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

/* ==========================================================================
   SUGGEST-TICKET BUTTON (inline in chat)
   ========================================================================== */
.suggest-btn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    background: #ffffff;
    border: 1px solid #f59e0b;
    color: #92400e;
    border-radius: 8px;
    padding: 6px 12px;
    font-size: 0.75rem;
    font-weight: 500;
    cursor: pointer;
    transition: background-color 0.15s ease, box-shadow 0.15s ease;
}
.suggest-btn:hover {
    background-color: #fffbeb;
    box-shadow: 0 0 0 2px rgba(245, 158, 11, 0.25);
}

/* Trello link button in header */
.trello-link-btn {
    margin-left: auto;
    display: flex;
    align-items: center;
    gap: 6px;
    background-color: #1e293b;
    color: #e2e8f0;
    text-decoration: none;
    font-size: 0.75rem;
    padding: 6px 12px;
    border-radius: 6px;
    border: 1px solid #334155;
    transition: all 0.15s ease;
}
.trello-link-btn:hover {
    background-color: #fbbf24;
    color: #0f172a;
    border-color: #fbbf24;
}
