/* --- basic reset ---------------------------------------------------- */
* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

/* design tokens */
:root {
  --bg: #0d0d0d;
  --fg: #fafafa;
  --surface: #1a1a1a;
  --border: #333;
}

@media (prefers-color-scheme: light) {
  :root {
    --bg: #fafafa;
    --fg: #111;
    --surface: #f4f4f4;
    --border: #ccc;
  }
}

html, body {
  height: 100%;
  font-family: "Inter", "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  background: var(--bg);
  color: var(--fg);
  display: flex;
  align-items: center;
  justify-content: center;
}

/* --- layout --------------------------------------------------------- */
body {
  display: flex;
  align-items: stretch;
  justify-content: flex-start;
  padding: 0;
  margin-left: 40px;
  transition: margin-left 0.3s ease;
}

body.sidebar-expanded {
  margin-left: 200px;
}

.container {
  display: grid;
  gap: 2rem;
  flex: 1;
  align-content: center;
  justify-items: center;
}

.city {
  text-align: center;
}

.city-name {
  font-size: 1.2rem;
  letter-spacing: 0.05em;
  opacity: 0.7;
  margin-bottom: 0.4rem;
}

.time {
  font-size: clamp(2.5rem, 6vw + 1rem, 6rem);
  font-weight: 700;
  letter-spacing: 0.05em;
}

/* --- converter ------------------------------------------------------ */
.converter {
  position: fixed;
  bottom: 1rem;
  right: 1rem;
  font-size: 0.9rem;
  text-align: right;
  z-index: 100;
}

.converter #toggle {
  background: var(--surface);
  color: var(--fg);
  border: 1px solid var(--border);
  padding: 0.5rem 1rem;
  border-radius: 6px;
  font-size: inherit;
  cursor: pointer;
  transition: all 0.2s ease;
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
}

.converter #toggle:hover {
  background: var(--border);
  transform: translateY(-1px);
  box-shadow: 0 4px 8px rgba(0, 0, 0, 0.15);
}

.converter form {
  margin-top: 0.75rem;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 1rem;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
  min-width: 280px;
}

.converter .form-group {
  margin-bottom: 0.75rem;
}

.converter .form-group:last-child {
  margin-bottom: 0;
}

.converter label {
  display: block;
  margin-bottom: 0.25rem;
  font-size: 0.85rem;
  opacity: 0.8;
  font-weight: 500;
}

.converter input[type="text"],
.converter select {
  width: 100%;
  background: var(--bg);
  color: var(--fg);
  border: 1px solid var(--border);
  padding: 0.5rem;
  border-radius: 4px;
  font-size: inherit;
  transition: border-color 0.2s ease;
}

.converter input[type="text"]:focus,
.converter select:focus {
  outline: none;
  border-color: #007acc;
  box-shadow: 0 0 0 2px rgba(0, 122, 204, 0.1);
}

.converter input[type="text"]:invalid {
  border-color: #dc3545;
}

.converter button[type="submit"] {
  background: var(--fg);
  color: var(--bg);
  border: none;
  padding: 0.5rem 1rem;
  border-radius: 4px;
  font-size: inherit;
  cursor: pointer;
  transition: all 0.2s ease;
  width: 100%;
  font-weight: 500;
}

.converter button[type="submit"]:hover {
  background: #333;
  transform: translateY(-1px);
}

.converter .error {
  color: #dc3545;
  font-size: 0.8rem;
  margin-top: 0.25rem;
  opacity: 0;
  transition: opacity 0.2s ease;
}

.converter .error.show {
  opacity: 1;
}

.results {
  margin-top: 1rem;
  padding: 0.75rem;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 4px;
  line-height: 1.6;
}

.results .result-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0.25rem 0;
  border-bottom: 1px solid var(--border);
}

.results .result-item:last-child {
  border-bottom: none;
}

.results .result-city {
  font-weight: 500;
  opacity: 0.9;
}

.results .result-time {
  font-family: 'SF Mono', Monaco, 'Cascadia Code', 'Roboto Mono', monospace;
  font-weight: 600;
  color: #007acc;
}

.results.empty {
  text-align: center;
  opacity: 0.6;
  font-style: italic;
}

.results .error-message {
  color: #dc3545;
  text-align: center;
  font-weight: 500;
}

/* --- settings ------------------------------------------------------- */
.settings {
  position: fixed;
  top: 1rem;
  right: 1rem;
}

.settings button {
  background: var(--surface);
  color: var(--fg);
  border: 1px solid var(--border);
  padding: 0.5rem;
  border-radius: 4px;
  cursor: pointer;
  font-size: 1rem;
}

/* --- modal --------------------------------------------------------- */
.modal {
  display: none;
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0, 0, 0, 0.5);
  z-index: 1000;
}

