/* style.css - Version 5.6 */

/* --- Default Theme (Base Styles) --- */
body {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
    background-color: #f4f7f9;
    color: #333;
    margin: 0;
    padding: 20px;
    display: flex;
    justify-content: center;
    align-items: flex-start;
    min-height: 100vh;
    transition: background-color 0.3s, color 0.3s;
}
.container { width: 100%; max-width: 1200px; background-color: #ffffff; border-radius: 8px; box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1); padding: 2rem; transition: background-color 0.3s, box-shadow 0.3s; }

/* Annotation: Changed header layout to Flexbox to fix control overlap. */
header {
    display: flex;
    flex-direction: column;
    align-items: center;
    border-bottom: 1px solid #e0e0e0;
    padding-bottom: 1.5rem;
    margin-bottom: 1.5rem;
}
.header-controls {
    order: -1; /* Move this element to the top of the flex container */
    align-self: flex-end; /* Push it to the right edge */
    display: flex;
    align-items: center;
    gap: 1rem;
    margin-bottom: 1rem; /* Add space between controls and title */
}

h1 { color: #1a202c; margin: 0; }
.app { display: flex; flex-direction: column; gap: 1.5rem; }
.settings-btn { background-color: #6b7280; font-size: 0.9rem; padding: 8px 16px; }
.settings-btn:hover { background-color: #4b5563; }
.modal-overlay { position: fixed; top: 0; left: 0; width: 100%; height: 100%; background-color: rgba(0, 0, 0, 0.6); z-index: 2000; display: flex; justify-content: center; align-items: center; }
.modal-content { background: #fff; padding: 2rem; border-radius: 8px; box-shadow: 0 5px 15px rgba(0,0,0,0.3); width: 90%; max-width: 600px; display: flex; flex-direction: column; max-height: 80vh; }
.modal-header { display: flex; justify-content: space-between; align-items: center; border-bottom: 1px solid #e2e8f0; padding-bottom: 1rem; margin-bottom: 1rem; flex-shrink: 0; }
.modal-header h2 { margin: 0; }
.close-btn { font-size: 2rem; font-weight: bold; color: #6b7280; background: none; border: none; cursor: pointer; line-height: 1; padding: 0; }
.modal-body { overflow-y: hidden; display: flex; flex-direction: column; }
#customActionsList { overflow-y: auto; flex-grow: 1; padding-right: 1rem; }
.new-action-form { display: flex; flex-direction: column; gap: 1rem; margin-top: 1.5rem; padding-top: 1.5rem; border-top: 1px solid #e2e8f0; flex-shrink: 0; }
.new-action-form input, .new-action-form textarea { width: 100%; padding: 10px; border: 1px solid #cbd5e0; border-radius: 6px; font-size: 1rem; box-sizing: border-box; }
.new-action-form textarea { height: 100px; resize: vertical; }
.new-action-form small { color: #6b7280; }
.new-action-form button { align-self: flex-end; }
#customActionsList .action-item { display: flex; justify-content: space-between; align-items: center; padding: 0.75rem 0; border-bottom: 1px solid #e2e8f0; }
#customActionsList .action-details { display: flex; flex-direction: column; }
#customActionsList .action-name { font-weight: bold; }
#customActionsList .action-prompt { font-style: italic; color: #6b7280; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 300px; }
.delete-action-btn { background-color: #e53e3e; font-size: 0.8rem; padding: 6px 12px; }
.delete-action-btn:hover { background-color: #c53030; }
.io-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 1.5rem; }
.textarea-container { display: flex; flex-direction: column; position: relative; }
label { font-weight: 600; margin-bottom: 0.5rem; color: #4a5568; }
textarea { width: 100%; height: 250px; padding: 12px; border: 1px solid #cbd5e0; border-radius: 6px; font-size: 1rem; line-height: 1.5; resize: vertical; box-sizing: border-box; background-color: #fff; color: #333; }
.counter { text-align: right; font-size: 0.85rem; color: #6b7280; padding-top: 0.5rem; height: 1.2em; }
textarea:focus { outline: none; border-color: #4299e1; box-shadow: 0 0 0 2px rgba(66, 153, 225, 0.5); }
.controls { display: flex; justify-content: center; align-items: center; gap: 1rem; flex-wrap: wrap; }
.ai-controls { display: flex; align-items: center; gap: 1rem; padding: 0.5rem; border: 1px solid #e2e8f0; border-radius: 8px; background-color: #f7fafc; }
.control-group { display: flex; align-items: center; gap: 0.5rem; }
.hidden { display: none !important; }
select { padding: 10px; border: 1px solid #cbd5e0; border-radius: 6px; font-size: 0.9rem; background-color: #fff; cursor: pointer; }
select:focus { outline: none; border-color: #4299e1; box-shadow: 0 0 0 2px rgba(66, 153, 225, 0.5); }
button { background-color: #2d3748; color: white; padding: 12px 24px; border: none; border-radius: 6px; font-size: 1rem; font-weight: 600; cursor: pointer; transition: background-color 0.2s ease, color 0.2s ease, border-color 0.2s ease; }
button:hover { background-color: #1a202c; }
.copy-btn { position: absolute; top: 30px; right: 0; background-color: #4a5568; padding: 6px 12px; font-size: 0.8rem; margin: 8px; }
.copy-btn:hover { background-color: #2d3748; }
.rephrase-btn { background-color: #38a169; }
.rephrase-btn:hover { background-color: #2f855a; }
.clear-btn { background-color: #6b7280; }
.clear-btn:hover { background-color: #4b5563; }
.results-container { background-color: #f7fafc; border: 1px solid #e2e8f0; border-radius: 6px; margin-top: 1rem; }
.tabs-nav { display: flex; border-bottom: 1px solid #e2e8f0; }
.tab-btn { background: none; border: none; padding: 1rem 1.5rem; cursor: pointer; font-size: 1rem; font-weight: 600; color: #4a5568; border-bottom: 3px solid transparent; margin-bottom: -1px; }
.tab-btn.active { color: #2d3748; border-bottom-color: #4299e1; }
.tabs-content { padding: 1.5rem; }
.tab-panel { display: none; }
.tab-panel.active { display: block; }
.tab-panel h3, .history-header h3, .modal-header h2 { margin-top: 0; color: #2d3748; }
.tab-panel ul, #historyList { padding-left: 20px; margin-bottom: 0; }
.tab-panel li { margin-bottom: 0.5rem; }
.tab-panel code { background-color: #e2e8f0; padding: 2px 6px; border-radius: 4px; font-family: "SFMono-Regular", Consolas, "Liberation Mono", Menlo, Courier, monospace; }
.tab-panel h4 { margin-top: 0; }
.history-container { background-color: #f7fafc; border: 1px solid #e2e8f0; border-radius: 6px; padding: 1rem; margin-top: 1.5rem; }
.history-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 1rem; }
.clear-history-btn { background-color: #e53e3e; padding: 6px 12px; font-size: 0.8rem; }
.clear-history-btn:hover { background-color: #c53030; }
#historyList { list-style: none; padding: 0; margin: 0; }
#historyList li { display: flex; justify-content: space-between; align-items: center; padding: 0.75rem 0; border-bottom: 1px solid #e2e8f0; }
#historyList li:last-child { border-bottom: none; }
.history-text { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; margin-right: 1rem; color: #4a5568; }
.restore-btn { background-color: #4a5568; padding: 6px 12px; font-size: 0.8rem; flex-shrink: 0; }
.restore-btn:hover { background-color: #2d3748; }
.loading-overlay { position: fixed; top: 0; left: 0; width: 100%; height: 100%; background-color: rgba(255, 255, 255, 0.7); display: none; justify-content: center; align-items: center; z-index: 1000; }
.spinner { border: 6px solid #f3f3f3; border-top: 6px solid #3498db; border-radius: 50%; width: 50px; height: 50px; animation: spin 1s linear infinite; }
@keyframes spin { 0% { transform: rotate(0deg); } 100% { transform: rotate(360deg); } }
footer { text-align: center; margin-top: 2rem; color: #a0aec0; font-size: 0.9rem; }
@media (max-width: 900px) { .io-grid { grid-template-columns: 1fr; } .controls, .ai-controls { flex-direction: column; align-items: stretch; } .ai-controls .rephrase-btn { width: 100%; justify-content: center; } .header-controls { align-self: stretch; flex-direction: column; margin-bottom: 1rem;} }

/* --- Theme Overrides --- */
body.theme-terminal { font-family: 'VT323', monospace; background-color: #000; color: #39FF14; }
.theme-terminal .container { background-color: #0a0a0a; border: 2px solid #39FF14; border-radius: 0; box-shadow: 0 0 15px #39FF1433; }
.theme-terminal h1, .theme-terminal h2, .theme-terminal h3 { color: #39FF14; text-shadow: 0 0 5px #39FF14; }
.theme-terminal header { border-color: #39FF14; }
.theme-terminal label, .theme-terminal p, .theme-terminal small { color: #39FF14; }
.theme-terminal textarea, .theme-terminal select, .theme-terminal input { background-color: #000; color: #39FF14; border: 1px solid #39FF14; border-radius: 0; }
.theme-terminal textarea:focus, .theme-terminal select:focus, .theme-terminal input:focus { box-shadow: 0 0 5px #39FF14; border-color: #39FF14; }
.theme-terminal button { background-color: #39FF14; color: #000; border-radius: 0; border: 1px solid #39FF14; font-family: 'VT323', monospace; }
.theme-terminal .ai-controls, .theme-terminal .results-container, .theme-terminal .history-container, .theme-terminal .modal-content { background-color: #050505; border-color: #39FF14; }
body.theme-pop-art { font-family: 'Bangers', cursive; background-color: #FFD700; background-image: radial-gradient(#00FFFF 15%, transparent 15%); background-size: 30px 30px; letter-spacing: 2px; }
.theme-pop-art .container { background-color: #fff; border: 4px solid #000; border-radius: 0; box-shadow: 10px 10px 0px #000; }
.theme-pop-art h1, .theme-pop-art h2, .theme-pop-art h3 { color: #000; -webkit-text-stroke: 2px #FF00FF; }
.theme-pop-art header { border-color: #000; }
.theme-pop-art textarea, .theme-pop-art select, .theme-pop-art input { font-family: sans-serif; border: 2px solid #000; border-radius: 0; }
.theme-pop-art textarea:focus, .theme-pop-art select:focus, .theme-pop-art input:focus { box-shadow: 0 0 0 3px #FF00FF; }
.theme-pop-art button { background-color: #FF00FF; color: #fff; border-radius: 0; border: 2px solid #000; box-shadow: 4px 4px 0px #000; font-family: 'Bangers', cursive; }
.theme-pop-art .rephrase-btn { background-color: #00FFFF; color: #000; }
.theme-pop-art .ai-controls, .theme-pop-art .results-container, .theme-pop-art .history-container, .theme-pop-art .modal-content { border: 2px solid #000; }
body.theme-natural-wood { font-family: 'Merriweather', serif; background-image: url('https://www.transparenttextures.com/patterns/wood-pattern.png'); background-color: #6B4F35; }
.theme-natural-wood .container { background-color: rgba(245, 245, 220, 0.9); border: 5px solid #8B4513; box-shadow: 0 0 20px rgba(0,0,0,0.5), inset 0 0 15px rgba(0,0,0,0.3); }
.theme-natural-wood h1, .theme-natural-wood h2, .theme-natural-wood h3 { color: #5C4033; }
.theme-natural-wood header { border-color: #8B4513; }
.theme-natural-wood textarea, .theme-natural-wood select, .theme-natural-wood input { background-color: #FAF3E0; border-color: #A0522D; box-shadow: inset 2px 2px 5px rgba(0,0,0,0.2); }
.theme-natural-wood button { background-color: #8B4513; color: #fff; border: 1px solid #5C4033; border-radius: 4px; box-shadow: 0 2px 3px rgba(0,0,0,0.4); }
.theme-natural-wood .rephrase-btn { background-color: #006400; }
.theme-natural-wood .ai-controls, .theme-natural-wood .results-container, .theme-natural-wood .history-container, .theme-natural-wood .modal-content { background-color: rgba(210, 180, 140, 0.7); border-color: #8B4513; }
body.theme-victorian { font-family: 'EB Garamond', serif; background-image: url('https://www.transparenttextures.com/patterns/old-paper.png'); background-color: #F3E5AB; }
.theme-victorian .container { background-color: #FAF0E6; border: 10px solid transparent; border-image: url('https://i.imgur.com/7H25gso.png') 30 stretch; box-shadow: 0 0 20px rgba(0,0,0,0.5); }
.theme-victorian h1 { font-family: 'Merriweather', serif; font-weight: bold; color: #5A2A27; }
.theme-victorian h2, .theme-victorian h3 { color: #5A2A27; border-bottom: 1px solid #CD7F32; padding-bottom: 5px; }
.theme-victorian header { border: none; }
.theme-victorian textarea, .theme-victorian select, .theme-victorian input { background-color: #FDF5E6; border-color: #CD7F32; }
.theme-victorian button { background: linear-gradient(#CD7F32, #8B4513); color: #fff; border: 1px solid #5A2A27; font-family: 'EB Garamond', serif; text-shadow: 1px 1px #000; }
.theme-victorian .rephrase-btn { background: linear-gradient(#006400, #556B2F); }
.theme-victorian .ai-controls, .theme-victorian .results-container, .theme-victorian .history-container, .theme-victorian .modal-content { background-color: rgba(205, 127, 50, 0.1); }