/* styles.css - Modern SaaS Theme for ContextAI */

/* --- 1. Variables & Base --- */
@import url('https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700&display=swap');

:root {
  /* Palette: Indigo & Slate */
  --primary: #4f46e5;       /* Indigo 600 */
  --primary-hover: #4338ca; /* Indigo 700 */
  --primary-light: #e0e7ff; /* Indigo 100 */
  
  --bg-body: #f8fafc;       /* Slate 50 */
  --bg-card: #ffffff;
  --bg-input: #ffffff;
  
  --text-main: #0f172a;     /* Slate 900 */
  --text-secondary: #475569;/* Slate 600 */
  --text-muted: #94a3b8;    /* Slate 400 */
  
  --border: #e2e8f0;        /* Slate 200 */
  --border-focus: #6366f1;  /* Indigo 500 */
  
  --shadow-sm: 0 1px 2px 0 rgb(0 0 0 / 0.05);
  --shadow-md: 0 4px 6px -1px rgb(0 0 0 / 0.1), 0 2px 4px -2px rgb(0 0 0 / 0.1);
  --shadow-lg: 0 10px 15px -3px rgb(0 0 0 / 0.1), 0 4px 6px -4px rgb(0 0 0 / 0.1);
  
  --radius-sm: 8px;
  --radius-md: 12px;
  --radius-lg: 16px;
  
  --header-height: 70px;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: 'Inter', system-ui, -apple-system, sans-serif;
  background: var(--bg-body);
  color: var(--text-main);
  -webkit-font-smoothing: antialiased;
  line-height: 1.5;
}

a { color: var(--primary); text-decoration: none; transition: 0.2s; }
a:hover { color: var(--primary-hover); }

/* --- 2. Layout & Header --- */
.container {
  max-width: 1024px;
  margin: 0 auto;
  padding: 24px;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

/* Topbar Styling */
.topbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 12px 0 20px;
  margin-bottom: 0;
}

.left-controls {
  display: flex;
  align-items: center;
  gap: 16px;
}

.menu-btn {
  font-size: 20px;
  padding: 8px;
  border-radius: var(--radius-sm);
  border: 1px solid transparent;
  background: transparent;
  color: var(--text-secondary);
  transition: all 0.2s;
}
.menu-btn:hover { background: var(--bg-card); color: var(--primary); box-shadow: var(--shadow-sm); }

.app-title {
  margin: 0;
  font-size: 20px;
  font-weight: 700;
  letter-spacing: -0.5px;
  color: var(--text-main);
}

.header-divider {
  display: none; /* Modern designs usually avoid harsh lines, using spacing instead */
}

/* User Controls (Tokens) */
.user-controls {
  display: flex;
  align-items: center;
  gap: 12px;
}

.token-box, .remaining-box {
  padding: 6px 12px;
  background: #fff;
  border-radius: 20px;
  font-size: 13px;
  font-weight: 500;
  border: 1px solid var(--border);
  color: var(--text-secondary);
  box-shadow: var(--shadow-sm);
  display: flex;
  align-items: center;
  transition: 0.2s;
}

.token-box:hover { border-color: var(--primary); color: var(--primary); }

.small-btn {
  padding: 8px 16px;
  border-radius: 20px;
  cursor: pointer;
  font-size: 13px;
  font-weight: 600;
  background: var(--primary);
  color: #fff !important; /* Force white text */
  border: 1px solid transparent;
  transition: all 0.2s;
  box-shadow: 0 2px 5px rgba(79, 70, 229, 0.3);
}

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

/* --- 3. Mode Switcher (Tabs) --- */
.mode-switch {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 24px;
  margin-top: 8px;
  background: #e2e8f0; /* Tab track background */
  padding: 4px;
  border-radius: var(--radius-lg);
  width: fit-content;
}

.mode-switch button {
  padding: 8px 16px;
  border-radius: var(--radius-md);
  border: none;
  background: transparent;
  color: var(--text-secondary);
  font-weight: 500;
  font-size: 14px;
  cursor: pointer;
  transition: all 0.2s ease;
}

.mode-switch button:hover {
  color: var(--text-main);
}

.mode-switch button.active {
  background: #fff;
  color: var(--primary);
  box-shadow: 0 2px 4px rgba(0,0,0,0.08);
  font-weight: 600;
}

/* Language Controls & Compare Btn override */
.lang-controls {
  margin-left: auto; /* Push to right */
  display: flex;
  gap: 12px;
  align-items: center;
}

