/*
 * Polling App Design System (poll-styles.css)
 * ---------------------------------------------------
 * Ultra-premium glassmorphism, responsive CSS grid/flex layout,
 * dark & light themes, custom chart styling, smooth micro-interactions.
 */

:root {
  --bg: #090d16;
  --bg-subtle: #0f172a;
  --bg-panel: rgba(15, 23, 42, 0.75);
  --panel-border: rgba(255, 255, 255, 0.1);
  --panel-border-hover: rgba(255, 255, 255, 0.2);
  --fg: #f8fafc;
  --muted: #94a3b8;
  --line: rgba(255, 255, 255, 0.08);

  --accent: #3b82f6;
  --accent-hover: #2563eb;
  --accent-glow: rgba(59, 130, 246, 0.35);

  --emerald: #10b981;
  --emerald-glow: rgba(16, 185, 129, 0.3);
  --rose: #f43f5e;
  --amber: #f59e0b;

  --card-bg: rgba(30, 41, 59, 0.65);
  --card-shadow: 0 12px 32px rgba(0, 0, 0, 0.4);

  --chart-grid: rgba(255, 255, 255, 0.06);
  --chart-label: #94a3b8;

  --font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  --radius-lg: 16px;
  --radius-md: 12px;
  --radius-sm: 8px;
}

[data-theme="light"] {
  --bg: #f1f5f9;
  --bg-subtle: #ffffff;
  --bg-panel: rgba(255, 255, 255, 0.85);
  --panel-border: rgba(0, 0, 0, 0.08);
  --panel-border-hover: rgba(0, 0, 0, 0.18);
  --fg: #0f172a;
  --muted: #64748b;
  --line: rgba(0, 0, 0, 0.08);

  --card-bg: rgba(255, 255, 255, 0.85);
  --card-shadow: 0 12px 32px rgba(0, 0, 0, 0.08);

  --chart-grid: rgba(0, 0, 0, 0.06);
  --chart-label: #64748b;
}

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

body {
  font-family: var(--font-family);
  background: var(--bg);
  color: var(--fg);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  line-height: 1.5;
  background-image: 
    radial-gradient(at 0% 0%, rgba(59, 130, 246, 0.12) 0px, transparent 50%),
    radial-gradient(at 100% 100%, rgba(139, 92, 246, 0.12) 0px, transparent 50%);
  background-attachment: fixed;
  transition: background-color 0.3s ease, color 0.3s ease;
}

/* ================= HEADER NAVBAR ================= */
.app-navbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 28px;
  background: var(--bg-panel);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border-bottom: 1px solid var(--panel-border);
  position: sticky;
  top: 0;
  z-index: 100;
}

.brand-wrap {
  display: flex;
  align-items: center;
  gap: 12px;
  text-decoration: none;
  color: var(--fg);
  font-weight: 800;
  font-size: 20px;
}

.brand-logo-icon {
  width: 36px;
  height: 36px;
  border-radius: 10px;
  background: linear-gradient(135deg, var(--accent), #8b5cf6);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 18px;
  color: #fff;
  box-shadow: 0 4px 14px var(--accent-glow);
}

.nav-actions {
  display: flex;
  align-items: center;
  gap: 12px;
}

/* ================= BUTTONS & INPUTS ================= */
.btn-primary {
  background: linear-gradient(135deg, var(--accent), #2563eb);
  color: #fff;
  border: none;
  padding: 10px 20px;
  border-radius: var(--radius-md);
  font-weight: 600;
  font-size: 14px;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  transition: all 0.2s ease;
  box-shadow: 0 4px 12px var(--accent-glow);
}

.btn-primary:hover {
  transform: translateY(-1px);
  box-shadow: 0 6px 18px var(--accent-glow);
}

.btn-secondary {
  background: rgba(255, 255, 255, 0.06);
  color: var(--fg);
  border: 1px solid var(--panel-border);
  padding: 10px 20px;
  border-radius: var(--radius-md);
  font-weight: 600;
  font-size: 14px;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  transition: all 0.2s ease;
}

.btn-secondary:hover {
  background: rgba(255, 255, 255, 0.12);
  border-color: var(--panel-border-hover);
}

.btn-danger {
  background: rgba(244, 63, 94, 0.15);
  color: var(--rose);
  border: 1px solid rgba(244, 63, 94, 0.3);
  padding: 8px 14px;
  border-radius: var(--radius-sm);
  font-weight: 600;
  font-size: 13px;
  cursor: pointer;
  transition: all 0.2s ease;
}

.btn-danger:hover {
  background: rgba(244, 63, 94, 0.25);
}

.btn-icon {
  width: 40px;
  height: 40px;
  border-radius: var(--radius-md);
  border: 1px solid var(--panel-border);
  background: var(--bg-panel);
  color: var(--fg);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  font-size: 16px;
  transition: all 0.2s ease;
}

.btn-icon:hover {
  border-color: var(--panel-border-hover);
  background: rgba(255, 255, 255, 0.1);
}

/* ================= CONTAINER & MAIN LAYOUT ================= */
.main-container {
  max-width: 1050px;
  width: 100%;
  margin: 30px auto;
  padding: 0 20px;
  flex: 1;
}

.glass-card {
  background: var(--card-bg);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border: 1px solid var(--panel-border);
  border-radius: var(--radius-lg);
  box-shadow: var(--card-shadow);
  padding: 32px;
  margin-bottom: 24px;
}

/* ================= POLL DISPLAY & VOTING VIEW ================= */
.poll-view-header {
  text-align: center;
  margin-bottom: 28px;
}

.poll-type-badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 12px;
  border-radius: 20px;
  background: rgba(59, 130, 246, 0.15);
  color: var(--accent);
  font-size: 12px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  margin-bottom: 12px;
}

.poll-question-title {
  font-size: 26px;
  font-weight: 800;
  line-height: 1.35;
  margin-bottom: 12px;
}

.poll-question-img-wrap {
  width: 100%;
  max-height: 380px;
  border-radius: var(--radius-md);
  overflow: hidden;
  margin: 16px 0 24px 0;
  border: 1px solid var(--panel-border);
}

.poll-question-img {
  width: 100%;
  height: 100%;
  max-height: 380px;
  object-fit: cover;
  display: block;
}

/* Options Grid */
.options-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
  gap: 16px;
  margin-bottom: 28px;
}

