/* ===== BASE STYLES ===== */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
}

body, html {
    height: 100%;
    background: #000000;
    color: #ffffff;
}

/* ===== HEADER ===== */
header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 12px 16px;
    background: #000000;
    height: 48px;
    border-bottom: 1px solid #1a1a1a;
}

.header-title {
    font-size: 1rem;
    font-weight: 600;
    color: #ffffff;
}

.user-id-display {
    color: #666666;
    font-size: 0.85rem;
}

/* ===== CHAT CONTAINER ===== */
#chat-container {
    display: flex;
    flex-direction: column;
    height: calc(100vh - 48px);
    background: #000000;
}

#chat {
  overflow-y: auto;
  max-height: calc(100vh - 200px);
}

/* ===== MESSAGES AREA ===== */
.messages {
    flex: 1;
    overflow-y: auto;
    padding: 16px;
    background: #000000;
    display: flex;
    flex-direction: column;
    gap: 12px;
}

/* ===== ENHANCED MESSAGE STYLING ===== */
.message {
    display: flex;
    flex-direction: column;
    max-width: 95%;
    position: relative;
    margin: 8px 0;
}

.message.user {
    align-self: flex-end;
}

.message.assistant {
    align-self: flex-start;
}

.message-content {
    background: #111111;
    color: #ffffff;
    padding: 16px 20px;
    border-radius: 16px;
    line-height: 1.6;
    word-wrap: break-word;
    font-size: 0.95rem;
    max-height: 300px;
    overflow-y: auto;
    border: 1px solid #1a1a1a;
    position: relative;
}

.message.user .message-content {
    border-right: 1px solid #111;
    border-bottom-right-radius: 4px;
}

.message.assistant .message-content {
    border-left: 1px solid #111;
    border-bottom-left-radius: 4px;
}

/* ===== ENHANCED CODE BLOCK STYLING - FIXED COLORS ===== */
.message-content pre {
    background: #0d1117;
    border: 1px solid #30363d;
    border-radius: 8px;
    margin: 12px 0;
    overflow: hidden;
    position: relative;
}

.message-content code {
    display: block;
    padding: 16px;
    overflow-x: auto;
    font-family: 'Consolas', 'Monaco', 'Courier New', monospace;
    font-size: 0.85rem;
    line-height: 1.5;
    /* FIXED: Harmonis dengan orange button - warm grey dengan hint orange */
    color: #e8ddd4;
    white-space: pre;
}

/* Inline code - subtle orange tint */
.message-content p code,
.message-content li code {
    display: inline;
    background: #21262d;
    /* FIXED: Soft orange untuk inline code */
    color: #ffb894;
    padding: 2px 6px;
    border-radius: 4px;
    font-size: 0.88rem;
    border: 1px solid #30363d;
}

/* Code block with language header */
.code-block {
    position: relative;
    margin: 12px 0;
}

.code-header {
    background: #21262d;
    color: #7d8590;
    padding: 8px 16px;
    font-size: 0.8rem;
    font-weight: 600;
    border-bottom: 1px solid #30363d;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

/* FIXED: Copy button dengan visibility yang lebih baik */
.code-copy-btn {
    background: transparent;
    border: 1px solid #30363d;
    color: #7d8590;
    padding: 4px 8px;
    border-radius: 4px;
    cursor: pointer;
    font-size: 0.75rem;
    transition: all 0.2s;
    opacity: 0.8;
}

.code-copy-btn:hover {
    background: #30363d;
    color: #ff7b54;
    opacity: 1;
    border-color: #ff7b54;
}

.code-copy-btn.copied {
    background: #ff7b54;
    color: #ffffff;
    border-color: #ff7b54;
    opacity: 1;
}

/* ===== COPY BUTTON FOR MESSAGES ===== */
.copy-btn {
    position: absolute;
    top: 8px;
    right: 8px;
    background: rgba(0, 0, 0, 0.8);
    border: 1px solid #30363d;
    color: #7d8590;
    padding: 6px 8px;
    border-radius: 4px;
    cursor: pointer;
    font-size: 0.8rem;
    opacity: 0;
    transition: all 0.2s;
}

.message:hover .copy-btn {
    opacity: 1;
}

.copy-btn:hover {
    background: rgba(48, 54, 61, 0.9);
    color: #ff7b54;
    border-color: #ff7b54;
}

/* ===== ENHANCED TIMESTAMP ===== */
.message-time {
    font-size: 0.75rem;
    color: #7d8590;
    margin-top: 6px;
    padding: 0 4px;
    background: rgba(13, 17, 23, 0.8);
    border-radius: 12px;
    display: inline-block;
    align-self: flex-end;
    backdrop-filter: blur(4px);
    border: 1px solid rgba(48, 54, 61, 0.3);
}

.message.user .message-time {
    align-self: flex-end;
    text-align: right;
}

.message.assistant .message-time {
    align-self: flex-start;
    text-align: left;
}

/* ===== ENHANCED INPUT AREA ===== */
.input-area {
    position: relative;
    padding: 12px;
    background: #000000;
    border-top: 1px solid #1a1a1a;
    display: flex;
    align-items: flex-end;
    gap: 8px;
}

#messageInput {
    flex: 1;
    padding: 12px 16px;
    border-radius: 12px;
    background: #0d1117;
    color: #ffffff;
    font-size: 1rem;
    outline: none;
    resize: none;
    min-height: 40px;
    max-height: 200px;
    overflow-y: auto;
    line-height: 1.4;
    font-family: inherit;
    transition: all 0.2s;
    border: none
}

