/* CSS Design System for dshbrd */

:root {
  --bg-app: radial-gradient(circle at 50% 0%, #151b2e 0%, #0a0d18 100%);
  --bg-widget: rgba(18, 22, 38, 0.5);
  --bg-widget-hover: rgba(22, 28, 48, 0.6);
  --border-widget: rgba(255, 255, 255, 0.05);
  --border-widget-focus: rgba(38, 140, 255, 0.3);
  
  /* Text and Accents */
  --text-main: #f3f4f6;
  --text-secondary: #9ca3af;
  --text-muted: #6b7280;
  
  --accent-blue: #3b82f6;
  --accent-cyan: #06b6d4;
  --accent-emerald: #10b981;
  --accent-amber: #f59e0b;
  --accent-rose: #f43f5e;
  
  /* Layout constraints */
  --header-height: 70px;
  --grid-gap: 16px;
  --border-radius: 14px;
  --transition-smooth: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

/* Reset & Global Styles */
* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

body {
  font-family: 'Inter', system-ui, -apple-system, sans-serif;
  background: var(--bg-app);
  color: var(--text-main);
  height: 100vh;
  overflow: hidden;
  user-select: none;
  -webkit-user-select: none;
  -webkit-font-smoothing: antialiased;
}

/* App Container */
#app-container {
  display: flex;
  flex-direction: column;
  height: 100vh;
  padding: 0 20px 20px 20px;
}

/* Top Header */
#top-header {
  height: var(--header-height);
  display: flex;
  justify-content: space-between;
  align-items: center;
  border-bottom: 1px solid var(--border-widget);
  margin-bottom: var(--grid-gap);
  padding: 10px 0;
}

.header-left {
  display: flex;
  align-items: center;
  gap: 12px;
}

.logo-container {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 42px;
  height: 42px;
  background: rgba(59, 130, 246, 0.15);
  border: 1px solid rgba(59, 130, 246, 0.3);
  border-radius: 10px;
  color: var(--accent-blue);
  box-shadow: 0 0 15px rgba(59, 130, 246, 0.2);
}

.logo-icon {
  width: 24px;
  height: 24px;
}

.title-container h1 {
  font-family: 'Outfit', sans-serif;
  font-size: 1.25rem;
  font-weight: 600;
  letter-spacing: -0.02em;
  color: #ffffff;
}

.title-container span {
  font-size: 0.75rem;
  color: var(--text-secondary);
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

/* Header Live Metrics */
.header-metrics {
  display: flex;
  gap: 16px;
  align-items: center;
}

.metric-item {
  display: flex;
  align-items: center;
  gap: 6px;
  background: rgba(255, 255, 255, 0.03);
  padding: 6px 12px;
  border-radius: 20px;
  border: 1px solid rgba(255, 255, 255, 0.05);
  font-family: 'Share Tech Mono', monospace;
  font-size: 0.8rem;
  color: var(--accent-emerald);
}

.metric-item svg {
  width: 14px;
  height: 14px;
  opacity: 0.8;
}

#metric-cache {
  color: var(--accent-amber);
}

/* Header Actions */
.header-actions {
  display: flex;
  gap: 10px;
  align-items: center;
}

.action-btn {
  display: flex;
  align-items: center;
  gap: 8px;
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 8px;
  color: var(--text-main);
  padding: 8px 16px;
  font-family: 'Inter', sans-serif;
  font-size: 0.85rem;
  font-weight: 500;
  cursor: pointer;
  transition: var(--transition-smooth);
}

.action-btn:hover {
  background: rgba(255, 255, 255, 0.1);
  border-color: rgba(255, 255, 255, 0.15);
  transform: translateY(-1px);
}

.action-btn svg {
  width: 16px;
  height: 16px;
}

.circle-btn {
  padding: 8px;
  border-radius: 50%;
  aspect-ratio: 1;
}

/* Main Grid Layout */
#dashboard-grid {
  flex: 1;
  display: grid;
  grid-template-columns: repeat(12, 1fr);
  grid-auto-rows: minmax(180px, auto);
  gap: var(--grid-gap);
  overflow-y: auto;
  padding-right: 4px;
}

/* Custom Scrollbar for Grid and Modals */
#dashboard-grid::-webkit-scrollbar,
.modal-content::-webkit-scrollbar {
  width: 6px;
}
#dashboard-grid::-webkit-scrollbar-track,
.modal-content::-webkit-scrollbar-track {
  background: transparent;
}
#dashboard-grid::-webkit-scrollbar-thumb,
.modal-content::-webkit-scrollbar-thumb {
  background: rgba(255, 255, 255, 0.15);
  border-radius: 10px;
}

