/* Index Page Styles */
:root {
    --primary-color: #ff6b35;
    --primary-light: #ff8c42;
    --primary-dark: #e55a2e;
    --primary-gradient: linear-gradient(135deg, #ff6b35 0%, #ff8c42 100%);
    --background-color: #ffffff;
    --secondary-bg: #f7f7f8;
    --text-color: #2d2d2d;
    --text-secondary: #6b7280;
    --border-color: #e5e7eb;
    --sidebar-bg: #171717;
    --sidebar-hover: #262626;
    --success-color: #10b981;
    --warning-color: #f59e0b;
    --error-color: #ef4444;
    --shadow-sm: 0 1px 2px 0 rgba(255, 107, 53, 0.05);
    --shadow-md: 0 4px 6px -1px rgba(255, 107, 53, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06);
    --shadow-lg: 0 10px 15px -3px rgba(255, 107, 53, 0.1), 0 4px 6px -2px rgba(0, 0, 0, 0.05);
    --shadow-xl: 0 20px 25px -5px rgba(255, 107, 53, 0.1), 0 10px 10px -5px rgba(0, 0, 0, 0.04);
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    font-family: 'Kanit', sans-serif;
}

/* ChatGPT Style Layout */
body {
    background: var(--background-color);
    min-height: 100vh;
    color: var(--text-color);
    display: flex;
    flex-direction: column;
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
}

.container {
    display: flex;
    height: 100vh;
    overflow: hidden;
}

/* ChatGPT-style Sidebar */
/* .sidebar duplicated in sidebar.css; use sidebar.css as single source */

.sidebar-header {
    padding: 16px;
    border-bottom: 1px solid #4a4a4a;
}

.new-chat-btn {
    width: 100%;
    padding: 12px 16px;
    background: transparent;
    border: 1px solid #4a4a4a;
    color: #ffffff;
    border-radius: 8px;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 14px;
    transition: all 0.2s ease;
}

.new-chat-btn:hover {
    background: #262626;
}

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

.chat-item {
    padding: 12px 16px;
    color: #b4b4b4;
    cursor: pointer;
    border-radius: 8px;
    margin-bottom: 4px;
    font-size: 14px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    transition: all 0.2s ease;
}

.chat-item:hover {
    background: #262626;
    color: #ffffff;
}

.chat-item.active {
    background: var(--primary-color);
    color: #ffffff;
}

/* Main Content Area */
.main-content {
    flex: 1;
    display: flex;
    flex-direction: column;
    background: var(--background-color);
    position: relative;
}

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

.table-container {
    background: white;
    border-radius: 12px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
    overflow: hidden;
}

table {
    width: 100%;
    border-collapse: collapse;
}

th, td {
    padding: 16px;
    text-align: left;
    border-bottom: 1px solid var(--border-color);
}

th {
    background: var(--secondary-bg);
    font-weight: 500;
}

tr:hover {
    background: var(--secondary-bg);
}

.action-buttons {
    display: flex;
    gap: 8px;
}

.btn-edit, .btn-delete {
    padding: 6px 12px;
    border-radius: 6px;
    font-size: 13px;
    border: none;
    cursor: pointer;
}

.btn-edit {
    background: #4CAF50;
    color: white;
}

.btn-delete {
    background: #f44336;
    color: white;
}

.form-control {
    width: 100%;
    padding: 10px;
    border: 1px solid var(--border-color);
    border-radius: 6px;
    font-size: 14px;
}

/* Modal Styles */
.modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.5);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
}

.modal-content {
    background: white;
    border-radius: 8px;
    padding: 0;
    width: 90%;
    max-width: 500px;
    max-height: 90vh;
    overflow-y: auto;
}

.modal-header {
    padding: 20px;
    border-bottom: 1px solid #eee;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.modal-header h2 {
    margin: 0;
    color: var(--text-color);
}

