/*! Wattif Orders Pages Styling
   Scope: Wattif Orders system pages only (NON-GLOBAL)
   Requires: ordering tokens from the theme app.css bundle
   Target Pages:
   - page-borettslag-search.php (Step 1A/1B)
   - page-order-form.php (Step 3) 
   - page-mine-bestillinger.php (Step 4)
   - single-borettslag.php (Step 2)
   
   Approach: Page-specific selectors + token-based color mapping
   Note: This CSS only affects wattif-orders pages, not global site styling
*/

/* ===== PAGE-SPECIFIC SELECTORS ===== */
/* Target only wattif-orders related pages */
body.page-template-page-borettslag-search,
body.page-template-page-order-form, 
body.page-template-page-mine-bestillinger,
body.single-borettslag,
body.woocommerce-checkout,
body.woocommerce-cart {

  /* ===== WATTIF COLOR TOKEN MAPPINGS ===== */
  /* Override generic Tailwind classes with Wattif brand tokens */
  
  /* Background Colors */
  .bg-gray-800 { background-color: var(--foreground) !important; } /* wattif-dark-blue */
  .bg-white { background-color: var(--background) !important; } /* wattif-white */
  .bg-green-50 { background-color: var(--secondary) !important; } /* wattif-light-green */
  .bg-green-400 { background-color: var(--primary) !important; } /* wattif-green */
  .bg-green-500 { background-color: var(--muted-foreground) !important; } /* wattif-dark-green */
  .bg-yellow-50 { background-color: oklch(0.98 0.03 85) !important; } /* Warning light */
  .bg-yellow-100 { background-color: oklch(0.95 0.05 85) !important; } /* Warning medium */
  .bg-red-50 { background-color: oklch(0.98 0.05 25) !important; } /* Error light */
  .bg-red-100 { background-color: oklch(0.95 0.08 25) !important; } /* Error medium */
  
  /* Text Colors */
  .text-white { color: var(--background) !important; } /* White text */
  .text-gray-800 { color: var(--foreground) !important; } /* wattif-dark-blue */
  .text-gray-600 { color: var(--muted-foreground) !important; } /* wattif-dark-green */
  .text-green-400 { color: var(--primary) !important; } /* wattif-green */
  .text-green-500 { color: var(--muted-foreground) !important; } /* wattif-dark-green */
  .text-yellow-600 { color: oklch(0.7 0.15 85) !important; } /* Warning dark */
  .text-yellow-700 { color: oklch(0.6 0.18 85) !important; } /* Warning darker */
  .text-yellow-800 { color: oklch(0.5 0.2 85) !important; } /* Warning darkest */
  .text-red-600 { color: oklch(0.6 0.2 25) !important; } /* Error dark */
  .text-red-700 { color: oklch(0.5 0.23 25) !important; } /* Error darker */
  .text-red-800 { color: oklch(0.45 0.25 25) !important; } /* Error darkest */
  
  /* Border Colors */
  .border-green-400 { border-color: var(--primary) !important; } /* wattif-green */
  .border-gray-800 { border-color: var(--foreground) !important; } /* wattif-dark-blue */
  .border-yellow-200 { border-color: oklch(0.9 0.08 85) !important; } /* Warning border */
  .border-yellow-300 { border-color: oklch(0.85 0.12 85) !important; } /* Warning border dark */
  .border-red-200 { border-color: oklch(0.9 0.08 25) !important; } /* Error border */
  .border-red-300 { border-color: oklch(0.85 0.12 25) !important; } /* Error border dark */
  
  /* Ring Colors (Focus States) */
  .focus\:ring-green-400\/20:focus { 
    --tw-ring-color: oklch(0.76 0.08 180 / 0.2) !important; 
  }
  .focus\:ring-green-400:focus { 
    --tw-ring-color: var(--primary) !important; 
  }
  .focus\:ring-offset-gray-800:focus { 
    --tw-ring-offset-color: var(--foreground) !important; 
  }
  
  /* Hover States */
  .hover\:bg-green-500:hover { background-color: var(--muted-foreground) !important; }
  .hover\:bg-green-100:hover { background-color: oklch(0.95 0.02 150) !important; }
  .hover\:text-white:hover { color: var(--background) !important; }
  .hover\:border-gray-800:hover { border-color: var(--foreground) !important; }
  .hover\:shadow-lg:hover { 
    box-shadow: 0 10px 15px -3px oklch(0 0 0 / 0.1), 0 4px 6px -2px oklch(0 0 0 / 0.05) !important; 
  }

  /* ===== ENHANCED PROTOTYPE STYLING ===== */
  
  /* Typography Enhancements */
  .text-4xl.font-black { 
    font-size: 2.25rem; 
    line-height: 2.5rem; 
    font-weight: 900;
    letter-spacing: -0.025em;
  }
  
  .text-3xl.font-bold { 
    font-size: 1.875rem; 
    line-height: 2.25rem; 
    font-weight: 700;
    letter-spacing: -0.025em;
  }
  
  .text-xl { 
    font-size: 1.25rem; 
    line-height: 1.75rem; 
  }
  
  .text-lg { 
    font-size: 1.125rem; 
    line-height: 1.75rem; 
  }

  /* Card Enhancements */
  .rounded-lg { border-radius: 0.75rem; } /* Enhanced border radius */
  .rounded-xl { border-radius: 0.875rem; } /* Card border radius */
  .rounded-full { border-radius: 9999px; } /* Perfect circles */
  
  /* Enhanced Shadows */
  .shadow-lg { 
    box-shadow: 0 10px 15px -3px oklch(0 0 0 / 0.1), 0 4px 6px -2px oklch(0 0 0 / 0.05); 
  }
  
  /* Transition Enhancements */
  .transition-colors { 
    transition-property: color, background-color, border-color;
    transition-timing-function: cubic-bezier(0.4, 0, 0.2, 1);
    transition-duration: 150ms;
  }
  
  .transition-shadow { 
    transition-property: box-shadow;
    transition-timing-function: cubic-bezier(0.4, 0, 0.2, 1);
    transition-duration: 150ms;
  }
  
  .transition-all { 
    transition-property: all;
    transition-timing-function: cubic-bezier(0.4, 0, 0.2, 1);
    transition-duration: 200ms;
  }

  /* ===== RESPONSIVE ENHANCEMENTS ===== */
  
  /* Container Improvements */
  .container {
    max-width: 80rem; /* 1280px - matches prototype max-width */
  }
  
  /* Enhanced Spacing */
  .py-12 { padding-top: 3rem; padding-bottom: 3rem; }
  .py-8 { padding-top: 2rem; padding-bottom: 2rem; }
  .py-4 { padding-top: 1rem; padding-bottom: 1rem; }
  .p-10 { padding: 2.5rem; }
  .p-8 { padding: 2rem; }
  .p-6 { padding: 1.5rem; }
  .p-4 { padding: 1rem; }
  .p-3 { padding: 0.75rem; }
  
  .mb-16 { margin-bottom: 4rem; }
  .mb-10 { margin-bottom: 2.5rem; }
  .mb-8 { margin-bottom: 2rem; }
  .mb-6 { margin-bottom: 1.5rem; }
  .mb-4 { margin-bottom: 1rem; }
  .mb-3 { margin-bottom: 0.75rem; }
  .mb-2 { margin-bottom: 0.5rem; }
  .mb-1 { margin-bottom: 0.25rem; }

  /* Enhanced Grid Layouts */
  @media (min-width: 768px) {
    .md\:grid-cols-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
    .md\:grid-cols-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  }
  
  /* Enhanced Flexbox */
  .flex { display: flex; }
  .items-center { align-items: center; }
  .justify-center { justify-content: center; }
  .justify-between { justify-content: space-between; }
  .flex-1 { flex: 1 1 0%; }
  .flex-shrink-0 { flex-shrink: 0; }
  
  /* Enhanced Form Styling */
  input[type="text"], 
  input[type="email"], 
  input[type="tel"], 
  select, 
  textarea {
    border: 2px solid var(--primary);
    background-color: var(--background);
    color: var(--foreground);
    border-radius: 0.5rem;
    padding: 1rem;
    font-size: 1.125rem;
    line-height: 1.75rem;
    transition: all 0.15s ease;
  }
  
  input[type="text"]:focus, 
  input[type="email"]:focus, 
  input[type="tel"]:focus, 
  select:focus, 
  textarea:focus {
    outline: none;
    border-color: var(--foreground);
    box-shadow: 0 0 0 3px oklch(0.76 0.08 180 / 0.2);
  }
  
  /* Enhanced Button Styling */
  button:not(.wc-block-components-button) {
    border-radius: 0.5rem;
    font-weight: 600;
    transition: all 0.15s ease;
    cursor: pointer;
  }
  
  button.bg-green-400:not(.wc-block-components-button) {
    background-color: var(--primary);
    color: var(--background);
  }
  
  button.bg-green-400:hover:not(.wc-block-components-button) {
    background-color: var(--muted-foreground);
  }

  /* ===== PROTOTYPE-SPECIFIC COMPONENTS ===== */
  
  /* Hero Section Enhancement */
  .text-center.mb-16 h1.text-4xl {
    color: var(--foreground);
    font-weight: 900;
    margin-bottom: 1rem;
  }
  
  .text-center.mb-16 p.text-xl {
    color: var(--muted-foreground);
    max-width: 48rem;
    margin: 0 auto 2rem auto;
  }
  
  /* Search Card Enhancement */
  .max-w-4xl.border-green-400 {
    border-color: var(--primary);
    background-color: var(--background);
    box-shadow: 0 10px 15px -3px oklch(0 0 0 / 0.1), 0 4px 6px -2px oklch(0 0 0 / 0.05);
  }
  
  /* Search Form Background */
  .bg-green-50.p-8 {
    background-color: var(--secondary);
    padding: 2rem;
    border-radius: 0.5rem;
  }
  
  /* Icon Containers */
  .p-4.bg-green-50.rounded-full,
  .p-3.bg-green-50.rounded-lg,
  .p-2.bg-green-50.rounded-lg {
    background-color: var(--secondary);
  }
  
  /* Status Badges */
  .bg-green-400.text-white {
    background-color: var(--primary);
    color: var(--background);
  }
  
  .border-yellow-400.text-yellow-600.bg-yellow-50 {
    border-color: oklch(0.85 0.12 85);
    color: oklch(0.7 0.15 85);
    background-color: oklch(0.98 0.03 85);
  }
  
  /* Feature Cards Enhancement */
  .grid.md\:grid-cols-3 > div {
    border-color: var(--primary);
    background-color: var(--background);
    transition: all 0.2s ease;
  }
  
  .grid.md\:grid-cols-3 > div:hover {
    box-shadow: 0 10px 15px -3px oklch(0 0 0 / 0.1), 0 4px 6px -2px oklch(0 0 0 / 0.05);
    border-color: var(--foreground);
  }

  /* ===== RESPONSIVE LAYOUT ENHANCEMENTS ===== */
  
  /* Container Max-Width (matches prototype) */
  .container {
    max-width: 80rem; /* 1280px */
  }
  
  /* Enhanced Grid Gaps */
  .gap-8 { gap: 2rem; }
  .gap-6 { gap: 1.5rem; }
  .gap-4 { gap: 1rem; }
  .gap-3 { gap: 0.75rem; }
  
  /* Enhanced Space Between */
  .space-y-6 > * + * { margin-top: 1.5rem; }
  .space-y-4 > * + * { margin-top: 1rem; }
  .space-y-3 > * + * { margin-top: 0.75rem; }
  .space-x-4 > * + * { margin-left: 1rem; }
  .space-x-2 > * + * { margin-left: 0.5rem; }

  /* ===== ACCESSIBILITY ENHANCEMENTS ===== */
  
  /* Enhanced Focus States */
  .focus\:outline-none:focus {
    outline: 2px solid transparent;
    outline-offset: 2px;
  }
  
  .focus\:ring-2:focus {
    box-shadow: 0 0 0 3px var(--ring);
  }
  
  /* Screen Reader Improvements */
  .sr-only {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
  }
  
  .focus\:not-sr-only:focus {
    position: static;
    width: auto;
    height: auto;
    padding: inherit;
    margin: inherit;
    overflow: visible;
    clip: auto;
    white-space: normal;
  }

  /* ===== LOADING & STATE ENHANCEMENTS ===== */
  
  /* Enhanced Loading Spinner */
  .animate-spin {
    animation: spin 1s linear infinite;
  }
  
  @keyframes spin {
    from { transform: rotate(0deg); }
    to { transform: rotate(360deg); }
  }
  
  /* Loading States */
  .border-b-2.border-green-400 {
    border-bottom: 2px solid var(--primary);
  }

  /* ===== FORM ENHANCEMENTS ===== */
  
  /* Organization Number Input */
  #org-number-input {
    border: 2px solid var(--primary) !important;
    background-color: var(--background) !important;
    color: var(--foreground) !important;
  }
  
  #org-number-input:focus {
    border-color: var(--foreground) !important;
    box-shadow: 0 0 0 3px oklch(0.76 0.08 180 / 0.2) !important;
  }
  
  /* Search Button Enhancement */
  #search-btn {
    background-color: var(--primary) !important;
    color: var(--background) !important;
    font-weight: 600;
    transition: all 0.15s ease;
  }
  
  #search-btn:hover {
    background-color: var(--muted-foreground) !important;
  }

  /* ===== RESULT CARDS ENHANCEMENT ===== */
  
  /* Result Card Styling */
  .cursor-pointer.transition-all {
    border-color: var(--primary);
    background-color: var(--background);
    transition: all 0.2s ease;
  }
  
  .cursor-pointer.transition-all:hover {
    box-shadow: 0 10px 15px -3px oklch(0 0 0 / 0.1), 0 4px 6px -2px oklch(0 0 0 / 0.05);
    border-color: var(--foreground);
    transform: translateY(-1px);
  }
  
  /* Result Card Content */
  .cursor-pointer h4 {
    color: var(--foreground) !important;
    font-weight: 700;
  }
  
  .cursor-pointer p {
    color: var(--muted-foreground) !important;
  }

  /* ===== CUSTOMER SUPPORT SECTION ===== */
  
  /* Dark Blue Section */
  .border-gray-800.bg-gray-800 {
    border-color: var(--foreground) !important;
    background-color: var(--foreground) !important;
  }
  
  /* Support Cards */
  .border-green-400.bg-white.hover\:shadow-lg {
    border-color: var(--primary) !important;
    background-color: var(--background) !important;
  }
  
  .border-green-400.bg-white.hover\:shadow-lg:hover {
    box-shadow: 0 10px 15px -3px oklch(0 0 0 / 0.1), 0 4px 6px -2px oklch(0 0 0 / 0.05) !important;
  }

  /* ===== FOOTER ENHANCEMENT ===== */
  
  footer.bg-green-50 {
    background-color: var(--secondary) !important;
    color: var(--foreground) !important;
  }

  /* ===== MOBILE RESPONSIVENESS ===== */
  
  /* Mobile-first spacing adjustments */
  @media (max-width: 767px) {
    .container { padding-left: 1rem; padding-right: 1rem; }
    .p-10 { padding: 1.5rem; }
    .p-8 { padding: 1.5rem; }
    .py-12 { padding-top: 2rem; padding-bottom: 2rem; }
    .text-4xl { font-size: 2rem; line-height: 2.25rem; }
    .text-3xl { font-size: 1.75rem; line-height: 2rem; }
  }
  
  /* Badge Responsive Visibility Fix */
  /* Mobile badge - only visible on mobile */
  .mt-2.block.md\:hidden {
    display: block;
  }
  
  @media (min-width: 768px) {
    .mt-2.block.md\:hidden {
      display: none !important;
    }
  }
  
  /* Desktop badge - only visible on desktop */
  .hidden.md\:flex {
    display: none;
  }
  
  @media (min-width: 768px) {
    .hidden.md\:flex {
      display: flex !important;
    }
  }
  
  /* Narrower layout for better readability */
  .max-w-4xl { max-width: 54rem; } /* Reduced from default 56rem to 42rem for narrower layout */
  
  /* Tablet adjustments */
  @media (min-width: 768px) and (max-width: 1023px) {
    .max-w-4xl { max-width: 54rem; } /* Reduced from 56rem to 42rem for narrower layout */
    .p-10 { padding: 2rem; }
  }

  /* ===== ANIMATION ENHANCEMENTS ===== */
  
  /* Smooth hover animations */
  .cursor-pointer {
    transition: transform 0.2s ease, box-shadow 0.2s ease, border-color 0.2s ease;
  }
  
  /* Button hover animations */
  button:not(.wc-block-components-button):hover {
    transform: translateY(-1px);
  }
  
  /* Icon hover animations */
  .p-1.hover\:bg-green-100:hover {
    background-color: var(--secondary) !important;
    transform: scale(1.05);
  }

  /* ===== PRINT STYLES ===== */
  
  @media print {
    .shadow-lg { box-shadow: none; }
    .hover\:shadow-lg:hover { box-shadow: none; }
    button { background-color: var(--primary) !important; }
  }
}

