/* Layout Styles */
html {
  overflow-x: hidden;
}

body {
  margin: 0;
  font-family: "Segoe UI", Tahoma, Geneva, Verdana, sans-serif;
  background-color: var(--bg-color);
  color: var(--text-color);
  display: flex;
  height: 100vh;
  overflow: hidden;
  overflow-x: hidden;
}

.app-container {
  display: flex;
  height: 100%;
  overflow-x: hidden;
}

/* Sidebar Controls - Left */
#controls {
  width: 400px;
  background-color: var(--panel-bg);
  padding: 0;
  overflow: hidden;
  box-shadow: 2px 0 10px rgba(0, 0, 0, 0.3);
  display: flex;
  flex-direction: column;
  z-index: 10;
  flex-shrink: 0;
  height: 100%;
  box-sizing: border-box;
  transition: transform 0.3s ease, opacity 0.3s ease;
}

/* Fullscreen Timer Controls */
#timer-controls.fullscreen-visible {
  position: fixed !important;
  bottom: 40px !important;
  left: 50% !important;
  transform: translateX(-50%) !important;
  z-index: 10001 !important;
  padding: 15px 25px !important;
  background: rgba(0, 0, 0, 0.85) !important;
  border-radius: 12px !important;
  box-shadow: 0 10px 40px rgba(0, 0, 0, 0.8) !important;
  backdrop-filter: blur(10px) !important;
  display: flex !important;
  width: auto !important;
  opacity: 1 !important;
  visibility: visible !important;
  transition: opacity 0.5s ease, visibility 0.5s ease !important;
}

#timer-controls.fullscreen-hidden {
  opacity: 0 !important;
  visibility: hidden !important;
  transition: opacity 0.5s ease, visibility 0.5s ease !important;
}

#timer-controls.fullscreen-visible button {
  font-size: 16px !important;
  padding: 12px 20px !important;
}

.categories-container {
  flex: 1;
  overflow-y: auto;
  overflow-x: hidden;
  padding: 12px;
  padding-bottom: 0;
  display: flex;
  flex-direction: column;
  gap: 10px;
  min-height: 0;
}

.ad-slot-sidebar {
  flex-shrink: 0;
}

/* Right Sidebar with Ads */
#sidebar-right {
  width: 320px;
  background-color: var(--panel-bg);
  padding: 20px;
  overflow-y: auto;
  overflow-x: hidden;
  box-shadow: -2px 0 10px rgba(0, 0, 0, 0.3);
  display: flex;
  flex-direction: column;
  gap: 20px;
  z-index: 10;
  flex-shrink: 0;
  color: var(--text-color);
}

/* Main Area (Preview + Content - Center) */
#main-area {
  flex: 1;
  min-width: 0;
  overflow-y: auto;
  overflow-x: hidden;
  display: flex;
  flex-direction: column;
  position: relative;
}

/* Preview Canvas Container */
#preview-container {
  min-height: 500px;
  background: linear-gradient(135deg, #1e1e2e 0%, #2d2d4a 100%);
  display: flex;
  justify-content: center;
  align-items: center;
  padding: 20px;
  box-sizing: border-box;
  position: relative;
  overflow-x: hidden;
}

#preview-container.fullscreen {
  position: fixed;
  top: 0;
  left: 0;
  width: 100vw;
  height: 100vh;
  z-index: 9999;
  padding: 0;
  min-height: 0;
}

#preview-container.fullscreen #countdownCanvas {
  max-width: 100vw;
  max-height: 100vh;
  border-radius: 0;
}

#btnFullscreen {
  position: absolute;
  top: 20px;
  right: 20px;
  background: rgba(0, 0, 0, 0.6);
  color: white;
  border: 2px solid rgba(255, 255, 255, 0.3);
  border-radius: 8px;
  padding: 10px 16px;
  font-size: 20px;
  cursor: pointer;
  transition: all 0.3s;
  z-index: 10;
}

#btnFullscreen:hover {
  background: rgba(0, 0, 0, 0.8);
  border-color: var(--accent-color);
  transform: scale(1.1);
}

#countdownCanvas {
  max-width: 100%;
  max-height: 100%;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.5);
  border-radius: 8px;
}

