/* =====================================================
   StreamUP Settings Viewer - Modern UI
   ===================================================== */

/* Import Bebas Neue font from Google Fonts */
@import url('https://fonts.googleapis.com/css2?family=Bebas+Neue&family=Inter:wght@400;500;600;700&display=swap');

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

:root {
    /* StreamUP Brand Colors */
    --streamup-cyan: #6af4ff;
    --streamup-pink: #ff86bd;
    --streamup-midnight: #1a1f35;

    /* Primary Colors - Using StreamUP Cyan */
    --primary: #6af4ff;
    --primary-hover: #4dd9e6;
    --primary-light: #a3f8ff;
    --primary-dark: #2bc4d4;

    /* Secondary Colors - Using StreamUP Pink */
    --secondary: #ff86bd;
    --secondary-hover: #ff6ba8;
    --secondary-light: #ffb3d6;

    /* Status Colors */
    --success: #10b981;
    --success-hover: #059669;
    --danger: #ef4444;
    --danger-hover: #dc2626;
    --warning: #f59e0b;
    --info: #3b82f6;

    /* Neutrals - Light Mode */
    --gray-50: #f9fafb;
    --gray-100: #f3f4f6;
    --gray-200: #e5e7eb;
    --gray-300: #d1d5db;
    --gray-400: #9ca3af;
    --gray-500: #6b7280;
    --gray-600: #4b5563;
    --gray-700: #374151;
    --gray-800: #1f2937;
    --gray-900: #111827;

    /* Semantic - Light Mode */
    --text-primary: var(--gray-900);
    --text-secondary: var(--gray-600);
    --text-muted: var(--gray-500);
    --bg-primary: #ffffff;
    --bg-secondary: var(--gray-50);
    --bg-tertiary: var(--gray-100);
    --border: var(--gray-200);
    --border-light: var(--gray-100);
    --bg-gradient: linear-gradient(135deg, #f5f7fa 0%, #c3cfe2 100%);

    /* Shadows */
    --shadow-sm: 0 1px 2px 0 rgb(0 0 0 / 0.05);
    --shadow: 0 1px 3px 0 rgb(0 0 0 / 0.1), 0 1px 2px -1px rgb(0 0 0 / 0.1);
    --shadow-md: 0 4px 6px -1px rgb(0 0 0 / 0.1), 0 2px 4px -2px rgb(0 0 0 / 0.1);
    --shadow-lg: 0 10px 15px -3px rgb(0 0 0 / 0.1), 0 4px 6px -4px rgb(0 0 0 / 0.1);
    --shadow-xl: 0 20px 25px -5px rgb(0 0 0 / 0.1), 0 8px 10px -6px rgb(0 0 0 / 0.1);

    /* Transitions */
    --transition: all 0.2s ease;
    --transition-slow: all 0.3s ease;

    /* Spacing */
    --spacing-xs: 0.25rem;
    --spacing-sm: 0.5rem;
    --spacing-md: 1rem;
    --spacing-lg: 1.5rem;
    --spacing-xl: 2rem;
    --spacing-2xl: 3rem;

    /* Border radius */
    --radius-sm: 0.375rem;
    --radius: 0.5rem;
    --radius-md: 0.75rem;
    --radius-lg: 1rem;
}

/* =====================================================
   Dark Mode
   ===================================================== */

[data-theme="dark"] {
    /* Semantic - Dark Mode */
    --text-primary: #f3f4f6;
    --text-secondary: #d1d5db;
    --text-muted: #9ca3af;
    --bg-primary: #1a1f35;
    --bg-secondary: #12151f;
    --bg-tertiary: #0d0f17;
    --border: #2d3748;
    --border-light: #374151;
    --bg-gradient: linear-gradient(135deg, #0d0f17 0%, #1a1f35 100%);

    /* Adjust shadows for dark mode */
    --shadow-sm: 0 1px 2px 0 rgb(0 0 0 / 0.5);
    --shadow: 0 1px 3px 0 rgb(0 0 0 / 0.7), 0 1px 2px -1px rgb(0 0 0 / 0.7);
    --shadow-md: 0 4px 6px -1px rgb(0 0 0 / 0.7), 0 2px 4px -2px rgb(0 0 0 / 0.7);
    --shadow-lg: 0 10px 15px -3px rgb(0 0 0 / 0.7), 0 4px 6px -4px rgb(0 0 0 / 0.7);
    --shadow-xl: 0 20px 25px -5px rgb(0 0 0 / 0.7), 0 8px 10px -6px rgb(0 0 0 / 0.7);

    /* StreamUP colors remain bright in dark mode */
    --primary: #6af4ff;
    --primary-hover: #a3f8ff;
    --primary-light: #c1fbff;
    --secondary: #ff86bd;
}


/* =====================================================
   Base Styles
   ===================================================== */

body {
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
  line-height: 1.6;
  color: var(--text-primary);
  background: var(--bg-gradient);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  transition: background 0.3s ease, color 0.3s ease;
}

/* Bebas Neue for headings */
h1, h2, h3, h4, h5, h6 {
  font-family: 'Bebas Neue', 'Impact', sans-serif;
  letter-spacing: 0.05em;
}

/* =====================================================
   Header
   ===================================================== */

header {
  background: linear-gradient(135deg, var(--streamup-midnight) 0%, #0d0f17 100%);
  color: white;
  padding: var(--spacing-md) var(--spacing-xl);
  box-shadow: var(--shadow-lg);
  position: sticky;
  top: 0;
  z-index: 100;
  border-bottom: 3px solid var(--streamup-cyan);
}

.header-content {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: var(--spacing-md);
}

.header-text {
  display: flex;
  align-items: center;
  gap: var(--spacing-md);
}

.header-logo {
  height: 40px;
  width: auto;
  flex-shrink: 0;
  transition: opacity 0.3s ease;
}

.header-logo:hover {
  opacity: 0.85;
}

header h1 {
  font-size: 1.5rem;
  font-weight: 400;
  margin: 0;
  text-shadow: 0 2px 4px rgba(0,0,0,0.3);
  background: linear-gradient(135deg, var(--streamup-cyan) 0%, var(--streamup-pink) 100%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

header p {
  opacity: 0.85;
  font-size: 0.813rem;
  margin-top: 2px;
  margin: 0;
}

/* Theme Toggle Button */
.theme-toggle {
  background: rgba(255, 255, 255, 0.2);
  border: 2px solid rgba(255, 255, 255, 0.3);
  border-radius: 50%;
  width: 40px;
  height: 40px;
  font-size: 1.25rem;
  cursor: pointer;
  transition: var(--transition);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  backdrop-filter: blur(10px);
}

.theme-toggle:hover {
  background: rgba(255, 255, 255, 0.3);
  border-color: rgba(255, 255, 255, 0.5);
  transform: scale(1.1) rotate(20deg);
}

.theme-toggle:active {
  transform: scale(0.95) rotate(0deg);
}


/* =====================================================
   Main Content
   ===================================================== */

main {
  padding: var(--spacing-xl);
  max-width: 1200px;
  margin: 0 auto;
  flex: 1;
  width: 100%;
}

main h2 {
  font-size: 1.5rem;
  font-weight: 600;
  margin-bottom: var(--spacing-lg);
  color: var(--text-primary);
}

.menu-header {
  margin-bottom: var(--spacing-xl);
}

.menu-header h2 {
  margin-bottom: var(--spacing-xs);
}

.menu-description {
  font-family: 'Inter', sans-serif;
  font-size: 1rem;
  color: var(--text-secondary);
  line-height: 1.5;
  max-width: 720px;
}

/* Product Title Banner */
.product-title-banner {
  background: linear-gradient(135deg, var(--primary) 0%, var(--secondary) 100%);
  padding: var(--spacing-md) var(--spacing-xl);
  border-radius: var(--radius-lg);
  margin-bottom: var(--spacing-xl);
  box-shadow: var(--shadow-lg);
  position: relative;
  overflow: hidden;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--spacing-lg);
  flex-wrap: wrap;
}

/* Add a subtle overlay for better text contrast */
.product-title-banner::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0, 0, 0, 0.15);
  z-index: 0;
}


.product-title-banner h2,
.product-title-banner p,
.product-title-meta-item {
  position: relative;
  z-index: 1;
}

.product-title-banner h2 {
  font-size: 1.75rem;
  font-weight: 700;
  margin: 0 0 var(--spacing-xs) 0;
  color: white;
  text-shadow: 0 2px 8px rgba(0,0,0,0.5), 0 0 30px rgba(0,0,0,0.3);
  letter-spacing: 0.025em;
}


.product-title-main {
  flex: 1 1 260px;
  min-width: 220px;
}

.product-title-banner p {
  font-size: 0.95rem;
  margin: 0;
  color: white;
  font-weight: 600;
  text-shadow: 0 1px 4px rgba(0,0,0,0.5);
  opacity: 0.9;
}

.product-title-author {
  margin-top: var(--spacing-xs);
}

.product-title-meta {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: var(--spacing-lg);
  flex: 1 1 240px;
  min-width: 200px;
}

.product-title-meta-item {
  display: flex;
  flex-direction: column;
  gap: calc(var(--spacing-xs) * 0.5);
  padding: var(--spacing-sm) var(--spacing-md);
  background: rgba(0, 0, 0, 0.2);
  border-radius: var(--radius);
  min-width: 140px;
}

.meta-label {
  font-size: 0.75rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: rgba(255, 255, 255, 0.8);
}

.meta-value {
  font-size: 1.1rem;
  font-weight: 700;
  color: white;
  line-height: 1.2;
}

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

button {
  display: inline-flex;
  align-items: center;
  gap: var(--spacing-xs);
  padding: var(--spacing-sm) var(--spacing-md);
  border: none;
  border-radius: var(--radius-sm);
  font-size: 0.875rem;
  font-weight: 600;
  cursor: pointer;
  transition: var(--transition);
  background: var(--primary);
  color: #0a0d14; /* Dark text for better contrast with light cyan */
  font-family: 'Inter', sans-serif;
  text-shadow: none;
}

button:hover:not(:disabled) {
  background: var(--primary-hover);
  transform: translateY(-1px);
  box-shadow: var(--shadow-md);
}

button:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

#saveBtn {
  margin-top: var(--spacing-lg);
  padding: var(--spacing-md) var(--spacing-xl);
  font-size: 1rem;
  font-weight: 700;
  letter-spacing: 0.025em;
}

/* =====================================================
   Footer
   ===================================================== */

footer {
  background: linear-gradient(135deg, var(--streamup-midnight) 0%, #0d0f17 100%);
  color: white;
  text-align: center;
  padding: var(--spacing-xl);
  font-size: 0.875rem;
  border-top: 3px solid var(--streamup-cyan);
  margin-top: auto;
  margin-bottom: 36px;
}

footer p {
  margin: 0;
  opacity: 0.85;
}

/* =====================================================
   Connection Status Bar (compact)
   ===================================================== */

.status-taskbar {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  height: 36px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 1.5rem;
  background: rgba(10, 13, 20, 0.92);
  border-top: 1px solid rgba(255, 255, 255, 0.1);
  backdrop-filter: blur(18px);
  z-index: 220;
}

[data-theme="light"] .status-taskbar {
  background: rgba(255, 255, 255, 0.95);
  border-top-color: rgba(0, 0, 0, 0.08);
}

.status-strip {
  display: flex;
  align-items: center;
  gap: 1rem;
  flex-wrap: wrap;
}

.status-item {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  font-size: 0.75rem;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  padding: 0.15rem 0.5rem;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid transparent;
}

[data-theme="light"] .status-item {
  background: rgba(0, 0, 0, 0.04);
}

.status-item.connected {
  border-color: rgba(16, 185, 129, 0.9);
  color: var(--success);
}

.status-item.disconnected {
  border-color: rgba(239, 68, 68, 0.8);
  color: var(--danger);
}

.status-item.unknown {
  border-color: rgba(245, 158, 11, 0.8);
  color: var(--warning);
}

.status-icon {
  width: 16px;
  height: 16px;
  border-radius: 4px;
  background: transparent;
}

.status-label {
  font-weight: 600;
  color: var(--text-secondary);
}

.status-item.connected .status-label,
.status-item.disconnected .status-label,
.status-item.unknown .status-label {
  color: inherit;
}

.status-select {
  border: none;
  background: transparent;
  color: inherit;
  font-weight: 600;
  padding: 0.1rem 0.4rem;
  border-radius: var(--radius-sm);
  text-transform: none;
  cursor: pointer;
}

.status-refresh {
  border: none;
  background: transparent;
  color: var(--text-secondary);
  cursor: pointer;
  padding: 0.25rem 0.5rem;
  border-radius: 6px;
  transition: var(--transition);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 28px;
  height: 28px;
}

.status-refresh svg {
  width: 18px;
  height: 18px;
  stroke: currentColor;
  fill: none;
  transition: var(--transition);
}

.status-refresh:hover {
  color: var(--primary);
}

.status-refresh:hover svg {
  transform: rotate(-30deg);
}

@media (max-width: 640px) {
  .status-taskbar {
    flex-direction: column;
    height: auto;
    padding: 0.5rem 1rem 0.6rem;
    gap: 0.4rem;
  }

  .status-strip {
    width: 100%;
    justify-content: space-between;
    gap: 0.5rem;
  }

  .status-item {
    flex: 1 1 auto;
    justify-content: center;
  }

  .status-select {
    min-width: 90px;
  }
}

/* =====================================================
   Tabs
   ===================================================== */

.tabs {
  display: flex;
  gap: var(--spacing-sm);
  flex-wrap: wrap;
  margin-bottom: var(--spacing-sm);
  border-bottom: 2px solid var(--border);
}

.tab-button {
  padding: var(--spacing-sm) var(--spacing-lg);
  border: none;
  background: transparent;
  border-bottom: 3px solid transparent;
  cursor: pointer;
  font-size: 0.938rem;
  font-weight: 500;
  color: var(--text-secondary);
  transition: var(--transition);
  margin-bottom: -2px;
}

.tab-button:hover {
  color: var(--primary);
  background: var(--bg-secondary);
}

.tab-button.active {
  background: transparent;
  border-bottom-color: var(--primary);
  color: var(--primary);
  font-weight: 600;
}

/* Light mode active tab - use darker color for better contrast */
[data-theme="light"] .tab-button.active {
  color: var(--primary-dark);
  border-bottom-color: var(--primary-dark);
}

[data-theme="light"] .tab-button:hover {
  background: rgba(106, 244, 255, 0.16);
  color: var(--gray-900);
  font-weight: 600;
}

.tab-content {
  background: var(--bg-primary);
  padding: var(--spacing-lg);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  min-height: 200px;
}

.page-wrapper h3 {
  margin-top: 0;
  margin-bottom: var(--spacing-lg);
  color: var(--text-primary);
  font-size: 1.25rem;
}

/* =====================================================
   Group Panels
   ===================================================== */

.group-panel {
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  margin-bottom: var(--spacing-lg);
  overflow: hidden;
  background: var(--bg-secondary);
  box-shadow: var(--shadow-sm);
  transition: var(--transition-slow);
}

.group-panel:hover {
  box-shadow: var(--shadow-md);
}

.group-header {
  display: flex;
  align-items: center;
  gap: var(--spacing-md);
  padding: var(--spacing-md);
  cursor: pointer;
  user-select: none;
  background: var(--bg-tertiary);
  transition: var(--transition);
}

.group-header:hover {
  background: var(--bg-primary);
}

.group-toggle {
  border: none;
  background: transparent;
  font-size: 1rem;
  width: 28px;
  height: 28px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  color: var(--text-primary);
  transition: var(--transition);
}

.group-toggle:hover {
  transform: scale(1.1);
  color: var(--primary);
}

.group-title {
  font-weight: 700;
  font-size: 1rem;
  color: var(--text-primary);
}

.group-desc {
  color: var(--text-muted);
  font-size: 0.875rem;
  margin-left: auto;
}

.group-content {
  padding: var(--spacing-lg);
  transition: max-height 200ms ease;
  background: var(--bg-primary);
}

.group-content.collapsed {
  display: none;
}

/* =====================================================
   Individual Settings
   ===================================================== */

.setting-item {
  display: flex;
  flex-direction: column;
  gap: var(--spacing-sm);
  border-bottom: 1px solid var(--border);
}

/* Boolean settings - horizontal layout with toggle next to label */
.setting-item[data-setting-type="boolean"] {
  flex-direction: row;
  align-items: center;
  justify-content: space-between;
  padding: var(--spacing-md) 0;
}

.setting-item[data-setting-type="boolean"] .setting-label {
  margin: 0;
  flex: 1;
}

.setting-item[data-setting-type="boolean"] .toggle-switch-wrapper {
  margin: 0;
}

.setting-item:last-child {
  border-bottom: none;
  padding-bottom: 0;
}

.setting-label {
  font-weight: 600;
  font-size: 0.875rem;
  color: var(--text-secondary);
}

.setting-control {
  padding: var(--spacing-sm) var(--spacing-md);
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  font-size: 0.938rem;
  max-width: 100%;
  background: var(--bg-primary);
  color: var(--text-primary);
  transition: var(--transition);
  font-family: 'Inter', sans-serif;
}

.setting-control:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(106, 244, 255, 0.2);
}

input[type="text"].setting-control,
input[type="number"].setting-control,
select.setting-control,
textarea.setting-control {
  width: 100%;
}

input[type="number"].setting-control {
  -moz-appearance: textfield;
}

input[type="number"].setting-control::-webkit-inner-spin-button,
input[type="number"].setting-control::-webkit-outer-spin-button {
  -webkit-appearance: none;
  margin: 0;
}

/* Textarea specific styling */
textarea.setting-control {
  resize: vertical; /* Only allow vertical resizing */
  min-height: 80px;
  max-width: 100%; /* Prevent horizontal expansion */
  min-width: 100%; /* Prevent horizontal shrinking */
  box-sizing: border-box;
}

select.setting-control {
  cursor: pointer;
  appearance: none;
  background-color: var(--bg-primary);
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'%3E%3Cpath fill='%2366' d='M6 9L1 4h10z'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 0.75rem center;
  background-size: 12px 12px;
  padding-right: 2.5rem;
}

/* Range slider with value display */
.range-wrapper {
  display: flex;
  align-items: center;
  gap: var(--spacing-md);
}

.range-value {
  min-width: 48px;
  text-align: right;
  font-weight: 600;
  color: var(--text-primary);
  font-size: 0.938rem;
}

input[type="range"] {
  flex: 1;
  appearance: none;
  height: 8px;
  background: linear-gradient(to right, var(--primary) 0%, var(--primary) var(--range-progress, 50%), var(--bg-tertiary) var(--range-progress, 50%), var(--bg-tertiary) 100%);
  border-radius: 10px;
  outline: none;
  position: relative;
  cursor: pointer;
  border: 1px solid var(--border);
}

input[type="range"]::-webkit-slider-thumb {
  appearance: none;
  width: 24px;
  height: 24px;
  background: linear-gradient(135deg, var(--primary) 0%, var(--primary-light) 100%);
  border-radius: 50%;
  cursor: grab;
  box-shadow: 0 2px 8px rgba(106, 244, 255, 0.4), var(--shadow-md);
  transition: var(--transition);
  border: 3px solid white;
  position: relative;
}

input[type="range"]::-webkit-slider-thumb:hover {
  background: linear-gradient(135deg, var(--primary-light) 0%, var(--primary) 100%);
  transform: scale(1.15);
  box-shadow: 0 4px 12px rgba(106, 244, 255, 0.6), var(--shadow-lg);
}

input[type="range"]::-webkit-slider-thumb:active {
  cursor: grabbing;
  transform: scale(1.05);
}

input[type="range"]::-moz-range-thumb {
  width: 24px;
  height: 24px;
  background: linear-gradient(135deg, var(--primary) 0%, var(--primary-light) 100%);
  border-radius: 50%;
  cursor: grab;
  border: 3px solid white;
  box-shadow: 0 2px 8px rgba(106, 244, 255, 0.4), var(--shadow-md);
  transition: var(--transition);
}

input[type="range"]::-moz-range-thumb:hover {
  background: linear-gradient(135deg, var(--primary-light) 0%, var(--primary) 100%);
  transform: scale(1.15);
  box-shadow: 0 4px 12px rgba(106, 244, 255, 0.6), var(--shadow-lg);
}

input[type="range"]::-moz-range-thumb:active {
  cursor: grabbing;
  transform: scale(1.05);
}

input[type="range"]::-moz-range-track {
  background: transparent;
  border: none;
}

/* Apple-style Toggle Switch */
.toggle-switch-wrapper {
  display: flex;
  align-items: center;
  gap: var(--spacing-md);
}

.toggle-switch {
  position: relative;
  display: inline-block;
  width: 51px;
  height: 31px;
  flex-shrink: 0;
}

.toggle-switch input[type="checkbox"] {
  opacity: 0;
  width: 0;
  height: 0;
  position: absolute;
}

.toggle-slider {
  position: absolute;
  cursor: pointer;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background-color: var(--gray-400);
  transition: 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  border-radius: 34px;
  box-shadow: inset 0 1px 3px rgba(0, 0, 0, 0.2);
}

[data-theme="dark"] .toggle-slider {
  background-color: var(--gray-600);
}

.toggle-slider:before {
  position: absolute;
  content: "";
  height: 27px;
  width: 27px;
  left: 2px;
  bottom: 2px;
  background-color: white;
  transition: 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  border-radius: 50%;
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.2), 0 1px 2px rgba(0, 0, 0, 0.1);
}

