/* 
 * Stylesheet for the Data Dashboard Interface
 */

body { 
    font-family: Arial, sans-serif; 
    margin: 0; 
    height: 100vh;
    height: 100dvh;
    overflow: hidden;
    background-color: white; 
}

.container { 
    box-sizing: border-box;
    width: 100%;
    height: 100vh;
    height: 100dvh;
    margin: 0;
    background: white; 
    padding: 24px 32px;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

h1 { 
    color: #333; 
}

.dashboard-title {
    display: flex;
    align-items: center;
    gap: 12px;
}

.dashboard-title #logout-button {
    margin-left: auto;
    margin-right: 4px;
    padding: 8px 14px;
}

.dashboard-title h1 {
    margin: 0;
}

#status-indicator {
    font-size: 0.75rem;
    font-weight: normal;
}
#status-indicator.status-loading,
#status-indicator.status-error {
    display: none;
}

#login-form {
    display: flex;
    flex-direction: column;
    gap: 10px;
    max-width: 400px;
}
#login-form input {
    padding: 10px;
    border: 1px solid #ccc;
    border-radius: 4px;
}
#login-message {
    margin-top: 10px;
}
.error-message,
.status-error {
    color: red;
}
.status-loading {
    color: orange;
}
.status-connected {
    display: inline-flex;
    align-items: center;
    padding: 3px 8px;
    color: green;
    background-color: #e8f5e9;
    border-radius: 999px;
}

/* Chat Styles */
#dashboard-content:not(.hidden) {
    display: flex;
    flex-direction: column;
    flex: 1;
    min-height: 0;
}
#chat-panel {
    display: flex;
    flex: 1;
    flex-direction: column;
    min-height: 0;
    margin-top: 20px;
}
.chat-header,
.chat-tab-bar,
.token-usage,
.chat-actions,
#chat-form {
    flex: 0 0 auto;
}
.chat-header,
.chat-actions {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
}
.chat-actions {
    flex-direction: row;
    align-items: center;
    justify-content: flex-start;
    margin: 0 0 12px;
}
.chat-header h3 {
    margin: 0;
}
.chat-tab-bar {
    display: flex;
    align-items: center;
    gap: 6px;
    margin-top: 16px;
    border-bottom: 1px solid #ddd;
}
.chat-tab-viewport {
    flex: 1;
    min-width: 0;
    overflow: hidden;
}
.chat-tabs {
    display: flex;
    width: max-content;
    min-width: 100%;
    gap: 6px;
}
.chat-tab-item {
    display: flex;
    flex: 0 0 auto;
    align-items: center;
    border-bottom: 2px solid transparent;
}
.chat-tab-item.active {
    border-bottom-color: #007bff;
}
.chat-tab {
    flex: 0 0 auto;
    max-width: 220px;
    overflow: hidden;
    padding: 8px 12px;
    border: 0;
    background: transparent;
    color: #555;
    cursor: pointer;
    text-overflow: ellipsis;
    white-space: nowrap;
}
.chat-tab.active {
    color: #007bff;
    font-weight: bold;
}
.chat-tab-close {
    align-self: stretch;
    padding: 0 7px;
    border: 0;
    background: transparent;
    color: #777;
    cursor: pointer;
    font-size: 1rem;
}
.chat-tab-close:hover {
    color: #b00020;
    background: #f5f5f5;
}
.chat-tab-scroll {
    flex: 0 0 auto;
    width: 28px;
    height: 30px;
    padding: 0;
    border: 0;
    background: transparent;
    color: #555;
    cursor: pointer;
    font-size: 1.1rem;
}
.chat-tab-scroll:disabled {
    color: #bbb;
    cursor: default;
}
.chat-tab-scroll[hidden] {
    display: none;
}
#new-chat-button {
    flex: 0 0 auto;
    margin: 0 4px 4px 0;
    padding: 6px 10px;
}
.token-usage {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-top: 10px;
    color: #555;
    font-size: 0.8rem;
}
#token-usage-progress {
    width: min(240px, 35vw);
    height: 10px;
    accent-color: #2e7d32;
}
.token-usage.is-warning #token-usage-progress {
    accent-color: #ed9b00;
}
.token-usage.is-critical #token-usage-progress {
    accent-color: #b00020;
}
#token-usage-progress[hidden] {
    display: none;
}
#message-display { 
    flex: 1 1 auto;
    min-height: 0;
    overflow-y: auto; 
    padding: 10px; 
    margin-bottom: 12px;
    border: 1px solid #ddd;
    border-radius: 6px;
    background: #fff;
}
.message { 
    margin-bottom: 10px; 
    padding: 8px; 
    border-radius: 12px; 
    max-width: 70%; 
}
.user-message { 
    background-color: #dcf8c6; 
    float: left; 
    clear: left; 
    margin-right: auto; 
}
.server-message { 
    background-color: #e9ecef; 
    float: left; 
    clear: left; 
    margin-right: auto; 
}
.typing-indicator {
    display: flex;
    align-items: center;
    gap: 4px;
    width: fit-content;
}
.typing-indicator span {
    width: 6px;
    height: 6px;
    background-color: #555;
    border-radius: 50%;
    animation: typing-dot 1s infinite ease-in-out;
}
.typing-indicator span:nth-child(2) {
    animation-delay: 0.15s;
}
.typing-indicator span:nth-child(3) {
    animation-delay: 0.3s;
}
@keyframes typing-dot {
    0%, 60%, 100% {
        opacity: 0.3;
        transform: translateY(0);
    }
    30% {
        opacity: 1;
        transform: translateY(-4px);
    }
}
.chat-notice {
    width: fit-content;
    max-width: 90%;
    margin: 0 auto 16px;
    padding: 6px 12px;
    color: #555;
    background-color: #f3f4f6;
    border-radius: 999px;
    font-size: 0.85rem;
    text-align: center;
    opacity: 1;
    transition: opacity 400ms ease;
}
#global-notice-area {
    position: fixed;
    z-index: 1000;
    top: 16px;
    left: 50%;
    display: flex;
    width: calc(100% - 32px);
    justify-content: center;
    transform: translateX(-50%);
    pointer-events: none;
}
#global-notice-area .chat-notice {
    max-width: 100%;
    margin: 0;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.15);
}
.chat-notice.is-fading {
    opacity: 0;
}
.chat-notice-error {
    color: #b00020;
    background-color: #fdecee;
}
.message p,
.message h1,
.message h2,
.message h3,
.message h4,
.message h5,
.message h6 {
    margin: 0 0 8px;
}
.message p:last-child,
.message h1:last-child,
.message h2:last-child,
.message h3:last-child,
.message h4:last-child,
.message h5:last-child,
.message h6:last-child {
    margin-bottom: 0;
}
.message pre {
    overflow-x: auto;
    white-space: pre-wrap;
    overflow-wrap: anywhere;
}
.message .markdown-table-wrapper {
    max-width: 100%;
    overflow-x: auto;
}
.message table {
    border-collapse: collapse;
    width: 100%;
}
.message th,
.message td {
    padding: 6px 10px;
    border: 1px solid #ccc;
    text-align: left;
}
.message th {
    background-color: #f3f4f6;
}
.message .math-display {
    display: block;
    text-align: center;
}
.message blockquote {
    margin: 8px 0;
    padding-left: 10px;
    border-left: 3px solid #ccc;
}
.message ul,
.message ol {
    padding-left: 24px;
}
#chat-form { 
    display: flex; 
    gap: 10px;
}
#user-input { 
    box-sizing: border-box;
    min-width: 0;
    flex-grow: 1; 
    padding: 10px; 
    border: 1px solid #ccc; 
    border-radius: 4px;
}
.button-primary { 
    background-color: #007bff; 
    color: white; 
    padding: 10px 15px; 
    border: none; 
    cursor: pointer; 
    border-radius: 4px;
}
.button-secondary {
    padding: 8px 12px;
    border: 1px solid #999;
    border-radius: 4px;
    background: white;
    color: #333;
    cursor: pointer;
}
.button-primary:disabled,
.button-secondary:disabled {
    cursor: not-allowed;
    opacity: 0.6;
}
.hidden { 
    display: none; 
}

