/* Import Google Font */
@import url('https://fonts.googleapis.com/css2?family=Poppins:wght@400;500;600;700&display=swap');

/* --- Color Palette --- */
:root {
  --primary-color: #0053a0;
  --primary-hover: #003d75;
  --secondary-color: #d40000;
  --secondary-hover: #a30000;
  --background-color: #f0f2f5;
  --card-background: #ffffff;
  --text-color: #1c1e21;
  --light-text-color: #606770;
  --border-color: #ced0d4;
  --success-color: #28a745;
}

:root[data-theme='dark'] {
  --primary-color: #007bff;
  --primary-hover: #0056b3;
  --secondary-color: #e63946;
  --secondary-hover: #b82c38;
  --background-color: #121212;
  --card-background: #1e1e1e;
  --text-color: #e4e6eb;
  --light-text-color: #b0b3b8;
  --border-color: #3a3b3c;
  --success-color: #28a745;
}


body {
  font-family: 'Poppins', sans-serif;
  background-color: var(--background-color);
  color: var(--text-color);
  margin: 0;
  padding: 20px;
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  min-height: 100vh;
  transition: background-color 0.3s, color 0.3s;
}

/* --- Logo Styles --- */
.logo {
  display: block;
  width: 350px;
  height: 282px;
  margin: 0 auto 20px auto;
}
.header-logo {
  height: 120px;
}

/* --- Main Containers --- */
.main-container {
  background-color: var(--card-background);
  padding: 30px 40px;
  border-radius: 12px;
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.08);
  width: 100%;
  max-width: 650px;
  box-sizing: border-box;
  transition: all 0.3s ease;
}

.hidden {
  display: none;
}

/* --- Auth Forms --- */
#auth-container p {
  text-align: center;
  margin-bottom: 25px;
  color: var(--light-text-color);
}

.form-control {
  margin-bottom: 20px;
}

.form-control label {
  display: block;
  margin-bottom: 8px;
  font-weight: 500;
}

.form-control input {
  width: 100%;
  padding: 12px;
  border: 1px solid var(--border-color);
  border-radius: 8px;
  font-size: 16px;
  box-sizing: border-box;
  background-color: var(--background-color);
  color: var(--text-color);
}

.auth-nav {
  display: flex;
  border-bottom: 1px solid var(--border-color);
  margin-bottom: 25px;
}

.auth-nav button {
  flex: 1;
  background-color: transparent;
  color: var(--light-text-color);
  border: none;
  border-bottom: 3px solid transparent;
  border-radius: 0;
  padding: 15px 5px;
  font-size: 16px;
  font-weight: 500;
}

.auth-nav button.active {
  color: var(--primary-color);
  border-bottom-color: var(--primary-color);
  font-weight: 600;
}

.full-width {
  width: 100%;
}

/* --- Buttons --- */
button {
  flex: 1;
  padding: 12px 20px;
  border: none;
  border-radius: 8px;
  font-size: 16px;
  font-weight: 600;
  cursor: pointer;
}

button:active {
  transform: scale(0.98);
}

#login-button, #signup-button {
  background-color: var(--primary-color);
  color: white;
}

button.secondary, #logout-button {
  background-color: var(--secondary-color);
  color: white;
}

/* --- App View --- */
.app-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  border-bottom: 1px solid var(--border-color);
  padding-bottom: 15px;
  margin-bottom: 10px;
}

.user-info {
  display: flex;
  align-items: center;
  gap: 15px;
}

#user-details {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  line-height: 1.3;
}

.user-name {
  font-weight: 600;
  font-size: 16px;
}

.user-email {
  font-size: 12px;
  color: var(--light-text-color);
}

.app-nav {
  display: flex;
  gap: 10px;
  border-bottom: 1px solid var(--border-color);
  margin-bottom: 20px;
}

.app-nav button {
  background-color: transparent;
  color: var(--light-text-color);
  border: none;
  border-bottom: 3px solid transparent;
  border-radius: 0;
  padding: 10px 5px;
  font-weight: 500;
  flex: none;
}

.app-nav button.active {
  color: var(--primary-color);
  border-bottom-color: var(--primary-color);
  font-weight: 600;
}

/* --- Polls & Results Cards --- */
#polls-container, #results-container {
  display: flex;
  flex-direction: column;
  gap: 25px;
}

.poll-card, .result-card {
  background-color: var(--background-color);
  padding: 20px;
  border-radius: 8px;
  border: 1px solid var(--border-color);
}

.poll-card h3, .result-card h3 {
  margin-top: 0;
  font-weight: 600;
}

.poll-card form .options {
  display: flex;
  flex-direction: column;
  gap: 15px;
  margin: 20px 0;
}

.poll-card .option {
  display: flex;
  align-items: center;
  gap: 10px;
  background-color: var(--card-background);
  padding: 12px;
  border-radius: 8px;
  border: 1px solid var(--border-color);
}

.poll-card .option-label {
  flex-grow: 1;
}

.poll-card button {
  width: 100%;
  background-color: var(--success-color);
  color: white;
}

