/*
 * =========================================
 *  Vote Manager - Material Design 3 Styles
 * =========================================
 */

/*
 * 1. THEME & GLOBAL SETUP
 */
:root {
  /* Primary Palette */
  --md-sys-color-primary: #6750A4;
  --md-sys-color-on-primary: #FFFFFF;
  --md-sys-color-primary-container: #EADDFF;
  --md-sys-color-on-primary-container: #21005D;

  /* Secondary Palette */
  --md-sys-color-secondary: #625B71;
  --md-sys-color-on-secondary: #FFFFFF;
  --md-sys-color-secondary-container: #E8DEF8;
  --md-sys-color-on-secondary-container: #1D192B;

  /* Error Palette */
  --md-sys-color-error: #B3261E;
  --md-sys-color-on-error: #FFFFFF;
  --md-sys-color-error-container: #F9DEDC;
  --md-sys-color-on-error-container: #410E0B;

  /* Surface & Background Palette */
  --md-sys-color-background: #FEF7FF;
  --md-sys-color-on-background: #1D1B20;
  --md-sys-color-surface: #FEF7FF;
  --md-sys-color-on-surface: #1D1B20;
  --md-sys-color-surface-variant: #E7E0EC;
  --md-sys-color-on-surface-variant: #49454F;
  --md-sys-color-surface-container: #F3EDF7;
  --md-sys-color-surface-container-low: #F7F2FA;
  --md-sys-color-surface-container-high: #ECE6F0;

  /* Outline */
  --md-sys-color-outline: #79747E;
  --md-sys-color-outline-variant: #CAC4D0;

  /* Elevation Shadows */
  --md-sys-elevation-level-1: 0px 1px 2px 0px rgba(0, 0, 0, 0.30), 0px 1px 3px 1px rgba(0, 0, 0, 0.15);
  --md-sys-elevation-level-2: 0px 1px 2px 0px rgba(0, 0, 0, 0.30), 0px 2px 6px 2px rgba(0, 0, 0, 0.15);
}

* {
  box-sizing: border-box;
}

body {
  /* A system font stack is more reliable for China than Google Fonts */
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "Helvetica Neue", Helvetica, "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", "微软雅黑", Arial, sans-serif;
  background-color: var(--md-sys-color-background);
  color: var(--md-sys-color-on-background);
  margin: 0;
  padding: 0;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

/*
 * 2. LAYOUT COMPONENTS
 */

/* App Bar */
.app-bar {
  background-color: var(--md-sys-color-surface-container);
  color: var(--md-sys-color-on-surface);
  padding: 16px 24px;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 16px;
}

.app-bar-title {
  font-size: 1.375rem;
  font-weight: 500;
  display: flex;
  align-items: center;
  gap: 12px;
}

/* Main Content Area */
.main-content {
  flex: 1;
  padding: 24px;
  max-width: 1200px;
  margin: 0 auto;
  width: 100%;
}

/* Footer */
.app-footer {
  background-color: var(--md-sys-color-surface-container);
  color: var(--md-sys-color-on-surface-variant);
  text-align: center;
  padding: 24px;
  font-size: 0.875rem;
}

.footer-content {
  display: flex;
  align-items: center;
  justify-content: center;
  flex-wrap: wrap;
  gap: 8px;
}

.footer-logo {
  height: 1.8em;
  vertical-align: middle;
  margin: 0 4px;
}

/*
 * 3. UI COMPONENTS
 */

/* Navigation Links */
.nav-links {
  display: flex;
  gap: 8px;
  align-items: center;
  flex-wrap: wrap;
}

.nav-link {
  color: var(--md-sys-color-on-surface-variant);
  text-decoration: none;
  padding: 8px 16px;
  border-radius: 20px;
  transition: background-color 0.2s ease, color 0.2s ease;
  display: flex;
  align-items: center;
  gap: 8px;
  font-weight: 500;
}

.nav-link:hover {
  background-color: var(--md-sys-color-surface-container-high);
}

.nav-link.active {
  background-color: var(--md-sys-color-secondary-container);
  color: var(--md-sys-color-on-secondary-container);
}

.nav-link--primary {
  background-color: var(--md-sys-color-primary);
  color: var(--md-sys-color-on-primary);
}

.nav-link--primary:hover {
  opacity: 0.9;
}

.nav-link__icon {
  font-size: 18px;
}

/* Message Cards (for Django messages framework) */
.message-container {
  margin-bottom: 24px;
}

.message-card {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 16px;
  border-radius: 8px;
  margin-bottom: 12px;
  font-weight: 500;
}

.message-card--success {
  background-color: var(--md-sys-color-primary-container);
  color: var(--md-sys-color-on-primary-container);
}

.message-card--error {
  background-color: var(--md-sys-color-error-container);
  color: var(--md-sys-color-on-error-container);
}

.message-card--warning {
  background-color: #FFECB3; /* A suitable yellow for warnings */
  color: #6D4C41;
}

/* Generic Card Style */
.md-card {
  background-color: var(--md-sys-color-surface-container-low);
  border-radius: 12px;
  padding: 24px;
  margin-bottom: 16px;
  box-shadow: var(--md-sys-elevation-level-1);
  transition: box-shadow 0.2s ease-in-out;
}

.md-card:hover {
  box-shadow: var(--md-sys-elevation-level-2);
}

/*
 * 4. ACCESSIBILITY & RESPONSIVE DESIGN
 */

/* Better focus indicators for keyboard navigation */
*:focus-visible {
  outline: 2px solid var(--md-sys-color-primary);
  outline-offset: 2px;
  border-radius: 4px;
}

/* Respect user's motion preferences */
@media (prefers-reduced-motion: reduce) {
  * {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}

/* Responsive adjustments for smaller screens */
@media (max-width: 768px) {
  .app-bar {
    justify-content: center;
  }
  .main-content {
    padding: 16px;
  }
  .md-card {
    padding: 16px;
  }
}

/* ==========================================================================
   Toast / Snackbar Component
   ========================================================================== */

.toast {
    position: fixed;
    bottom: 24px;
    left: 50%;
    /* Start off-screen */
    transform: translate(-50%, 150%);
    background-color: var(--md-sys-color-surface-container-high);
    color: var(--md-sys-color-on-surface);
    padding: 14px 16px;
    border-radius: 12px; /* Using a fixed value as the variable is not in this file */
    box-shadow: var(--md-sys-elevation-level-2);
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    min-width: 320px;
    max-width: 500px;
    z-index: 2000;
    transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1), visibility 0.3s;
    /* Hide until the 'show' class is added */
    visibility: hidden;
}

.toast.show {
    /* Slide into view */
    transform: translate(-50%, 0);
    visibility: visible;
}

.toast__message {
    flex-grow: 1;
    font-size: 0.875rem;
}

.toast__actions {
    display: flex;
    align-items: center;
    gap: 8px;
    /* Prevent the action area from shrinking */
    flex-shrink: 0;
}

/* Responsive adjustments for smaller screens */
@media (max-width: 600px) {
    .toast {
        left: 16px;
        right: 16px;
        bottom: 16px;
        width: auto;
        transform: translate(0, 150%);
    }

    .toast.show {
        transform: translate(0, 0);
    }
}