/* Widget Cards */
.widget-card {
  background: var(--bg-widget);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border: 1px solid var(--border-widget);
  border-radius: var(--border-radius);
  padding: 16px;
  position: relative;
  display: flex;
  flex-direction: column;
  gap: 12px;
  transition: var(--transition-smooth);
  overflow: hidden;
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.2);
}

.widget-card:hover {
  background: var(--bg-widget-hover);
  border-color: var(--border-widget-focus);
  box-shadow: 0 8px 30px rgba(0, 0, 0, 0.3);
}

/* Grid Layout Spanning */
.col-1 { grid-column: span 1; }
.col-2 { grid-column: span 2; }
.col-3 { grid-column: span 3; }
.col-4 { grid-column: span 4; }
.col-5 { grid-column: span 5; }
.col-6 { grid-column: span 6; }
.col-7 { grid-column: span 7; }
.col-8 { grid-column: span 8; }
.col-9 { grid-column: span 9; }
.col-10 { grid-column: span 10; }
.col-11 { grid-column: span 11; }
.col-12 { grid-column: span 12; }

.row-1 { grid-row: span 1; }
.row-2 { grid-row: span 2; }
.row-3 { grid-row: span 3; }

/* Widget Headers */
.widget-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  border-bottom: 1px solid rgba(255, 255, 255, 0.05);
  padding-bottom: 8px;
}

.widget-title {
  display: flex;
  align-items: center;
  gap: 8px;
  font-family: 'Outfit', sans-serif;
  font-size: 0.95rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.03em;
  color: var(--text-secondary);
}

.widget-title-icon {
  width: 16px;
  height: 16px;
  color: var(--accent-blue);
}

.widget-controls {
  display: flex;
  gap: 6px;
  opacity: 0;
  transition: opacity 0.2s ease;
}

.widget-card:hover .widget-controls {
  opacity: 1;
}

.widget-btn {
  background: transparent;
  border: none;
  color: var(--text-secondary);
  cursor: pointer;
  padding: 4px;
  border-radius: 4px;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: var(--transition-smooth);
}

.widget-btn:hover {
  background: rgba(255, 255, 255, 0.08);
  color: #ffffff;
}

.widget-btn.delete:hover {
  background: rgba(244, 63, 94, 0.15);
  color: var(--accent-rose);
}

.widget-content {
  flex: 1;
  display: flex;
  flex-direction: column;
  position: relative;
  overflow: hidden;
}

/* WIDGET: Clock */
.clock-widget {
  justify-content: center;
  align-items: flex-start;
  padding-left: 8px;
}
.clock-time {
  font-family: 'Orbitron', monospace;
  font-size: 3.5rem;
  font-weight: 700;
  line-height: 1;
  color: #ffffff;
  letter-spacing: -0.02em;
  text-shadow: 0 0 20px rgba(59, 130, 246, 0.35);
  margin-bottom: 8px;
}
.clock-date {
  font-size: 1.1rem;
  color: var(--text-secondary);
  margin-bottom: 6px;
}
.clock-greeting {
  font-size: 1rem;
  font-weight: 500;
  color: var(--accent-cyan);
  display: flex;
  align-items: center;
  gap: 6px;
  margin-bottom: 12px;
}
.clock-gc-note {
  font-size: 0.8rem;
  background: rgba(245, 158, 11, 0.08);
  border: 1px solid rgba(245, 158, 11, 0.15);
  border-radius: 8px;
  padding: 8px 12px;
  color: var(--accent-amber);
  display: flex;
  align-items: center;
  gap: 8px;
  width: 100%;
}
.clock-gc-note svg {
  width: 16px;
  height: 16px;
  flex-shrink: 0;
}

/* WIDGET: Weather */
.weather-details {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 16px;
  margin-bottom: 12px;
}
.weather-temp-main {
  display: flex;
  flex-direction: column;
  justify-content: center;
}
.weather-val {
  font-family: 'Outfit', sans-serif;
  font-size: 3rem;
  font-weight: 500;
  line-height: 1;
  color: #ffffff;
}
.weather-desc {
  font-size: 0.85rem;
  color: var(--text-secondary);
  margin-top: 4px;
}
.weather-stats {
  display: flex;
  flex-direction: column;
  justify-content: center;
  gap: 6px;
  font-size: 0.8rem;
  color: var(--text-secondary);
}
.weather-stat-row {
  display: flex;
  align-items: center;
  gap: 8px;
}
.weather-stat-row svg {
  width: 14px;
  height: 14px;
  color: var(--accent-cyan);
}
.weather-sun-times {
  display: flex;
  gap: 16px;
  font-size: 0.75rem;
  color: var(--text-muted);
  border-top: 1px solid rgba(255, 255, 255, 0.04);
  padding-top: 8px;
  margin-bottom: 12px;
}
.weather-chart-container {
  height: 60px;
  width: 100%;
  margin-top: auto;
}
.weather-chart-container svg {
  width: 100%;
  height: 100%;
}