.close-btn {
    background: none;
    border: none;
    font-size: 24px;
    cursor: pointer;
    color: #999;
    padding: 0;
    width: 30px;
    height: 30px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.close-btn:hover {
    color: #333;
}

.form-group {
    margin-bottom: 15px;
    padding: 0 20px;
}

.form-group label {
    display: block;
    margin-bottom: 5px;
    font-weight: 500;
    color: var(--text-color);
}

.form-group input {
    width: 100%;
    padding: 10px;
    border: 1px solid var(--border-color);
    border-radius: 4px;
    font-size: 14px;
}

.form-actions {
    padding: 20px;
    border-top: 1px solid #eee;
    display: flex;
    gap: 10px;
    justify-content: flex-end;
}

.form-actions button {
    padding: 10px 20px;
    border: none;
    border-radius: 4px;
    cursor: pointer;
    font-size: 14px;
}

.form-actions button[type="button"] {
    background: #f5f5f5;
    color: #333;
}

.form-actions button[type="submit"] {
    background: var(--primary-color);
    color: white;
}

.form-actions button:hover {
    opacity: 0.9;
}

/* ChatGPT-style Chat Container */
.chat-container {
    flex: 1;
    display: flex;
    flex-direction: column;
    background: var(--background-color);
    height: 100vh;
    position: relative;
    overflow: hidden;
}

.chat-header {
    padding: 16px 24px;
    border-bottom: 1px solid var(--border-color);
    background: var(--background-color);
    display: flex;
    align-items: center;
    justify-content: center;
    position: sticky;
    top: 0;
    z-index: 100;
    width: 100%;
}

.header-content {
    display: flex;
    align-items: center;
    justify-content: space-between;
    width: 100%;
    gap: 12px;
}

.chat-title h1 {
    margin: 0;
    font-size: 18px;
    font-weight: 600;
    color: var(--text-color);
    line-height: 1.2;
}

.chat-subtitle {
    display: none;
}

.header-actions {
    display: flex;
    gap: 12px;
}

.btn-icon {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 44px;
    height: 44px;
    border: none;
    border-radius: 12px;
    background: rgba(255, 255, 255, 0.8);
    color: var(--text-secondary);
    cursor: pointer;
    transition: all 0.3s ease;
    backdrop-filter: blur(10px);
    border: 1px solid var(--border-color);
    box-shadow: var(--shadow-sm);
}

.btn-icon:hover {
    background: var(--primary-color);
    color: white;
    transform: translateY(-2px);
    box-shadow: var(--shadow-md);
    border-color: var(--primary-color);
}

.btn-clear-chat {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 60px;
    height: 60px;
    border: none;
    border-radius: 12px;
    background: rgba(255, 255, 255, 0.8);
    color: var(--text-secondary);
    cursor: pointer;
    transition: all 0.3s ease;
    backdrop-filter: blur(10px);
    border: 1px solid var(--border-color);
    box-shadow: var(--shadow-sm);
    flex-direction: column;
    padding: 8px 4px;
}

.btn-clear-chat:hover {
    background: var(--error-color);
    color: white;
    transform: translateY(-2px);
    box-shadow: var(--shadow-md);
    border-color: var(--error-color);
}

.btn-clear-chat:active {
    transform: translateY(0);
    box-shadow: var(--shadow-sm);
}

.btn-demo-chart {
    background: linear-gradient(135deg, #3b82f6, #1d4ed8);
    color: white;
    border: none;
    border-radius: 12px;
    padding: 12px 16px;
    cursor: pointer;
    transition: all 0.3s ease;
    display: flex;
    align-items: center;
    gap: 8px;
    box-shadow: var(--shadow-md);
    font-size: 14px;
    font-weight: 500;
}

.btn-demo-chart:hover {
    background: linear-gradient(135deg, #1d4ed8, #1e40af);
    transform: translateY(-2px);
    box-shadow: var(--shadow-lg);
}

.btn-demo-chart:active {
    transform: translateY(0);
    box-shadow: var(--shadow-sm);
}

.btn-font-size {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 60px;
    height: 60px;
    border: none;
    border-radius: 12px;
    background: rgba(255, 255, 255, 0.8);
    color: var(--text-secondary);
    cursor: pointer;
    transition: all 0.3s ease;
    backdrop-filter: blur(10px);
    border: 1px solid var(--border-color);
    box-shadow: var(--shadow-sm);
    flex-direction: column;
    padding: 8px 4px;
}

.btn-font-size:hover {
    background: var(--primary-color);
    color: white;
    transform: translateY(-2px);
    box-shadow: var(--shadow-md);
    border-color: var(--primary-color);
}

.btn-font-size:active {
    transform: translateY(0);
    box-shadow: var(--shadow-sm);
}

.btn-content {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 2px;
}

.btn-label {
    font-size: 10px;
    font-weight: 500;
    line-height: 1;
    margin-top: 2px;
}

.chat-messages {
    flex: 1;
    overflow-y: auto;
    padding: 0;
    background: var(--background-color);
    scroll-behavior: smooth;
    position: relative;
}

/* Background Logo Styles */
.chat-background-logo {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    z-index: 0;
    pointer-events: none;
    user-select: none;
    transition: opacity 0.5s ease;
}

.background-logo {
    width: 300px;
    height: auto;
    opacity: 0.015;
    filter: sepia(100%) saturate(300%) hue-rotate(25deg) brightness(1.3);
    transition: all 0.3s ease;
    max-width: 90vw;
    max-height: 40vh;
    object-fit: contain;
}

/* Hide logo when chat has many messages */
.chat-messages.has-messages .chat-background-logo {
    opacity: 0.005;
}

/* Show logo more prominently when chat is empty or has few messages */
.chat-messages.empty .background-logo {
    opacity: 0.04;
    transform: scale(0.9);
}

/* Responsive logo sizing */
@media (max-width: 767px) {
    .background-logo {
        width: 200px;
        opacity: 0.01;
    }
    
    .chat-messages.empty .background-logo {
        opacity: 0.03;
    }
    
    .input-wrapper {
        padding: 14px 100px 14px 20px;
        border-radius: 24px;
    }
    
    .input-wrapper.multiline {
        padding: 18px 100px 18px 20px;
        border-radius: 28px;
    }
    
    .chat-input-wrapper {
        padding: 16px 20px 24px;
    }
    
    .image-preview img {
        max-width: 150px;
        max-height: 150px;
    }
    
    .remove-image-btn {
        width: 28px;
        height: 28px;
        top: 6px;
        right: 6px;
    }
    
    .btn-attach,
    .btn-send {
        width: 36px;
        height: 36px;
    }
    
    .input-actions {
        right: 6px;
        gap: 6px;
    }
    
    .input-hint {
        font-size: 11px;
        margin-top: 6px;
    }
    
    .header-actions {
        gap: 8px;
    }
    
    .btn-font-size,
    .btn-clear-chat,
    .btn-demo-chart {
        width: 50px;
        height: 50px;
        padding: 6px 4px;
    }
    
    .btn-font-size svg,
    .btn-clear-chat svg,
    .btn-demo-chart svg {
        width: 16px;
        height: 16px;
    }
    
    .btn-label {
        font-size: 9px;
    }
}

.chat-input-wrapper {
    padding: 24px 32px 40px;
    background: rgba(255, 255, 255, 0.95);
    backdrop-filter: blur(20px);
    border-top: 1px solid var(--border-color);
    position: relative;
    display: flex;
    flex-direction: column;
}

.chat-input-wrapper::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 1px;
    background: linear-gradient(90deg, transparent, var(--primary-color), transparent);
}

.chat-input-container {
    max-width: 900px;
    margin: 0 auto;
    width: 100%;
}

.input-hint {
    text-align: center;
    font-size: 12px;
    color: var(--text-secondary);
    margin-top: 8px;
    opacity: 0.7;
    transition: opacity 0.3s ease;
}

.input-hint:hover {
    opacity: 1;
}

.input-hint strong {
    color: var(--primary-color);
    font-weight: 600;
}

.input-wrapper {
    position: relative;
    background: white;
    border: 2px solid var(--border-color);
    border-radius: 28px;
    padding: 16px 110px 16px 24px;
    box-shadow: var(--shadow-lg);
    transition: all 0.3s ease;
    backdrop-filter: blur(10px);
    flex: 1;
    min-height: 56px;
    display: flex;
    align-items: center;
}

.input-wrapper:focus-within {
    border-color: var(--primary-color);
    box-shadow: 0 8px 25px -8px rgba(255, 107, 53, 0.3);
    transform: translateY(-2px);
    background: rgba(255, 255, 255, 0.98);
}

.input-wrapper.has-content {
    min-height: 60px;
    border-color: var(--primary-light);
}

.input-wrapper.multiline {
    min-height: 80px;
    border-radius: 32px;
    padding: 20px 110px 20px 24px;
}

#messageInput {
    width: 100%;
    border: none;
    outline: none;
    resize: none;
    font-size: 16px;
    line-height: 1.5;
    color: var(--text-color);
    background: transparent;
    font-family: inherit;
    min-height: 24px;
    max-height: 120px;
    font-weight: 500;
    transition: color 0.2s ease;
}

#messageInput::placeholder {
    color: var(--text-secondary);
    font-weight: 400;
    opacity: 0.8;
    transition: opacity 0.3s ease;
}