/* ===== SPECIFIC PAGE ENHANCEMENTS ===== */

/* Borettslag Search Page Specific */
body.page-template-page-borettslag-search {
  /* Page-specific enhancements can go here */
}

/* Order Form Page Specific */
body.page-template-page-order-form {
  /* Page-specific enhancements can go here */
}

/* My Orders Page Specific */
body.page-template-page-mine-bestillinger {
  /* Order status badge alignment and spacing fixes */
  .status-badge {
    display: inline-flex;
    align-items: center;
    vertical-align: middle;
    margin-left: 1rem; /* 16px spacing from order number */
    line-height: 1;
    font-size: 0.875rem;
    font-weight: 600;
    padding: 0.25rem 0.75rem;
    border-radius: 9999px;
    text-transform: uppercase;
    letter-spacing: 0.025em;
  }
  
  /* Ensure proper alignment of order title and badge container */
  .flex.items-center.mb-2 {
    align-items: baseline; /* Align to text baseline instead of center */
  }
  
  /* Specific spacing for order number and badge */
  .flex.items-center.mb-2 h3 {
    margin-right: 1rem; /* 16px spacing */
    line-height: 1.5;
  }
  
  /* Status badge specific styling */
  .status-badge.px-3.py-1 {
    padding: 0.25rem 0.75rem !important;
    font-size: 0.75rem !important;
    font-weight: 700 !important;
    line-height: 1 !important;
    vertical-align: middle !important;
    display: inline-flex !important;
    align-items: center !important;
  }
}

