/* --- Global & Dark Mode Theme --- */
html, body {
    height: 100%;
    margin: 0;
    padding: 0;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
    background-color: #121212;
    color: #e0e0e0;
    font-size: 16px;
}

h1 {
    color: #bb86fc;
    text-align: center;
    margin-bottom: 25px;
}

/* --- Main Translator Page (chat.html/index.php) --- */
#chat-container {
    width: 100%;
    height: 100vh;
    background-color: #121212;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

#header-area {
    padding: 16px 20px;
    background-color: #1e1e1e;
    color: #e0e0e0;
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-shrink: 0;
    border-bottom: 1px solid #3f3f3f;
}
#header-area h4 { margin: 0; font-weight: 600; font-size: 1.3em; }

/* MODIFIED: Header buttons to align icons and text */
.header-buttons { display: flex; align-items: center; }
.header-buttons a { 
    display: inline-flex; 
    align-items: center;
    color: #e0e0e0; 
    text-decoration: none; 
    font-size: 0.9em; 
    font-weight: 500; 
    padding: 6px 12px; 
    border: 1px solid #555; 
    border-radius: 20px; 
    transition: all 0.2s; 
    margin-left: 10px; 
}
.header-buttons a:hover {
    background-color: #007acc;
    border-color: #007acc;
    color: #fff;
}
.btn-icon { margin-right: 5px; font-size: 1.1em; } /* Space between icon and text */