input[type="checkbox"]:checked + .toggle-slider {
  background-color: var(--primary);
}

[data-theme="dark"] input[type="checkbox"]:checked + .toggle-slider {
  background-color: var(--primary);
}

input[type="checkbox"]:checked + .toggle-slider:before {
  transform: translateX(20px);
}

input[type="checkbox"]:focus + .toggle-slider {
  box-shadow: 0 0 0 3px rgba(106, 244, 255, 0.3), inset 0 1px 3px rgba(0, 0, 0, 0.2);
}

.toggle-slider:hover {
  opacity: 0.9;
}

input[type="checkbox"]:disabled + .toggle-slider {
  opacity: 0.5;
  cursor: not-allowed;
}

input[type="checkbox"]:disabled + .toggle-slider:before {
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.2);
}

/* Add subtle animation on toggle */
input[type="checkbox"]:active:not(:disabled) + .toggle-slider:before {
  width: 30px;
}

input[type="checkbox"]:checked:active:not(:disabled) + .toggle-slider:before {
  transform: translateX(17px);
}

/* Date/Time inputs */
input[type="date"],
input[type="time"],
input[type="datetime-local"] {
  cursor: pointer;
  color-scheme: dark;
  min-height: 40px;
}

[data-theme="light"] input[type="date"],
[data-theme="light"] input[type="time"],
[data-theme="light"] input[type="datetime-local"] {
  color-scheme: light;
}