#messageInput:focus::placeholder {
    opacity: 0.5;
}

#messageInput:focus {
    color: var(--primary-color);
}

.input-actions {
    position: absolute;
    right: 8px;
    top: 50%;
    transform: translateY(-50%);
    display: flex;
    gap: 8px;
    align-items: center;
}

.btn-attach,
.btn-send {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 40px;
    height: 40px;
    border: none;
    border-radius: 20px;
    cursor: pointer;
    transition: all 0.3s ease;
    background: transparent;
    color: var(--text-secondary);
    position: relative;
    overflow: hidden;
    flex-shrink: 0;
}

.btn-attach::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: var(--secondary-bg);
    border-radius: inherit;
    opacity: 0;
    transition: all 0.3s ease;
    z-index: -1;
}

.btn-attach:hover::before {
    opacity: 1;
}

.btn-attach:hover {
    color: var(--primary-color);
    transform: scale(1.05);
}

.btn-attach:hover::before {
    opacity: 1;
}

.btn-attach:hover {
    color: var(--text-color);
    transform: scale(1.05);
}

.btn-send {
    background: var(--primary-gradient);
    color: white;
    box-shadow: var(--shadow-md);
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    position: relative;
    overflow: hidden;
}

.btn-send::before {
    content: '';
    position: absolute;
    top: 0;
    left: -100%;
    width: 100%;
    height: 100%;
    background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.2), transparent);
    transition: left 0.6s ease;
}

.btn-send:hover {
    transform: scale(1.05) translateY(-1px);
    box-shadow: var(--shadow-lg);
    background: linear-gradient(135deg, var(--primary-color) 0%, var(--primary-dark) 100%);
}

.btn-send:hover::before {
    left: 100%;
}

.btn-send:active {
    transform: scale(0.95);
    transition: transform 0.1s ease;
}

.btn-send:disabled {
    background: var(--text-secondary);
    cursor: not-allowed;
    transform: none;
    box-shadow: none;
}

.btn-send.loading {
    pointer-events: none;
}

.btn-send.loading svg {
    animation: spin 1s linear infinite;
}

@keyframes spin {
    from { transform: rotate(0deg); }
    to { transform: rotate(360deg); }
}

.btn-send:disabled {
    background: #ccc;
    cursor: not-allowed;
    transform: none;
}

.image-preview {
    margin-bottom: 16px;
    display: none;
    position: relative;
    border-radius: 16px;
    overflow: hidden;
    box-shadow: var(--shadow-lg);
    transition: all 0.3s ease;
    background: white;
    border: 2px solid var(--border-color);
    width: fit-content;
    max-width: 100%;
    margin-left: auto;
    margin-right: auto;
}

.image-preview:empty {
    display: none !important;
    margin: 0;
    padding: 0;
    border: none;
    box-shadow: none;
}

.image-preview.show {
    display: block;
}

.image-preview img {
    max-width: 200px;
    max-height: 200px;
    border-radius: 12px;
    object-fit: cover;
    display: block;
    margin: 0;
}

.remove-image-btn {
    position: absolute;
    top: 8px;
    right: 8px;
    width: 32px;
    height: 32px;
    border-radius: 50%;
    border: none;
    background: rgba(0, 0, 0, 0.7);
    color: white;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s ease;
    backdrop-filter: blur(8px);
}

.remove-image-btn:hover {
    background: var(--error-color);
    transform: scale(1.1);
}

.remove-image-btn:active {
    transform: scale(0.9);
}

/* ChatGPT-style Messages */
.chat-messages {
    flex: 1;
    overflow-y: auto;
    background: var(--background-color);
}

.message {
    margin: 0;
    padding: 24px;
    display: flex;
    justify-content: center;
    width: 100%;
    position: relative;
    transition: background-color 0.2s ease;
    z-index: 1;
}

.message:hover {
    background: rgba(0, 0, 0, 0.02);
}

.message.user {
    background: var(--secondary-bg);
}

.message.ai {
    background: var(--background-color);
}

.message::before {
    display: none;
}

.message-content {
    max-width: 768px;
    width: 100%;
    padding: 0;
    margin: 0;
    word-wrap: break-word;
    word-break: break-word;
    white-space: pre-wrap;
    line-height: 1.6;
    font-size: 16px;
    color: var(--text-color);
    position: relative;
}