.modal.show {
  display: flex;
  align-items: center;
  justify-content: center;
}

.modal-content {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 8px;
  max-width: 500px;
  width: 90%;
  max-height: 80vh;
  overflow-y: auto;
}

.modal-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 1rem;
  border-bottom: 1px solid var(--border);
}

.modal-header h2 {
  margin: 0;
  font-size: 1.5rem;
}

.modal-header button {
  background: none;
  border: none;
  color: var(--fg);
  font-size: 1.5rem;
  cursor: pointer;
  padding: 0;
  width: 2rem;
  height: 2rem;
  display: flex;
  align-items: center;
  justify-content: center;
}

.modal-body {
  padding: 1rem;
}

.timezone-list {
  margin-bottom: 1rem;
}

.timezone-item {
  display: flex;
  gap: 0.5rem;
  margin-bottom: 0.5rem;
  align-items: center;
}

.timezone-select {
  flex: 1;
  background: var(--bg);
  color: var(--fg);
  border: 1px solid var(--border);
  padding: 0.5rem;
  border-radius: 4px;
  font-size: 0.9rem;
}

.remove-timezone {
  background: var(--bg);
  color: var(--fg);
  border: 1px solid var(--border);
  padding: 0.5rem;
  border-radius: 4px;
  cursor: pointer;
  width: 2rem;
  height: 2rem;
  display: flex;
  align-items: center;
  justify-content: center;
}

#add-timezone {
  background: var(--bg);
  color: var(--fg);
  border: 1px solid var(--border);
  padding: 0.5rem 1rem;
  border-radius: 4px;
  cursor: pointer;
  margin-bottom: 1rem;
  width: 100%;
}

.modal-actions {
  display: flex;
  gap: 0.5rem;
  justify-content: flex-end;
}

.modal-actions button {
  background: var(--bg);
  color: var(--fg);
  border: 1px solid var(--border);
  padding: 0.5rem 1rem;
  border-radius: 4px;
  cursor: pointer;
}

.modal-actions button:first-child {
  background: var(--fg);
  color: var(--bg);
}

/* --- sidebar -------------------------------------------------------- */
.sidebar {
  width: 200px;
  background: var(--surface);
  border-right: 1px solid var(--border);
  padding: 1rem;
  display: flex;
  flex-direction: column;
  height: 100vh;
  position: fixed;
  left: -200px;
  top: 0;
  overflow-y: auto;
  transition: left 0.3s ease;
  z-index: 100;
}

.sidebar.expanded {
  left: 0;
}

.sidebar-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 1rem;
  padding-bottom: 0.5rem;
  border-bottom: 1px solid var(--border);
}

.sidebar-header h3 {
  margin: 0;
  font-size: 1.1rem;
  opacity: 0.9;
}

.sidebar-header button {
  background: none;
  border: none;
  color: var(--fg);
  cursor: pointer;
  padding: 0.25rem;
  border-radius: 4px;
  transition: background 0.2s ease;
}

.sidebar-header button:hover {
  background: var(--bg);
}

.links-container {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.sidebar-link {
  color: var(--fg);
  text-decoration: none;
  padding: 0.5rem;
  border-radius: 4px;
  transition: background 0.2s ease;
  font-size: 0.9rem;
}

.sidebar-link:hover {
  background: var(--bg);
}

.sidebar-link:active {
  opacity: 0.7;
}

/* --- links modal ---------------------------------------------------- */
.links-list {
  margin-bottom: 1rem;
}

.link-item {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  margin-bottom: 0.5rem;
  padding: 0.75rem;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 4px;
}

.link-name-input,
.link-url-input {
  background: var(--bg);
  color: var(--fg);
  border: 1px solid var(--border);
  padding: 0.5rem;
  border-radius: 4px;
  font-size: 0.9rem;
  width: 100%;
}

.link-name-input:focus,
.link-url-input:focus {
  outline: none;
  border-color: #007acc;
  box-shadow: 0 0 0 2px rgba(0, 122, 204, 0.1);
}

.remove-link {
  background: var(--bg);
  color: var(--fg);
  border: 1px solid var(--border);
  padding: 0.25rem 0.5rem;
  border-radius: 4px;
  cursor: pointer;
  align-self: flex-end;
  font-size: 0.8rem;
}

.remove-link:hover {
  background: #dc3545;
  color: white;
  border-color: #dc3545;
}

#add-link {
  background: var(--bg);
  color: var(--fg);
  border: 1px solid var(--border);
  padding: 0.5rem 1rem;
  border-radius: 4px;
  cursor: pointer;
  margin-bottom: 1rem;
  width: 100%;
}

#add-link:hover {
  background: var(--border);
}