/* Ensure calendar and clock icons inherit theme colors */
input[type="date"]::-webkit-calendar-picker-indicator,
input[type="datetime-local"]::-webkit-calendar-picker-indicator {
  cursor: pointer;
  filter: invert(1);
  opacity: 1;
  width: 20px;
  height: 20px;
}

[data-theme="light"] input[type="date"]::-webkit-calendar-picker-indicator,
[data-theme="light"] input[type="datetime-local"]::-webkit-calendar-picker-indicator {
  filter: invert(0);
}

/* Custom clock icon for time inputs - Dark mode */
input[type="time"]::-webkit-calendar-picker-indicator {
  cursor: pointer;
  opacity: 1 !important;
  width: 20px !important;
  height: 20px !important;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='20' height='20' viewBox='0 0 24 24' fill='none' stroke='white' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Ccircle cx='12' cy='12' r='10'%3E%3C/circle%3E%3Cpolyline points='12 6 12 12 16 14'%3E%3C/polyline%3E%3C/svg%3E") !important;
  background-size: contain !important;
  background-repeat: no-repeat !important;
  background-position: center !important;
  filter: none !important;
}

/* Custom clock icon for time inputs - Light mode */
[data-theme="light"] input[type="time"]::-webkit-calendar-picker-indicator {
  cursor: pointer;
  opacity: 1 !important;
  width: 20px !important;
  height: 20px !important;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='20' height='20' viewBox='0 0 24 24' fill='none' stroke='%23374151' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Ccircle cx='12' cy='12' r='10'%3E%3C/circle%3E%3Cpolyline points='12 6 12 12 16 14'%3E%3C/polyline%3E%3C/svg%3E") !important;
  background-size: contain !important;
  background-repeat: no-repeat !important;
  background-position: center !important;
  filter: none !important;
}