.message.user .message-content {
    background: transparent;
    color: var(--text-color);
    font-weight: 400;
}

.message.user .message-content::before {
    content: "คุณ";
    display: block;
    font-weight: 700;
    color: var(--primary-color);
    margin-bottom: 8px;
    font-size: 14px;
}

.message.ai .message-content {
    background: transparent;
    color: var(--text-color);
    font-weight: 400;
}

.message.ai .message-content::before {
    content: "🤖 Weston AI";
    display: block;
    font-weight: 700;
    color: var(--primary-color);
    margin-bottom: 8px;
    font-size: 14px;
}

/* Animations */
@keyframes slideIn {
    from { 
        opacity: 0;
        transform: translateY(20px);
    }
    to { 
        opacity: 1;
        transform: translateY(0);
    }
}

@keyframes fadeIn {
    from { 
        opacity: 0;
        transform: scale(0.95);
    }
    to { 
        opacity: 1;
        transform: scale(1);
    }
}

@keyframes pulse {
    0%, 100% { 
        opacity: 0.6;
    }
    50% { 
        opacity: 1;
    }
}

@keyframes shimmer {
    0% {
        background-position: -1000px 0;
    }
    100% {
        background-position: 1000px 0;
    }
}

/* Animations */
@keyframes slideIn {
    from { 
        opacity: 0;
        transform: translateY(20px);
    }
    to { 
        opacity: 1;
        transform: translateY(0);
    }
}

@keyframes pulse {
    0%, 100% { 
        opacity: 0.4;
        transform: scale(1);
    }
    50% { 
        opacity: 1;
        transform: scale(1.1);
    }
}

@keyframes fadeIn {
    from { 
        opacity: 0;
        transform: scale(0.95);
    }
    to { 
        opacity: 1;
        transform: scale(1);
    }
}

.thinking {
    display: flex;
    justify-content: center;
    padding: 24px;
    background: var(--background-color);
    animation: slideIn 0.3s ease-out;
}

.thinking-content {
    max-width: 800px;
    width: 100%;
    display: flex;
    align-items: center;
    gap: 12px;
}

.thinking-content::before {
    content: "🤖 Weston AI";
    font-weight: 600;
    color: var(--primary-color);
    font-size: 14px;
    flex-shrink: 0;
}

#waiting-message {
    transition: opacity 0.2s ease-in-out;
    color: #666;
    font-size: 14px;
}

.typing-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: var(--primary-color);
    opacity: 0.6;
    animation: pulse 1s infinite;
}

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

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

/* Thai text specific styling */
.message-content:lang(th) {
    font-size: 1.1em;
    line-height: 1.8;
    letter-spacing: 0.5px;
    word-spacing: 2px;
}

.message img {
    max-width: 200px;
    border-radius: 10px;
    margin-top: 5px;
}

/* ChatGPT-style Input Area */
.chat-input {
    padding: 20px 24px;
    background: var(--background-color);
    border-top: 1px solid var(--border-color);
    position: sticky;
    bottom: 0;
    max-width: 768px;
    margin: 0 auto;
    width: 100%;
}

.input-container {
    display: flex;
    align-items: flex-end;
    gap: 12px;
    background: var(--background-color);
    border: 2px solid var(--border-color);
    border-radius: 24px;
    padding: 12px 16px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
    transition: all 0.2s ease;
}

.input-container:focus-within {
    border-color: var(--primary-color);
    box-shadow: 0 2px 8px rgba(255, 107, 53, 0.15);
}

#messageInput {
    flex: 1;
    padding: 8px 0;
    border: none;
    font-size: 16px;
    background: transparent;
    color: var(--text-color);
    resize: none;
    min-height: 24px;
    max-height: 200px;
    outline: none;
    font-family: inherit;
    line-height: 1.5;
}

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

#messageInput:focus {
    outline: none;
}

/* ChatGPT-style Send Button */
.btn {
    padding: 10px;
    border: none;
    border-radius: 50%;
    cursor: pointer;
    transition: all 0.2s ease;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 40px;
    height: 40px;
}

.btn-primary {
    background: var(--primary-color);
    color: white;
}

.btn-primary:hover {
    background: var(--primary-dark);
    transform: scale(1.05);
}

.btn-primary:disabled {
    background: var(--border-color);
    cursor: not-allowed;
    transform: none;
}

.btn-secondary {
    background: var(--secondary-bg);
    color: var(--text-color);
    border: 1px solid var(--border-color);
}

.btn-secondary:hover {
    background: var(--border-color);
}

#imageInput {
    display: none;
}

/* Additional ChatGPT-style improvements */
.chat-messages {
    scroll-behavior: smooth;
}

.chat-messages::-webkit-scrollbar {
    width: 6px;
}

.chat-messages::-webkit-scrollbar-track {
    background: transparent;
}

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

.chat-messages::-webkit-scrollbar-thumb:hover {
    background: var(--primary-color);
}

.btn:hover {
    background: var(--primary-light);
    transform: translateY(-1px);
}

.btn-secondary:hover {
    background: var(--border-color);
}

.btn:hover {
    opacity: 0.9;
}

.image-preview {
    margin-top: 10px;
    display: none;
}

.image-preview img {
    max-height: 100px;
    border-radius: 5px;
}

/* Settings Menu Styles */
.settings-dropdown {
    position: relative;
    display: inline-block;
}

.settings-btn {
    padding: 8px 16px;
    display: flex;
    align-items: center;
    gap: 8px;
    background: var(--secondary-bg);
    border: 1px solid var(--border-color);
    color: var(--text-color);
    font-size: 14px;
}