.lang-controls select {
  padding: 8px 12px;
  border-radius: var(--radius-md);
  border: 1px solid var(--border);
  background: #fff;
  font-size: 14px;
  outline: none;
  cursor: pointer;
}
.lang-controls select:focus { border-color: var(--primary); }

.compare-btn {
  padding: 8px 16px;
  border-radius: var(--radius-md);
  border: 1px solid var(--border);
  background: #fff;
  color: var(--text-secondary);
  font-weight: 500;
  font-size: 14px;
  transition: 0.2s;
}
.compare-btn:hover { border-color: var(--primary); color: var(--primary); background: var(--primary-light); }


/* --- 4. Main Content Areas --- */
main { flex: 1; }

.mode { display: none; animation: fadeIn 0.3s ease; }
.mode.active { display: block; }
@keyframes fadeIn { from { opacity: 0; transform: translateY(5px); } to { opacity: 1; transform: translateY(0); } }

/* Dialog Mode */
.dialog-list {
  background: var(--bg-card);
  padding: 20px;
  border-radius: var(--radius-md);
  min-height: 300px;
  max-height: 500px;
  overflow-y: auto;
  border: 1px solid var(--border);
  box-shadow: var(--shadow-sm);
  margin-bottom: 20px;
}

.bubble { display: flex; flex-direction: column; gap: 4px; margin-bottom: 16px; }
.bubble .meta { font-size: 11px; color: var(--text-muted); margin-left: 4px; }
.bubble .text {
  padding: 12px 16px;
  border-radius: 18px;
  background: #f1f5f9;
  color: var(--text-main);
  max-width: 85%;
  font-size: 15px;
  line-height: 1.6;
  border-bottom-left-radius: 4px;
}

.bubble.me { align-items: flex-end; }
.bubble.me .meta { margin-right: 4px; margin-left: 0; }
.bubble.me .text {
  background: var(--primary);
  color: #fff;
  border-bottom-left-radius: 18px;
  border-bottom-right-radius: 4px;
}

/* Input Area */
.input-row { display: flex; gap: 12px; align-items: flex-start; }

textarea {
  flex: 1;
  min-height: 80px;
  padding: 12px 16px;
  border-radius: var(--radius-md);
  border: 1px solid var(--border);
  font-family: inherit;
  font-size: 15px;
  resize: vertical;
  background: var(--bg-input);
  outline: none;
  transition: border-color 0.2s, box-shadow 0.2s;
}

textarea:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(79, 70, 229, 0.1);
}

.controls-col { display: flex; flex-direction: column; gap: 8px; }
.controls-col button, #sideTranslateBtn, #sideSummarizeBtn, #uploadBtn {
  padding: 10px 20px;
  border-radius: var(--radius-md);
  border: none;
  cursor: pointer;
  font-weight: 600;
  font-size: 14px;
  transition: 0.2s;
}

#sendBtn, #uploadBtn, #sideTranslateBtn {
  background: var(--primary);
  color: white;
  box-shadow: 0 2px 5px rgba(79, 70, 229, 0.3);
}
#sendBtn:hover, #uploadBtn:hover, #sideTranslateBtn:hover {
  background: var(--primary-hover);
  transform: translateY(-1px);
}

#clearListBtn, #sideSummarizeBtn {
  background: #fff;
  border: 1px solid var(--border);
  color: var(--text-secondary);
}
#clearListBtn:hover, #sideSummarizeBtn:hover {
  border-color: var(--text-muted);
  background: #f8fafc;
}

/* Side by Side Mode */
.side-wrapper { display: flex; gap: 16px; }
.side-wrapper textarea { width: 50%; min-height: 300px; }
@media (max-width: 768px) { .side-wrapper { flex-direction: column; } .side-wrapper textarea { width: 100%; } }

.side-actions { 
  margin-top: 16px; 
  display: flex; 
  justify-content: center; 
  gap: 12px; 
}
.side-summary {
  margin-top: 16px;
  padding: 16px;
  background: #fff;
  border-radius: var(--radius-md);
  border: 1px solid var(--primary-light);
  box-shadow: var(--shadow-sm);
  white-space: pre-wrap;
  border-left: 4px solid var(--primary);
}

/* Document Upload Mode */
#uploadForm {
  background: #fff;
  border: 2px dashed var(--border);
  border-radius: var(--radius-lg);
  padding: 40px;
  text-align: center;
  transition: 0.2s;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 16px;
}
#uploadForm:hover { border-color: var(--primary); background: #fdfdff; }

#fileInput {
    padding: 10px;
    background: #f1f5f9;
    border-radius: 8px;
    width: 100%;
    max-width: 400px;
}

