:root {
  --bg-primary: #0B0E14;
  --bg-secondary: #151A23;
  --bg-glass: rgba(21, 26, 35, 0.7);
  --bg-glass-hover: rgba(30, 36, 48, 0.8);
  
  --accent-primary: #8B5CF6;
  --accent-secondary: #6D28D9;
  --accent-success: #10B981;
  --accent-warning: #F59E0B;
  --accent-danger: #EF4444;
  --accent-info: #3B82F6;
  
  --text-primary: #F3F4F6;
  --text-secondary: #9CA3AF;
  --text-muted: #6B7280;
  
  --border-light: rgba(255, 255, 255, 0.1);
  --border-glass: rgba(255, 255, 255, 0.05);
  
  --shadow-sm: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06);
  --shadow-md: 0 10px 15px -3px rgba(0, 0, 0, 0.2), 0 4px 6px -2px rgba(0, 0, 0, 0.1);
  --shadow-glow: 0 0 20px rgba(139, 92, 246, 0.3);
  
  --radius-md: 12px;
  --radius-lg: 16px;
  --radius-full: 9999px;
  
  --transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

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

body {
  font-family: 'Inter', sans-serif;
  background-color: var(--bg-primary);
  background-image: 
    radial-gradient(circle at 15% 50%, rgba(139, 92, 246, 0.08) 0%, transparent 50%),
    radial-gradient(circle at 85% 30%, rgba(16, 185, 129, 0.05) 0%, transparent 50%);
  background-attachment: fixed;
  color: var(--text-primary);
  line-height: 1.5;
  min-height: 100vh;
}

/* Typography */
h1, h2, h3 { font-weight: 600; letter-spacing: -0.025em; }
h1 { font-size: 1.75rem; color: #fff; }
h2 { font-size: 1.25rem; margin-bottom: 1rem; color: #fff; }

.text-center { text-align: center; }
.hidden { display: none !important; }

/* Buttons */
button {
  cursor: pointer;
  border: none;
  background: none;
  font-family: inherit;
  font-size: 0.95rem;
  transition: var(--transition);
}

.submit-btn {
  width: 100%;
  padding: 0.875rem;
  border-radius: var(--radius-md);
  background: linear-gradient(135deg, var(--accent-primary), var(--accent-secondary));
  color: white;
  font-weight: 600;
  box-shadow: var(--shadow-md);
  margin-top: 1rem;
}
.submit-btn:hover {
  box-shadow: var(--shadow-glow);
  transform: translateY(-2px);
}
.submit-btn:disabled {
  opacity: 0.7;
  cursor: not-allowed;
  transform: none;
  box-shadow: none;
}

.btn-secondary {
  padding: 0.5rem 1rem;
  border-radius: var(--radius-full);
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid var(--border-light);
  color: var(--text-primary);
  font-weight: 500;
}
.btn-secondary:hover {
  background: rgba(255, 255, 255, 0.1);
}

.btn-icon {
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid var(--border-light);
  color: var(--text-primary);
  width: 36px;
  height: 36px;
  border-radius: var(--radius-md);
  display: flex;
  align-items: center;
  justify-content: center;
}
.btn-icon:hover {
  background: rgba(255, 255, 255, 0.1);
}

.refresh-btn {
  color: var(--text-secondary);
  background: rgba(255, 255, 255, 0.05);
  padding: 0.4rem 0.8rem;
  border-radius: var(--radius-md);
  font-size: 0.85rem;
}
.refresh-btn:hover { background: rgba(255, 255, 255, 0.1); color: var(--text-primary); }

/* Layout */
.app-layout {
  display: flex;
  height: 100vh;
  overflow: hidden;
}

.sidebar {
  width: 250px;
  background: rgba(10, 15, 30, 0.8);
  border-right: 1px solid var(--border-glass);
  backdrop-filter: blur(10px);
  display: flex;
  flex-direction: column;
  padding: 1.5rem 1rem;
}

.sidebar-logo {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 2rem;
  padding-bottom: 1rem;
  border-bottom: 1px solid rgba(255, 255, 255, 0.05);
}

.sidebar-logo img {
  height: 35px;
  width: auto;
  filter: drop-shadow(0 0 5px rgba(255,255,255,0.1));
}
.sidebar-logo h1 {
  font-size: 1.25rem;
  margin: 0;
}

.sidebar-nav {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.nav-item {
  text-decoration: none;
  color: var(--text-secondary);
  padding: 0.8rem 1rem;
  border-radius: var(--radius-md);
  transition: all 0.2s ease;
  font-weight: 500;
  display: flex;
  align-items: center;
  gap: 10px;
}
.nav-item:hover {
  background: rgba(255, 255, 255, 0.05);
  color: var(--text-primary);
}
.nav-item.active {
  background: linear-gradient(135deg, rgba(37, 211, 102, 0.15), rgba(18, 140, 126, 0.15));
  color: var(--accent-primary);
  border-left: 3px solid var(--accent-primary);
}

.app-container {
  flex: 1;
  max-width: 1400px;
  margin: 0 auto;
  padding: 1rem 2rem;
  overflow-y: auto;
  width: 100%;
}

.app-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 1rem;
  padding-bottom: 0.5rem;
  border-bottom: 1px solid var(--border-glass);
}

.header-right {
  display: flex;
  align-items: center;
  gap: 1rem;
}

/* Glass Panel */
.glass-panel {
  background: var(--bg-glass);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border: 1px solid var(--border-light);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-md);
}

.section-card {
  background: var(--bg-secondary);
  border: 1px solid var(--border-glass);
  border-radius: var(--radius-lg);
  padding: 1.5rem;
}

/* Dashboard Grid */
.dashboard-grid {
  display: grid;
  grid-template-columns: 3fr 1fr;
  gap: 2rem;
}

@media (max-width: 1024px) {
  .dashboard-grid {
    grid-template-columns: 1fr;
  }
}

/* Calendar Styling */
.calendar-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 0.75rem;
}

