/* =====================================================
   STOKVEL SOCIETY — AUTH SECTION (Unified with Dashboard v2.1.0)
   Version: 2.1.0 - FULL WIDTH MOBILE
   Namespace: .auth-section
   ===================================================== */

/* ============= GLOBAL WRAPPER ============= */
.auth-section {
    background: linear-gradient(135deg, #083421, #0f5c3a, #147445) !important;
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0;
    font-family: 'Inter', 'Segoe UI', Roboto, -apple-system, sans-serif;
    position: relative;
    overflow: hidden;
}

/* Subtle Twinkling Stars */
.auth-section::after {
    content: '';
    position: absolute;
    inset: 0;
    background-image: 
        radial-gradient(1.5px 1.5px at 20% 30%, rgba(255,255,255,0.4) 50%, transparent 100%),
        radial-gradient(1.2px 1.2px at 40% 70%, rgba(255,255,255,0.3) 50%, transparent 100%),
        radial-gradient(1px 1px at 60% 20%, rgba(255,255,255,0.5) 50%, transparent 100%),
        radial-gradient(1.3px 1.3px at 80% 50%, rgba(255,255,255,0.35) 50%, transparent 100%),
        radial-gradient(1.1px 1.1px at 30% 80%, rgba(255,255,255,0.4) 50%, transparent 100%),
        radial-gradient(1.4px 1.4px at 70% 10%, rgba(255,255,255,0.45) 50%, transparent 100%),
        radial-gradient(1px 1px at 10% 40%, rgba(255,255,255,0.3) 50%, transparent 100%),
        radial-gradient(1.2px 1.2px at 90% 90%, rgba(255,255,255,0.35) 50%, transparent 100%),
        radial-gradient(1px 1px at 15% 60%, rgba(255,255,255,0.4) 50%, transparent 100%),
        radial-gradient(1.3px 1.3px at 55% 85%, rgba(255,255,255,0.3) 50%, transparent 100%),
        radial-gradient(1px 1px at 85% 25%, rgba(255,255,255,0.5) 50%, transparent 100%),
        radial-gradient(1.2px 1.2px at 45% 35%, rgba(255,255,255,0.35) 50%, transparent 100%);
    background-size: 250px 250px;
    animation: multiTwinkle 5s ease-in-out infinite;
    pointer-events: none;
    z-index: 1;
}

/* Enhanced Multi-layered Twinkle Animation */
@keyframes multiTwinkle {
    0%, 100% {
        opacity: 0.3;
        filter: brightness(0.8);
    }
    25% {
        opacity: 0.6;
        filter: brightness(1.2);
    }
    50% {
        opacity: 0.4;
        filter: brightness(1);
    }
    75% {
        opacity: 0.7;
        filter: brightness(1.3);
    }
}

/* Add a second layer of stars with different timing */
.auth-section::before {
    content: '';
    position: absolute;
    inset: 0;
    background-image: 
        radial-gradient(1px 1px at 25% 35%, rgba(255,255,255,0.25) 50%, transparent 100%),
        radial-gradient(1.2px 1.2px at 65% 75%, rgba(255,255,255,0.2) 50%, transparent 100%),
        radial-gradient(0.8px 0.8px at 45% 15%, rgba(255,255,255,0.3) 50%, transparent 100%),
        radial-gradient(1.1px 1.1px at 75% 45%, rgba(255,255,255,0.15) 50%, transparent 100%),
        radial-gradient(0.9px 0.9px at 35% 85%, rgba(255,255,255,0.25) 50%, transparent 100%),
        radial-gradient(1px 1px at 85% 5%, rgba(255,255,255,0.3) 50%, transparent 100%);
    background-size: 300px 300px;
    animation: delayedTwinkle 7s ease-in-out infinite;
    pointer-events: none;
    z-index: 1;
}

@keyframes delayedTwinkle {
    0%, 100% {
        opacity: 0.2;
    }
    33% {
        opacity: 0.4;
    }
    66% {
        opacity: 0.25;
    }
}

/* Ensure auth container stays above stars */
.auth-section .auth-container {
    position: relative;
    z-index: 10;
}

/* ============= CONTAINER & CARD ============= */
.auth-section .auth-container {
    width: 100%;
    max-width: 520px;
    position: relative;
    z-index: 2;
}

.auth-section .auth-container.wide {
    max-width: 580px;
}

.auth-section .auth-container.register-wide {
    max-width: 900px;
}

.auth-section .auth-card {
    background: rgba(255,255,255,0.95);
    backdrop-filter: blur(20px);
    border-radius: 24px;
    padding: 48px 40px;
    box-shadow: 0 20px 40px rgba(0,0,0,0.1);
    border: 1px solid rgba(255,255,255,0.2);
    animation: authCardSlide 0.8s cubic-bezier(0.4, 0, 0.2, 1);
    position: relative;
    overflow: hidden;
}

.auth-section .auth-card::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0; right: 0; height: 4px;
    background: linear-gradient(135deg, #147445, #0d8b5e, #10b981);
    box-shadow: 0 2px 12px rgba(20,116,69,0.4);
}

/* ============= HEADER ============= */
.auth-section .auth-header { 
  text-align: center; 
  margin-bottom: 20px; /* was 40px */
}

.auth-section .auth-logo {
  width: 90px; 
  height: 90px;
  background: linear-gradient(135deg, #147445, #0d8b5e);
  border-radius: 22px;
  margin: 0 auto 28px;
  display: flex; 
  align-items: center; 
  justify-content: center;
  color: white; 
  font-size: 36px; 
  font-weight: 700;
  border: 3px solid rgba(255,255,255,0.8);
  box-shadow: 0 8px 32px rgba(20,116,69,0.4);
  animation: authLogoPulse 3s ease-in-out infinite;
}

@keyframes authLogoPulse {
  0%, 100% { transform: scale(1); }
  50% { transform: scale(1.08); }
}

.auth-section .auth-title {
  color: #147445;
  font-size: 32px;
  font-weight: 800;
  margin-bottom: 8px;
}

.auth-section .auth-subtitle {
  color: #64748b;
  font-size: 16px;
  margin: 0;
  font-weight: 500;
}

/* ============= FORM STYLES ============= */
.auth-section .auth-form {
  display: flex;
  flex-direction: column;
  gap: 22px;
}

.auth-section .form-group {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.auth-section label {
  color: #334155;
  font-weight: 600;
  font-size: 14px;
}

/* INPUT STYLES - CRITICAL FIX */
.auth-section input[type="text"],
.auth-section input[type="password"],
.auth-section input[type="email"],
.auth-section .auth-input {
  width: 100%;
  padding: 16px 18px;
  border: 2px solid #e2e8f0;
  border-radius: 14px;
  background: rgba(255,255,255,0.95);
  font-size: 16px;
  color: #1e293b;
  transition: all 0.3s ease;
  font-family: inherit;
  box-sizing: border-box;
}

.auth-section input:focus,
.auth-section .auth-input:focus {
  outline: none;
  border-color: #147445;
  box-shadow: 0 0 0 4px rgba(20,116,69,0.15);
  background: rgba(255,255,255,0.98);
  transform: translateY(-2px);
}

.auth-section input::placeholder,
.auth-section .auth-input::placeholder {
  color: #94a3b8;
  opacity: 0.8;
}

/* ============= BUTTONS ============= */
.auth-section .auth-button {
  width: 100%;
  padding: 18px 24px;
  border: none;
  border-radius: 16px;
  background: linear-gradient(135deg, #147445, #0d8b5e);
  color: #fff;
  font-size: 16px;
  font-weight: 700;
  cursor: pointer;
  transition: all 0.3s ease;
  box-shadow: 0 8px 25px rgba(20,116,69,0.4);
  font-family: inherit;
}

.auth-section .auth-button:hover {
  background: linear-gradient(135deg, #0d8b5e, #147445);
  transform: translateY(-3px);
  box-shadow: 0 12px 30px rgba(20,116,69,0.5);
}

.auth-section .auth-button:disabled {
  opacity: 0.7;
  cursor: not-allowed;
  transform: none;
}

/* ============= REMEMBER ME CHECKBOX ============= */
.auth-section .remember-group {
  margin: 10px 0 20px 0;
}

.auth-section .checkbox-label {
  display: flex;
  align-items: center;
  gap: 12px;
  cursor: pointer;
  font-weight: 500;
  color: #475569;
}

.auth-section .checkbox-label input[type="checkbox"] {
  display: none;
}

.auth-section .checkmark {
  width: 20px;
  height: 20px;
  border: 2px solid #cbd5e1;
  border-radius: 6px;
  position: relative;
  transition: all 0.3s ease;
}

.auth-section .checkbox-label input[type="checkbox"]:checked + .checkmark {
  background: #147445;
  border-color: #147445;
}

.auth-section .checkbox-label input[type="checkbox"]:checked + .checkmark::after {
  content: '✓';
  position: absolute;
  color: white;
  font-size: 14px;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
}

/* ============= LINKS ============= */
.auth-section .auth-links {
  margin-top: 16px;
  padding-top: 12px;
  border-top: 1px solid rgba(226,232,240,0.5);
  text-align: center;
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.auth-section .auth-link {
  color: #147445;
  text-decoration: none;
  font-weight: 600;
  transition: all 0.3s ease;
}

.auth-section .auth-link.accent {
  color: #0d8b5e;
  font-weight: 700;
}

.auth-section .auth-link:hover {
  color: #0f5c36;
  transform: translateX(2px);
}

/* ============= REGISTRATION FORM FIXES ============= */
.register-form label:after {
    content: " *";
    color: #dc2626;
    font-weight: 700;
}

.register-form .form-group.full-width {
    grid-column: 1 / -1;
    width: 100%;
}

/* Enhanced password hint */
.register-form .field-hint {
    color: #64748b;
    font-size: 12px;
    margin-top: 4px;
    display: block;
}

.auth-section .auth-text {
  color: #64748b;
  font-weight: 500;
}

/* ============= MESSAGES ============= */
.auth-section .auth-message {
  padding: 18px;
  border-radius: 14px;
  margin-bottom: 24px;
  font-weight: 600;
  text-align: center;
  animation: authFadeIn 0.5s ease;
}

.auth-section .auth-message.error {
  background: linear-gradient(135deg, rgba(239,68,68,0.1), rgba(220,38,38,0.05));
  color: #dc2626;
  border: 1px solid rgba(220,38,38,0.2);
}

.auth-section .auth-message.success {
  background: linear-gradient(135deg, rgba(20,116,69,0.15), rgba(13,139,94,0.08));
  color: #147445;
  border: 1px solid rgba(20,116,69,0.2);
}

.auth-section .auth-message ul {
  margin: 0;
  padding: 0;
  list-style: none;
}

.auth-section .auth-message li {
  margin: 5px 0;
}

@keyframes authFadeIn {
  from { opacity: 0; transform: translateY(-10px); }
  to { opacity: 1; transform: translateY(0); }
}

/* ============= PROFESSIONAL REGISTRATION FORM ============= */
.auth-section .register-form .form-columns {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 24px;
  margin-bottom: 10px;
}

.auth-section .register-form .form-column {
  display: flex;
  flex-direction: column;
  gap: 22px;
}

.auth-section .register-form .full-width {
  grid-column: 1 / -1;
}

/* Field hints and labels */
.auth-section .field-hint {
  display: block;
  font-size: 12px;
  color: #64748b;
  margin-top: 4px;
  font-weight: 400;
}

.auth-section label {
  color: #334155;
  font-weight: 600;
  font-size: 14px;
  display: flex;
  align-items: center;
  gap: 4px;
}

.auth-section label:after {
  content: '*';
  color: #dc2626;
  font-weight: 700;
}

/* Form footer with privacy notice */
.auth-section .form-footer {
  margin-top: 10px;
  text-align: center;
}

.auth-section .privacy-notice {
  font-size: 13px;
  color: #64748b;
  margin-top: 16px;
  line-height: 1.4;
}

.auth-section .privacy-notice a {
  color: #147445;
  text-decoration: none;
  font-weight: 500;
}

.auth-section .privacy-notice a:hover {
  text-decoration: underline;
}

/* Enhanced input styling for better UX */
.auth-section .auth-input {
  transition: all 0.3s ease;
}

.auth-section .auth-input:valid {
  border-color: #d1d5db;
}

.auth-section .auth-input:invalid:not(:focus):not(:placeholder-shown) {
  border-color: #fca5a5;
}

/* Focus states for better accessibility */
.auth-section .auth-input:focus {
  outline: none;
  border-color: #147445;
  box-shadow: 0 0 0 3px rgba(20, 116, 69, 0.1);
  background: rgba(255, 255, 255, 0.98);
  transform: translateY(-1px);
}

/* Loading state for form submission */
.auth-section .auth-form.processing {
  opacity: 0.7;
  pointer-events: none;
}

.auth-section .auth-form.processing .auth-button {
  position: relative;
  color: transparent;
}

.auth-section .auth-form.processing .auth-button:after {
  content: '';
  position: absolute;
  width: 20px;
  height: 20px;
  top: 50%;
  left: 50%;
  margin-left: -10px;
  margin-top: -10px;
  border: 2px solid #ffffff;
  border-radius: 50%;
  border-right-color: transparent;
  animation: button-spinner 0.8s linear infinite;
}

@keyframes button-spinner {
  from { transform: rotate(0deg); }
  to { transform: rotate(360deg); }
}

/* ============= NOTIFICATIONS & SPINNER ============= */
.auth-notification {
  position: absolute;
  top: 20px;
  left: 50%;
  transform: translateX(-50%) translateY(-20px);
  padding: 12px 24px;
  border-radius: 8px;
  color: #fff;
  opacity: 0;
  transition: all 0.3s ease;
  z-index: 100;
  font-weight: 600;
}

.auth-notification.show {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}

.auth-notification.success { 
  background-color: #147445; 
}

.auth-notification.error { 
  background-color: #c0392b; 
}

.auth-spinner {
  display: inline-block;
  width: 24px;
  height: 24px;
}

.auth-spinner .spinner {
  animation: rotate 1s linear infinite;
  width: 100%;
  height: 100%;
}

.auth-spinner .path {
  stroke: #fff;
  stroke-linecap: round;
  animation: dash 1.5s ease-in-out infinite;
}

@keyframes rotate { 
  100% { transform: rotate(360deg); } 
}

@keyframes dash {
  0% { stroke-dasharray: 1,150; stroke-dashoffset: 0; }
  50% { stroke-dasharray: 90,150; stroke-dashoffset: -35; }
  100% { stroke-dasharray: 90,150; stroke-dashoffset: -124; }
}

/* ============= FULL WIDTH MOBILE STYLES ============= */
@media (max-width: 768px) {
    .auth-section {
        padding: 0 !important;
    }
    
    .auth-section .auth-container {
        width: 100% !important;
        max-width: 100% !important;
        padding: 0 !important;
        margin: 0 !important;
    }
    
    .auth-section .auth-card {
        width: 100%;
        min-height: auto;
        border-radius: 0 !important;
        margin: 0 !important;
        padding: 40px 24px !important;
        box-shadow: none !important;
        border: none !important;
    }
    
    /* Full width form elements */
    .auth-section input[type="text"],
    .auth-section input[type="password"],
    .auth-section input[type="email"],
    .auth-section input[type="tel"],
    .ss-form-input,
    .auth-input {
        font-size: 16px !important;
        padding: 16px 14px !important;
        width: 100% !important;
    }
    
    /* REGISTRATION FORM MOBILE LAYOUT FIX */
    .auth-section .register-form .form-columns {
        display: flex !important;
        flex-direction: column !important;
        gap: 0 !important;
    }
    
    .auth-section .register-form .form-column {
        width: 100% !important;
    }
    
    .auth-section .register-form .form-group {
        order: initial !important;
        width: 100% !important;
    }
    
    /* Ensure proper field order */
    .register-form .form-group.full-width {
        grid-column: 1 !important;
    }
    
    /* TOUCH TARGET SIZES FOR MOBILE */
    .auth-section .auth-button,
    .auth-section .checkbox-label,
    .auth-section .auth-link {
        min-height: 48px;
        min-width: 48px;
        padding: 14px 16px;
    }
    
    .auth-section .checkbox-label {
        padding: 12px 0;
    }
    
    /* Larger tap area for checkboxes */
    .auth-section .checkmark {
        min-width: 24px;
        min-height: 24px;
    }
    
    /* Reduce animation complexity on mobile */
    .auth-section::after,
    .auth-section::before {
        animation: none;
        opacity: 0.4;
    }
    
    .auth-section .auth-logo {
        animation: none;
    }
    
    .auth-section .auth-title {
        font-size: 28px;
    }
    
    .auth-section .auth-logo {
        width: 80px;
        height: 80px;
        font-size: 32px;
    }
}

/* Additional responsive adjustments */
@media (max-width: 520px) {
  .auth-section .auth-card {
    padding: 32px 20px !important;
  }
  
  .auth-section .auth-title { 
    font-size: 26px; 
  }
  
  .auth-section .auth-logo { 
    width: 75px; 
    height: 75px; 
    font-size: 28px; 
  }
  
  .auth-section .auth-button { 
    padding: 16px 20px; 
  }
}

@media (max-width: 480px) {
    .auth-section .auth-card {
        padding: 32px 20px !important;
    }
    
    .auth-section .auth-title {
        font-size: 26px;
    }
    
    .auth-section .auth-subtitle {
        font-size: 14px;
    }
    
    .auth-section input[type="text"],
    .auth-section input[type="password"],
    .auth-section input[type="email"],
    .auth-section .auth-input {
        padding: 14px 12px !important;
    }
    
    .auth-section .auth-logo {
        width: 70px;
        height: 70px;
        font-size: 28px;
    }
}

/* Very small devices */
@media (max-width: 360px) {
    .auth-section .auth-card {
        padding: 24px 16px !important;
    }
    
    .auth-section .auth-title {
        font-size: 24px;
    }
    
    .auth-section .auth-logo {
        width: 60px;
        height: 60px;
        font-size: 24px;
    }
}

/* Desktop styles - keep original design for larger screens */
@media (min-width: 769px) {
    .auth-section {
        padding: 20px;
    }
    
    .auth-section .auth-card {
        min-height: auto;
        border-radius: 24px;
        box-shadow: 0 20px 40px rgba(0,0,0,0.1) !important;
        border: 1px solid rgba(255,255,255,0.2) !important;
    }
}

/* ============= RESPONSIVE DESIGN FOR REGISTRATION FORM ============= */
@media (max-width: 768px) {
  .auth-section .register-form .form-columns {
    grid-template-columns: 1fr;
    gap: 22px;
  }
  
  .auth-section .auth-container.register-wide {
    max-width: 100%;
  }
}

/* Additional responsive adjustments for wider forms */
@media (max-width: 1024px) {
  .auth-section .auth-container.register-wide {
    max-width: 800px;
  }
}

@media (max-width: 900px) {
  .auth-section .auth-container.register-wide {
    max-width: 700px;
  }
}

@media (max-width: 768px) {
  .auth-section .auth-container.register-wide {
    max-width: 100%;
  }
}

/* =====================================================
   ULTRA-COMPACT AUTH FORMS - SPACE REDUCTION FIX (RESTORED)
   ===================================================== */

@media (max-width: 768px) {
    /* DRAMATIC SPACE REDUCTION - FORM FIELDS */
    .auth-section .form-group {
        margin-bottom: 6px !important;
        gap: 4px !important;
    }
    
    /* Ultra-compact form layout */
    .auth-section .auth-form {
        gap: 8px !important;
    }
    
    /* Tighter input spacing */
    .auth-section input[type="text"],
    .auth-section input[type="password"],
    .auth-section input[type="email"],
    .auth-section .auth-input {
        padding: 10px 12px !important;
        border-radius: 8px !important;
        font-size: 16px !important;
        min-height: 44px !important;
    }
    
    /* Reduce label spacing */
    .auth-section label {
        margin-bottom: 2px !important;
        font-size: 13px !important;
    }
    
    /* Compact header */
    .auth-section .auth-header {
        margin-bottom: 16px !important;
        padding: 0 !important;
    }
    
    .auth-section .auth-logo {
        width: 48px !important;
        height: 48px !important;
        font-size: 20px !important;
        margin: 0 auto 12px !important;
        border-radius: 12px !important;
    }
    
    .auth-section .auth-title {
        font-size: 1.4rem !important;
        margin-bottom: 4px !important;
    }
    
    .auth-section .auth-subtitle {
        font-size: 0.8rem !important;
        margin: 0 !important;
    }
    
    /* Compact buttons */
    .auth-section .auth-button {
        padding: 12px 16px !important;
        margin-top: 4px !important;
        min-height: 46px !important;
        border-radius: 10px !important;
        font-size: 15px !important;
    }
    
    /* Tighter checkbox spacing */
    .auth-section .remember-group {
        margin: 4px 0 8px 0 !important;
    }
    
    .auth-section .checkbox-label {
        gap: 8px !important;
        padding: 6px 0 !important;
        font-size: 13px !important;
    }
    
    /* Compact links section */
    .auth-section .auth-links {
        margin-top: 16px !important;
        padding-top: 12px !important;
        gap: 10px !important;
        font-size: 13px !important;
    }
    
    .auth-section .auth-link {
        padding: 6px 0 !important;
    }
    
    /* Reduce message spacing */
    .auth-section .auth-message {
        padding: 12px !important;
        margin-bottom: 16px !important;
        font-size: 13px !important;
    }
    
    /* REGISTRATION FORM SPECIFIC COMPACTION */
    .auth-section .register-form .form-columns {
        gap: 8px !important;
        margin-bottom: 6px !important;
    }
    
    .auth-section .register-form .form-column {
        gap: 8px !important;
    }
    
    /* Field hints - smaller */
    .auth-section .field-hint {
        font-size: 11px !important;
        margin-top: 2px !important;
    }
    
    /* Privacy notice - more compact */
    .auth-section .privacy-notice {
        margin-top: 10px !important;
        font-size: 11px !important;
        line-height: 1.3 !important;
    }
    
    /* Remove any remaining excessive padding */
    .auth-section .auth-card {
        padding: 20px 16px !important;
    }
}

/* ============= EXTRA COMPACT FOR SMALL MOBILE ============= */
@media (max-width: 480px) {
    .auth-section .auth-card {
        padding: 16px 12px !important;
    }
    
    .auth-section .form-group {
        margin-bottom: 4px !important;
    }
    
    .auth-section .auth-form {
        gap: 6px !important;
    }
    
    .auth-section input[type="text"],
    .auth-section input[type="password"],
    .auth-section input[type="email"],
    .auth-section .auth-input {
        padding: 8px 10px !important;
        min-height: 42px !important;
    }
    
    .auth-section .auth-button {
        padding: 10px 14px !important;
        min-height: 44px !important;
    }
    
    .auth-section .auth-logo {
        width: 42px !important;
        height: 42px !important;
        font-size: 18px !important;
        margin-bottom: 8px !important;
    }
    
    .auth-section .auth-title {
        font-size: 1.2rem !important;
    }
}

/* ============= LOGIN FORM - EXTRA TIGHT ============= */
@media (max-width: 768px) {
    .auth-form:not(.register-form) .form-group {
        margin-bottom: 5px !important;
    }
    
    .auth-form:not(.register-form) .remember-group {
        margin: 2px 0 6px 0 !important;
    }
    
    .auth-form:not(.register-form) .auth-button {
        margin-top: 2px !important;
    }
    
    .auth-form:not(.register-form) + .auth-links {
        margin-top: 12px !important;
        padding-top: 8px !important;
    }
}