/* Firefox time/date picker icons */
input[type="date"]::-moz-calendar-picker-indicator,
input[type="time"]::-moz-calendar-picker-indicator,
input[type="datetime-local"]::-moz-calendar-picker-indicator {
  cursor: pointer;
  opacity: 1;
}

/* Color picker custom styling */
input[type="color"] {
  cursor: pointer;
  padding: 2px;
}

input[type="color"]::-webkit-color-swatch-wrapper {
  padding: 0;
  border-radius: calc(var(--radius-sm) - 2px);
}

input[type="color"]::-webkit-color-swatch {
  border: none;
  border-radius: calc(var(--radius-sm) - 2px);
}

input[type="color"]::-moz-color-swatch {
  border: none;
  border-radius: calc(var(--radius-sm) - 2px);
}

/* Single setting outside groups */
.single-setting-wrapper {
  padding: var(--spacing-md) 0;
}

/* No settings placeholder */
.no-settings {
  color: var(--text-muted);
  font-style: italic;
  padding: var(--spacing-lg) 0;
  text-align: center;
}

/* =====================================================
   Product Information Box
   ===================================================== */

.product-box {
  background: var(--bg-primary);
  padding: var(--spacing-lg);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow);
  margin-bottom: var(--spacing-xl);
  border: 1px solid var(--border);
  transition: var(--transition-slow);
}

