/**
 * DAMP Smart Drinkware - Authentication UI Styles
 * 
 * Comprehensive styling for authentication modals, forms, and user interface
 */

/* Simple Auth Modal Base */
.auth-modal {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0, 0, 0, 0.8);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 10000;
  backdrop-filter: blur(4px);
}

.modal-overlay {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  cursor: pointer;
}

.modal-content {
  position: relative;
  background: white;
  border-radius: 12px;
  box-shadow: 0 20px 40px rgba(0, 0, 0, 0.3);
  max-width: 400px;
  width: 90%;
  max-height: 90vh;
  overflow-y: auto;
  animation: slideIn 0.3s ease-out;
}

@keyframes slideIn {
  from {
    opacity: 0;
    transform: scale(0.9) translateY(20px);
  }
  to {
    opacity: 1;
    transform: scale(1) translateY(0);
  }
}

.modal-close {
  position: absolute;
  top: 12px;
  right: 12px;
  background: none;
  border: none;
  font-size: 20px;
  color: #666;
  cursor: pointer;
  width: 28px;
  height: 28px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  transition: all 0.2s;
}

.modal-close:hover {
  background: #f0f0f0;
  color: #333;
}

/* Auth Form Styles */
.auth-form {
  padding: 32px 24px 24px;
  display: none;
}

.auth-form.active {
  display: block;
}

.auth-form h2 {
  font-size: 24px;
  font-weight: 700;
  color: #1a1a1a;
  margin: 0 0 8px 0;
  text-align: center;
}

.auth-form p {
  font-size: 14px;
  color: #666;
  margin: 0 0 24px 0;
  text-align: center;
}

/* Form Elements */
.form-group {
  margin-bottom: 16px;
}

.form-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
  margin-bottom: 16px;
}

.form-group input {
  width: 100%;
  padding: 12px 16px;
  border: 2px solid #e0e0e0;
  border-radius: 8px;
  font-size: 14px;
  transition: border-color 0.2s;
  box-sizing: border-box;
}