#options-area { display: flex; flex-wrap: wrap; justify-content: space-between; gap: 15px; padding: 15px 20px; background-color: #1e1e1e; border-bottom: 1px solid #333; flex-shrink: 0; align-items: center; }
.language-switcher { display: flex; align-items: center; gap: 10px; flex-grow: 2; min-width: 250px; }
.language-arrow { color: #888; font-size: 1.5em; font-weight: bold; }
.option-group { flex: 1; min-width: 150px; }
.option-group input, .option-group select { width: 100%; padding: 8px 10px; border: 1px solid #444; border-radius: 4px; font-size: 0.95em; box-sizing: border-box; background-color: #2a2a2a; color: #e0e0e0; }

#status-messages { padding: 0; margin: 0; flex-shrink: 0; }
.status-message.error { background-color: #cf6679; color: #121212; font-weight: bold; padding: 10px 20px; text-align: center; }

#chatbox { flex-grow: 1; overflow-y: auto; padding: 20px; display: flex; flex-direction: column; }

.message-wrapper { 
    display: flex; 
    align-items: center;
    gap: 8px;
    margin-bottom: 15px; 
    max-width: 100%; 
}
.message-wrapper:has(.user-message) { justify-content: flex-end; }

.message { padding: 10px 15px; border-radius: 18px; max-width: 85%; line-height: 1.5; word-wrap: break-word; box-shadow: 0 1px 4px rgba(0,0,0,0.4); }

.user-message { background-color: #007acc; color: #fff; margin-left: auto; border-bottom-right-radius: 5px; }
.bot-message { background-color: #333333; color: #e0e0e0; margin-right: auto; border-bottom-left-radius: 5px; transition: background-color 0.2s; }
.bot-message.editable { cursor: pointer; }
.bot-message.editable:hover { background-color: #444; }
.bot-message.editing { background-color: #444; border: 1px solid #bb86fc; color: #fff; }
.bot-message.thinking { font-style: italic; color: #aaa; }

#input-area { display: flex; border-top: 1px solid #333; padding: 12px 20px; background-color: #1e1e1e; flex-shrink: 0; align-items: center; }
#userInput { flex-grow: 1; padding: 12px 15px; border: 1px solid #444; border-radius: 25px; outline: none; font-size: 1em; margin-right: 10px; background-color: #2a2a2a; color: #e0e0e0; transition: border-color 0.2s; }
#userInput:focus { border-color: #007acc; }
#sendButton { padding: 0 22px; height: 44px; background-color: #007acc; color: #fff; border: none; border-radius: 25px; cursor: pointer; font-weight: 500; transition: background-color 0.2s;}
#sendButton:hover { background-color: #005c9e; }
#sendButton:disabled { background-color: #444; color: #888; cursor: not-allowed; }

/* --- Feature-Specific Styles --- */
.resend-btn {
    background: none;
    border: none;
    color: #666;
    font-size: 1.2em;
    cursor: pointer;
    padding: 5px;
    border-radius: 50%;
    opacity: 0;
    transition: opacity 0.2s, color 0.2s, background-color 0.2s;
    order: 1;
}
.message-wrapper:has(.user-message) .resend-btn { order: -1; }
.message-wrapper:hover .resend-btn { opacity: 1; }
.resend-btn:hover { color: #e0e0e0; background-color: #333; }

#stopBtn { display: none; background-color: #cf6679; margin-left: 10px; color: #121212; font-weight: bold; }

.collapsible-header { display: flex; justify-content: space-between; align-items: center; cursor: pointer; }
.collapse-arrow { transition: transform 0.3s ease; display: inline-block; }
.collapsible-content { max-height: 0; overflow: hidden; transition: max-height 0.3s ease-out; border-top: 1px solid rgba(255,255,255,0.1); margin-top: 10px; padding-top: 10px; }
.collapsible-user-message.expanded .collapsible-content { max-height: 500px; overflow-y: auto; }
.collapsible-user-message.expanded .collapse-arrow { transform: rotate(90deg); }

/* --- Settings & Saved Chats Pages --- */
.container { max-width: 700px; background: #1e1e1e; padding: 25px 30px; border-radius: 8px; box-shadow: 0 4px 15px rgba(0,0,0,0.5); margin: 20px auto; border: 1px solid #333; }
.chat-list, .prompt-list { list-style: none; padding: 0; }
.chat-item, .prompt-item { display: flex; justify-content: space-between; align-items: center; padding: 15px; border-bottom: 1px solid #333; }
.chat-item:hover { background-color: #2a2a2a; }
.chat-name, .prompt-text { font-weight: 600; font-size: 1.1em; color: #e0e0e0; margin-right: 15px; word-break: break-word; }
.chat-info { font-size: 0.9em; color: #aaa; }
.actions a, .actions button { text-decoration: none; margin-left: 10px; padding: 6px 12px; border-radius: 6px; font-weight: 500; cursor: pointer; border: 1px solid transparent; transition: background-color 0.2s; }
.load-btn { background-color: #007acc; color: #fff; }
.load-btn:hover { background-color: #005c9e; }
.delete-btn, .btn-danger { background-color: #cf6679; color: #121212; font-weight: bold; font-size: 0.9em; padding: 5px 10px;}
.delete-btn:hover, .btn-danger:hover { background-color: #b00020; }
.form-group { margin-bottom: 20px; }
.form-group label { color: #aaa; display: block; font-weight: 600; margin-bottom: 5px; }
.form-group input[type="text"], .form-group textarea, .form-group select { width: 100%; padding: 10px; box-sizing: border-box; background-color: #2a2a2a; color: #e0e0e0; border: 1px solid #444; border-radius: 4px; font-family: inherit; }
.btn { padding: 10px 20px; border: none; border-radius: 6px; cursor: pointer; font-weight: 500; font-size: 1em; transition: background-color 0.2s; }
.btn-primary { background-color: #007acc; color: #fff; }
.btn-primary:hover { background-color: #005c9e; }
hr { border: 0; border-top: 1px solid #333; margin: 30px 0; }
.nav-link { color: #bb86fc; text-decoration: none; font-weight: 600; display: block; text-align: center; margin-top: 25px; }
.nav-link:hover { text-decoration: underline; }

/* =======================================================
   NEW: MOBILE RESPONSIVENESS (Phones/Small Screens)
   ======================================================= */
@media (max-width: 650px) {
    /* Compress the header area */
    #header-area { padding: 12px 15px; }
    #header-area h4 { font-size: 1.1em; }
    
    /* Change buttons into pure icons without borders */
    .header-buttons a {
        padding: 8px;
        margin-left: 5px;
        border: none;
        border-radius: 50%;
        background-color: transparent;
    }
    .header-buttons a:hover {
        background-color: #333;
    }
    /* Hide the text, slightly enlarge the icon */
    .btn-text { display: none; }
    .btn-icon { margin-right: 0; font-size: 1.3em; }

    /* Make the options area stack vertically on phones so inputs don't squish */
    #options-area { flex-direction: column; align-items: stretch; padding: 10px 15px; gap: 10px; }
    .language-switcher { width: 100%; justify-content: space-between; }
    .language-switcher .option-group { flex: 1; }
    #instruction-group { width: 100%; }
    .toggle-switch { transform: scale(0.9); } /* Slightly shrink toggle on mobile */
    
    /* Make the input bar look nicer on mobile */
    #input-area { padding: 10px; }
    #userInput { padding: 10px 15px; }
    #sendButton { padding: 0 15px; height: 40px; }
}