.product-box:hover {
  box-shadow: var(--shadow-md);
}

.product-info-table-wrapper {
  width: 100%;
  overflow-x: auto;
}

.product-info-table {
  width: 100%;
  border-collapse: collapse;
  table-layout: fixed;
}

.product-info-table th,
.product-info-table td {
  padding: var(--spacing-md) var(--spacing-sm);
  text-align: left;
  font-size: 0.95rem;
  border-bottom: 1px solid var(--border);
}

.product-info-table th {
  width: 30%;
  color: var(--text-secondary);
  font-weight: 600;
}

.product-info-table td {
  color: var(--text-primary);
  font-weight: 500;
  word-break: break-word;
}

.product-info-table tr:last-child th,
.product-info-table tr:last-child td {
  border-bottom: none;
}

/* =====================================================
   Dark Mode Overrides
   ===================================================== */

[data-theme="dark"] .tab-button {
  color: var(--text-secondary);
}

[data-theme="dark"] .tab-button:hover {
  background: var(--bg-tertiary);
  color: var(--primary);
}

[data-theme="dark"] .tab-button.active {
  color: var(--primary);
}

[data-theme="dark"] .tab-content {
  background: var(--bg-primary);
}

[data-theme="dark"] .setting-control {
  background: var(--bg-tertiary);
  border-color: var(--border);
  color: var(--text-primary);
}