.poll-card button:disabled {
  background-color: #555;
  color: #999;
  cursor: not-allowed;
}

/* --- Results Card Styles --- */
.result-card .result-item {
  margin-bottom: 15px;
}
.result-card .option-name {
  font-weight: 500;
  display: block;
  margin-bottom: 8px;
}
.result-bar-container {
  position: relative;
  height: 35px;
  width: 100%;
  background-color: #e9ecef;
  border-radius: 8px;
}
.result-bar-fill {
  height: 100%;
  width: 0%;
  background-color: var(--primary-color);
  border-radius: 8px;
  transition: width 0.8s ease-in-out;
}
.result-bar-text {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0 12px;
  box-sizing: border-box;
  font-weight: 600;
  font-size: 14px;
}
.result-bar-text .option-label {
  color: var(--text-color);
}
.result-bar-text .vote-label {
  color: var(--light-text-color);
}
.result-item.winner .option-name {
  font-weight: 700;
  color: var(--success-color);
}
.result-item.winner .option-name::before {
  content: '🏆';
  margin-right: 8px;
}
.result-item.winner .result-bar-fill {
  background-color: var(--success-color);
}
.result-item.winner .result-bar-text .option-label,
.result-item.winner .result-bar-text .vote-label {
  color: white;
}
.result-card .final-winner-announcement {
  text-align: center;
  font-size: 1.1em;
  font-weight: bold;
  margin-top: 20px;
  padding: 10px;
  background-color: var(--primary-color);
  color: white;
  border-radius: 6px;
}
:root[data-theme='dark'] .result-bar-container {
  background-color: #3a3b3c;
}
:root[data-theme='dark'] .result-item.winner .option-name {
  color: #70e094;
}

/* --- Welcome Animation --- */
@keyframes fadeInOut {
  0% { opacity: 0; transform: scale(0.9); }
  20% { opacity: 1; transform: scale(1.05); }
  80% { opacity: 1; transform: scale(1.05); }
  100% { opacity: 0; transform: scale(0.9); }
}

#welcome-animation {
  text-align: center;
  animation: fadeInOut 3s ease-in-out forwards;
}
#welcome-animation h2 {
  font-size: 2em;
  color: var(--primary-color);
}

/* --- Footer --- */
footer {
  margin-top: 30px;
  color: var(--light-text-color);
  text-align: center;
  font-size: 14px;
}

/* --- Toast Notification Styles --- */
#toast-container {
  position: fixed;
  top: 20px;
  right: 20px;
  z-index: 1000;
}
.toast {
  background-color: var(--card-background);
  padding: 15px 20px;
  border-radius: 8px;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
  border-left: 5px solid;
  transform: translateX(120%);
  transition: transform 0.5s ease-in-out;
}
.toast.show {
  transform: translateX(0);
}
.toast.success {
  border-left-color: var(--success-color);
}
.toast.error {
  border-left-color: var(--secondary-color);
}

/* --- Skeleton Loader Styles --- */
.skeleton-card {
  background-color: var(--card-background);
  padding: 20px;
  border-radius: 8px;
  border: 1px solid var(--border-color);
  margin-bottom: 25px;
}
.skeleton-line {
  height: 20px;
  background-color: #e9ecef;
  border-radius: 4px;
  margin-bottom: 15px;
  animation: pulse 1.5s cubic-bezier(0.4, 0, 0.6, 1) infinite;
}
.skeleton-line:last-child { margin-bottom: 0; }
.skeleton-line.short { width: 60%; }
.skeleton-line.button { height: 45px; margin-top: 25px; }
@keyframes pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.6; }
}

/* --- Interactive Hover Effects --- */
button, .poll-card {
  transition: all 0.2s ease-in-out;
}
button:not(:disabled):hover {
  transform: translateY(-2px);
  box-shadow: 0 4px 8px rgba(0, 0, 0, 0.1);
  filter: brightness(1.1);
}
.poll-card:hover {
  transform: translateY(-3px);
  box-shadow: 0 6px 12px rgba(0, 0, 0, 0.1);
}

/* --- Theme Switcher Styles --- */
.theme-switcher {
  margin-left: auto;
  margin-right: 20px;
}
.theme-toggle-label {
  position: relative;
  display: inline-block;
  width: 50px;
  height: 26px;
}
.theme-toggle-label input {
  opacity: 0;
  width: 0;
  height: 0;
}
.slider {
  position: absolute;
  cursor: pointer;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background-color: #ccc;
  transition: .4s;
  border-radius: 26px;
  display: flex;
  align-items: center;
}
.slider:before {
  position: absolute;
  content: "☀️";
  display: flex;
  justify-content: center;
  align-items: center;
  font-size: 12px;
  height: 18px;
  width: 18px;
  left: 4px;
  bottom: 4px;
  background-color: white;
  transition: .4s;
  border-radius: 50%;
}
input:checked + .slider {
  background-color: var(--primary-color);
}
input:checked + .slider:before {
  content: "🌙";
  transform: translateX(24px);
}