.option-card {
  background: var(--bg-panel);
  border: 2px solid var(--panel-border);
  border-radius: var(--radius-md);
  padding: 16px 20px;
  cursor: pointer;
  transition: all 0.25 ease;
  display: flex;
  align-items: center;
  gap: 14px;
  position: relative;
  overflow: hidden;
}

.option-card:hover {
  border-color: var(--accent);
  transform: translateY(-2px);
  box-shadow: 0 8px 20px rgba(0, 0, 0, 0.2);
}

.option-card.selected {
  border-color: var(--accent);
  background: rgba(59, 130, 246, 0.12);
  box-shadow: 0 0 0 3px var(--accent-glow);
}

.option-radio-circle {
  width: 22px;
  height: 22px;
  border-radius: 50%;
  border: 2px solid var(--muted);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  transition: all 0.2s ease;
}

.option-card.selected .option-radio-circle {
  border-color: var(--accent);
  background: var(--accent);
}

.option-radio-circle::after {
  content: '';
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: #fff;
  opacity: 0;
  transition: opacity 0.2s ease;
}

.option-card.selected .option-radio-circle::after {
  opacity: 1;
}

.option-thumb {
  width: 54px;
  height: 54px;
  border-radius: var(--radius-sm);
  object-fit: cover;
  flex-shrink: 0;
  border: 1px solid var(--panel-border);
}

.option-text-content {
  font-weight: 600;
  font-size: 16px;
  color: var(--fg);
  flex: 1;
}

/* ================= MODAL DIALOG ================= */
.modal-overlay {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0, 0, 0, 0.7);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  z-index: 1000;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.25s ease;
}

.modal-overlay.active {
  opacity: 1;
  pointer-events: auto;
}

.modal-card {
  background: var(--bg-subtle);
  border: 1px solid var(--panel-border);
  border-radius: var(--radius-lg);
  box-shadow: 0 20px 40px rgba(0, 0, 0, 0.5);
  max-width: 480px;
  width: 100%;
  padding: 28px;
  transform: scale(0.92);
  transition: transform 0.25s ease;
}

.modal-overlay.active .modal-card {
  transform: scale(1);
}

.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 18px;
}

.modal-header h3 {
  font-size: 20px;
  font-weight: 700;
}

.btn-close-modal {
  background: none;
  border: none;
  font-size: 24px;
  color: var(--muted);
  cursor: pointer;
  padding: 4px;
}

.form-group {
  margin-bottom: 18px;
}

.form-group label {
  display: block;
  font-size: 13px;
  font-weight: 600;
  color: var(--muted);
  margin-bottom: 6px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.form-input {
  width: 100%;
  padding: 12px 16px;
  background: var(--bg);
  border: 1px solid var(--panel-border);
  border-radius: var(--radius-md);
  color: var(--fg);
  font-size: 15px;
  outline: none;
  transition: border-color 0.2s ease;
}

.form-input:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-glow);
}

/* ================= RESULTS & GRAPH VISUALIZATION ================= */
.results-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 16px;
  margin-bottom: 24px;
}

.chart-tabs {
  display: flex;
  background: var(--bg);
  padding: 4px;
  border-radius: var(--radius-md);
  border: 1px solid var(--panel-border);
}

.tab-btn {
  background: none;
  border: none;
  color: var(--muted);
  padding: 8px 16px;
  border-radius: var(--radius-sm);
  font-weight: 600;
  font-size: 13px;
  cursor: pointer;
  transition: all 0.2s ease;
}

.tab-btn.active {
  background: var(--accent);
  color: #fff;
  box-shadow: 0 2px 8px var(--accent-glow);
}