.form-group input:focus {
  outline: none;
  border-color: var(--primary-color, #2563eb);
}

.auth-btn {
  width: 100%;
  padding: 12px 16px;
  border-radius: 8px;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  margin-bottom: 12px;
  border: 1px solid transparent;
}

.auth-btn.primary {
  background: var(--primary-color, #2563eb);
  color: white;
}

.auth-btn.primary:hover:not(:disabled) {
  background: var(--primary-dark, #1d4ed8);
}

.auth-btn.social {
  background: white;
  border: 1px solid #ddd;
  color: #333;
}

.auth-btn.social:hover {
  background: #f9f9f9;
}

.auth-btn:disabled {
  opacity: 0.6;
  cursor: not-allowed;
}

/* Checkbox */
.checkbox {
  display: flex;
  align-items: flex-start;
  cursor: pointer;
  font-size: 14px;
  line-height: 1.4;
}

.checkbox input {
  width: auto !important;
  margin-right: 8px;
  margin-top: 2px;
}

.label-text a {
  color: var(--primary-color, #2563eb);
  text-decoration: none;
}

.label-text a:hover {
  text-decoration: underline;
}

/* Auth Divider */
.auth-divider {
  text-align: center;
  margin: 16px 0;
  color: #999;
  font-size: 12px;
  position: relative;
}

.auth-divider::before {
  content: '';
  position: absolute;
  top: 50%;
  left: 0;
  right: 0;
  height: 1px;
  background: #e0e0e0;
}

.auth-divider::before {
  background: white;
  padding: 0 8px;
  position: relative;
}

/* Auth Footer */
.auth-footer {
  text-align: center;
  margin-top: 16px;
}

.auth-footer p {
  margin: 0 0 8px 0;
  font-size: 14px;
  color: #666;
}

.link-btn {
  background: none;
  border: none;
  color: var(--primary-color, #2563eb);
  cursor: pointer;
  font-size: 14px;
  text-decoration: none;
}

.link-btn:hover {
  text-decoration: underline;
}

/* Auth Message */
.auth-message {
  padding: 24px;
  text-align: center;
}

.message-icon {
  font-size: 32px;
  margin-bottom: 12px;
}

.message-title {
  font-size: 18px;
  font-weight: 600;
  margin: 0 0 8px 0;
}

.auth-message.success .message-title {
  color: #059669;
}

.auth-message.error .message-title {
  color: #dc2626;
}

.message-text {
  color: #666;
  margin: 0;
  font-size: 14px;
}

/* Auth Navigation */
.auth-nav {
  display: flex;
  align-items: center;
  gap: 16px;
}

.auth-buttons {
  display: flex;
  gap: 8px;
}

.auth-nav-btn {
  padding: 8px 16px;
  border-radius: 6px;
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.2s;
  text-decoration: none;
  border: 1px solid transparent;
}

.auth-nav-btn.signin {
  background: none;
  border-color: #ddd;
  color: #333;
}

.auth-nav-btn.signin:hover {
  background: #f9f9f9;
}

.auth-nav-btn.signup {
  background: var(--primary-color, #2563eb);
  color: white;
}

.auth-nav-btn.signup:hover {
  background: var(--primary-dark, #1d4ed8);
}

/* User Menu */
.user-menu {
  position: relative;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 12px;
  border-radius: 8px;
  background: #f5f5f5;
  cursor: pointer;
}

.user-avatar {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background: #ddd;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 14px;
}

.user-info {
  display: flex;
  flex-direction: column;
}

.user-name {
  font-size: 14px;
  font-weight: 600;
  color: #333;
}

.user-email {
  font-size: 12px;
  color: #666;
}

.user-menu-btn {
  background: none;
  border: none;
  cursor: pointer;
  font-size: 10px;
  color: #666;
}

.user-dropdown {
  position: absolute;
  top: 100%;
  right: 0;
  background: white;
  border: 1px solid #ddd;
  border-radius: 8px;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
  min-width: 160px;
  z-index: 1000;
}

.user-dropdown a,
.user-dropdown button {
  display: block;
  width: 100%;
  padding: 8px 12px;
  text-align: left;
  text-decoration: none;
  color: #333;
  border: none;
  background: none;
  cursor: pointer;
  font-size: 14px;
}

.user-dropdown a:hover,
.user-dropdown button:hover {
  background: #f5f5f5;
}

/* Responsive */
@media (max-width: 480px) {
  .modal-content {
    width: 95%;
  }
  
  .auth-form {
    padding: 24px 20px 20px;
  }
  
  .form-row {
    grid-template-columns: 1fr;
  }
  
  .auth-buttons {
    flex-direction: column;
    width: 100%;
  }
  
  .auth-nav-btn {
    width: 100%;
    text-align: center;
  }
}

/* Dark mode support */
@media (prefers-color-scheme: dark) {
  .modal-content {
    background: #1f2937;
    color: #f9fafb;
  }
  
  .auth-form h2 {
    color: #f9fafb;
  }
  
  .form-group input {
    background: #374151;
    border-color: #4b5563;
    color: #f9fafb;
  }
  
  .user-dropdown {
    background: #1f2937;
    border-color: #4b5563;
  }
}

/* DAMP Auth Modal Base */
.damp-auth-modal {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0, 0, 0, 0.8);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 10000;
  backdrop-filter: blur(5px);
  -webkit-backdrop-filter: blur(5px);
}

.auth-modal-overlay {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  cursor: pointer;
}

.auth-modal-content {
  position: relative;
  background: #ffffff;
  border-radius: 16px;
  box-shadow: 0 25px 50px rgba(0, 0, 0, 0.3);
  max-width: 480px;
  width: 90%;
  max-height: 90vh;
  overflow-y: auto;
  animation: modalSlideIn 0.3s ease-out;
}

@keyframes modalSlideIn {
  from {
    opacity: 0;
    transform: scale(0.9) translateY(20px);
  }
  to {
    opacity: 1;
    transform: scale(1) translateY(0);
  }
}

.auth-modal-close {
  position: absolute;
  top: 16px;
  right: 16px;
  background: none;
  border: none;
  font-size: 24px;
  color: #666;
  cursor: pointer;
  width: 32px;
  height: 32px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  transition: all 0.2s ease;
  z-index: 1;
}

.auth-modal-close:hover {
  background: #f5f5f5;
  color: #333;
}

/* Auth Form Styles */
.auth-form {
  padding: 40px 32px 32px;
}

.auth-header {
  text-align: center;
  margin-bottom: 32px;
}

.auth-logo {
  margin-bottom: 24px;
}

.auth-logo-img {
  height: 48px;
  width: auto;
}

.auth-title {
  font-size: 28px;
  font-weight: 700;
  color: #1a1a1a;
  margin: 0 0 8px 0;
  line-height: 1.2;
}

.auth-subtitle {
  font-size: 16px;
  color: #666;
  margin: 0;
  line-height: 1.4;
}

/* Form Fields */
.auth-form-fields {
  margin-bottom: 24px;
}

.form-group {
  position: relative;
  margin-bottom: 20px;
}

.form-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
  margin-bottom: 20px;
}

.form-group input {
  width: 100%;
  padding: 16px 20px;
  padding-left: 48px;
  border: 2px solid #e5e5e5;
  border-radius: 12px;
  font-size: 16px;
  transition: all 0.2s ease;
  background: #fafafa;
  color: #333;
  box-sizing: border-box;
}

.form-group input:focus {
  outline: none;
  border-color: var(--primary-color, #2563eb);
  background: #ffffff;
  box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.1);
}

.form-group input.error {
  border-color: #ef4444;
  background: #fef2f2;
}

.form-group input.error:focus {
  border-color: #ef4444;
  box-shadow: 0 0 0 3px rgba(239, 68, 68, 0.1);
}

.input-icon {
  position: absolute;
  left: 16px;
  top: 50%;
  transform: translateY(-50%);
  font-size: 18px;
  pointer-events: none;
  z-index: 1;
}

.password-toggle {
  position: absolute;
  right: 16px;
  top: 50%;
  transform: translateY(-50%);
  background: none;
  border: none;
  cursor: pointer;
  padding: 4px;
  border-radius: 6px;
  transition: background 0.2s ease;
}

.password-toggle:hover {
  background: #f0f0f0;
}

.password-toggle-icon {
  font-size: 18px;
}

.field-error {
  color: #ef4444;
  font-size: 14px;
  margin-top: 6px;
  margin-left: 4px;
}

/* Form Options */
.form-options {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 24px;
  font-size: 14px;
}

.checkbox-label {
  display: flex;
  align-items: center;
  cursor: pointer;
  color: #666;
  font-size: 14px;
  line-height: 1.4;
}

.checkbox-label input {
  display: none;
}

.checkmark {
  width: 18px;
  height: 18px;
  border: 2px solid #d1d5db;
  border-radius: 4px;
  margin-right: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 12px;
  color: transparent;
  transition: all 0.2s ease;
}

.checkbox-label input:checked + .checkmark {
  background: var(--primary-color, #2563eb);
  border-color: var(--primary-color, #2563eb);
  color: white;
}

.forgot-password-link {
  background: none;
  border: none;
  color: var(--primary-color, #2563eb);
  cursor: pointer;
  font-size: 14px;
  text-decoration: none;
  transition: color 0.2s ease;
}

.forgot-password-link:hover {
  color: var(--primary-dark, #1d4ed8);
  text-decoration: underline;
}

/* Submit Button */
.auth-submit-btn {
  width: 100%;
  padding: 16px 24px;
  background: var(--primary-color, #2563eb);
  color: white;
  border: none;
  border-radius: 12px;
  font-size: 16px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s ease;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  margin-bottom: 24px;
}

.auth-submit-btn:hover:not(:disabled) {
  background: var(--primary-dark, #1d4ed8);
  transform: translateY(-1px);
  box-shadow: 0 4px 12px rgba(37, 99, 235, 0.3);
}

.auth-submit-btn:disabled {
  opacity: 0.6;
  cursor: not-allowed;
  transform: none;
}

.button-loader {
  font-size: 14px;
}

/* Auth Divider */
.auth-divider {
  text-align: center;
  margin: 24px 0;
  position: relative;
  color: #999;
  font-size: 14px;
}

.auth-divider::before {
  content: '';
  position: absolute;
  top: 50%;
  left: 0;
  right: 0;
  height: 1px;
  background: #e5e5e5;
}

.auth-divider span {
  background: white;
  padding: 0 16px;
  position: relative;
}

/* Social Buttons */
.auth-social {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
  margin-bottom: 24px;
}

.social-btn {
  padding: 12px 16px;
  border: 2px solid #e5e5e5;
  border-radius: 10px;
  background: white;
  cursor: pointer;
  transition: all 0.2s ease;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  font-weight: 500;
  font-size: 14px;
}

.social-btn:hover {
  border-color: #d1d5db;
  background: #f9f9f9;
  transform: translateY(-1px);
}

.google-btn:hover {
  border-color: #4285f4;
  color: #4285f4;
}

.facebook-btn:hover {
  border-color: #1877f2;
  color: #1877f2;
}

.social-icon {
  font-size: 18px;
}

/* Auth Preferences */
.auth-preferences {
  margin-bottom: 20px;
  padding: 16px;
  background: #f8f9fa;
  border-radius: 10px;
}

.auth-preferences h4 {
  margin: 0 0 12px 0;
  font-size: 14px;
  font-weight: 600;
  color: #333;
}

.auth-preferences .checkbox-label {
  margin-bottom: 8px;
}

.auth-preferences .checkbox-label:last-child {
  margin-bottom: 0;
}

/* Auth Terms */
.auth-terms {
  margin-bottom: 24px;
}

.auth-terms .checkbox-label {
  align-items: flex-start;
  line-height: 1.5;
}

.auth-terms a {
  color: var(--primary-color, #2563eb);
  text-decoration: none;
}

.auth-terms a:hover {
  text-decoration: underline;
}

/* Auth Footer */
.auth-footer {
  text-align: center;
  color: #666;
  font-size: 14px;
}

.auth-switch-link {
  background: none;
  border: none;
  color: var(--primary-color, #2563eb);
  cursor: pointer;
  font-size: 14px;
  text-decoration: none;
  font-weight: 500;
  transition: color 0.2s ease;
}

.auth-switch-link:hover {
  color: var(--primary-dark, #1d4ed8);
  text-decoration: underline;
}

/* Auth Message */
.auth-message {
  padding: 32px;
  text-align: center;
}

.message-icon {
  font-size: 48px;
  margin-bottom: 16px;
}

.message-title {
  font-size: 20px;
  font-weight: 600;
  margin: 0 0 8px 0;
}

.auth-message.success .message-title {
  color: #059669;
}

.auth-message.error .message-title {
  color: #dc2626;
}

.message-text {
  color: #666;
  margin: 0;
  line-height: 1.5;
}

/* Auth Navigation */
.auth-navigation {
  display: flex;
  align-items: center;
}

.auth-buttons {
  display: flex;
  align-items: center;
  gap: 12px;
}

.auth-btn {
  padding: 10px 16px;
  border-radius: 8px;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.2s ease;
  display: flex;
  align-items: center;
  gap: 6px;
  text-decoration: none;
  font-size: 14px;
}

.signin-btn {
  background: none;
  border: 1px solid #e5e5e5;
  color: #333;
}

.signin-btn:hover {
  background: #f9f9f9;
  border-color: #d1d5db;
}

.signup-btn {
  background: var(--primary-color, #2563eb);
  border: 1px solid var(--primary-color, #2563eb);
  color: white;
}

.signup-btn:hover {
  background: var(--primary-dark, #1d4ed8);
  border-color: var(--primary-dark, #1d4ed8);
}

.btn-icon {
  font-size: 16px;
}

/* User Menu */
.user-menu {
  position: relative;
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 8px 12px;
  border-radius: 12px;
  background: #f8f9fa;
  cursor: pointer;
  transition: background 0.2s ease;
}

.user-menu:hover {
  background: #e9ecef;
}

.user-avatar {
  position: relative;
  width: 36px;
  height: 36px;
  border-radius: 50%;
  overflow: hidden;
  background: #e5e5e5;
  display: flex;
  align-items: center;
  justify-content: center;
}

.avatar-img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.avatar-fallback {
  font-size: 18px;
  color: #666;
}

.user-info {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  max-width: 150px;
}

.user-name {
  font-weight: 600;
  font-size: 14px;
  color: #333;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  width: 100%;
}

.user-email {
  font-size: 12px;
  color: #666;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  width: 100%;
}

.user-menu-dropdown {
  position: relative;
}

.dropdown-toggle {
  background: none;
  border: none;
  cursor: pointer;
  padding: 4px;
  color: #666;
  transition: color 0.2s ease;
}

.dropdown-toggle:hover {
  color: #333;
}

.dropdown-icon {
  font-size: 12px;
  transition: transform 0.2s ease;
}

.dropdown-menu.show .dropdown-icon {
  transform: rotate(180deg);
}

.dropdown-menu {
  position: absolute;
  top: calc(100% + 8px);
  right: 0;
  background: white;
  border: 1px solid #e5e5e5;
  border-radius: 12px;
  box-shadow: 0 10px 25px rgba(0, 0, 0, 0.1);
  min-width: 200px;
  opacity: 0;
  visibility: hidden;
  transform: translateY(-10px);
  transition: all 0.2s ease;
  z-index: 1000;
}

.dropdown-menu.show {
  opacity: 1;
  visibility: visible;
  transform: translateY(0);
}

.dropdown-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 16px;
  color: #333;
  text-decoration: none;
  transition: background 0.2s ease;
  border: none;
  background: none;
  width: 100%;
  text-align: left;
  cursor: pointer;
  font-size: 14px;
}

.dropdown-item:hover {
  background: #f8f9fa;
}

.dropdown-item:first-child {
  border-radius: 12px 12px 0 0;
}

.dropdown-item:last-child {
  border-radius: 0 0 12px 12px;
}

.item-icon {
  font-size: 16px;
  width: 20px;
  text-align: center;
}

.dropdown-divider {
  height: 1px;
  background: #e5e5e5;
  margin: 4px 0;
}

/* Loading States */
.damp-auth-modal.loading {
  pointer-events: none;
}

.damp-auth-modal.loading .auth-modal-content {
  opacity: 0.7;
}

/* Responsive Design */
@media (max-width: 768px) {
  .auth-modal-content {
    width: 95%;
    margin: 20px;
    max-height: calc(100vh - 40px);
  }
  
  .auth-form {
    padding: 32px 24px 24px;
  }
  
  .auth-title {
    font-size: 24px;
  }
  
  .form-row {
    grid-template-columns: 1fr;
    gap: 16px;
  }
  
  .auth-social {
    grid-template-columns: 1fr;
  }
  
  .auth-buttons {
    flex-direction: column;
    gap: 8px;
    width: 100%;
  }
  
  .auth-btn {
    width: 100%;
    justify-content: center;
  }
  
  .user-menu {
    padding: 6px 8px;
  }
  
  .user-info {
    max-width: 120px;
  }
  
  .dropdown-menu {
    min-width: 180px;
  }
}

@media (max-width: 480px) {
  .auth-form {
    padding: 24px 20px 20px;
  }
  
  .form-group input {
    padding: 14px 18px;
    padding-left: 44px;
    font-size: 16px; /* Prevent zoom on iOS */
  }
  
  .input-icon {
    left: 14px;
  }
  
  .password-toggle {
    right: 14px;
  }
}

/* Dark Mode Support */
@media (prefers-color-scheme: dark) {
  .auth-modal-content {
    background: #1f2937;
    color: #f9fafb;
  }
  
  .auth-title {
    color: #f9fafb;
  }
  
  .auth-subtitle {
    color: #d1d5db;
  }
  
  .form-group input {
    background: #374151;
    border-color: #4b5563;
    color: #f9fafb;
  }
  
  .form-group input:focus {
    background: #4b5563;
    border-color: var(--primary-color, #3b82f6);
  }
  
  .social-btn {
    background: #374151;
    border-color: #4b5563;
    color: #f9fafb;
  }
  
  .social-btn:hover {
    background: #4b5563;
  }
  
  .user-menu {
    background: #374151;
  }
  
  .user-menu:hover {
    background: #4b5563;
  }
  
  .dropdown-menu {
    background: #1f2937;
    border-color: #4b5563;
  }
  
  .dropdown-item:hover {
    background: #374151;
  }
}

/* High contrast mode */
@media (prefers-contrast: high) {
  .form-group input {
    border-width: 3px;
  }
  
  .auth-submit-btn {
    border: 2px solid var(--primary-color, #2563eb);
  }
  
  .social-btn {
    border-width: 3px;
  }
} 