@media (max-width: 600px) {
    .container {
        padding: 12px;
    }
    .dashboard-title {
        gap: 8px;
    }
    .dashboard-title h1 {
        font-size: clamp(1.35rem, 6vw, 1.8rem);
    }
    .dashboard-title #logout-button {
        min-height: 44px;
        margin-right: 0;
        padding: 8px 12px;
    }
    .chat-header {
        align-items: flex-start;
        flex-direction: column;
    }
    .chat-header h3 {
        font-size: 1.1rem;
    }
    .chat-tab-bar {
        gap: 4px;
        margin-top: 10px;
    }
    #new-chat-button {
        min-height: 44px;
        margin-right: 0;
        padding: 8px 10px;
    }
    .chat-tab-scroll {
        width: 36px;
        height: 40px;
    }
    .chat-tab {
        min-height: 44px;
        padding: 10px 12px;
    }
    .chat-tab-close {
        min-width: 36px;
    }
    .token-usage {
        flex-wrap: wrap;
        gap: 6px 10px;
        margin-top: 8px;
        font-size: 0.85rem;
    }
    #token-usage-progress {
        width: min(180px, 55vw);
    }
    #message-display {
        padding: 8px;
        margin-bottom: 8px;
    }
    .message {
        max-width: 90%;
        padding: 10px;
        font-size: 1rem;
        overflow-wrap: anywhere;
    }
    .chat-actions {
        gap: 8px;
        margin-bottom: 8px;
    }
    .chat-actions .button-secondary {
        flex: 1 1 0;
        min-height: 44px;
        padding: 8px 10px;
        font-size: 0.9rem;
    }
    #chat-form {
        gap: 8px;
    }
    #user-input {
        min-height: 48px;
        padding: 12px;
        font-size: 16px;
    }
    #chat-form .button-primary {
        min-width: 64px;
        min-height: 48px;
        padding: 10px 12px;
        font-size: 1rem;
    }
}

@media (max-width: 380px) {
    .container {
        padding: 10px;
    }
    .dashboard-title {
        gap: 6px;
    }
    .dashboard-title h1 {
        font-size: 1.3rem;
    }
    .dashboard-title #logout-button {
        padding: 6px 9px;
    }
    #new-chat-button {
        padding: 7px 8px;
        font-size: 0.85rem;
    }
    .chat-tab {
        max-width: 150px;
    }
}