/* Auth Modal Styles */
.auth-modal {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  z-index: 10000;
  display: flex;
  align-items: center;
  justify-content: center;
  animation: fadeIn 0.2s ease;
}

@keyframes fadeIn {
  from { opacity: 0; }
  to { opacity: 1; }
}

.auth-modal-overlay {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0, 0, 0, 0.85);
  backdrop-filter: blur(8px);
}

.auth-modal-content {
  position: relative;
  width: 90%;
  max-width: 450px;
  max-height: 90vh;
  overflow-y: auto;
  background: var(--bg-2);
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 16px;
  padding: 2.5rem;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.5);
  animation: slideUp 0.3s ease;
  -webkit-overflow-scrolling: touch;
}

@keyframes slideUp {
  from {
    transform: translateY(30px);
    opacity: 0;
  }
  to {
    transform: translateY(0);
    opacity: 1;
  }
}

.auth-modal-close {
  position: absolute;
  top: 1rem;
  right: 1rem;
  background: none;
  border: none;
  color: var(--muted);
  font-size: 1.5rem;
  cursor: pointer;
  padding: 0.5rem;
  line-height: 1;
  transition: color 0.2s ease;
}

.auth-modal-close:hover {
  color: var(--text);
}

.auth-header {
  text-align: center;
  margin-bottom: 2rem;
}

.auth-header h2 {
  margin: 0 0 0.5rem 0;
  font-size: 1.75rem;
  color: var(--text);
}

.auth-header p {
  margin: 0;
  color: var(--muted);
  font-size: 0.95rem;
}

.auth-form {
  display: flex !important;
  flex-direction: column;
  gap: 1.25rem;
  width: 100%;
}

.form-group {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  width: 100%;
}

.form-group label {
  font-size: 0.9rem;
  font-weight: 600;
  color: var(--text);
  display: block;
}

.form-group input {
  padding: 0.875rem 1rem;
  background: var(--bg);
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 8px;
  color: var(--text);
  font-size: 1rem;
  transition: all 0.2s ease;
  width: 100%;
  display: block;
}

.form-group input:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(91, 138, 255, 0.1);
}

.form-group input:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.form-group small {
  font-size: 0.85rem;
  color: var(--muted-2);
}

.btn-full {
  width: 100%;
  padding: 1rem;
  font-size: 1rem;
  font-weight: 600;
  margin-top: 0.5rem;
}

.auth-links {
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 0.75rem;
  margin-top: 0.5rem;
}

.auth-links a {
  color: var(--accent);
  text-decoration: none;
  font-size: 0.9rem;
  transition: color 0.2s ease;
}

.auth-links a:hover {
  color: var(--accent-bright);
  text-decoration: underline;
}

.auth-message {
  padding: 1rem;
  border-radius: 8px;
  margin-top: 1rem;
  font-size: 0.95rem;
  animation: slideIn 0.3s ease;
}

@keyframes slideIn {
  from {
    transform: translateY(-10px);
    opacity: 0;
  }
  to {
    transform: translateY(0);
    opacity: 1;
  }
}

.auth-message.success {
  background: rgba(34, 197, 94, 0.15);
  border: 1px solid rgba(34, 197, 94, 0.3);
  color: rgb(134, 239, 172);
}

.auth-message.error {
  background: rgba(239, 68, 68, 0.15);
  border: 1px solid rgba(239, 68, 68, 0.3);
  color: rgb(252, 165, 165);
}

.auth-message.info {
  background: rgba(59, 130, 246, 0.15);
  border: 1px solid rgba(59, 130, 246, 0.3);
  color: rgb(147, 197, 253);
}

/* Auth benefits section */
.auth-benefits {
  margin-top: 1.5rem;
  padding: 1.25rem;
  background: rgba(91, 138, 255, 0.08);
  border: 1px solid rgba(91, 138, 255, 0.2);
  border-radius: 12px;
}

.auth-benefits h4 {
  margin: 0 0 1rem 0;
  font-size: 0.95rem;
  font-weight: 600;
  color: var(--text);
  text-align: center;
}

.auth-benefits ul {
  margin: 0;
  padding: 0;
  list-style: none;
}

.auth-benefits li {
  padding: 0.5rem 0;
  font-size: 0.9rem;
  color: var(--text);
  line-height: 1.5;
}

.auth-benefits li strong {
  color: var(--accent);
}

.auth-footer {
  margin-top: 1.5rem;
  padding-top: 1.25rem;
  border-top: 1px solid rgba(255, 255, 255, 0.1);
  text-align: center;
}

.auth-footer p {
  margin: 0;
  font-size: 0.85rem;
  color: var(--muted-2);
}

/* Cloud sync indicator */
#cloud-sync-indicator {
  display: flex;
  align-items: center;
  gap: 0.25rem;
  padding: 0.35rem 0.5rem;
  color: var(--muted);
  font-size: 0.9rem;
  cursor: pointer;
  flex-shrink: 0;
}

#cloud-sync-indicator:hover {
  color: var(--text);
}

.sync-icon {
  font-size: 1.1rem;
  line-height: 1;
}

/* Auth button - match other header buttons */
#auth-button {
  white-space: nowrap;
  flex-shrink: 0;
  font-size: 0.9rem;
  padding: 0.5rem 1rem;
  max-width: 150px;
  overflow: hidden;
  text-overflow: ellipsis;
  background: rgba(0,0,0,.3) !important;
  background-image: none !important;
  border: 1px solid rgba(255,255,255,.2) !important;
  border-radius: 12px;
  color: #fff;
}
#auth-button:hover {
  background: rgba(0,0,0,.4) !important;
}