#messageInput:focus {
    background: #161b22;
    border-color: #ff7b54;
    box-shadow: 0 0 0 2px rgba(255, 123, 84, 0.1);
}

#messageInput::placeholder {
    color: rgba(255, 255, 255, 0.15);
}

/* Auto-resize textarea styling */
#messageInput::-webkit-scrollbar {
    width: 6px;
}

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

#messageInput::-webkit-scrollbar-thumb {
    background: #30363d;
    border-radius: 3px;
}

#messageInput::-webkit-scrollbar-thumb:hover {
     background: #484f58;
}

.send-button {
    width: 44px;
    height: 44px;
    border: none;
    border-radius: 12px;
    background: #ff7b54;
    color: #ffffff;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s;
    flex-shrink: 0;
}

.send-button:hover:not(:disabled) {
    background: #ff9575;
    transform: translateY(-1px);
}

.send-button:disabled {
    background: #21262d;
    cursor: not-allowed;
    transform: none;
}

/* ===== MINIMAL STATUS - HIDDEN READY STATE ===== */
.status {
    height: 1px;
    background: #1a1a1a;
    transition: all 0.3s ease;
    /* FIXED: Hide status when ready */
    opacity: 0;
}

.status.loading {
    background: #ff7b54;
    opacity: 0.3;
}

.status.error {
    background: rgba(255, 68, 68, 0.5);
    opacity: 1;
}

/* Status text - hide when ready */
.status:not(.loading):not(.error) {
    color: transparent;
    height: 0;
}

/* ===== MARKDOWN ENHANCEMENTS ===== */
.message-content h1, .message-content h2, .message-content h3,
.message-content h4, .message-content h5, .message-content h6 {
    color: #e6edf3;
    margin: 16px 0 8px 0;
    font-weight: 600;
}

.message-content h1 { font-size: 1.5rem; border-bottom: 1px solid #30363d; padding-bottom: 8px; }
.message-content h2 { font-size: 1.3rem; }
.message-content h3 { font-size: 1.1rem; }

.message-content ul, .message-content ol {
    margin: 8px 0;
    padding-left: 20px;
}

.message-content li {
    margin: 4px 0;
}

.message-content blockquote {
    border-left: 4px solid #ff7b54;
    margin: 12px 0;
    padding: 8px 16px;
    background: rgba(255, 123, 84, 0.05);
    border-radius: 0 8px 8px 0;
    color: #e6edf3;
}

.message-content a {
    color: #58a6ff;
    text-decoration: none;
}

.message-content a:hover {
    text-decoration: underline;
}

.message-content table {
    border-collapse: collapse;
    margin: 12px 0;
    width: 100%;
}

.message-content th, .message-content td {
    border: 1px solid #30363d;
    padding: 8px 12px;
    text-align: left;
}

.message-content th {
    background: #21262d;
    font-weight: 600;
}

/* ===== SCROLLBARS ===== */
.messages::-webkit-scrollbar {
    width: 6px;
}

.messages::-webkit-scrollbar-track {
    background: #0d1117;
}

.messages::-webkit-scrollbar-thumb {
    background: #30363d;
    border-radius: 3px;
}

.messages::-webkit-scrollbar-thumb:hover {
    background: #484f58;
}

/* ===== RESPONSIVE ===== */
@media (max-width: 768px) {
    .message {
        max-width: 95%;
    }
    
    .message-content {
        padding: 12px 16px;
        font-size: 0.9rem;
    }
    
    #messageInput {
        font-size: 16px; /* Prevent zoom on iOS */
    }
}
