/*
 * Admiral Energy - Custom Styles
 * Version: 2.0
 * Works with: Tailwind CSS 3.x
 * Browser Support: Modern browsers (ES6+)
 * Brand: "No pitch. Just math."
 */

/* ==========================================================================
   Base Resets & Defaults
   ========================================================================== */

html {
  scroll-behavior: smooth;
}

/* System font stack for performance */
body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
}

/* Ensure consistent box-sizing */
*,
*::before,
*::after {
  box-sizing: border-box;
}

/* ==========================================================================
   Form Elements
   ========================================================================== */

/* Form Labels */
.ae-label {
  display: block;
  font-size: 0.875rem; /* 14px */
  font-weight: 600;
  color: #0C2F4A; /* Admiral Navy */
  margin-bottom: 0.5rem;
}

/* Text Inputs (text, email, tel, etc.) */
.ae-input {
  display: block !important;
  width: 100% !important;
  padding: 0.75rem 1rem !important;
  border: 2px solid #d1d5db !important; /* gray-300 - visible border */
  border-radius: 0.5rem !important;
  background-color: white !important;
  font-size: 1rem !important;
  line-height: 1.5 !important;
  color: #1f2937 !important; /* gray-800 */
  transition: all 150ms ease-in-out !important;
}

.ae-input::placeholder {
  color: #9ca3af !important; /* gray-400 */
  opacity: 1 !important;
}

.ae-input:hover:not(:focus):not(:disabled) {
  border-color: #9ca3af !important; /* gray-400 */
}

.ae-input:focus {
  outline: none !important;
  border-color: #C9A648 !important; /* Admiral Gold */
  box-shadow: 0 0 0 3px rgba(201, 166, 72, 0.1) !important;
}

.ae-input:disabled {
  background-color: #f3f4f6 !important; /* gray-100 */
  cursor: not-allowed !important;
  opacity: 0.6 !important;
}

/* Select Dropdowns */
.ae-select {
  display: block !important;
  width: 100% !important;
  padding: 0.75rem 2.5rem 0.75rem 1rem !important;
  border: 2px solid #d1d5db !important; /* gray-300 */
  border-radius: 0.5rem !important;
  background-color: white !important;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'%3E%3Cpath fill='%230C2F4A' d='M6 9L1 4h10z'/%3E%3C/svg%3E") !important;
  background-position: right 0.75rem center !important;
  background-repeat: no-repeat !important;
  font-size: 1rem !important;
  line-height: 1.5 !important;
  color: #1f2937 !important; /* gray-800 */
  cursor: pointer !important;
  appearance: none !important;
  -webkit-appearance: none !important;
  -moz-appearance: none !important;
  transition: all 150ms ease-in-out !important;
}

.ae-select:hover:not(:focus):not(:disabled) {
  border-color: #9ca3af !important; /* gray-400 */
}

.ae-select:focus {
  outline: none !important;
  border-color: #C9A648 !important; /* Admiral Gold */
  box-shadow: 0 0 0 3px rgba(201, 166, 72, 0.1) !important;
}

.ae-select:disabled {
  background-color: #f3f4f6 !important; /* gray-100 */
  cursor: not-allowed !important;
  opacity: 0.6 !important;
}

/* Textarea */
.ae-textarea {
  display: block !important;
  width: 100% !important;
  padding: 0.75rem 1rem !important;
  border: 2px solid #d1d5db !important; /* gray-300 */
  border-radius: 0.5rem !important;
  background-color: white !important;
  font-size: 1rem !important;
  line-height: 1.5 !important;
  color: #1f2937 !important; /* gray-800 */
  resize: vertical !important;
  min-height: 120px !important;
  transition: all 150ms ease-in-out !important;
}

.ae-textarea::placeholder {
  color: #9ca3af !important; /* gray-400 */
  opacity: 1 !important;
}

.ae-textarea:hover:not(:focus):not(:disabled) {
  border-color: #9ca3af !important; /* gray-400 */
}

.ae-textarea:focus {
  outline: none !important;
  border-color: #C9A648 !important; /* Admiral Gold */
  box-shadow: 0 0 0 3px rgba(201, 166, 72, 0.1) !important;
}

.ae-textarea:disabled {
  background-color: #f3f4f6 !important; /* gray-100 */
  cursor: not-allowed !important;
  opacity: 0.6 !important;
}

/* Helper Text */
.ae-help {
  font-size: 0.75rem; /* 12px */
  line-height: 1.4;
  color: #6b7280; /* gray-500 */
  margin-top: 0.25rem;
}

/* ==========================================================================
   Form Validation States
   ========================================================================== */

/* Error State */
.ae-input.error,
.ae-select.error,
.ae-textarea.error {
  border-color: #ef4444; /* red-500 */
  background-color: #fef2f2; /* red-50 */
}

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

/* Success State */
.ae-input.success,
.ae-select.success,
.ae-textarea.success {
  border-color: #10b981; /* green-500 */
  background-color: #f0fdf4; /* green-50 */
}

.ae-input.success:focus,
.ae-select.success:focus,
.ae-textarea.success:focus {
  border-color: #10b981;
  box-shadow: 0 0 0 3px rgba(16, 185, 129, 0.1);
}

/* Warning State */
.ae-input.warning,
.ae-select.warning,
.ae-textarea.warning {
  border-color: #f59e0b; /* amber-500 */
  background-color: #fffbeb; /* amber-50 */
}

.ae-input.warning:focus,
.ae-select.warning:focus,
.ae-textarea.warning:focus {
  border-color: #f59e0b;
  box-shadow: 0 0 0 3px rgba(245, 158, 11, 0.1);
}

