/* ===============================
   BashWeather - Main Styles
   =============================== */

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

html {
  scroll-behavior: smooth;
  -webkit-text-size-adjust: 100%;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, sans-serif;
  background: transparent;
  color: var(--text-primary);
  transition: color 0.4s ease;
  line-height: 1.6;
  overflow-x: hidden;
  -webkit-font-smoothing: antialiased;
  min-height: 100vh;
}

/* ===============================
   Sky Background — realistic photo-style
   =============================== */

.sky-bg {
  position: fixed;
  inset: 0;
  z-index: -1;
  overflow: hidden;
  transition: background 0.6s ease;

  /* Photo-realistic sky: layered gradients simulate wispy cloud scatter */
  background:
    radial-gradient(ellipse 75vw 18vh at 22% 24%, rgba(255,255,255,0.42) 0%, rgba(255,255,255,0.12) 45%, transparent 70%),
    radial-gradient(ellipse 55vw 14vh at 72% 14%, rgba(255,255,255,0.36) 0%, rgba(255,255,255,0.08) 45%, transparent 70%),
    radial-gradient(ellipse 45vw 12vh at 48% 42%, rgba(255,255,255,0.22) 0%, transparent 65%),
    radial-gradient(ellipse 35vw  9vh at 88% 32%, rgba(255,255,255,0.18) 0%, transparent 60%),
    radial-gradient(ellipse 30vw  8vh at  8% 55%, rgba(255,255,255,0.14) 0%, transparent 60%),
    radial-gradient(ellipse 60vw 20vh at 55% 68%, rgba(255,255,255,0.08) 0%, transparent 60%),
    linear-gradient(180deg,
      #0f5aa8 0%,
      #1976d2 18%,
      #2196f3 40%,
      #42a5f5 62%,
      #7ec8f7 82%,
      #b3dff7 100%
    );
}