.calendar-header h2 { margin: 0; }

.calendar-grid-header {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  text-align: center;
  font-weight: 600;
  color: var(--text-secondary);
  margin-bottom: 0.5rem;
}

.calendar-grid-days {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 0.5rem;
}

.calendar-day {
  background: rgba(255, 255, 255, 0.02);
  border: 1px solid var(--border-glass);
  border-radius: var(--radius-md);
  min-height: 75px;
  padding: 0.5rem;
  cursor: pointer;
  transition: var(--transition);
  position: relative;
  display: flex;
  flex-direction: column;
}

.calendar-day:hover {
  background: var(--bg-glass-hover);
  border-color: rgba(255, 255, 255, 0.15);
  transform: translateY(-2px);
}

.calendar-day.empty {
  background: transparent;
  border-color: transparent;
  cursor: default;
}
.calendar-day.empty:hover { transform: none; }

.calendar-day.today {
  border-color: var(--accent-primary);
  background: rgba(139, 92, 246, 0.05);
}

.day-number {
  font-weight: 600;
  font-size: 1.1rem;
  align-self: flex-end;
  color: var(--text-secondary);
}
.calendar-day.today .day-number { color: var(--accent-primary); }

.day-indicators {
  margin-top: auto;
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
}
.day-indicator {
  width: 8px;
  height: 8px;
  border-radius: 50%;
}
.day-indicator.pending { background: var(--accent-warning); }
.day-indicator.sent { background: var(--accent-success); }
.day-indicator.failed { background: var(--accent-danger); }

/* Status Indicator */
.status-indicator {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.5rem 1rem;
  background: rgba(255, 255, 255, 0.05);
  border-radius: var(--radius-full);
  border: 1px solid var(--border-light);
}

.status-indicator-badge {
  width: 10px;
  height: 10px;
  border-radius: 50%;
}

.state-initializing { background: var(--accent-warning); box-shadow: 0 0 8px var(--accent-warning); animation: pulse 1.5s infinite; }
.state-qr-code { background: var(--accent-primary); box-shadow: 0 0 8px var(--accent-primary); }
.state-connected { background: var(--accent-success); box-shadow: 0 0 8px var(--accent-success); }
.state-disconnected { background: var(--accent-danger); box-shadow: 0 0 8px var(--accent-danger); }

/* QR Section */
.qr-container {
  display: flex;
  justify-content: center;
  align-items: center;
  min-height: 250px;
  margin: 2rem 0;
}
#qr-image {
  background: white;
  padding: 1rem;
  border-radius: var(--radius-md);
  width: 250px;
  height: 250px;
}