/* Invalid state (native HTML5 validation) */
.ae-input:invalid:not(:placeholder-shown),
.ae-select:invalid:not(:placeholder-shown),
.ae-textarea:invalid:not(:placeholder-shown) {
  border-color: #ef4444; /* red-500 */
}

/* ==========================================================================
   Custom Utilities
   ========================================================================== */

/* Custom Shadow Utilities */
.admiral-shadow {
  box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06);
}

.admiral-shadow-lg {
  box-shadow: 0 10px 15px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -2px rgba(0, 0, 0, 0.05);
}

.admiral-shadow-xl {
  box-shadow: 0 20px 25px -5px rgba(0, 0, 0, 0.1), 0 10px 10px -5px rgba(0, 0, 0, 0.04);
}

/* Custom Transition Utility */
.admiral-transition {
  transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

/* Smooth Fade-in Animation */
@keyframes fadeIn {
  from {
    opacity: 0;
    transform: translateY(10px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.admiral-fade-in {
  animation: fadeIn 0.5s ease-out;
}

/* ==========================================================================
   Accessibility
   ========================================================================== */

/* Enhanced Focus Visibility */
*:focus-visible {
  outline: 2px solid #C9A648; /* Admiral Gold */
  outline-offset: 2px;
}

/* Remove default focus outline for mouse users */
*:focus:not(:focus-visible) {
  outline: none;
}

/* Maintain specific focus styles for links and buttons */
a:focus,
button:focus {
  outline: 2px solid #C9A648;
  outline-offset: 2px;
}

/* Skip to Main Content Link (for screen readers) */
.skip-link {
  position: absolute;
  top: -40px;
  left: 0;
  background-color: #0C2F4A; /* Admiral Navy */
  color: white;
  padding: 8px 16px;
  text-decoration: none;
  z-index: 100;
  border-radius: 0 0 4px 0;
  font-weight: 600;
}

.skip-link:focus {
  top: 0;
}

/* Screen Reader Only Text */
.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border-width: 0;
}

/* ==========================================================================
   Responsive Adjustments
   ========================================================================== */

/* Mobile Optimizations (prevent iOS zoom on input focus) */
@media (max-width: 768px) {
  .ae-input,
  .ae-select,
  .ae-textarea {
    font-size: 16px; /* Prevents iOS zoom */
  }
  
  /* Adjust padding for smaller screens */
  .ae-input,
  .ae-select,
  .ae-textarea {
    padding: 0.625rem 0.875rem;
  }
  
  .ae-select {
    padding-right: 2.25rem;
  }
}

/* Tablet and up: Optimize for larger touch targets */
@media (min-width: 769px) {
  .ae-input,
  .ae-select,
  .ae-textarea {
    padding: 0.75rem 1rem;
  }
}

/* Mobile-specific adjustments */
@media (max-width: 640px) {
  .hero-title {
    font-size: 2.5rem;
    line-height: 1.1;
  }
  
  .hero-subtitle {
    font-size: 1.25rem;
  }
  
  .section-header {
    font-size: 2rem;
  }
}

/* ==========================================================================
   Print Styles
   ========================================================================== */

@media print {
  /* Hide non-essential elements */
  nav,
  footer,
  .no-print,
  button[type="submit"],
  .skip-link {
    display: none !important;
  }
  
  /* Ensure form fields are visible */
  .ae-input,
  .ae-select,
  .ae-textarea {
    border: 1px solid #000;
    background-color: transparent;
    color: #000;
  }
  
  /* Print-friendly colors */
  body {
    background-color: white !important;
    color: black !important;
  }
  
  /* Ensure links are visible */
  a {
    text-decoration: underline;
    color: #000 !important;
  }
  
  /* Page breaks */
  section {
    page-break-inside: avoid;
  }
  
  h1, h2, h3 {
    page-break-after: avoid;
  }
}

/* ==========================================================================
   Additional Enhancements
   ========================================================================== */

/* Smooth color transitions for interactive elements */
a,
button {
  transition: color 0.15s ease-in-out, background-color 0.15s ease-in-out, border-color 0.15s ease-in-out;
}

/* Prevent text selection on buttons */
button {
  user-select: none;
  -webkit-user-select: none;
  -moz-user-select: none;
}

/* Custom scrollbar (optional, for webkit browsers) */
::-webkit-scrollbar {
  width: 10px;
}

::-webkit-scrollbar-track {
  background: #f1f1f1;
}

::-webkit-scrollbar-thumb {
  background: #0C2F4A; /* Admiral Navy */
  border-radius: 5px;
}

::-webkit-scrollbar-thumb:hover {
  background: #C9A648; /* Admiral Gold */
}

/* Form autofill styling (override browser defaults) */
.ae-input:-webkit-autofill,
.ae-select:-webkit-autofill,
.ae-textarea:-webkit-autofill {
  -webkit-box-shadow: 0 0 0 1000px white inset;
  box-shadow: 0 0 0 1000px white inset;
  -webkit-text-fill-color: #1f2937;
}

/* Loading state for form submission */
.ae-loading {
  position: relative;
  pointer-events: none;
  opacity: 0.6;
}

.ae-loading::after {
  content: '';
  position: absolute;
  top: 50%;
  left: 50%;
  width: 20px;
  height: 20px;
  margin-top: -10px;
  margin-left: -10px;
  border: 2px solid #C9A648;
  border-top-color: transparent;
  border-radius: 50%;
  animation: spin 0.6s linear infinite;
}

@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}

/* High contrast mode support */
@media (prefers-contrast: high) {
  .ae-input,
  .ae-select,
  .ae-textarea {
    border-width: 3px;
  }
}

/* Reduced motion support */
@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
    scroll-behavior: auto !important;
  }
}