[data-theme="dark"] .setting-control:focus {
  background: var(--bg-primary);
  border-color: var(--primary);
}

[data-theme="dark"] select.setting-control {
  background-color: var(--bg-tertiary);
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'%3E%3Cpath fill='%236af4ff' d='M6 9L1 4h10z'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 0.75rem center;
  background-size: 12px 12px;
}

[data-theme="dark"] .product-box {
  background: var(--bg-primary);
  border-color: var(--border);
}

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

@media (max-width: 768px) {
  main {
    padding: var(--spacing-md);
  }

  header {
    padding: var(--spacing-md);
  }

  .header-content {
    flex-direction: column;
    align-items: flex-start;
  }

  header h1 {
    font-size: 1.25rem;
  }

  header p {
    font-size: 0.75rem;
  }

  .tabs {
    overflow-x: auto;
  }

  .product-title-banner {
    flex-direction: column;
    align-items: flex-start;
    gap: var(--spacing-md);
    padding: var(--spacing-lg);
  }

  .product-title-meta {
    width: 100%;
    justify-content: flex-start;
    flex-wrap: wrap;
  }

  .product-title-meta-item {
    width: 100%;
  }

  .product-info-table th,
  .product-info-table td {
    font-size: 0.875rem;
    padding: var(--spacing-sm) var(--spacing-xs);
  }

  .product-info-table th {
    width: 40%;
  }

  .theme-toggle {
    position: absolute;
    top: var(--spacing-md);
    right: var(--spacing-md);
  }
}