/* Modals */
.modal-overlay {
  position: fixed;
  top: 0; left: 0; right: 0; bottom: 0;
  background: rgba(0, 0, 0, 0.6);
  backdrop-filter: blur(4px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
  opacity: 1;
  transition: opacity 0.3s ease;
}

.modal-overlay.hidden {
  opacity: 0;
  pointer-events: none;
}

.modal-content {
  width: 100%;
  max-width: 500px;
  max-height: 90vh;
  display: flex;
  flex-direction: column;
}
.modal-content.large-modal { max-width: 800px; }

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

.close-modal-btn {
  font-size: 1.5rem;
  color: var(--text-secondary);
  line-height: 1;
}
.close-modal-btn:hover { color: var(--text-primary); }

.modal-body {
  padding: 1.5rem;
  overflow-y: auto;
}

/* Forms inside Modals */
.form-group {
  margin-bottom: 1.5rem;
}
.form-group label {
  display: block;
  margin-bottom: 0.5rem;
  font-size: 0.9rem;
  font-weight: 500;
  color: var(--text-secondary);
}
.sub-label {
  margin-top: 1rem;
}

input[type="text"], input[type="time"], textarea {
  width: 100%;
  background: rgba(0, 0, 0, 0.2);
  border: 1px solid var(--border-glass);
  border-radius: var(--radius-md);
  padding: 0.75rem 1rem;
  color: var(--text-primary);
  font-family: inherit;
  font-size: 0.95rem;
  transition: var(--transition);
}
input[type="text"]:focus, input[type="time"]:focus, textarea:focus {
  outline: none;
  border-color: var(--accent-primary);
  background: rgba(0, 0, 0, 0.4);
}

/* Type Toggle */
.type-toggle-container {
  display: flex;
  background: rgba(0, 0, 0, 0.2);
  border-radius: var(--radius-md);
  padding: 0.25rem;
  border: 1px solid var(--border-glass);
}
.type-toggle-container input[type="radio"] { display: none; }
.toggle-btn {
  flex: 1;
  text-align: center;
  padding: 0.5rem;
  border-radius: calc(var(--radius-md) - 2px);
  cursor: pointer;
  color: var(--text-secondary);
  transition: var(--transition);
  font-size: 0.9rem;
  margin-bottom: 0 !important;
}
.type-toggle-container input[type="radio"]:checked + .toggle-btn {
  background: rgba(255, 255, 255, 0.1);
  color: var(--text-primary);
  font-weight: 500;
}

/* Dropzone */
.file-dropzone {
  border: 2px dashed var(--border-glass);
  border-radius: var(--radius-md);
  padding: 1.5rem;
  text-align: center;
  position: relative;
  transition: var(--transition);
  background: rgba(0, 0, 0, 0.1);
}
.file-dropzone:hover {
  border-color: var(--accent-primary);
  background: rgba(139, 92, 246, 0.05);
}
.file-dropzone input[type="file"] {
  position: absolute;
  top: 0; left: 0; width: 100%; height: 100%;
  opacity: 0; cursor: pointer;
}
.dropzone-text {
  display: block; color: var(--text-secondary); margin-bottom: 0.5rem; font-size: 0.9rem;
}
.file-name-display {
  display: block; color: var(--accent-primary); font-size: 0.85rem; font-weight: 500;
}

/* Queue & Gallery List */
.queue-header, .gallery-header {
  display: flex; justify-content: space-between; align-items: center; margin-bottom: 1rem; gap: 0.5rem;
}
.gallery-header h2 {
  font-size: 1.1rem; margin-bottom: 0; line-height: 1.2;
}
.gallery-instructions {
  margin-bottom: 1rem; font-size: 0.85rem; color: var(--text-secondary); background: rgba(0,0,0,0.2); padding: 0.75rem; border-radius: var(--radius-md); border: 1px solid var(--border-glass);
}
.gallery-grid {
  display: grid; 
  grid-template-columns: repeat(2, 1fr); 
  gap: 0.75rem;
  max-height: calc(100vh - 250px);
  min-height: 300px;
  overflow-y: auto;
  padding-right: 5px;
}

/* Custom Scrollbar for Gallery Grid */
.gallery-grid::-webkit-scrollbar {
  width: 6px;
}
.gallery-grid::-webkit-scrollbar-track {
  background: rgba(0, 0, 0, 0.2);
  border-radius: 10px;
}
.gallery-grid::-webkit-scrollbar-thumb {
  background: rgba(255, 255, 255, 0.15);
  border-radius: 10px;
}
.gallery-grid::-webkit-scrollbar-thumb:hover {
  background: rgba(255, 255, 255, 0.3);
}
.gallery-item {
  width: 100%; aspect-ratio: 1; border-radius: var(--radius-md); object-fit: cover; cursor: grab; border: 2px solid transparent; transition: var(--transition); background: #000;
}
.gallery-item:active { cursor: grabbing; transform: scale(0.95); opacity: 0.8; }
.gallery-item:hover { border-color: var(--accent-primary); box-shadow: var(--shadow-glow); }

.gallery-item-delete {
  position: absolute;
  top: 5px;
  right: 5px;
  background: rgba(239, 68, 68, 0.9);
  color: white;
  border: none;
  border-radius: 50%;
  width: 24px;
  height: 24px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 14px;
  cursor: pointer;
  z-index: 5;
  box-shadow: 0 2px 4px rgba(0,0,0,0.5);
  transition: transform 0.2s;
}
.gallery-item-delete:hover {
  transform: scale(1.1);
  background: rgb(220, 38, 38);
}

.add-media-btn {
  cursor: pointer; display: inline-block; white-space: nowrap; font-size: 0.85rem; padding: 0.4rem 0.8rem;
}

/* Drag and drop effects */
.calendar-day.drag-over {
  background: rgba(139, 92, 246, 0.2);
  border-color: var(--accent-primary);
  transform: scale(1.02);
  z-index: 10;
  box-shadow: var(--shadow-glow);
}
.queue-list {
  display: flex; flex-direction: column; gap: 1rem;
}
.empty-state {
  text-align: center; padding: 2rem; color: var(--text-muted); font-size: 0.9rem;
}

.queue-card {
  background: rgba(0, 0, 0, 0.2);
  border: 1px solid var(--border-glass);
  border-radius: var(--radius-md);
  padding: 1rem;
}

.card-top {
  display: flex; justify-content: space-between; align-items: flex-start; margin-bottom: 0.75rem;
}
.card-top-inner { display: flex; gap: 1rem; }
.card-info { display: flex; flex-direction: column; gap: 0.25rem; }

.post-type-tag {
  font-size: 0.7rem; text-transform: uppercase; letter-spacing: 0.05em; font-weight: 600; color: var(--text-secondary);
}
.post-time { font-size: 1rem; font-weight: 600; }
.post-countdown { font-size: 0.8rem; color: var(--accent-warning); margin-top: 2px; }

.badge {
  padding: 0.25rem 0.5rem; border-radius: var(--radius-full); font-size: 0.75rem; font-weight: 600;
}
.badge.pending { background: rgba(245, 158, 11, 0.1); color: var(--accent-warning); border: 1px solid rgba(245, 158, 11, 0.2); }
.badge.sent { background: rgba(16, 185, 129, 0.1); color: var(--accent-success); border: 1px solid rgba(16, 185, 129, 0.2); }
.badge.failed { background: rgba(239, 68, 68, 0.1); color: var(--accent-danger); border: 1px solid rgba(239, 68, 68, 0.2); }

.card-img-preview { width: 50px; height: 50px; object-fit: cover; border-radius: 8px; }
.post-content-preview { font-size: 0.9rem; color: var(--text-secondary); background: rgba(255, 255, 255, 0.02); padding: 0.75rem; border-radius: 8px; margin-bottom: 0.75rem; }
.card-error-msg { font-size: 0.8rem; color: var(--accent-danger); background: rgba(239, 68, 68, 0.05); padding: 0.5rem; border-radius: 6px; margin-bottom: 0.75rem; }

.card-bottom { display: flex; justify-content: space-between; gap: 0.5rem; }
.delete-btn { font-size: 0.85rem; color: var(--text-muted); }
.delete-btn:hover { color: var(--accent-danger); }
.fire-btn { font-size: 0.85rem; color: var(--accent-info); font-weight: 500; }
.fire-btn:hover { text-decoration: underline; }

/* Day Actions */
.day-action-bar { margin-bottom: 1.5rem; }

/* Logs View */
.logs-container {
  display: flex; flex-direction: column; gap: 0.5rem;
}
.log-entry {
  padding: 0.75rem;
  border-radius: 8px;
  background: rgba(0,0,0,0.2);
  border-left: 4px solid var(--border-glass);
  font-size: 0.85rem;
}
.log-entry.info { border-left-color: var(--accent-info); }
.log-entry.success { border-left-color: var(--accent-success); }
.log-entry.warning { border-left-color: var(--accent-warning); }
.log-entry.error { border-left-color: var(--accent-danger); }
.log-time { color: var(--text-muted); margin-bottom: 0.25rem; font-size: 0.75rem; }
.log-message { color: var(--text-primary); }
.log-details { margin-top: 0.5rem; padding: 0.5rem; background: rgba(0,0,0,0.3); border-radius: 4px; font-family: monospace; font-size: 0.75rem; color: var(--text-secondary); overflow-x: auto;}

/* Connection Info */
.info-row {
  display: flex; justify-content: space-between; padding: 0.75rem 0; border-bottom: 1px solid var(--border-glass);
}
.info-row:last-child { border-bottom: none; }
.info-label { color: var(--text-secondary); }
.info-value { font-weight: 600; color: var(--text-primary); }

.spinner {
  width: 40px; height: 40px; border: 4px solid rgba(255, 255, 255, 0.1); border-top-color: var(--accent-primary); border-radius: 50%; animation: spin 1s linear infinite; margin: 0 auto;
}

@keyframes spin { to { transform: rotate(360deg); } }
@keyframes pulse { 0% { opacity: 1; } 50% { opacity: 0.5; } 100% { opacity: 1; } }

/* Fix Chrome Autofill Background in Dark Mode */
input:-webkit-autofill,
input:-webkit-autofill:hover, 
input:-webkit-autofill:focus, 
input:-webkit-autofill:active{
    -webkit-box-shadow: 0 0 0 30px #1a2030 inset !important;
    -webkit-text-fill-color: white !important;
    transition: background-color 5000s ease-in-out 0s;
}

/* Custom Select Dropdown Styling */
select {
  appearance: none;
  background-image: url("data:image/svg+xml;charset=US-ASCII,%3Csvg%20xmlns%3D%22http%3A%2F%2Fwww.w3.org%2F2000%2Fsvg%22%20width%3D%22292.4%22%20height%3D%22292.4%22%3E%3Cpath%20fill%3D%22%239CA3AF%22%20d%3D%22M287%2069.4a17.6%2017.6%200%200%200-13-5.4H18.4c-5%200-9.3%201.8-12.9%205.4A17.6%2017.6%200%200%200%200%2082.2c0%205%201.8%209.3%205.4%2012.9l128%20127.9c3.6%203.6%207.8%205.4%2012.8%205.4s9.2-1.8%2012.8-5.4L287%2095c3.5-3.5%205.4-7.8%205.4-12.8%200-5-1.9-9.2-5.5-12.8z%22%2F%3E%3C%2Fsvg%3E");
  background-repeat: no-repeat;
  background-position: right 1rem top 50%;
  background-size: 0.65rem auto;
}

select option {
  background-color: var(--bg-secondary);
  color: var(--text-primary);
  padding: 0.5rem;
}

/* Custom File Input Styling */
input[type="file"]::file-selector-button {
  background: var(--bg-glass);
  color: var(--text-primary);
  border: 1px solid var(--border-light);
  padding: 0.5rem 1rem;
  border-radius: var(--radius-sm);
  cursor: pointer;
  margin-right: 1rem;
  transition: var(--transition);
  font-family: inherit;
  font-size: 0.85rem;
}

input[type="file"]::file-selector-button:hover {
  background: rgba(255, 255, 255, 0.1);
  border-color: var(--accent-primary);
}

/* Quadrants UI */
.quadrants-container {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 1rem;
}

.variation-quadrant {
  background: rgba(0,0,0,0.2);
  border: 1px solid var(--border-light);
  border-radius: var(--radius-md);
  padding: 1rem;
  transition: all 0.2s;
}

.variation-quadrant.inactive {
  opacity: 0.5;
  filter: grayscale(1);
}

.quadrant-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 0.75rem;
  padding-bottom: 0.5rem;
  border-bottom: 1px solid var(--border-glass);
}

.quadrant-title {
  font-weight: 600;
  color: var(--text-primary);
  font-size: 0.9rem;
}

/* Toggle Switch */
.toggle-switch {
  position: relative;
  display: inline-block;
  width: 40px;
  height: 20px;
}

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

.toggle-slider {
  position: absolute;
  cursor: pointer;
  top: 0; left: 0; right: 0; bottom: 0;
  background-color: rgba(239, 68, 68, 0.5);
  transition: .4s;
  border-radius: 20px;
}

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

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

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