/* Base reset and global styles */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --bg: #f4f6f8;
  --surface: #ffffff;
  --accent: #2aabee;
  --accent-dark: #1a8fc7;
  --bubble-mine: #dff1ff;
  --bubble-theirs: #ffffff;
  --text-primary: #1f2937;
  --text-secondary: #6b7280;
  --text-muted: #9ca3af;
  --border: #e5e7eb;
  --error: #dc2626;
  --success: #16a34a;
  --shadow: 0 1px 3px rgba(0,0,0,.08), 0 1px 2px rgba(0,0,0,.06);
  --shadow-md: 0 4px 6px -1px rgba(0,0,0,.1), 0 2px 4px -1px rgba(0,0,0,.06);
  --radius: 12px;
  --radius-sm: 8px;
}

[data-theme="dark"] {
  --bg: #0f1117;
  --surface: #1a1d2e;
  --bubble-mine: #1a3a5c;
  --bubble-theirs: #252840;
  --text-primary: #e9ecf1;
  --text-secondary: #8b95aa;
  --text-muted: #5c6478;
  --border: #2a2f45;
  --error: #f87171;
  --success: #4ade80;
  --shadow: 0 1px 3px rgba(0,0,0,.3), 0 1px 2px rgba(0,0,0,.2);
  --shadow-md: 0 4px 6px -1px rgba(0,0,0,.4), 0 2px 4px -1px rgba(0,0,0,.2);
}

html, body { height: 100%; }

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  font-size: 15px;
  color: var(--text-primary);
  background: var(--bg);
  line-height: 1.5;
}

a { color: var(--accent); }
a:hover { color: var(--accent-dark); }

input, textarea, select {
  width: 100%;
  padding: 10px 14px;
  border: 1.5px solid var(--border);
  border-radius: var(--radius-sm);
  font-size: 15px;
  font-family: inherit;
  color: var(--text-primary);
  background: var(--surface);
  transition: border-color .15s;
  outline: none;
}
input:focus, textarea:focus, select:focus { border-color: var(--accent); }
textarea { resize: none; }

label { display: block; font-size: 13px; font-weight: 600; color: var(--text-secondary); margin-bottom: 6px; }

button { cursor: pointer; font-family: inherit; border: none; outline: none; }

/* Button variants */
.btn-primary {
  background: var(--accent);
  color: #fff;
  padding: 10px 20px;
  border-radius: var(--radius-sm);
  font-size: 15px;
  font-weight: 600;
  transition: background .15s;
}
.btn-primary:hover { background: var(--accent-dark); }
.btn-primary:disabled { opacity: .6; cursor: default; }

.btn-outline {
  background: transparent;
  color: var(--accent);
  border: 1.5px solid var(--accent);
  padding: 10px 20px;
  border-radius: var(--radius-sm);
  font-size: 15px;
  font-weight: 600;
  transition: .15s;
}
.btn-outline:hover { background: var(--accent); color: #fff; }

.btn-sm {
  padding: 6px 12px;
  font-size: 13px;
  border-radius: 6px;
  background: var(--bg);
  color: var(--text-primary);
  border: 1px solid var(--border);
  font-weight: 500;
}
.btn-sm:hover { background: var(--border); }

.btn-full { width: 100%; display: block; text-align: center; }

.btn-danger-sm {
  background: #fee2e2;
  color: var(--error);
  border: 1px solid #fecaca;
  padding: 5px 10px;
  border-radius: 6px;
  font-size: 13px;
}
.btn-danger-sm:hover { background: #fecaca; }

.icon-btn {
  background: none;
  border: none;
  padding: 8px;
  border-radius: 50%;
  font-size: 18px;
  color: var(--text-secondary);
  display: flex; align-items: center; justify-content: center;
  transition: background .15s;
}
.icon-btn:hover { background: var(--bg); }

/* Form helpers */
.form-group { margin-bottom: 16px; }
.form-error { color: var(--error); font-size: 13px; margin-top: 4px; display: block; min-height: 18px; }
.form-success { color: var(--success); font-size: 13px; margin-top: 4px; }
.field-hint { color: var(--text-muted); font-size: 12px; margin-top: 4px; }
.info-box {
  background: #eff6ff;
  border: 1px solid #bfdbfe;
  border-radius: var(--radius-sm);
  padding: 10px 14px;
  font-size: 13px;
  color: #1e40af;
  margin-bottom: 16px;
}
[data-theme="dark"] .info-box {
  background: rgba(42, 171, 238, .1);
  border-color: rgba(42, 171, 238, .25);
  color: #7dd3fc;
}
.empty-hint { color: var(--text-muted); text-align: center; padding: 24px; font-size: 14px; }

/* Toast */
#toast-container {
  position: fixed; bottom: 24px; right: 24px; z-index: 9999;
  display: flex; flex-direction: column; gap: 8px;
  pointer-events: none;
}
.toast {
  padding: 12px 20px;
  border-radius: var(--radius-sm);
  font-size: 14px;
  font-weight: 500;
  max-width: 320px;
  transform: translateX(110%);
  transition: transform .3s ease;
  pointer-events: auto;
  box-shadow: var(--shadow-md);
}
.toast-show { transform: translateX(0); }
.toast-info    { background: #1e40af; color: #fff; }
.toast-success { background: var(--success); color: #fff; }
.toast-error   { background: var(--error); color: #fff; }

/* Modal */
.modal-overlay {
  position: fixed; inset: 0;
  background: rgba(0,0,0,.5);
  z-index: 1000;
  display: flex; align-items: center; justify-content: center;
  padding: 16px;
}
.modal-box {
  background: var(--surface);
  border-radius: var(--radius);
  padding: 24px;
  max-width: 480px;
  width: 100%;
  position: relative;
  max-height: 80vh;
  overflow-y: auto;
  box-shadow: var(--shadow-md);
}
.modal-box h3 { margin-bottom: 16px; }
.modal-close {
  position: absolute; top: 12px; right: 12px;
  background: none; border: none; font-size: 18px;
  color: var(--text-muted); cursor: pointer;
}

/* Input with icon */
.input-icon-wrap {
  position: relative;
}
.input-icon-wrap .input-icon {
  position: absolute;
  left: 13px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--text-muted);
  pointer-events: none;
  font-size: 14px;
  z-index: 1;
}
.input-icon-wrap input,
.input-icon-wrap select {
  padding-left: 38px;
}

/* Theme toggle button */
.theme-toggle-btn {
  background: none;
  border: none;
  padding: 6px 10px;
  border-radius: 6px;
  font-size: 16px;
  color: var(--text-secondary);
  cursor: pointer;
  transition: background .15s, color .15s;
  display: flex;
  align-items: center;
}
.theme-toggle-btn:hover {
  background: var(--border);
  color: var(--accent);
}

/* Scrollbar */
::-webkit-scrollbar { width: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border); border-radius: 3px; }