/* =====================================================
   Utility Classes
   ===================================================== */

/* Markdown content styling */
.markdown-content h1,
.markdown-content h2,
.markdown-content h3,
.markdown-content h4,
.markdown-content h5,
.markdown-content h6 {
  color: var(--text-primary);
  margin: 0.5em 0 0.3em 0;
  font-weight: 600;
}

.markdown-content h1 { font-size: 1.5rem; }
.markdown-content h2 { font-size: 1.35rem; }
.markdown-content h3 { font-size: 1.2rem; }
.markdown-content h4 { font-size: 1.1rem; }
.markdown-content h5 { font-size: 1rem; }
.markdown-content h6 { font-size: 0.9rem; }

.markdown-content p {
  margin: 0.5em 0;
}

.markdown-content strong {
  color: var(--text-primary);
  font-weight: 600;
}

.markdown-content em {
  font-style: italic;
}

.markdown-content code {
  font-family: 'Consolas', 'Monaco', 'Courier New', monospace;
}

.markdown-content a {
  color: #0066cc;
  text-decoration: underline;
  font-weight: 600;
  transition: var(--transition);
  text-underline-offset: 2px;
  text-decoration-thickness: 1.5px;
}

.markdown-content a:hover {
  color: #004499;
  text-decoration-thickness: 2px;
  text-shadow: 0 0 1px rgba(0, 102, 204, 0.3);
}