.settings-menu {
    position: absolute;
    right: 0;
    top: 100%;
    background: white;
    border: 1px solid var(--border-color);
    border-radius: 8px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
    display: none;
    z-index: 1000;
    min-width: 200px;
    margin-top: 4px;
}

.settings-menu.show {
    display: block;
    animation: fadeIn 0.2s ease-out;
}

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

.settings-item {
    display: flex;
    align-items: center;
    gap: 8px;
    width: 100%;
    padding: 12px 16px;
    border: none;
    background: none;
    text-align: left;
    cursor: pointer;
    color: var(--text-color);
    font-family: inherit;
    font-size: 14px;
    transition: background-color 0.2s;
}

.settings-item:hover {
    background: var(--secondary-bg);
}

.settings-item:first-child {
    border-radius: 8px 8px 0 0;
}

.settings-item:last-child {
    border-radius: 0 0 8px 8px;
}

/* Modal Styles - Enhanced */
.modal {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.5);
    z-index: 1000;
    align-items: center;
    justify-content: center;
}

.modal.show {
    display: flex;
    animation: modalFadeIn 0.3s ease-out;
}

@keyframes modalFadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

.modal-content {
    background: white;
    padding: 24px;
    border-radius: 12px;
    width: 90%;
    max-width: 400px;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.15);
}

.modal-header {
    margin-bottom: 20px;
}

.modal-header h2 {
    margin: 0;
    font-size: 20px;
    color: var(--text-color);
}

.modal-body {
    margin-bottom: 24px;
}

.modal-footer {
    display: flex;
    justify-content: flex-end;
    gap: 12px;
}

/* Change Password Modal Specific Styles */
.change-password-modal {
    background: white;
    color: var(--text-color);
}

.modal-header {
    margin-bottom: 20px;
    padding-right: 24px;
}

.close-btn {
    position: absolute;
    right: 20px;
    top: 20px;
    background: none;
    border: none;
    font-size: 24px;
    cursor: pointer;
    color: #666;
}

.close-btn:hover {
    color: #333;
}

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

.modal-body .input-group label {
    display: block;
    margin-bottom: 8px;
    color: var(--text-color);
    font-weight: 500;
}

.password-input {
    width: 100%;
    padding: 12px;
    border: 1px solid var(--border-color);
    border-radius: 6px;
    font-size: 14px;
    transition: border-color 0.3s;
}

.password-input:focus {
    border-color: var(--primary-color);
    outline: none;
    box-shadow: 0 0 0 2px rgba(255, 107, 53, 0.1);
}

.modal-footer {
    display: flex;
    justify-content: flex-end;
    gap: 12px;
    margin-top: 24px;
}

/* Responsive Design */
@media (max-width: 767px) {
    .chat-container {
        margin-left: 0;
        max-width: 100%;
    }

    .header-content {
        padding: 12px 16px;
    }

    .chat-title h1 {
        font-size: 18px;
    }

    .chat-subtitle {
        font-size: 13px;
    }

    .chat-input-wrapper {
        padding: 16px 16px 24px;
    }

    .input-wrapper {
        padding: 10px 50px 10px 16px;
    }

    #messageInput {
        font-size: 16px; /* Prevent zoom on iOS */
    }

    .message {
        padding: 16px;
    }

    .message-content {
        font-size: 15px;
        line-height: 1.5;
    }

    .modal-content {
        width: 95%;
        margin: 20px;
    }

    .btn-icon {
        width: 36px;
        height: 36px;
    }

    .input-actions {
        right: 6px;
    }

    .btn-attach,
    .btn-send {
        width: 36px;
        height: 36px;
    }
}

/* ===== RESPONSIVE DESIGN ===== */

/* Mobile First Approach */
@media (max-width: 767px) {
    .container {
        flex-direction: column;
        height: 100vh;
        overflow: hidden;
    }

    /* .sidebar responsive overrides moved to sidebar.css */

    .logo-container {
        padding: 0;
        margin-right: auto;
    }

    .logo-text {
        font-size: 14px;
        display: none;
    }

    .sidebar-menu {
        display: none;
    }

    .profile-section {
        margin-left: auto;
    }

    .profile-button {
        padding: 8px;
    }

    .profile-info {
        display: none;
    }

    .profile-avatar {
        width: 36px;
        height: 36px;
        font-size: 16px;
    }

    .chat-container {
        width: 100%;
        margin-top: 70px;
        height: calc(100vh - 70px);
        display: flex;
        flex-direction: column;
    }

    .chat-header {
        padding: 16px;
        min-height: auto;
    }

    .header-content {
        flex-direction: column;
        align-items: flex-start;
        gap: 12px;
    }

    .chat-title h1 {
        font-size: 20px;
    }

    .chat-subtitle {
        font-size: 13px;
        display: block;
    }

    .header-actions {
        width: 100%;
        justify-content: space-between;
        gap: 8px;
    }

    .btn-font-size,
    .btn-clear-chat {
        padding: 8px 12px;
        min-width: auto;
        flex: 1;
    }

    .btn-content {
        flex-direction: column;
        gap: 4px;
    }

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

    .btn-label {
        font-size: 11px;
    }

    .chat-messages {
        padding: 16px 12px;
        flex: 1;
        overflow-y: auto;
    }

    .message {
        margin-bottom: 16px;
    }

    .message-content {
        padding: 12px 16px;
        font-size: 15px;
        line-height: 1.5;
        max-width: 100%;
    }

    .message.user .message-content {
        margin-left: 0;
    }

    .message.ai .message-content {
        margin-right: 0;
    }

    .chat-input-wrapper {
        padding: 12px;
        background: white;
        border-top: 1px solid var(--border-color);
    }

    .input-wrapper {
        min-height: 48px;
        padding: 12px 90px 12px 16px !important;
    }

    .input-wrapper textarea {
        font-size: 16px; /* Prevent zoom on iOS */
    }

    .input-actions {
        right: 8px;
        gap: 4px;
    }

    .btn-attach,
    .btn-send {
        width: 36px;
        height: 36px;
        padding: 8px;
    }

    .btn-attach svg,
    .btn-send svg {
        width: 16px;
        height: 16px;
    }

    .input-hint {
        font-size: 12px;
        padding: 8px 4px;
        text-align: center;
    }

    .background-logo {
        width: 80px;
        height: 80px;
        opacity: 0.05;
    }

    /* Profile Menu Mobile */
    .profile-menu {
        position: fixed;
        top: 70px;
        right: 12px;
        left: auto;
        width: 200px;
        z-index: 1001;
    }
}