/* Dark sky */
body.dark-theme  .sky-bg,
body.auto-theme  .sky-bg {
  background:
    radial-gradient(ellipse 70vw 16vh at 25% 20%, rgba(80,110,200,0.22) 0%, transparent 65%),
    radial-gradient(ellipse 50vw 12vh at 70% 12%, rgba(80,110,200,0.18) 0%, transparent 65%),
    radial-gradient(ellipse 40vw 10vh at 50% 40%, rgba(80,110,200,0.12) 0%, transparent 60%),
    linear-gradient(180deg, #020818 0%, #060f2e 25%, #0a1840 55%, #0d2060 100%);
}

@media (prefers-color-scheme: dark) {
  body.auto-theme .sky-bg {
    background:
      radial-gradient(ellipse 70vw 16vh at 25% 20%, rgba(80,110,200,0.22) 0%, transparent 65%),
      radial-gradient(ellipse 50vw 12vh at 70% 12%, rgba(80,110,200,0.18) 0%, transparent 65%),
      radial-gradient(ellipse 40vw 10vh at 50% 40%, rgba(80,110,200,0.12) 0%, transparent 60%),
      linear-gradient(180deg, #020818 0%, #060f2e 25%, #0a1840 55%, #0d2060 100%);
  }
}

/* Subtle slow cloud drift via transform */
.sky-bg::before {
  content: '';
  position: absolute;
  inset: 0;
  background:
    radial-gradient(ellipse 40vw 10vh at 35% 18%, rgba(255,255,255,0.18) 0%, transparent 60%),
    radial-gradient(ellipse 28vw  7vh at 80% 28%, rgba(255,255,255,0.14) 0%, transparent 55%);
  animation: sky-drift 90s ease-in-out infinite alternate;
}

@keyframes sky-drift {
  from { transform: translateX(0); }
  to   { transform: translateX(3vw); }
}

body.rtl {
  direction: rtl;
  text-align: right;
}

body.ltr {
  direction: ltr;
  text-align: left;
}

/* ===============================
   Layout & Containers
   =============================== */

.app-header {
  background: var(--bg-secondary);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border-bottom: 1px solid var(--border-color);
  padding: 0.75rem 0;
  padding-top: calc(env(safe-area-inset-top) + 0.75rem);
  position: sticky;
  top: 0;
  z-index: 100;
  box-shadow: var(--card-shadow);
}

.header-content {
  display: flex;
  justify-content: space-between;
  align-items: center;
  max-width: 1200px;
  margin: 0 auto;
  padding: 0 calc(env(safe-area-inset-right) + 1rem);
  padding-left: calc(env(safe-area-inset-left) + 1rem);
  gap: 1rem;
}

.header-title h1 {
  font-size: 1.5rem;
  font-weight: 600;
}

.header-controls {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.app-main {
  max-width: 1200px;
  margin: 0 auto;
  padding: 2rem calc(env(safe-area-inset-right) + 1rem);
  padding-left: calc(env(safe-area-inset-left) + 1rem);
  min-height: calc(100vh - 100px);
}

.app-footer {
  background: var(--bg-secondary);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border-top: 1px solid var(--border-color);
  padding: 1.5rem;
  padding-bottom: calc(env(safe-area-inset-bottom) + 1rem);
  text-align: center;
  font-size: 0.875rem;
  color: var(--text-secondary);
  margin-top: 2rem;
}

/* ===============================
   Buttons
   =============================== */

button {
  cursor: pointer;
  border: none;
  font-family: inherit;
  font-size: inherit;
  transition: all 0.2s ease;
  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
}

.btn-primary {
  background: var(--color-primary);
  color: white;
  padding: 0.75rem 1.5rem;
  border-radius: 0.5rem;
  font-weight: 600;
  border: 2px solid var(--color-primary);
}

.btn-primary:hover {
  background: var(--color-primary-dark);
  border-color: var(--color-primary-dark);
  transform: translateY(-2px);
  box-shadow: 0 4px 12px rgba(59, 130, 246, 0.3);
}

.btn-primary:active {
  transform: translateY(0);
}

.btn-secondary {
  background: var(--bg-tertiary);
  color: var(--text-primary);
  padding: 0.75rem 1.5rem;
  border-radius: 0.5rem;
  font-weight: 600;
  border: 1px solid var(--border-color);
}

.btn-secondary:hover {
  background: var(--border-color);
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
}

.btn-small {
  background: transparent;
  color: var(--color-primary);
  padding: 0.5rem 1rem;
  border-radius: 0.375rem;
  font-weight: 500;
  border: 1px solid var(--color-primary);
}

.btn-small:hover {
  background: var(--color-primary);
  color: white;
}

.btn-icon {
  background: transparent;
  color: var(--text-primary);
  width: 2.5rem;
  height: 2.5rem;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1rem;
  border: 1px solid var(--border-color);
}

.btn-icon:hover {
  background: var(--bg-tertiary);
}

.btn-block {
  width: 100%;
  justify-content: center;
}

.btn-large {
  padding: 1rem 2rem;
  font-size: 1.1rem;
}

.btn-close {
  background: transparent;
  color: var(--text-primary);
  width: 2rem;
  height: 2rem;
  font-size: 1.5rem;
  padding: 0;
  border-radius: 0.25rem;
}

.btn-close:hover {
  background: var(--bg-tertiary);
}

/* ===============================
   Modals
   =============================== */

.modal {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0, 0, 0, 0.5);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
  animation: fadeIn 0.2s ease;
}

.modal.hidden {
  display: none;
}

.modal-content {
  background: var(--bg-primary);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  border: 1px solid var(--border-color);
  border-radius: 0.75rem;
  width: 90%;
  max-width: 500px;
  box-shadow: 0 20px 48px rgba(0, 0, 0, 0.25);
  animation: slideUp 0.3s ease;
}

@media (max-width: 600px) {
  .modal {
    align-items: flex-end;
  }

  .modal-content {
    width: 100%;
    max-width: 100%;
    border-radius: 1.25rem 1.25rem 0 0;
    padding-bottom: env(safe-area-inset-bottom);
    animation: slideUpSheet 0.35s cubic-bezier(0.32, 0.72, 0, 1);
  }
}

@keyframes slideUpSheet {
  from {
    opacity: 0;
    transform: translateY(100%);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

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

.modal-header h2 {
  font-size: 1.25rem;
  font-weight: 600;
}

.modal-body {
  padding: 1.5rem;
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

/* ===============================
   Messages & Status
   =============================== */

.status-message {
  padding: 1rem;
  border-radius: 0.5rem;
  font-size: 0.875rem;
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.status-message.hidden {
  display: none;
}

.status-message.success {
  background: rgba(34, 197, 94, 0.1);
  color: #22c55e;
  border: 1px solid rgba(34, 197, 94, 0.3);
}

.status-message.error {
  background: rgba(239, 68, 68, 0.1);
  color: #ef4444;
  border: 1px solid rgba(239, 68, 68, 0.3);
}

.status-message.info {
  background: rgba(59, 130, 246, 0.1);
  color: #3b82f6;
  border: 1px solid rgba(59, 130, 246, 0.3);
}

.error-message {
  background: rgba(239, 68, 68, 0.1);
  color: #ef4444;
  padding: 1rem;
  border-radius: 0.5rem;
  border: 1px solid rgba(239, 68, 68, 0.3);
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.error-message.hidden {
  display: none;
}

.error-message::before {
  content: "⚠️";
  font-size: 1.25rem;
}

/* ===============================
   Welcome Screen
   =============================== */

.welcome-screen {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 80vh;
  text-align: center;
  padding: 2rem 1.5rem;
}

.welcome-screen.hidden {
  display: none;
}

.welcome-content {
  max-width: 440px;
  width: 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0;
}

.welcome-icon {
  width: 90px;
  height: 68px;
  margin-bottom: 1.25rem;
  drop-shadow: 0 4px 16px rgba(0,0,0,0.25);
  filter: drop-shadow(0 4px 12px rgba(0,0,0,0.3));
}

.welcome-icon svg {
  width: 100%;
  height: 100%;
}

.welcome-content h2 {
  font-size: 2.6rem;
  font-weight: 800;
  color: #ffffff;
  line-height: 1.15;
  margin-bottom: 0.75rem;
  text-shadow: 0 2px 12px rgba(0,0,0,0.25);
  letter-spacing: -0.02em;
}

.welcome-content p {
  font-size: 1rem;
  color: rgba(255, 255, 255, 0.85);
  margin-bottom: 2rem;
  line-height: 1.6;
  text-shadow: 0 1px 6px rgba(0,0,0,0.2);
}

.welcome-actions {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
  width: 100%;
}

/* Dark pill button — matches screenshot */
.btn-dark-pill {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.6rem;
  width: 100%;
  padding: 0.9rem 1.5rem;
  background: rgba(8, 12, 24, 0.88);
  color: #2dd4bf;
  border: none;
  border-radius: 50px;
  font-size: 1rem;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.2s ease, transform 0.15s ease;
  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
  letter-spacing: 0.01em;
}

.btn-dark-pill:hover {
  background: rgba(8, 12, 24, 0.96);
  transform: translateY(-1px);
}

.btn-dark-pill:active {
  transform: translateY(0);
}

.pill-icon {
  width: 18px;
  height: 18px;
  flex-shrink: 0;
  color: #2dd4bf;
}

/* ===============================
   Loading & Animations
   =============================== */

.loading-spinner {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 300px;
  gap: 1rem;
}

.loading-spinner.hidden {
  display: none;
}

.loading-spinner::before {
  content: "";
  width: 2rem;
  height: 2rem;
  border: 3px solid var(--border-color);
  border-top-color: var(--color-primary);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

@keyframes fadeIn {
  from { opacity: 0; }
  to { opacity: 1; }
}

@keyframes slideUp {
  from {
    opacity: 0;
    transform: translateY(20px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

/* ===============================
   Responsive Design
   =============================== */

@media (max-width: 768px) {
  .header-content {
    flex-direction: row;
  }

  .header-title h1 {
    font-size: 1.25rem;
  }

  .header-controls {
    gap: 0.25rem;
  }

  .btn-icon {
    width: 2.25rem;
    height: 2.25rem;
    font-size: 0.875rem;
  }

  .app-main {
    padding: 1rem;
  }

  .welcome-content h2 {
    font-size: 2.2rem;
  }

  .modal-content {
    width: 95%;
    margin: 1rem;
  }
}

@media (max-width: 480px) {
  .app-header {
    padding: 0.75rem 0;
  }

  .header-content {
    padding: 0 0.75rem;
  }

  .header-title h1 {
    font-size: 1rem;
  }

  .header-controls {
    gap: 0.25rem;
  }

  .btn-primary {
    padding: 0.5rem 1rem;
    font-size: 0.875rem;
  }

  .app-main {
    padding: 1rem 0.5rem;
  }

  .app-footer {
    padding: 1rem;
    font-size: 0.75rem;
  }

  .welcome-content h2 {
    font-size: 2rem;
  }

  .welcome-content p {
    font-size: 0.95rem;
  }

  .welcome-icon {
    width: 72px;
    height: 54px;
  }
}

/* ===============================
   Accessibility
   =============================== */

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}

/* Focus styles for keyboard navigation */
.btn-primary:focus,
.btn-secondary:focus,
.btn-icon:focus {
  outline: 2px solid var(--color-primary);
  outline-offset: 2px;
}

/* High contrast mode support */
@media (prefers-contrast: more) {
  button {
    border-width: 2px;
  }
}