/* Single Borettslag Page Specific */
body.single-borettslag {
  /* Page-specific enhancements can go here */
}

/* Order Form Page Specific Enhancements */
body.page-template-page-order-form {
  
  /* Fix icon sizes - ensure SVG icons display at correct size */
  svg {
    flex-shrink: 0;
    display: inline-block;
  }
  
  /* Specific icon size fixes for form labels */
  label svg {
    width: 1rem !important;
    height: 1rem !important;
    flex-shrink: 0;
    min-width: 1rem;
    min-height: 1rem;
    max-width: 1rem;
    max-height: 1rem;
  }
  
  /* Specific icon size fixes for sidebar headings */
  h4 svg,
  .font-semibold svg {
    width: 1.25rem !important;
    height: 1.25rem !important;
    flex-shrink: 0;
    min-width: 1.25rem;
    min-height: 1.25rem;
    max-width: 1.25rem;
    max-height: 1.25rem;
  }
  
  /* Button icons */
  button svg {
    width: 1.25rem !important;
    height: 1.25rem !important;
    flex-shrink: 0;
  }
  
  /* Override any conflicting Tailwind classes */
  .h-4 {
    height: 1rem !important;
  }
  
  .w-4 {
    width: 1rem !important;
  }
  
  .h-5 {
    height: 1.25rem !important;
  }
  
  .w-5 {
    width: 1.25rem !important;
  }
  
  /* Enhanced Form Field Icons */
  .relative input[type="text"],
  .relative input[type="email"],
  .relative input[type="tel"] {
    transition: all 0.2s ease-in-out;
  }
  
  .relative input[type="text"]:focus,
  .relative input[type="email"]:focus,
  .relative input[type="tel"]:focus {
    border-color: var(--primary);
    box-shadow: 0 0 0 3px oklch(0.76 0.08 180 / 0.1);
    transform: translateY(-1px);
  }
  
  .relative input[type="text"]:focus + .absolute svg,
  .relative input[type="email"]:focus + .absolute svg,
  .relative input[type="tel"]:focus + .absolute svg {
    color: var(--primary);
  }
  
  /* Enhanced Checkbox Styling */
  input[type="checkbox"] {
    -webkit-appearance: none;
    -moz-appearance: none;
    appearance: none;
    background-color: white;
    border: 2px solid #d1d5db;
    border-radius: 0.375rem;
    cursor: pointer;
    position: relative;
    transition: all 0.2s ease-in-out;
    width: 1.25rem;
    height: 1.25rem;
    display: inline-block;
    vertical-align: middle;
  }
  
  input[type="checkbox"]:checked {
    background-color: var(--primary, #10b981);
    border-color: var(--primary, #10b981);
  }
  
  input[type="checkbox"]:checked::after {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 12px;
    height: 12px;
    background-image: url("data:image/svg+xml,%3csvg viewBox='0 0 16 16' fill='white' xmlns='http://www.w3.org/2000/svg'%3e%3cpath d='m13.854 3.646-7.5 7.5a.5.5 0 0 1-.708 0l-3.5-3.5a.5.5 0 1 1 .708-.708L6 10.293l7.146-7.147a.5.5 0 0 1 .708.708z'/%3e%3c/svg%3e");
    background-size: 12px 12px;
    background-repeat: no-repeat;
    background-position: center;
  }
  
  input[type="checkbox"]:focus {
    outline: none;
    box-shadow: 0 0 0 3px oklch(0.76 0.08 180 / 0.2);
  }
  
  input[type="checkbox"]:hover {
    border-color: var(--primary, #10b981);
    transform: scale(1.05);
  }
  
  /* Enhanced Button Styling */
  button[type="submit"] {
    position: relative;
    overflow: hidden;
  }
  
  button[type="submit"]:not(:disabled):hover {
    box-shadow: 0 20px 25px -5px oklch(0 0 0 / 0.1), 0 10px 10px -5px oklch(0 0 0 / 0.04);
  }
  
  button[type="submit"]:disabled {
    transform: none !important;
    box-shadow: none !important;
  }
  
  /* Form Field Helper Text */
  .text-gray-500 {
    color: var(--muted-foreground);
  }
  
  /* Enhanced Focus States for All Form Elements */
  textarea:focus,
  select:focus {
    border-color: var(--primary);
    box-shadow: 0 0 0 3px oklch(0.76 0.08 180 / 0.1);
    outline: none;
  }
  
  /* Improved Label Styling */
  label {
    font-weight: 500;
    color: var(--foreground);
  }
  
  /* Required Field Indicator */
  label:has(+ input[required])::after,
  label:has(+ div input[required])::after {
    content: ' *';
    color: #ef4444;
  }
}

/* ===== DARK MODE SUPPORT ===== */

.dark body.page-template-page-borettslag-search,
.dark body.page-template-page-order-form,
.dark body.page-template-page-mine-bestillinger,
.dark body.single-borettslag {
  /* Dark mode token mappings */
  .bg-white { background-color: var(--background) !important; }
  .text-gray-800 { color: var(--foreground) !important; }
  .text-gray-600 { color: var(--muted-foreground) !important; }
}