/* Tablet Styles */
@media (min-width: 769px) and (max-width: 1024px) {
    .sidebar {
        width: 220px;
    }

    .logo-text {
        font-size: 15px;
    }

    .chat-container {
        width: calc(100% - 220px);
    }

    .chat-header {
        padding: 20px 24px;
    }

    .chat-title h1 {
        font-size: 22px;
    }

    .header-actions {
        gap: 8px;
    }

    .btn-font-size,
    .btn-clear-chat {
        padding: 10px 16px;
    }

    .chat-messages {
        padding: 20px 24px;
    }

    .message-content {
        max-width: 85%;
    }

    .chat-input-wrapper {
        padding: 20px 24px;
    }
}

/* Small Mobile Styles */
@media (max-width: 480px) {
    /* .sidebar responsive overrides moved to sidebar.css */

    .logo {
        width: 32px;
        height: 32px;
    }

    .profile-avatar {
        width: 32px;
        height: 32px;
        font-size: 14px;
    }

    .chat-container {
        margin-top: 60px;
        height: calc(100vh - 60px);
    }

    .chat-header {
        padding: 12px;
    }

    .chat-title h1 {
        font-size: 18px;
    }

    .chat-subtitle {
        font-size: 12px;
    }

    .header-actions {
        flex-wrap: wrap;
        gap: 6px;
    }

    .btn-font-size,
    .btn-clear-chat {
        padding: 6px 10px;
        min-width: 60px;
    }

    .btn-label {
        font-size: 10px;
    }

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

    .message-content {
        padding: 10px 14px;
        font-size: 14px;
    }

    .chat-input-wrapper {
        padding: 8px;
    }

    .input-wrapper {
        min-height: 44px;
        padding: 10px 80px 10px 12px !important;
    }

    .input-wrapper textarea {
        font-size: 16px;
    }

    .input-actions {
        right: 6px;
        gap: 2px;
    }

    .btn-attach,
    .btn-send {
        width: 32px;
        height: 32px;
        padding: 6px;
    }

    .btn-attach svg,
    .btn-send svg {
        width: 14px;
        height: 14px;
    }

    .input-hint {
        font-size: 11px;
        padding: 6px 4px;
    }

    .background-logo {
        width: 60px;
        height: 60px;
    }

    /* Hide complex elements on very small screens */
    .chat-subtitle {
        display: none;
    }

    .input-hint {
        display: none;
    }
}

/* Large Desktop Styles */
@media (min-width: 1200px) {
    /* .sidebar responsive overrides moved to sidebar.css */

    .chat-container {
        width: calc(100% - 280px);
    }

    .chat-messages {
        padding: 32px 48px;
    }

    .message-content {
        max-width: 70%;
        padding: 18px 24px;
        font-size: 16px;
    }

    .chat-input-wrapper {
        padding: 24px 48px;
    }
}

/* Landscape Mobile */
@media (max-height: 500px) and (orientation: landscape) {
    .chat-header {
        padding: 8px 16px;
        min-height: auto;
    }

    .header-content {
        flex-direction: row;
        align-items: center;
        gap: 16px;
    }

    .chat-title h1 {
        font-size: 16px;
    }

    .chat-subtitle {
        display: none;
    }

    .header-actions {
        gap: 6px;
    }

    .btn-font-size,
    .btn-clear-chat {
        padding: 4px 8px;
    }

    .btn-content {
        flex-direction: row;
        gap: 4px;
    }

    .btn-label {
        font-size: 10px;
    }

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

    .chat-input-wrapper {
        padding: 8px 16px;
    }
}

/* Print Styles */
@media print {
    .sidebar,
    .chat-header,
    .chat-input-wrapper {
        display: none;
    }

    .chat-container {
        width: 100%;
    }

    .chat-messages {
        padding: 0;
    }

    .message {
        page-break-inside: avoid;
        margin-bottom: 12px;
    }

    .message-content {
        border: 1px solid #ccc;
        padding: 12px;
        background: white;
    }
}

/* High DPI Displays */
@media (-webkit-min-device-pixel-ratio: 2), (min-resolution: 192dpi) {
    .logo,
    .background-logo {
        image-rendering: -webkit-optimize-contrast;
        image-rendering: crisp-edges;
    }
}

@media (max-width: 480px) {
    .chat-title h1 {
        font-size: 16px;
    }

    .chat-subtitle {
        display: none;
    }

    .header-actions {
        gap: 4px;
    }
}

/* ===== AI TABLE STYLES ===== */
.ai-table-container {
    margin: 16px 0;
    overflow-x: auto;
    background: #ffffff;
    border-radius: 12px;
    border: 1px solid #e5e7eb;
    box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06);
}

.ai-table {
    width: 100%;
    border-collapse: collapse;
    font-family: 'Kanit', sans-serif;
    font-size: 14px;
    background: white;
}