/* Ensure links are visible in dark mode */
[data-theme="dark"] .markdown-content a {
  color: #5eb3ff;
  text-shadow: 0 0 1px rgba(94, 179, 255, 0.2);
}

[data-theme="dark"] .markdown-content a:hover {
  color: #8eccff;
  text-decoration-thickness: 2px;
  text-shadow: 0 0 2px rgba(94, 179, 255, 0.4);
}

.text-center {
  text-align: center;
}

.mt-1 { margin-top: var(--spacing-sm); }
.mt-2 { margin-top: var(--spacing-md); }
.mt-3 { margin-top: var(--spacing-lg); }

.mb-1 { margin-bottom: var(--spacing-sm); }
.mb-2 { margin-bottom: var(--spacing-md); }
.mb-3 { margin-bottom: var(--spacing-lg); }

.p-1 { padding: var(--spacing-sm); }
.p-2 { padding: var(--spacing-md); }
.p-3 { padding: var(--spacing-lg); }

/* =====================================================
   Flatpickr Minimal Styling
   ===================================================== */

/* Flatpickr wrapper */
.flatpickr-wrapper {
  position: relative;
}

.flatpickr-input {
  cursor: pointer;
  padding-right: 40px !important;
}

/* =====================================================
   Notification Toast Styles
   ===================================================== */

.notification-toast {
  position: fixed;
  top: 20px;
  right: 20px;
  min-width: 300px;
  max-width: 500px;
  padding: var(--spacing-md);
  background: var(--bg-secondary);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  box-shadow: 0 10px 40px rgba(0, 0, 0, 0.3);
  display: flex;
  align-items: center;
  gap: var(--spacing-sm);
  z-index: 10000;
  opacity: 0;
  transform: translateX(400px);
  transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.notification-toast.notification-show {
  opacity: 1;
  transform: translateX(0);
}

.notification-toast.notification-fade-out {
  opacity: 0;
  transform: translateX(400px);
}

.notification-icon {
  flex-shrink: 0;
  width: 24px;
  height: 24px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 16px;
  font-weight: bold;
  border-radius: 50%;
}

.notification-message {
  flex: 1;
  color: var(--text-primary);
  font-size: 14px;
  line-height: 1.5;
}

.notification-close {
  flex-shrink: 0;
  background: none;
  border: none;
  color: var(--text-secondary);
  font-size: 24px;
  line-height: 1;
  cursor: pointer;
  padding: 0;
  width: 24px;
  height: 24px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: var(--radius-sm);
  transition: all 0.2s;
}

.notification-close:hover {
  background: var(--bg-tertiary);
  color: var(--text-primary);
}

/* Notification type variants */
.notification-success {
  border-left: 4px solid var(--success);
}

.notification-success .notification-icon {
  background: var(--success);
  color: white;
}

.notification-error {
  border-left: 4px solid var(--danger);
}

.notification-error .notification-icon {
  background: var(--danger);
  color: white;
}

.notification-warning {
  border-left: 4px solid var(--warning);
}

.notification-warning .notification-icon {
  background: var(--warning);
  color: white;
}

.notification-info {
  border-left: 4px solid var(--info);
}

.notification-info .notification-icon {
  background: var(--info);
  color: white;
}

/* =====================================================
   Loading Overlay Styles
   ===================================================== */

.loading-overlay {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0, 0, 0, 0.7);
  backdrop-filter: blur(4px);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: var(--spacing-lg);
  z-index: 9999;
  opacity: 0;
  animation: fadeIn 0.3s forwards;
}

.loading-overlay.loading-fade-out {
  animation: fadeOut 0.3s forwards;
}

.loading-spinner {
  width: 48px;
  height: 48px;
  border: 4px solid var(--bg-tertiary);
  border-top-color: var(--primary);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

.loading-message {
  color: var(--text-primary);
  font-size: 16px;
  font-weight: 500;
}

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

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

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

/* Responsive notification styles */
@media (max-width: 640px) {
  .notification-toast {
    left: 10px;
    right: 10px;
    min-width: auto;
    max-width: none;
    top: 10px;
  }
}