.upload-result {
  margin-top: 20px;
  background: #fff;
  padding: 20px;
  border-radius: var(--radius-md);
  border: 1px solid var(--border);
  min-height: 150px;
  box-shadow: var(--shadow-sm);
}

/* --- 5. Navigation Sidebar --- */
.side-nav {
  position: fixed;
  top: 0; left: -320px;
  width: 280px; height: 100vh;
  background: #fff;
  box-shadow: var(--shadow-lg);
  z-index: 1300;
  transition: left 0.3s cubic-bezier(0.16, 1, 0.3, 1);
  display: flex; flex-direction: column; padding: 24px;
}
.side-nav.open { left: 0; }

.side-nav-header {
  display: flex; justify-content: space-between; align-items: center;
  margin-bottom: 24px; padding-bottom: 12px;
  border-bottom: 1px solid var(--border);
}
.side-nav-header strong { font-size: 18px; color: var(--text-main); }

.side-nav-list a {
  display: block;
  padding: 12px 16px;
  margin-bottom: 4px;
  border-radius: var(--radius-sm);
  color: var(--text-secondary);
  font-weight: 500;
}
.side-nav-list a:hover {
  background: var(--primary-light);
  color: var(--primary);
}
.side-nav-footer { margin-top: auto; text-align: center; color: var(--text-muted); font-size: 12px; }

/* Backdrop */
.side-nav-backdrop, .modal-backdrop {
  position: fixed; inset: 0;
  background: rgba(15, 23, 42, 0.4); /* Slate 900 with opacity */
  backdrop-filter: blur(2px);
  opacity: 0; pointer-events: none; transition: opacity 0.2s; z-index: 1250;
}
.side-nav-backdrop[data-hidden="false"], .modal[aria-hidden="false"] .modal-backdrop { opacity: 1; pointer-events: auto; }

/* --- 6. Modals & Extras --- */
.modal {
  position: fixed; inset: 0;
  display: none; align-items: center; justify-content: center; z-index: 1260;
}
.modal[aria-hidden="false"] { display: flex; }

.modal-panel {
  position: relative; width: 90%; max-width: 500px;
  background: #fff; padding: 32px;
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg);
  z-index: 1270;
}
.modal-panel h3 { margin-top: 0; color: var(--text-main); font-size: 20px; }

.modal-btn {
  padding: 10px 18px; border-radius: var(--radius-sm); border: 1px solid var(--border);
  background: #fff; font-weight: 500; cursor: pointer; transition: 0.2s;
}
.modal-btn:hover { background: var(--bg-body); }
.modal-btn.primary {
  background: var(--primary); color: #fff; border-color: var(--primary);
}
.modal-btn.primary:hover { background: var(--primary-hover); }

/* Compare Block */
.compare-block pre {
  background: #f8fafc; padding: 16px; border-radius: var(--radius-sm);
  border: 1px solid var(--border); font-family: 'Menlo', 'Monaco', monospace; font-size: 13px; color: var(--text-secondary);
}
.compare-block.highlight pre {
  background: #ecfdf5; border-color: #34d399; color: #064e3b;
}

/* Footer */
footer {
  margin-top: 40px; padding-top: 20px;
  border-top: 1px solid var(--border);
  color: var(--text-muted); font-size: 13px; text-align: center;
}

/* Pricing / Tiers (for Buy Page compatibility) */
.buy-card {
  max-width: 800px; margin: 40px auto; padding: 32px;
  background: #fff; border-radius: var(--radius-lg); border: 1px solid var(--border);
  box-shadow: var(--shadow-lg);
}
.tier {
  display: flex; justify-content: space-between; align-items: center;
  padding: 20px; border-radius: var(--radius-md); margin-bottom: 16px;
  border: 1px solid var(--border); transition: 0.2s; background: #fff;
}
.tier:hover { border-color: var(--primary); box-shadow: var(--shadow-sm); }
.tier.selected {
  border-color: var(--primary); background: var(--primary-light);
  box-shadow: 0 0 0 2px var(--primary);
}
.choose-btn {
  background: var(--text-main); color: #fff; border: none; padding: 8px 16px; border-radius: var(--radius-sm);
}

/* Responsive */
@media (max-width: 640px) {
  .topbar { flex-direction: column; gap: 16px; align-items: stretch; }
  .left-controls { justify-content: space-between; }
  .user-controls { justify-content: space-between; }
  .lang-controls { width: 100%; margin-top: 12px; }
  .lang-controls select { flex: 1; }
  .mode-switch { width: 100%; overflow-x: auto; flex-wrap: nowrap; }
  .mode-switch button { white-space: nowrap; flex: 1; text-align: center; }
}