/* Header controls responsive optimization */
.header-ctls {
  flex-shrink: 0;
  min-width: 0; /* Allow flex items to shrink */
}

/* Responsive header optimizations */
@media (max-width: 1200px) {
  #auth-button {
    font-size: 0.85rem;
    padding: 0.45rem 0.85rem;
    max-width: 130px;
  }

  #cloud-sync-indicator {
    padding: 0.35rem 0.4rem;
  }

  .sync-icon {
    font-size: 1rem;
  }
}

@media (max-width: 1060px) {
  /* Mobile view - make auth button even more compact */
  #auth-button {
    font-size: 0.8rem;
    padding: 0.4rem 0.75rem;
    max-width: 110px;
  }

  #cloud-sync-indicator {
    padding: 0.3rem;
  }

  .sync-icon {
    font-size: 0.95rem;
  }
}

@media (max-width: 768px) {
  /* Extra small screens - minimize auth UI */
  #auth-button {
    font-size: 0.75rem;
    padding: 0.35rem 0.65rem;
    max-width: 100px;
  }

  #cloud-sync-indicator {
    padding: 0.25rem;
  }

  .sync-icon {
    font-size: 0.9rem;
  }
}

@media (max-width: 480px) {
  /* Very small screens - use icons only if possible */
  #auth-button {
    font-size: 0.7rem;
    padding: 0.3rem 0.5rem;
    max-width: 90px;
  }

  #auth-button span:last-child {
    max-width: 60px;
    overflow: hidden;
    text-overflow: ellipsis;
  }
}

/* User menu (for signed-in state) */
.user-menu {
  position: relative;
}

.user-menu-trigger {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.5rem 1rem;
  background: rgba(91, 138, 255, 0.1);
  border: 1px solid rgba(91, 138, 255, 0.3);
  border-radius: 8px;
  color: var(--text);
  cursor: pointer;
  transition: all 0.2s ease;
}

.user-menu-trigger:hover {
  background: rgba(91, 138, 255, 0.15);
  border-color: rgba(91, 138, 255, 0.4);
}

.user-avatar {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--accent), var(--accent-bright));
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 600;
  font-size: 0.9rem;
}

.user-menu-dropdown {
  position: absolute;
  top: calc(100% + 0.5rem);
  right: 0;
  background: var(--bg-2);
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 12px;
  padding: 0.5rem;
  min-width: 200px;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.5);
  display: none;
}

.user-menu-dropdown.show {
  display: block;
  animation: slideDown 0.2s ease;
}

@keyframes slideDown {
  from {
    transform: translateY(-10px);
    opacity: 0;
  }
  to {
    transform: translateY(0);
    opacity: 1;
  }
}

.user-menu-item {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.75rem 1rem;
  color: var(--text);
  text-decoration: none;
  border-radius: 8px;
  transition: background 0.2s ease;
  cursor: pointer;
  white-space: nowrap;
}

.user-menu-item:hover {
  background: rgba(255, 255, 255, 0.05);
}

.user-menu-divider {
  height: 1px;
  background: rgba(255, 255, 255, 0.1);
  margin: 0.5rem 0;
}

/* Responsive */
@media (max-width: 768px) {
  .auth-modal {
    align-items: flex-start;
    padding-top: 2rem;
  }

  .auth-modal-content {
    width: 92%;
    max-height: calc(100vh - 4rem);
    padding: 2rem 1.75rem;
  }

  .auth-header h2 {
    font-size: 1.6rem;
  }

  .form-group input {
    font-size: 16px; /* Prevents iOS zoom on focus */
  }
}

@media (max-width: 480px) {
  .auth-modal {
    align-items: flex-start;
    padding-top: 1rem;
  }

  .auth-modal-content {
    width: 95%;
    max-height: calc(100vh - 2rem);
    padding: 1.5rem 1.25rem;
    border-radius: 12px;
  }

  .auth-modal-close {
    top: 0.75rem;
    right: 0.75rem;
    font-size: 1.25rem;
    padding: 0.25rem;
  }

  .auth-header {
    margin-bottom: 1.5rem;
  }

  .auth-header h2 {
    font-size: 1.4rem;
  }

  .auth-header p {
    font-size: 0.85rem;
  }

  .auth-form {
    gap: 1rem;
  }

  .form-group {
    gap: 0.4rem;
  }

  .form-group label {
    font-size: 0.85rem;
  }

  .form-group input {
    padding: 0.75rem 0.85rem;
    font-size: 16px; /* Prevents iOS zoom on focus */
  }

  .btn-full {
    padding: 0.875rem;
    font-size: 0.95rem;
  }

  .auth-links {
    flex-direction: column;
    align-items: stretch;
    gap: 0.5rem;
  }

  .auth-links a {
    text-align: center;
    font-size: 0.85rem;
  }

  .auth-benefits {
    padding: 1rem;
    margin-top: 1.25rem;
  }

  .auth-benefits h4 {
    font-size: 0.9rem;
  }

  .auth-benefits li {
    font-size: 0.85rem;
    padding: 0.4rem 0;
  }

  .auth-footer {
    margin-top: 1.5rem;
    padding-top: 1.25rem;
  }

  .auth-footer p {
    font-size: 0.8rem;
  }
}

@media (max-width: 360px) {
  .auth-modal-content {
    width: 96%;
    padding: 1.25rem 1rem;
  }

  .auth-header h2 {
    font-size: 1.25rem;
  }
}

/* Sync notification animation */
@keyframes slideInRight {
  from {
    transform: translateX(400px);
    opacity: 0;
  }
  to {
    transform: translateX(0);
    opacity: 1;
  }
}