/* WIDGET: Departures (Västtrafik) */
.departures-container {
  display: flex;
  flex-direction: column;
  gap: 10px;
  height: 100%;
  overflow-y: auto;
}
.departure-row {
  display: grid;
  grid-template-columns: 36px 1fr 50px 32px;
  align-items: center;
  padding: 8px 10px;
  background: rgba(255, 255, 255, 0.02);
  border-radius: 8px;
  border: 1px solid rgba(255, 255, 255, 0.04);
  gap: 8px;
  font-size: 0.85rem;
}
.departure-line {
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  height: 24px;
  width: 24px;
  border-radius: 4px;
  color: #fff;
  font-size: 0.75rem;
}

/* Västtrafik Line Color Palette */
.line-tram-blue { background-color: #005c87; }
.line-bus-cyan { background-color: #008eb0; }
.line-express-green { background-color: #2196f3; }
.line-generic { background-color: #607d8b; }

.departure-dest {
  font-weight: 500;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  color: #ffffff;
}
.departure-time {
  text-align: right;
  font-weight: 600;
  color: var(--accent-emerald);
  font-family: 'Share Tech Mono', monospace;
}
.departure-track {
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(255, 255, 255, 0.05);
  font-size: 0.75rem;
  height: 20px;
  width: 20px;
  border-radius: 50%;
  color: var(--text-secondary);
}

/* WIDGET: Sticky Notes */
.notes-container {
  display: flex;
  flex-direction: column;
  height: 100%;
}
.notes-area {
  flex: 1;
  background: transparent;
  border: none;
  resize: none;
  outline: none;
  color: var(--text-main);
  font-family: inherit;
  font-size: 0.9rem;
  line-height: 1.5;
}
.notes-status {
  text-align: right;
  font-size: 0.7rem;
  color: var(--text-muted);
  padding-top: 4px;
}

/* WIDGET: Links */
.links-container {
  display: flex;
  flex-direction: column;
  gap: 12px;
  height: 100%;
}
.search-bar {
  display: flex;
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 8px;
  overflow: hidden;
}
.search-bar input {
  flex: 1;
  background: transparent;
  border: none;
  outline: none;
  padding: 8px 12px;
  color: var(--text-main);
  font-size: 0.8rem;
}
.search-bar button {
  background: rgba(255, 255, 255, 0.05);
  border: none;
  color: var(--text-secondary);
  padding: 0 12px;
  cursor: pointer;
}
.search-bar button:hover {
  background: rgba(255, 255, 255, 0.1);
  color: #fff;
}
.links-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 8px;
  overflow-y: auto;
  flex: 1;
}
.link-item {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 10px;
  background: rgba(255, 255, 255, 0.02);
  border: 1px solid rgba(255, 255, 255, 0.04);
  border-radius: 8px;
  text-decoration: none;
  color: var(--text-secondary);
  font-size: 0.8rem;
  transition: var(--transition-smooth);
}
.link-item:hover {
  background: rgba(59, 130, 246, 0.1);
  border-color: rgba(59, 130, 246, 0.2);
  color: #ffffff;
}
.link-icon {
  font-size: 1rem;
}

/* Modals Overlay */
.modal-overlay {
  position: fixed;
  top: 0;
  left: 0;
  width: 100vw;
  height: 100vh;
  background: rgba(0, 0, 0, 0.7);
  backdrop-filter: blur(8px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 100;
  transition: opacity 0.3s ease;
}

.modal-container {
  background: #0f1322;
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: var(--border-radius);
  width: 90%;
  max-width: 600px;
  max-height: 85vh;
  display: flex;
  flex-direction: column;
  box-shadow: 0 10px 40px rgba(0,0,0,0.5);
  animation: modalScale 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
}

@keyframes modalScale {
  from { transform: scale(0.9); opacity: 0; }
  to { transform: scale(1); opacity: 1; }
}

.modal-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 16px 20px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.05);
}

.modal-header h2 {
  font-family: 'Outfit', sans-serif;
  font-size: 1.2rem;
  font-weight: 600;
}

.modal-close {
  background: transparent;
  border: none;
  color: var(--text-secondary);
  font-size: 1.5rem;
  cursor: pointer;
}

.modal-content {
  padding: 20px;
  overflow-y: auto;
  flex: 1;
}

/* Form Styling */
.form-section {
  margin-bottom: 24px;
  border-bottom: 1px solid rgba(255,255,255,0.03);
  padding-bottom: 20px;
}
.form-section h3 {
  font-size: 0.95rem;
  color: #fff;
  margin-bottom: 6px;
}
.section-desc {
  font-size: 0.75rem;
  color: var(--text-secondary);
  margin-bottom: 14px;
}
.section-desc a {
  color: var(--accent-blue);
  text-decoration: none;
}
.form-group {
  margin-bottom: 14px;
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.form-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
}
.form-group label {
  font-size: 0.75rem;
  color: var(--text-secondary);
  font-weight: 500;
}
.form-group input,
.form-group select {
  background: rgba(255, 255, 255, 0.03);
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 6px;
  padding: 10px 12px;
  color: var(--text-main);
  font-family: inherit;
  font-size: 0.85rem;
  outline: none;
  transition: var(--transition-smooth);
}
.form-group input:focus,
.form-group select:focus {
  border-color: var(--accent-blue);
  background: rgba(255, 255, 255, 0.06);
}

.form-actions {
  display: flex;
  justify-content: space-between;
  margin-top: 10px;
}

.btn {
  padding: 10px 20px;
  border-radius: 6px;
  font-size: 0.85rem;
  font-weight: 500;
  cursor: pointer;
  border: none;
}
.btn-primary {
  background: var(--accent-blue);
  color: #fff;
}
.btn-primary:hover {
  background: #2563eb;
}
.btn-secondary {
  background: rgba(244, 63, 94, 0.15);
  color: var(--accent-rose);
}
.btn-secondary:hover {
  background: rgba(244, 63, 94, 0.25);
}

/* Widget Catalog Selection Grid */
.widget-grid-selector {
  display: grid;
  grid-template-columns: 1fr;
  gap: 12px;
}
.widget-template-card {
  display: grid;
  grid-template-columns: 48px 1fr;
  grid-template-areas: 
    "icon title"
    "icon desc";
  align-items: center;
  padding: 14px;
  background: rgba(255,255,255,0.02);
  border: 1px solid rgba(255, 255, 255, 0.05);
  border-radius: 10px;
  cursor: pointer;
  transition: var(--transition-smooth);
  gap: 4px 12px;
}
.widget-template-card:hover {
  background: rgba(59, 130, 246, 0.05);
  border-color: rgba(59, 130, 246, 0.25);
}
.template-icon {
  grid-area: icon;
  font-size: 1.8rem;
  text-align: center;
}
.widget-template-card h3 {
  grid-area: title;
  font-size: 0.95rem;
  font-weight: 600;
}
.widget-template-card p {
  grid-area: desc;
  font-size: 0.75rem;
  color: var(--text-secondary);
}

/* Helper Class */
.hidden {
  display: none !important;
}

/* SCREENSAVER OVERLAY STYLE */
#screensaver-overlay {
  position: fixed;
  top: 0;
  left: 0;
  width: 100vw;
  height: 100vh;
  z-index: 999;
  cursor: pointer;
}
.screensaver-dimmer {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0, 0, 0, 0.95);
}
#screensaver-content {
  position: absolute;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  pointer-events: none;
  transition: all 5s ease-in-out; /* Smooth drift positioning */
  padding: 20px;
  border-radius: 10px;
}
.screensaver-clock {
  font-family: 'Orbitron', monospace;
  font-size: 4rem;
  font-weight: 700;
  color: rgba(59, 130, 246, 0.5); /* Dimmed Accent */
  text-shadow: 0 0 15px rgba(59, 130, 246, 0.25);
}
.screensaver-date {
  font-size: 1.2rem;
  color: rgba(156, 163, 175, 0.4);
  margin-top: 8px;
}
.screensaver-hint {
  font-size: 0.75rem;
  color: rgba(107, 114, 128, 0.3);
  margin-top: 16px;
}

/* Toast warning */
#offline-toast {
  position: fixed;
  bottom: 24px;
  left: 50%;
  transform: translateX(-50%);
  background: rgba(245, 158, 11, 0.95);
  color: #000;
  font-weight: 600;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 20px;
  border-radius: 25px;
  z-index: 50;
  box-shadow: 0 4px 15px rgba(0,0,0,0.3);
  font-size: 0.85rem;
}
.toast-icon {
  width: 16px;
  height: 16px;
}

/* Tablet adjustments */
@media (max-width: 900px) {
  #dashboard-grid {
    grid-template-columns: repeat(6, 1fr);
  }
  .col-3, .col-4 { grid-column: span 3; }
  .col-8 { grid-column: span 6; }
}

@media (max-width: 600px) {
  #dashboard-grid {
    grid-template-columns: 1fr;
  }
  .col-1, .col-2, .col-3, .col-4, .col-5, .col-6, .col-7, .col-8, .col-9, .col-10, .col-11, .col-12 {
    grid-column: span 1 !important;
  }
  #top-header {
    flex-direction: column;
    height: auto;
    gap: 12px;
    padding: 15px 0;
  }
  .header-metrics {
    width: 100%;
    justify-content: space-between;
  }
}