.live-indicator {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 12px;
  font-weight: 700;
  color: var(--emerald);
  background: rgba(16, 185, 129, 0.15);
  padding: 4px 10px;
  border-radius: 12px;
}

.live-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--emerald);
  animation: pulseDot 1.5s infinite;
}

@keyframes pulseDot {
  0% { transform: scale(0.95); opacity: 1; }
  50% { transform: scale(1.3); opacity: 0.4; }
  100% { transform: scale(0.95); opacity: 1; }
}

.chart-render-area {
  min-height: 320px;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 100%;
}

.poll-svg-chart {
  width: 100%;
  height: 100%;
}

.horizontal-bars-wrap {
  width: 100%;
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.hbar-item {
  background: var(--bg-panel);
  border: 1px solid var(--panel-border);
  padding: 14px 18px;
  border-radius: var(--radius-md);
}

.hbar-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 8px;
}

.hbar-title {
  font-weight: 600;
  display: flex;
  align-items: center;
  gap: 8px;
}

.hbar-thumb {
  width: 24px;
  height: 24px;
  border-radius: 4px;
  object-fit: cover;
}

.hbar-track {
  height: 10px;
  background: var(--bg);
  border-radius: 5px;
  overflow: hidden;
}

.hbar-fill {
  height: 100%;
  border-radius: 5px;
  transition: width 0.6s cubic-bezier(0.4, 0, 0.2, 1);
}

.pie-chart-flex {
  display: flex;
  align-items: center;
  justify-content: space-around;
  flex-wrap: wrap;
  gap: 24px;
  width: 100%;
}

.pie-svg-wrap {
  width: 240px;
  height: 240px;
}

.pie-legend-wrap {
  display: flex;
  flex-direction: column;
  gap: 10px;
  max-width: 280px;
}

.legend-item {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 14px;
}

.legend-dot {
  width: 12px;
  height: 12px;
  border-radius: 50%;
  flex-shrink: 0;
}

.legend-text {
  flex: 1;
  font-weight: 500;
}

.legend-val {
  font-weight: 700;
}

/* ================= OWNER DASHBOARD TABLE ================= */
.polls-table {
  width: 100%;
  border-collapse: collapse;
  margin-top: 16px;
}

.polls-table th, .polls-table td {
  padding: 14px 18px;
  text-align: left;
  border-bottom: 1px solid var(--line);
}

.polls-table th {
  font-size: 12px;
  font-weight: 700;
  text-transform: uppercase;
  color: var(--muted);
}

.polls-table tr:hover td {
  background: rgba(255, 255, 255, 0.03);
}

.status-badge {
  display: inline-block;
  padding: 3px 10px;
  border-radius: 12px;
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
}

.status-badge.active {
  background: rgba(16, 185, 129, 0.15);
  color: var(--emerald);
}

.status-badge.closed {
  background: rgba(148, 163, 184, 0.15);
  color: var(--muted);
}

/* ================= HEADER DROPDOWN MENU ================= */
.poll-dropdown-menu {
  position: absolute;
  top: 48px;
  right: 0;
  min-width: 220px;
  background: var(--bg-subtle);
  border: 1px solid var(--panel-border);
  border-radius: var(--radius-md);
  box-shadow: 0 12px 32px rgba(0, 0, 0, 0.4);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  padding: 8px;
  z-index: 1000;
  animation: fadeInDown 0.2s ease;
}

@keyframes fadeInDown {
  from { opacity: 0; transform: translateY(-8px); }
  to { opacity: 1; transform: translateY(0); }
}

.dropdown-user-info {
  padding: 10px 12px;
  font-size: 13px;
  font-weight: 700;
  color: var(--accent);
  border-bottom: 1px solid var(--line);
  margin-bottom: 6px;
  word-break: break-word;
}

.poll-dropdown-item {
  width: 100%;
  padding: 10px 14px;
  background: transparent;
  border: none;
  border-radius: var(--radius-sm);
  color: var(--fg);
  font-size: 14px;
  font-weight: 600;
  text-align: left;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 10px;
  transition: all 0.15s ease;
}

.poll-dropdown-item:hover {
  background: rgba(255, 255, 255, 0.08);
}

.poll-dropdown-item.primary {
  color: var(--accent);
}

.poll-dropdown-item.danger {
  color: var(--rose);
}

.poll-dropdown-item.danger:hover {
  background: rgba(244, 63, 94, 0.15);
}

/* Responsive adjustments for smartphones */
@media (max-width: 640px) {
  .app-navbar {
    padding: 10px 16px;
  }
  .main-container {
    padding: 0 10px;
    margin: 14px auto;
  }
  .glass-card {
    padding: 18px 14px;
    border-radius: var(--radius-md);
  }
  .poll-question-title {
    font-size: 19px;
  }
  .poll-dropdown-menu {
    right: -4px;
    min-width: 210px;
  }
  .polls-table th, .polls-table td {
    padding: 10px 12px;
    font-size: 13px;
  }
  .btn-primary, .btn-secondary {
    padding: 8px 14px;
    font-size: 13px;
  }
}