/* Mobile Adjustments */
@media (max-width: 768px) {
  body {
    overflow: auto;
  }

  .app-container {
    flex-direction: column;
    height: auto;
  }

  #controls {
    width: 100%;
    box-sizing: border-box;
    height: auto;
    overflow-y: auto; /* Allow scrolling on mobile */
    max-height: none; /* Remove max-height restriction */
  }

  .categories-container {
    overflow-y: hidden;
    overflow-x: hidden;
    flex: 1;
    min-height: 0;
    max-height: calc(100vh - 100px); /* Limit height on mobile */
  }

  #sidebar-right {
    width: 100%;
    box-sizing: border-box;
    height: auto;
    flex-direction: row;
    flex-wrap: wrap;
  }

  .ad-slot-right {
    flex: 1 1 calc(50% - 10px);
    height: 200px;
  }

  #preview-container {
    min-height: 300px;
  }
}

/* Mobile Tab Navigation */
.mobile-tabs {
  display: none;
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  background: var(--panel-bg);
  z-index: 1000;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.2);
  padding: 0;
  height: 50px;
}

.tab-btn {
  flex: 1;
  padding: 12px 10px;
  border: none;
  background: transparent;
  color: var(--text-color);
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s;
  border-bottom: 2px solid transparent;
  opacity: 0.7;
}

.tab-btn.active {
  color: var(--accent-color);
  border-bottom-color: var(--accent-color);
  opacity: 1;
}

/* Allow scrolling in appearance category on mobile */
#cat-appearance .category-content {
  overflow-y: auto;
  max-height: 300px; /* Reasonable max height for scrolling */
}

/* Mobile Responsive Styles */
@media (max-width: 1024px) {
  .mobile-tabs {
    display: flex;
  }

  body {
    padding-top: 50px;
    height: calc(100vh - 50px);
    overflow-x: hidden;
  }

  .app-container {
    display: block;
    height: 100%;
  }

  #controls {
    height: 100%;
    max-height: 100%;
    overflow: hidden;
    box-shadow: none;
    display: none;
    z-index: 10;
    width: 100vw;
  }

  #controls.mobile-visible {
    display: block;
  }

  #main-area {
    height: 100%;
    overflow-y: auto;
    overflow-x: hidden;
    display: block;
    z-index: 1;
  }

  #main-area.mobile-hidden {
    display: none;
  }

  #sidebar-right {
    display: none;
  }

  #preview-container {
    min-height: 60vh;
    padding: 15px;
    overflow-x: hidden;
  }

  #timer-controls {
    margin: 20px 15px;
    flex-direction: row;
  }

  .export-section {
    padding: 20px 15px;
  }

  .seo-content {
    padding: 20px 15px;
  }

  footer {
    padding: 15px;
  }
}

/* Tablet Styles */
@media (min-width: 1025px) and (max-width: 1200px) {
  #controls {
    width: 50vw;
  }
}

@media (max-width: 768px) {
  .tab-btn {
    font-size: 13px;
    padding: 10px 8px;
  }

  #preview-container {
    min-height: 50vh;
    padding: 10px;
    overflow-x: hidden;
  }

  .category-section {
    margin-bottom: 8px;
  }

  .control-group {
    margin-bottom: 10px;
  }

  #timer-controls {
    flex-direction: column;
    gap: 8px;
    margin: 15px 10px;
  }

  #timer-controls button {
    width: 100%;
    padding: 12px;
  }

  .export-btn {
    font-size: 14px;
    padding: 12px;
  }

  .share-buttons {
    flex-direction: column;
  }

  .share-btn {
    width: 100%;
    margin-bottom: 8px;
  }
}

@media (max-width: 480px) {
  body {
    padding-top: 45px;
  }

  .mobile-tabs {
    height: 45px;
  }

  .tab-btn {
    padding: 10px 6px;
    font-size: 12px;
  }

  #controls,
  #main-area {
    top: 45px;
  }

  #preview-container {
    min-height: 45vh;
    padding: 8px;
  }

  .category-title {
    font-size: 0.85em;
  }

  .control-group label {
    font-size: 0.9em;
  }

  input[type="text"],
  input[type="number"],
  input[type="datetime-local"],
  select {
    font-size: 14px;
    padding: 8px;
  }

  #timer-controls button {
    padding: 10px;
    font-size: 14px;
  }
}
