:root {
  --background-color: #f8f9fe;
  --text-color: #1f1f1f;
  --primary-color: #655af3;
  --secondary-color: #3f3d56;
  --accent-color: #ff6584;
  --card-bg: #ffffff;
  --card-text: #1f1f1f;
  --border-color: #e4e6f0;
  --header-bg: linear-gradient(90deg, #655af3, #ff6584);
  --sidebar-bg: #fff;
  --sidebar-text-color: #444;
  --shadow: 0 2px 6px rgba(0, 0, 0, 0.1);
  --header-text-color: #fff;
  --primary-color-rgb: 101, 90, 243;
  --secondary-color-rgb: 63, 61, 86;
  --accent-color-rgb: 255, 101, 132;
  --background-color-rgb: 248, 249, 254;
  --text-color-rgb: 31, 31, 31;
  --card-bg-rgb: 255, 255, 255;
  --card-text-rgb: 31, 31, 31;
  --border-color-rgb: 228, 230, 240;
  --sidebar-bg-rgb: 255, 255, 255;
  --sidebar-text-color-rgb: 68, 68, 68;
}

.dark-theme {
  --background-color: #202225;
  --text-color: #e3e3e3;
  --primary-color: #655af3;
  --secondary-color: #888;
  --accent-color: #ff6584;
  --card-bg: #2f3136;
  --card-text: #ffffff;
  --border-color: #3f3f46;
  --header-bg: linear-gradient(90deg, #1f1f1f, #333);
  --sidebar-bg: #2f3136;
  --sidebar-text-color: #ddd;
  --shadow: 0 2px 8px rgba(0, 0, 0, 0.4);
  --header-text-color: #ffffff;
  --primary-color-rgb: 101, 90, 243;
  --secondary-color-rgb: 136, 136, 136;
  --accent-color-rgb: 255, 101, 132;
  --background-color-rgb: 32, 34, 37;
  --text-color-rgb: 227, 227, 227;
  --card-bg-rgb: 47, 49, 54;
  --card-text-rgb: 255, 255, 255;
  --border-color-rgb: 63, 63, 70;
  --sidebar-bg-rgb: 47, 49, 54;
  --sidebar-text-color-rgb: 221, 221, 221;
}

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

body {
  font-family: 'Arial', sans-serif;
  background-color: var(--background-color);
  color: var(--text-color);
  line-height: 1.5;
  transition:
    background-color 0.3s,
    color 0.3s;
}

.header {
  background: var(--header-bg);
  color: var(--header-text-color);
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  align-items: center;
  padding: 0.75rem 1.5rem;
  box-shadow: 0 2px 10px rgba(0, 0, 0, 0.15);
  position: relative;
  top: auto; 
  z-index: 100;
}

.header-left {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 2rem;
  flex: 1 1 auto;
}

.header-logo {
  font-size: 1.3rem;
  font-weight: bold;
  transition: transform 0.2s;
}

.header-logo:hover {
  transform: scale(1.05);
}

.header-logo img {
  max-height: 60px;
  display: block;
}

.card h2 {
  font-size: 2rem;
  font-weight: 600;
  color: var(--accent-color);
}

.header-tabs {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.5rem;
  flex: 1 1 auto;
}

.header-tabs .tab-btn {
  background: none;
  border: none;
  color: var(--header-text-color);
  font-size: 0.95rem;
  font-weight: 600;
  padding: 0.6rem 1.2rem;
  cursor: pointer;
  border-radius: 6px;
  transition: all 0.2s;
  position: relative;
}

.header-tabs .tab-btn:hover {
  background-color: rgba(255, 255, 255, 0.15);
  transform: translateY(-2px);
}

.header-tabs .tab-btn.active {
  background-color: rgba(255, 255, 255, 0.2);
}

.header-tabs .tab-btn.active::after {
  content: '';
  position: absolute;
  bottom: -2px;
  left: 50%;
  transform: translateX(-50%);
  width: 30px;
  height: 3px;
  background-color: var(--accent-color);
  border-radius: 3px;
}

.header-controls {
  display: flex;
  align-items: center;
  gap: 1rem;
  flex: 0 0 auto;
}

.header-controls label {
  margin-right: 0.25rem;
  font-weight: 500;
  font-size: 0.9rem;
}

.header-controls select,
.header-controls button {
  background-color: var(--card-bg);
  color: var(--text-color);
  border: 1px solid var(--border-color);
  border-radius: 4px;
  padding: 0.5rem 1rem;
  font-size: 0.9rem;
  cursor: pointer;
  transition:
    background-color 0.3s,
    color 0.3s,
    border-color 0.3s;
}

.header-controls select:hover,
.header-controls button:hover {
  background-color: var(--accent-color);
  color: #fff;
}

.header-controls select:focus,
.header-controls button:focus {
  outline: 2px solid var(--primary-color);
  outline-offset: 2px;
}

.timezone-container {
  display: flex;
  align-items: center;
  background-color: rgba(255, 255, 255, 0.1);
  padding: 0.5rem 0.75rem;
  border-radius: 6px;
}

.toggle-switch {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.toggle-label {
  font-size: 0.85rem;
}

.switch {
  position: relative;
  display: inline-block;
  width: 40px;
  height: 20px;
}

.switch input {
  opacity: 0;
  width: 0;
  height: 0;
}

.slider {
  position: absolute;
  cursor: pointer;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background-color: rgba(255, 255, 255, 0.3);
  transition: .4s;
}

.slider:before {
  position: absolute;
  content: "";
  height: 16px;
  width: 16px;
  left: 2px;
  bottom: 2px;
  background-color: white;
  transition: .4s;
}

input:checked + .slider {
  background-color: var(--accent-color);
}

input:focus + .slider {
  box-shadow: 0 0 1px var(--accent-color);
}

input:checked + .slider:before {
  transform: translateX(20px);
}

.slider.round {
  border-radius: 20px;
}

.slider.round:before {
  border-radius: 50%;
}

.header-controls button {
  background-color: rgba(255, 255, 255, 0.15);
  color: var(--header-text-color);
  border: none;
  border-radius: 6px;
  padding: 0.5rem 1rem;
  font-size: 0.9rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s;
}

.header-controls button:hover {
  background-color: var(--accent-color);
  transform: translateY(-2px);
}

.container {
  display: flex;
  min-height: calc(100vh - 70px);
}

.sidebar {
  background-color: var(--sidebar-bg);
  width: 240px;
  padding: 1rem;
  border-right: none;
  box-shadow: 2px 0 8px rgba(0, 0, 0, 0.1);
}

.content {
  flex: 1;
  padding: 2rem;
  overflow-y: auto;
}

.card {
  background-color: var(--card-bg);
  color: var(--card-text);
  border: 1px solid var(--border-color);
  border-radius: 8px;
  padding: 1rem;
  box-shadow: var(--shadow);
  margin-bottom: 1.5rem;
  transition:
    background-color 0.3s,
    color 0.3s;
}

.toast-container {
  position: fixed;
  bottom: 2rem;
  left: 50%;
  transform: translateX(-50%);
  z-index: 9999;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  max-width: 80%;
  min-width: 300px;
}

.toast {
  background-color: var(--accent-color);
  color: #fff;
  padding: 0.75rem 1.25rem;
  border-radius: 6px;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.2);
  transition: transform 0.3s, opacity 0.3s;
  opacity: 0.95;
  text-align: center;
  font-weight: 500;
  animation: toast-in 0.3s ease-out forwards;
}

.toast.success {
  background-color: var(--primary-color);
}

.toast.error {
  background-color: #e74c3c;
}

.toast.hide {
  animation: toast-out 0.3s ease-in forwards;
}

@keyframes toast-in {
  from {
    transform: translateY(20px);
    opacity: 0;
  }
  to {
    transform: translateY(0);
    opacity: 0.95;
  }
}

@keyframes toast-out {
  from {
    transform: translateY(0);
    opacity: 0.95;
  }
  to {
    transform: translateY(20px);
    opacity: 0;
  }
}

@media (max-width: 768px) {
  .header {
    padding: 0.5rem 1rem;
  }

  .header-logo img {
    max-height: 50px;
  }

  .header-tabs .tab-btn {
    font-size: 0.85rem;
    padding: 0.4rem 0.8rem;
  }

  .header-controls {
    margin-top: 0.5rem;
    width: 100%;
    justify-content: flex-end;
  }

  .timezone-container {
    padding: 0.3rem 0.5rem;
  }
}

@media (max-width: 576px) {
  .toast-container {
    min-width: 250px;
    max-width: 90%;
    bottom: 1rem;
  }
  
  .toast {
    padding: 0.6rem 1rem;
    font-size: 0.9rem;
  }
}

/* PWA Install Button Styles */
.pwa-install-button {
  background-color: var(--primary-color);
  color: white;
  border: none;
  border-radius: 8px;
  padding: 10px 15px;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  box-shadow: 0 4px 8px rgba(0, 0, 0, 0.15);
  display: flex;
  align-items: center;
  gap: 8px;
  transition: transform 0.2s, background-color 0.2s;
}

.pwa-install-button:hover {
  background-color: var(--accent-color);
  transform: translateY(-2px);
}

/* Offline mode indicator */
#offline-indicator {
  background-color: var(--accent-color);
  color: white;
  font-weight: 500;
  text-align: center;
  padding: 8px;
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  z-index: 9999;
  box-shadow: 0 -2px 10px rgba(0, 0, 0, 0.1);
}

/* Window Controls Overlay Styles */
:root {
  /* Default fallback values, will be updated by JS when WCO is active */
  --titlebar-x: 0px;
  --titlebar-y: 0px;
  --titlebar-width: 100%;
  --titlebar-height: 0px;
  --effective-titlebar-height: 0px;
}

/* Apply to elements that will be in the title bar area */
.title-bar-region {
  position: fixed;
  top: var(--titlebar-y);
  left: var(--titlebar-x);
  width: var(--titlebar-width);
  height: var(--titlebar-height);
  display: flex;
  align-items: center;
  padding: 0 8px;
  z-index: 9999;
  color: var(--header-text-color);
  background-color: var(--primary-color);
  font-size: 14px;
  app-region: drag; /* Make the title bar draggable */
  overflow: hidden;
}

/* Pin toggle button in title bar */
.title-bar-pin {
  margin-left: auto;
  padding: 2px 4px;
  cursor: pointer;
  background: none;
  border: none;
  color: var(--header-text-color);
  opacity: 0.7;
  font-size: 12px;
  transition: opacity 0.2s, transform 0.2s;
  app-region: no-drag;
}

.title-bar-pin:hover {
  opacity: 1;
  transform: scale(1.1);
}

.title-bar-pin-icon {
  display: inline-block;
  transform: rotate(0deg);
  transition: transform 0.3s;
}

.title-bar-region.pinned .title-bar-pin-icon {
  transform: rotate(45deg);
}

/* Ensure elements in title bar are not draggable (for interactive elements) */
.title-bar-region button,
.title-bar-region select,
.title-bar-region input,
.title-bar-region a {
  app-region: no-drag;
}

/* Only show title bar content when WCO is active or pinned */
.title-bar-region {
  display: none;
}

/* Show title bar in WCO mode */
@media (display-mode: window-controls-overlay) {
  .title-bar-region {
    display: flex;
  }
  
  /* Add space for the title bar when WCO is active */
  body {
    padding-top: var(--titlebar-height);
  }
}

/* Show pinned title bar when WCO is pinned */
body.wco-pinned .title-bar-region {
  display: flex;
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 33px; /* Fixed height for pinned mode */
}

/* Add space for pinned title bar */
body.wco-pinned {
  padding-top: var(--effective-titlebar-height);
}

/* For actual WCO mode, position at the correct coordinates */
@media (display-mode: window-controls-overlay) {
  .title-bar-region {
    top: var(--titlebar-y);
    left: var(--titlebar-x);
    width: var(--titlebar-width);
  }
  
  body {
    padding-top: var(--effective-titlebar-height);
  }
}

/* Class for elements that use WCO when available but remain visible otherwise */
.wco-adaptable {
  position: relative;
}

/* When in WCO mode, elements with .wco-active class are shown in title bar */
.wco-active {
  display: none;
}

@media (display-mode: window-controls-overlay) {
  .wco-active {
    display: flex;
  }
  
  .wco-inactive {
    display: none;
  }
}

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

.modal-content {
  background-color: var(--card-bg);
  margin: 5% auto;
  padding: 1rem;
  width: 90%;
  max-width: 500px;
  border-radius: 8px;
  position: relative;
  color: var(--card-text);
}

.close {
  position: absolute;
  right: 1rem;
  top: 1rem;
  font-size: 1.5rem;
  cursor: pointer;
}

#tooltip {
  position: absolute;
  pointer-events: none;
  background: rgba(0, 0, 0, 0.85);
  color: #fff;
  padding: 0.5rem 0.75rem;
  border-radius: 4px;
  font-size: 0.85rem;
  opacity: 0;
  transition: opacity 0.2s;
  z-index: 9999;
}

@media (max-width: 768px) {
  .container {
    flex-direction: column;
  }

  .sidebar {
    width: 100%;
    border-right: none;
    border-bottom: 1px solid var(--border-color);
  }

  .content {
    padding: 1rem;
  }

  .header-left {
    flex: 1 1 100%;
    justify-content: space-between;
  }

  .header-controls {
    flex: 1 1 100%;
    margin-top: 0.5rem;
    justify-content: flex-end;
  }
}