/* ================================================================
   FILE: css/style.css
   MÔ TẢ: CSS tùy chỉnh bổ sung cho Tailwind CSS
          (animation, biến màu, loading spinner, scrollbar...)
   ================================================================ */

/* ── CSS Custom Properties (Corporate Theme) ─────────────────── */
:root {
  --primary:    #1A3A5C;
  --secondary:  #2E6DA4;
  --accent:     #0099CC;
  --bg:         #F4F6F9;
  --card:       #FFFFFF;
  --text:       #1A1A1A;
  --text-sub:   #555555;
  --error:      #D93025;
  --success:    #1E8E3E;
  --shadow:     0 4px 20px rgba(26, 58, 92, 0.10);
  --radius:     1rem;
  --transition: 0.2s ease;
}

/* ── Dark Mode ────────────────────────────────────────────────── */
[data-theme="dark"] {
  --bg:       #0F1923;
  --card:     #1A2535;
  --text:     #E8EDF3;
  --text-sub: #8FA3BA;
  --shadow:   0 4px 20px rgba(0, 0, 0, 0.35);
}
[data-theme="dark"] body       { background-color: var(--bg); color: var(--text); }
[data-theme="dark"] .bg-white  { background-color: var(--card) !important; }
[data-theme="dark"] .text-gray-700 { color: var(--text) !important; }
[data-theme="dark"] .text-gray-500,
[data-theme="dark"] .text-gray-400 { color: var(--text-sub) !important; }
[data-theme="dark"] .border-gray-100 { border-color: #2a3a4e !important; }

/* ── Base ─────────────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; }

body {
  background-color: var(--bg);
  color: var(--text);
  font-family: 'Calibri', 'Segoe UI', system-ui, sans-serif;
  min-height: 100vh;
}

/* Màu navy cho Tailwind custom */
.text-navy  { color: var(--primary); }
.bg-navy    { background-color: var(--primary); }
.border-navy { border-color: var(--primary); }

/* ── Animations ───────────────────────────────────────────────── */
@keyframes fadeIn {
  from { opacity: 0; transform: translateY(12px); }
  to   { opacity: 1; transform: translateY(0);    }
}
@keyframes slideInRight {
  from { opacity: 0; transform: translateX(100%); }
  to   { opacity: 1; transform: translateX(0);    }
}
@keyframes spin {
  to { transform: rotate(360deg); }
}
@keyframes pulse {
  0%, 100% { opacity: 1; }
  50%       { opacity: 0.5; }
}

.fade-in     { animation: fadeIn      0.45s ease both; }
.slide-in    { animation: slideInRight 0.35s ease both; }

/* ── Loading Spinner ──────────────────────────────────────────── */
.spinner {
  width: 20px;
  height: 20px;
  border: 2.5px solid rgba(255,255,255,0.35);
  border-top-color: #fff;
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
  display: inline-block;
}

/* ── Toast Notification ───────────────────────────────────────── */
.toast {
  position: fixed;
  top: 1.25rem;
  right: 1.25rem;
  z-index: 9999;
  min-width: 260px;
  max-width: 380px;
  padding: 0.85rem 1.1rem;
  border-radius: 0.75rem;
  box-shadow: 0 8px 24px rgba(0,0,0,0.15);
  display: flex;
  align-items: center;
  gap: 0.7rem;
  font-size: 0.9rem;
  font-weight: 500;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.3s ease, transform 0.3s ease;
  transform: translateX(120%);
}
.toast--visible {
  opacity: 1;
  pointer-events: auto;
  transform: translateX(0);
}
.toast--error   { background: #FEF2F2; color: #991B1B; border-left: 4px solid var(--error); }
.toast--success { background: #F0FDF4; color: #14532D; border-left: 4px solid var(--success); }
.toast--info    { background: #EFF6FF; color: #1E3A5F; border-left: 4px solid var(--accent); }

/* ── Hero Section ─────────────────────────────────────────────── */
.hero-section {
  background: linear-gradient(135deg, var(--primary) 0%, var(--secondary) 60%, var(--accent) 100%);
  position: relative;
  overflow: hidden;
}
.hero-section::before {
  content: "";
  position: absolute;
  inset: 0;
  background: url("../assets/images/hero-bg.jpg") center/cover no-repeat;
  opacity: 0.12;
}

/* ── Search Input ─────────────────────────────────────────────── */
.search-input {
  border: 2px solid transparent;
  transition: border-color var(--transition), box-shadow var(--transition);
}
.search-input:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 4px rgba(0,153,204,0.15);
}

/* ── Search Error ─────────────────────────────────────────────── */
.search-error {
  color: var(--error);
  font-size: 0.8rem;
  margin-top: 0.35rem;
}

/* ── Weather Card ─────────────────────────────────────────────── */
.weather-card {
  background: var(--card);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  border: 1px solid rgba(0,0,0,0.06);
  transition: box-shadow var(--transition);
}
.weather-card:hover { box-shadow: 0 8px 32px rgba(26,58,92,0.14); }

/* ── Detail Cards ─────────────────────────────────────────────── */
.detail-card {
  background: var(--card);
  border-radius: 0.875rem;
  box-shadow: var(--shadow);
  border: 1px solid rgba(0,0,0,0.05);
  padding: 1.1rem 1.25rem;
  display: flex;
  align-items: center;
  gap: 0.9rem;
  transition: transform var(--transition), box-shadow var(--transition);
}
.detail-card:hover {
  transform: translateY(-2px);
  box-shadow: 0 8px 20px rgba(26,58,92,0.12);
}
.detail-icon {
  font-size: 1.5rem;
  width: 2.5rem;
  height: 2.5rem;
  border-radius: 50%;
  background: linear-gradient(135deg, #EBF4FF, #D6E8F7);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

/* ── Unit Toggle Buttons ──────────────────────────────────────── */
.unit-btn {
  padding: 0.2rem 0.6rem;
  border-radius: 0.375rem;
  font-size: 0.85rem;
  font-weight: 500;
  color: rgba(255,255,255,0.65);
  transition: background var(--transition), color var(--transition);
  cursor: pointer;
}
.unit-active {
  background: rgba(255,255,255,0.25);
  color: #fff;
}

/* ── Forecast Card ────────────────────────────────────────────── */
.forecast-card { transition: transform 0.2s ease, box-shadow 0.2s ease; }

/* ── History Dropdown ─────────────────────────────────────────── */
#history-dropdown {
  position: absolute;
  top: calc(100% + 4px);
  left: 0;
  right: 0;
  background: var(--card);
  border-radius: 0.75rem;
  box-shadow: 0 8px 24px rgba(26,58,92,0.15);
  border: 1px solid rgba(0,0,0,0.07);
  max-height: 280px;
  overflow-y: auto;
  z-index: 50;
}
.history-item:first-child { border-radius: 0.75rem 0.75rem 0 0; }

/* ── Custom Scrollbar ─────────────────────────────────────────── */
::-webkit-scrollbar       { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: #C5D6E8; border-radius: 99px; }
::-webkit-scrollbar-thumb:hover { background: var(--secondary); }

/* ── Responsive temperature text ─────────────────────────────── */
#current-temp {
  font-size: clamp(3.5rem, 10vw, 5.5rem);
  font-weight: 700;
  line-height: 1;
  color: var(--primary);
}

/* ── Chart container ──────────────────────────────────────────── */
.chart-container {
  background: var(--card);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 1.5rem;
  border: 1px solid rgba(0,0,0,0.05);
}
#temp-chart { display: block; width: 100%; }

/* ── Utility ──────────────────────────────────────────────────── */
.hidden { display: none !important; }