.ai-table thead {
    background: linear-gradient(135deg, #ff6b35, #ff8c42);
    color: #000000;
}

.ai-table thead th {
    padding: 16px 20px;
    text-align: left;
    font-weight: 600;
    font-size: 15px;
    border-bottom: 2px solid #ff6b35;
    position: relative;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: #000000;
}

.ai-table thead th:first-child {
    border-top-left-radius: 12px;
}

.ai-table thead th:last-child {
    border-top-right-radius: 12px;
}

.ai-table tbody td {
    padding: 14px 20px;
    border-bottom: 1px solid #f3f4f6;
    color: #374151;
    font-weight: 500;
    vertical-align: top;
    line-height: 1.5;
}

.ai-table tbody tr:hover {
    background: linear-gradient(135deg, #fef3ec, #fef0e7);
    transition: all 0.2s ease;
}

.ai-table tbody tr:last-child td {
    border-bottom: none;
}

.ai-table tbody tr:last-child td:first-child {
    border-bottom-left-radius: 12px;
}

.ai-table tbody tr:last-child td:last-child {
    border-bottom-right-radius: 12px;
}

/* Responsive Table */
@media (max-width: 767px) {
    .ai-table-container {
        margin: 12px 0;
        border-radius: 8px;
    }
    
    .ai-table {
        font-size: 13px;
    }
    
    .ai-table thead th {
        padding: 12px 16px;
        font-size: 14px;
    }
    
    .ai-table tbody td {
        padding: 10px 16px;
        font-size: 13px;
    }
}

@media (max-width: 480px) {
    .ai-table thead th {
        padding: 10px 12px;
        font-size: 13px;
    }
    
    .ai-table tbody td {
        padding: 8px 12px;
        font-size: 12px;
    }
}

/* ===== AI CHART STYLES ===== */
.ai-chart-container {
    margin: 16px 0;
    background: #ffffff;
    border-radius: 12px;
    border: 1px solid #e5e7eb;
    box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06);
    padding: 20px;
    overflow-x: auto;
    max-width: 100%;
}

.ai-chart-ascii {
    font-family: 'Courier New', 'Monaco', 'Menlo', 'SF Mono', monospace;
    font-size: 16px;
    line-height: 1.4;
    white-space: pre;
    color: #374151;
    background: #f8fafc;
    padding: 20px;
    border-radius: 8px;
    border: 1px solid #e2e8f0;
    overflow-x: auto;
    max-width: 100%;
    letter-spacing: 0;
    font-weight: 500;
}

.chart-line {
    margin: 0;
    padding: 0;
    white-space: pre;
    display: block;
    min-height: 1.4em;
}

/* Chart Block Colors - ปรับให้สีสันชัดเจนขึ้น */
.chart-block {
    font-weight: bold;
    display: inline;
    font-size: inherit;
    text-shadow: 0 1px 2px rgba(0, 0, 0, 0.1);
    transition: all 0.3s ease;
}

.chart-block:hover {
    transform: scale(1.1);
    text-shadow: 0 2px 4px rgba(0, 0, 0, 0.2);
}

/* สีแบบดั้งเดิม */
.chart-full {
    color: #dc2626;
    background: linear-gradient(135deg, #dc2626, #ef4444);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.chart-87 { color: #ea580c; }
.chart-75 { color: #f59e0b; }
.chart-62 { color: #eab308; }
.chart-50 { color: #84cc16; }
.chart-37 { color: #22c55e; }
.chart-25 { color: #10b981; }
.chart-12 { color: #14b8a6; }

/* สีรุ้ง (Rainbow Colors) */
.chart-red { color: #ef4444; }
.chart-orange { color: #f97316; }
.chart-yellow { color: #eab308; }
.chart-green { color: #22c55e; }
.chart-blue { color: #3b82f6; }
.chart-indigo { color: #6366f1; }
.chart-purple { color: #a855f7; }
.chart-pink { color: #ec4899; }

/* สี Gradient */
.chart-gradient-1 { 
    color: #f43f5e; 
    background: linear-gradient(45deg, #f43f5e, #fb7185); 
    -webkit-background-clip: text; 
    background-clip: text; 
    -webkit-text-fill-color: transparent; 
}
.chart-gradient-2 { 
    color: #f97316; 
    background: linear-gradient(45deg, #f97316, #fb923c); 
    -webkit-background-clip: text; 
    background-clip: text; 
    -webkit-text-fill-color: transparent; 
}
.chart-gradient-3 { 
    color: #eab308; 
    background: linear-gradient(45deg, #eab308, #fbbf24); 
    -webkit-background-clip: text; 
    background-clip: text; 
    -webkit-text-fill-color: transparent; 
}
.chart-gradient-4 { 
    color: #22c55e; 
    background: linear-gradient(45deg, #22c55e, #4ade80); 
    -webkit-background-clip: text; 
    background-clip: text; 
    -webkit-text-fill-color: transparent; 
}
.chart-gradient-5 { 
    color: #3b82f6; 
    background: linear-gradient(45deg, #3b82f6, #60a5fa); 
    -webkit-background-clip: text; 
    background-clip: text; 
    -webkit-text-fill-color: transparent; 
}
.chart-gradient-6 { 
    color: #a855f7; 
    background: linear-gradient(45deg, #a855f7, #c084fc); 
    -webkit-background-clip: text; 
    background-clip: text; 
    -webkit-text-fill-color: transparent; 
}

/* สีเย็น (Cool Colors) */
.chart-cyan { color: #06b6d4; }
.chart-teal { color: #14b8a6; }

/* สีโทนเทา (Monochrome) */
.chart-dark { color: #1f2937; }
.chart-gray { color: #6b7280; }
.chart-light { color: #9ca3af; }
.chart-lighter { color: #d1d5db; }

/* Chart Circle & Dot Elements */
.chart-circle, .chart-dot {
    font-weight: bold;
    display: inline;
    transition: all 0.3s ease;
}

.chart-circle:hover, .chart-dot:hover {
    transform: scale(1.2);
    filter: brightness(1.2);
}

/* Chart Line Elements */
.chart-line-h, .chart-cross {
    font-weight: bold;
    transition: all 0.3s ease;
}

/* Chart Legend */
.chart-legend {
    display: flex;
    flex-wrap: wrap;
    gap: 12px;
    margin-top: 16px;
    padding: 12px;
    background: rgba(255, 255, 255, 0.5);
    border-radius: 8px;
    backdrop-filter: blur(10px);
}

.legend-item {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 12px;
    color: #374151;
}

.legend-color {
    width: 12px;
    height: 12px;
    border-radius: 50%;
    border: 1px solid rgba(0, 0, 0, 0.1);
}

/* Chart Controls */
.chart-controls {
    display: flex;
    gap: 8px;
    margin-top: 12px;
    padding: 8px;
    background: rgba(255, 255, 255, 0.8);
    border-radius: 6px;
    backdrop-filter: blur(5px);
}

.chart-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 32px;
    height: 32px;
    border: none;
    border-radius: 6px;
    background: rgba(255, 107, 53, 0.1);
    color: #ff6b35;
    cursor: pointer;
    transition: all 0.3s ease;
    position: relative;
}

.chart-btn:hover {
    background: rgba(255, 107, 53, 0.2);
    transform: scale(1.05);
}

.chart-btn:active {
    transform: scale(0.95);
}

/* Chart Tooltip */
.chart-tooltip {
    position: absolute;
    top: -40px;
    left: 50%;
    transform: translateX(-50%);
    background: #1f2937;
    color: white;
    padding: 6px 12px;
    border-radius: 6px;
    font-size: 12px;
    white-space: nowrap;
    opacity: 0;
    transition: all 0.3s ease;
    pointer-events: none;
    z-index: 1000;
}

.chart-tooltip::before {
    content: '';
    position: absolute;
    top: 100%;
    left: 50%;
    transform: translateX(-50%);
    border: 5px solid transparent;
    border-top-color: #1f2937;
}

.chart-tooltip.show {
    opacity: 1;
    transform: translateX(-50%) translateY(-5px);
}

/* Chart Themes */
.ai-chart-container.theme-dark {
    background: #1f2937;
    border-color: #374151;
}

.ai-chart-container.theme-dark .ai-chart-ascii {
    background: #111827;
    color: #f9fafb;
    border-color: #374151;
}

.ai-chart-container.theme-dark .chart-axis {
    color: #9ca3af;
}

.ai-chart-container.theme-neon {
    background: #0a0a0a;
    border: 2px solid #00ff88;
    box-shadow: 0 0 20px rgba(0, 255, 136, 0.3);
}

.ai-chart-container.theme-neon .ai-chart-ascii {
    background: #000000;
    color: #00ff88;
    border-color: #00ff88;
}

.ai-chart-container.theme-neon .chart-block {
    color: #00ff88;
    text-shadow: 0 0 10px #00ff88;
}

.ai-chart-container.theme-pastel {
    background: linear-gradient(135deg, #fef7cd, #fecaca, #ddd6fe);
    border: none;
}

.ai-chart-container.theme-pastel .ai-chart-ascii {
    background: rgba(255, 255, 255, 0.8);
    backdrop-filter: blur(10px);
}

.ai-chart-container.theme-pastel .chart-block {
    text-shadow: none;
}

/* Chart Axis */
.chart-axis {
    color: #475569;
    font-weight: 600;
    text-shadow: none;
}

/* Responsive Chart */
@media (max-width: 767px) {
    .ai-chart-container {
        margin: 12px 0;
        padding: 16px;
        border-radius: 8px;
    }
    
    .ai-chart-ascii {
        font-size: 14px;
        padding: 16px;
        line-height: 1.3;
        overflow-x: auto;
    }
    
    .chart-line {
        min-height: 1.3em;
    }
    
    .chart-legend {
        gap: 8px;
        margin-top: 12px;
        padding: 8px;
    }
    
    .legend-item {
        font-size: 11px;
    }
    
    .chart-controls {
        gap: 6px;
        margin-top: 8px;
        padding: 6px;
        flex-wrap: wrap;
    }
    
    .chart-btn {
        width: 28px;
        height: 28px;
    }
    
    .chart-btn svg {
        width: 14px;
        height: 14px;
    }
}

@media (max-width: 480px) {
    .ai-chart-container {
        padding: 12px;
        margin: 8px 0;
    }
    
    .ai-chart-ascii {
        font-size: 12px;
        padding: 12px;
        line-height: 1.2;
    }
    
    .chart-line {
        min-height: 1.2em;
    }
    
    .chart-legend {
        flex-direction: column;
        gap: 6px;
        margin-top: 8px;
        padding: 6px;
    }
    
    .legend-item {
        font-size: 10px;
    }
    
    .legend-color {
        width: 10px;
        height: 10px;
    }
    
    .chart-controls {
        justify-content: center;
        gap: 4px;
        margin-top: 6px;
        padding: 4px;
    }
    
    .chart-btn {
        width: 24px;
        height: 24px;
    }
    
    .chart-btn svg {
        width: 12px;
        height: 12px;
    }
    
    .chart-tooltip {
        font-size: 10px;
        padding: 4px 8px;
        top: -35px;
    }
}

/* Animation keyframes */
@keyframes chartPulse {
    0% { transform: scale(1); }
    50% { transform: scale(1.05); }
    100% { transform: scale(1); }
}

@keyframes chartGlow {
    0% { text-shadow: 0 0 5px currentColor; }
    50% { text-shadow: 0 0 20px currentColor, 0 0 30px currentColor; }
    100% { text-shadow: 0 0 5px currentColor; }
}

/* Interactive states */
.chart-block.animated {
    animation: chartPulse 0.6s ease-in-out;
}

.ai-chart-container.theme-neon .chart-block.animated {
    animation: chartGlow 0.8s ease-in-out;
}