/* --- Responsive Design --- */
@media (max-width: 600px) {
  body { padding: 10px; }
  .main-container { padding: 20px; }
  .app-header { flex-direction: column; gap: 15px; }
}

/* --- NEW: Fullscreen Results Modal --- */
.result-card-footer {
  margin-top: 20px;
  text-align: right;
}

.fullscreen-overlay {
  position: fixed;
  top: 0;
  left: 0;
  width: 100vw;
  height: 100vh;
  z-index: 3000;
  display: flex;
  justify-content: center;
  align-items: center;
  background-color: #003366;
}
/* This new rule correctly hides the modal */
.fullscreen-overlay.hidden {
  display: none;
}

.fullscreen-content {
  color: white;
  width: 100%;
  height: 100%;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  align-items: center;
  padding: 40px;
  box-sizing: border-box;
  font-family: 'Arial', sans-serif;
}

.fullscreen-header {
  display: flex;
  justify-content: space-around;
  text-align: center;
  width: 100%;
  border-bottom: 2px solid rgba(255, 255, 255, 0.5);
  padding-bottom: 20px;
}

.fullscreen-header > div {
  flex: 1;
}

.fullscreen-header span {
  display: block;
  font-weight: bold;
}

.fullscreen-header span:first-child {
  font-size: 1.5em;
  letter-spacing: 2px;
  opacity: 0.8;
}

.fullscreen-header span:last-child {
  font-size: 3.5em;
  margin-top: 10px;
}

.fullscreen-main {
  flex-grow: 1;
  display: flex;
  justify-content: center;
  align-items: center;
}

#fs-status {
  font-size: 5em;
  font-weight: bold;
  letter-spacing: 5px;
  text-align: center;
}

#fs-close-btn {
  background-color: rgba(255, 255, 255, 0.1);
  border: 1px solid white;
  color: white;
  flex: none;
}
#fs-close-btn:hover {
  background-color: rgba(255, 255, 255, 0.2);
}

@media (max-width: 600px) {
  .fullscreen-header span:first-child { font-size: 1em; }
  .fullscreen-header span:last-child { font-size: 2em; }
  #fs-status { font-size: 2.5em; }
}
/* --- Fullscreen Results Modal --- */
.fullscreen-overlay {
  position: fixed;
  top: 0;
  left: 0;
  width: 100vw;
  height: 100vh;
  z-index: 3000;
  display: flex;
  justify-content: center;
  align-items: center;
  background-color: #003366; /* Default Blue */
}
.fullscreen-overlay.rejected {
  background-color: #d40000; /* Red for rejected votes */
}
.fullscreen-overlay.hidden {
  display: none;
}
.result-card-footer {
  margin-top: 20px;
  text-align: right;
}
.fullscreen-content {
  color: white;
  width: 100%;
  height: 100%;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  align-items: center;
  padding: 20px 40px;
  box-sizing: border-box;
  font-family: 'Arial', sans-serif;
}
.fullscreen-top-bar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  width: 100%;
  padding-bottom: 15px;
  font-size: 1.5em;
  font-weight: bold;
}
.top-bar-left, .top-bar-right {
  flex: 1;
  display: flex; /* Add flex display */
  align-items: center; /* This vertically centers the content */
}
.top-bar-right {
  justify-content: flex-end; /* This keeps it aligned to the right */
  text-align: right;
}
.top-bar-center {
  flex: 2;
  display: flex;
  flex-direction: row; /* This is the main change */
  align-items: center;
  justify-content: center; /* This ensures it stays centered */
  gap: 15px; /* Adds a nice space between the logo and text */
  text-align: left; /* Aligns the text to the left */
}

.fullscreen-logo {
  height: 90px;
  margin-bottom: 5px;
}
.fullscreen-header {
  display: flex;
  justify-content: space-around;
  text-align: center;
  width: 100%;
  border-top: 1px solid rgba(255, 255, 255, 0.5);
  border-bottom: 1px solid rgba(255, 255, 255, 0.5);
  padding: 15px 0;
}
.fullscreen-header > div {
  flex: 1;
}
.fullscreen-header span {
  display: block;
  font-weight: bold;
}
.fullscreen-header span:first-child {
  font-size: 1.5em;
  letter-spacing: 2px;
  opacity: 0.8;
}
.fullscreen-header span:last-child {
  font-size: 3.5em;
  margin-top: 10px;
}
.fullscreen-main {
  flex-grow: 1;
  display: flex;
  justify-content: center;
  align-items: center;
}
#fs-status {
  font-size: 5em;
  font-weight: bold;
  letter-spacing: 5px;
  text-align: center;
}
#fs-close-btn {
  background-color: rgba(255, 255, 255, 0.1);
  border: 1px solid white;
  color: white;
  flex: none;
}
#fs-close-btn:hover {
  background-color: rgba(255, 255, 255, 0.2);
}
@media (max-width: 600px) {
  .fullscreen-header span:first-child { font-size: 1em; }
  .fullscreen-header span:last-child { font-size: 2em; }
  #fs-status { font-size: 2.5em; }
}