/* ============================================================
   AHS Order Now – Modal & Form Styles
   Namespaced to .ahs-* to prevent Divi/WooCommerce conflicts
   ============================================================ */

:root {
    --ahs-navy:       #1a3a5c;
    --ahs-blue:       #1a6bbf;
    --ahs-blue-light: #e8f1fb;
    --ahs-accent:     #e8a020;
    --ahs-text:       #1a2332;
    --ahs-muted:      #6b7a90;
    --ahs-border:     #d4dce8;
    --ahs-bg:         #f4f7fb;
    --ahs-white:      #ffffff;
    --ahs-success:    #1a7a4a;
    --ahs-error:      #c0392b;
    --ahs-radius:     10px;
    --ahs-radius-sm:  6px;
    --ahs-shadow:     0 24px 64px rgba(26, 58, 92, 0.22), 0 4px 16px rgba(26, 58, 92, 0.10);
    --ahs-transition: 0.22s cubic-bezier(0.4, 0, 0.2, 1);
}

/* ── Trigger Button ──────────────────────────────────────── */

.ahs-order-trigger {
    display:         inline-flex;
    align-items:     center;
    gap:             8px;
    background:      var(--ahs-accent);
    color:           var(--ahs-navy);
    font-family:     'Montserrat', 'Trebuchet MS', sans-serif;
    font-size:       13px;
    font-weight:     700;
    letter-spacing:  0.06em;
    text-transform:  uppercase;
    border:          none;
    border-radius:   50px;
    padding:         10px 22px 10px 16px;
    cursor:          pointer;
    transition:      background var(--ahs-transition), transform var(--ahs-transition), box-shadow var(--ahs-transition);
    box-shadow:      0 2px 8px rgba(232, 160, 32, 0.35);
    white-space:     nowrap;
}

.ahs-order-trigger:hover,
.ahs-order-trigger:focus-visible {
    background:   #f0a800;
    transform:    translateY(-1px);
    box-shadow:   0 6px 18px rgba(232, 160, 32, 0.45);
    outline:      none;
}

.ahs-order-trigger:active {
    transform:  translateY(0);
}

.ahs-btn-icon {
    display:          flex;
    align-items:      center;
    justify-content:  center;
    width:            22px;
    height:           22px;
    background:       rgba(26, 58, 92, 0.12);
    border-radius:    50%;
    font-size:        16px;
    line-height:      1;
}

/* ── Overlay ─────────────────────────────────────────────── */

.ahs-overlay {
    position:        fixed;
    inset:           0;
    z-index:         999999; /* above Divi header (z ~100000) */
    background:      rgba(10, 20, 40, 0.72);
    backdrop-filter: blur(4px);
    display:         flex;
    align-items:     center;
    justify-content: center;
    padding:         20px;
    opacity:         0;
    transition:      opacity var(--ahs-transition);
}

.ahs-overlay:not([hidden]) {
    opacity: 1;
}

.ahs-overlay[hidden] {
    display: none;
}

/* ── Modal ───────────────────────────────────────────────── */

.ahs-modal {
    background:    var(--ahs-white);
    border-radius: var(--ahs-radius);
    box-shadow:    var(--ahs-shadow);
    width:         100%;
    max-width:     680px;
    max-height:    90vh;
    overflow-y:    auto;
    display:       flex;
    flex-direction: column;
    transform:     translateY(20px) scale(0.98);
    transition:    transform var(--ahs-transition);
    scroll-behavior: smooth;
}

.ahs-overlay:not([hidden]) .ahs-modal {
    transform: translateY(0) scale(1);
}

/* Scrollbar styling */
.ahs-modal::-webkit-scrollbar       { width: 6px; }
.ahs-modal::-webkit-scrollbar-track { background: var(--ahs-bg); }
.ahs-modal::-webkit-scrollbar-thumb { background: var(--ahs-border); border-radius: 3px; }

/* ── Modal Header ────────────────────────────────────────── */

.ahs-modal__header {
    position:       sticky;
    top:            0;
    z-index:        10;
    display:        flex;
    align-items:    center;
    justify-content: space-between;
    padding:        20px 28px;
    background:     var(--ahs-navy);
    border-radius:  var(--ahs-radius) var(--ahs-radius) 0 0;
}

.ahs-modal__header-inner {
    display:     flex;
    align-items: center;
    gap:         14px;
}

.ahs-modal__logo-mark {
    width:            44px;
    height:           44px;
    background:       var(--ahs-accent);
    color:            var(--ahs-navy);
    font-family:      'Montserrat', sans-serif;
    font-weight:      900;
    font-size:        13px;
    letter-spacing:   0.05em;
    display:          flex;
    align-items:      center;
    justify-content:  center;
    border-radius:    var(--ahs-radius-sm);
    flex-shrink:      0;
}

.ahs-modal__title {
    color:        var(--ahs-white);
    font-family:  'Montserrat', 'Trebuchet MS', sans-serif;
    font-size:    20px;
    font-weight:  700;
    margin:       0;
    line-height:  1.2;
}

.ahs-modal__subtitle {
    color:       rgba(255, 255, 255, 0.55);
    font-size:   12px;
    margin:      2px 0 0;
    font-weight: 500;
    letter-spacing: 0.04em;
}

.ahs-modal__close {
    background:    rgba(255, 255, 255, 0.1);
    border:        1px solid rgba(255, 255, 255, 0.15);
    color:         rgba(255, 255, 255, 0.8);
    width:         36px;
    height:        36px;
    border-radius: 50%;
    display:       flex;
    align-items:   center;
    justify-content: center;
    cursor:        pointer;
    transition:    background var(--ahs-transition), color var(--ahs-transition);
    flex-shrink:   0;
}

.ahs-modal__close:hover {
    background: rgba(255, 255, 255, 0.2);
    color:      var(--ahs-white);
}

/* ── Modal Body ──────────────────────────────────────────── */

.ahs-modal__body {
    padding: 28px;
}

/* ── Sections ────────────────────────────────────────────── */

.ahs-section {
    margin-bottom: 28px;
}

.ahs-section__label {
    display:       flex;
    align-items:   center;
    gap:           10px;
    font-family:   'Montserrat', sans-serif;
    font-size:     11px;
    font-weight:   700;
    letter-spacing: 0.1em;
    text-transform: uppercase;
    color:         var(--ahs-navy);
    margin:        0 0 18px;
    padding-bottom: 10px;
    border-bottom: 2px solid var(--ahs-blue-light);
}

.ahs-section__num {
    display:          flex;
    align-items:      center;
    justify-content:  center;
    width:            24px;
    height:           24px;
    background:       var(--ahs-blue);
    color:            var(--ahs-white);
    font-size:        10px;
    font-weight:      800;
    border-radius:    50%;
    flex-shrink:      0;
}

/* ── Grid ────────────────────────────────────────────────── */

.ahs-grid {
    display: grid;
    gap:     14px;
}

.ahs-grid--2 {
    grid-template-columns: 1fr 1fr;
}

@media (max-width: 520px) {
    .ahs-grid--2 {
        grid-template-columns: 1fr;
    }
}

/* ── Fields ──────────────────────────────────────────────── */

.ahs-field {
    display:        flex;
    flex-direction: column;
    gap:            5px;
}

.ahs-field--full {
    grid-column: 1 / -1;
}

.ahs-label {
    font-size:      12px;
    font-weight:    600;
    color:          var(--ahs-text);
    letter-spacing: 0.02em;
}

.ahs-required {
    color:       var(--ahs-error);
    margin-left: 2px;
}

.ahs-optional {
    color:       var(--ahs-muted);
    font-weight: 400;
    font-size:   11px;
}

.ahs-input,
.ahs-select {
    width:         100%;
    padding:       10px 14px;
    border:        1.5px solid var(--ahs-border);
    border-radius: var(--ahs-radius-sm);
    font-size:     14px;
    font-family:   inherit;
    color:         var(--ahs-text);
    background:    var(--ahs-white);
    transition:    border-color var(--ahs-transition), box-shadow var(--ahs-transition);
    box-sizing:    border-box;
    -webkit-appearance: none;
    appearance:    none;
}

.ahs-input::placeholder {
    color: #b0bac8;
}

.ahs-input:focus,
.ahs-select:focus {
    outline:      none;
    border-color: var(--ahs-blue);
    box-shadow:   0 0 0 3px rgba(26, 107, 191, 0.12);
}

.ahs-input.ahs--invalid,
.ahs-select.ahs--invalid {
    border-color: var(--ahs-error);
    box-shadow:   0 0 0 3px rgba(192, 57, 43, 0.10);
}

.ahs-select {
    background-image:    url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8' viewBox='0 0 12 8'%3E%3Cpath d='M1 1l5 5 5-5' stroke='%236b7a90' stroke-width='1.5' fill='none' stroke-linecap='round'/%3E%3C/svg%3E");
    background-repeat:   no-repeat;
    background-position: right 14px center;
    padding-right:       36px;
    cursor:              pointer;
}

/* ── Smaller input variant ───────────────────────────────── */

.ahs-input--sm {
    padding:   8px 12px;
    font-size: 13px;
}

/* Address row — 3 columns: Address wide, City medium, State narrow */
.ahs-field--address {
    grid-column: 1 / -1; /* full width by default, overridden below */
}

/* On the 2-col grid, use a nested 3-col row for address/city/state */
.ahs-grid--2 .ahs-field--address,
.ahs-grid--2 .ahs-field--city,
.ahs-grid--2 .ahs-field--state {
    grid-column: span 1;
}

/* Override: make address+city+state sit in a dedicated 3-col subgrid */
.ahs-grid--address-row {
    display:               grid;
    grid-template-columns: 2fr 1.5fr 0.6fr;
    gap:                   12px;
    grid-column:           1 / -1;
}

@media (max-width: 520px) {
    .ahs-grid--address-row {
        grid-template-columns: 1fr;
    }
}

/* ── Field Hint ──────────────────────────────────────────── */

.ahs-field-hint {
    display:     block;
    font-size:   11px;
    font-weight: 400;
    color:       var(--ahs-muted);
    margin-top:  2px;
    font-style:  italic;
}

/* ── Radio Buttons ───────────────────────────────────────── */

.ahs-radio-group {
    display:    flex;
    gap:        12px;
    margin-top: 4px;
    flex-wrap:  wrap;
}

.ahs-radio-label {
    display:       flex;
    align-items:   center;
    gap:           8px;
    cursor:        pointer;
    font-size:     14px;
    color:         var(--ahs-text);
    font-weight:   500;
    padding:       10px 20px;
    border:        1.5px solid var(--ahs-border);
    border-radius: var(--ahs-radius-sm);
    transition:    border-color var(--ahs-transition), background var(--ahs-transition);
    user-select:   none;
}

.ahs-radio-label:hover {
    border-color: var(--ahs-blue);
    background:   var(--ahs-blue-light);
}

.ahs-radio {
    position: absolute;
    opacity:  0;
    width:    0;
    height:   0;
}

.ahs-radio-custom {
    width:           18px;
    height:          18px;
    border:          2px solid var(--ahs-border);
    border-radius:   50%;
    display:         flex;
    align-items:     center;
    justify-content: center;
    flex-shrink:     0;
    transition:      border-color var(--ahs-transition), background var(--ahs-transition);
}

.ahs-radio:checked + .ahs-radio-custom {
    border-color: var(--ahs-blue);
    background:   var(--ahs-blue);
    box-shadow:   inset 0 0 0 3px var(--ahs-white);
}

.ahs-radio-label:has(.ahs-radio:checked) {
    border-color: var(--ahs-blue);
    background:   var(--ahs-blue-light);
    color:        var(--ahs-blue);
}

.ahs-radio-group.ahs--invalid-group .ahs-radio-label {
    border-color: var(--ahs-error);
    background:   rgba(192, 57, 43, 0.04);
}

/* ── Line Items ──────────────────────────────────────────── */

.ahs-line-item {
    background:    var(--ahs-bg);
    border:        1.5px solid var(--ahs-border);
    border-radius: var(--ahs-radius);
    padding:       16px;
    margin-bottom: 12px;
    position:      relative;
    transition:    border-color var(--ahs-transition), box-shadow var(--ahs-transition);
}

.ahs-line-item:hover {
    border-color: var(--ahs-blue);
    box-shadow:   0 2px 10px rgba(26, 107, 191, 0.07);
}

.ahs-line-item__header {
    display:         flex;
    align-items:     center;
    justify-content: space-between;
    margin-bottom:   12px;
}

.ahs-line-item__num {
    font-size:      11px;
    font-weight:    700;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    color:          var(--ahs-blue);
}

.ahs-line-item__remove {
    background:    none;
    border:        1.5px solid var(--ahs-border);
    color:         var(--ahs-muted);
    width:         28px;
    height:        28px;
    border-radius: 50%;
    display:       flex;
    align-items:   center;
    justify-content: center;
    cursor:        pointer;
    font-size:     16px;
    line-height:   1;
    transition:    border-color var(--ahs-transition), color var(--ahs-transition), background var(--ahs-transition);
    padding:       0;
}

.ahs-line-item__remove:hover {
    border-color: var(--ahs-error);
    color:        var(--ahs-error);
    background:   rgba(192, 57, 43, 0.06);
}

.ahs-line-item__grid {
    display:               grid;
    grid-template-columns: 1fr 1fr;
    gap:                   10px;
}

@media (max-width: 520px) {
    .ahs-line-item__grid {
        grid-template-columns: 1fr;
    }
}

.ahs-line-item__desc {
    grid-column: 1 / -1;
}

.ahs-order-num-row {
    display:     flex;
    gap:         10px;
    align-items: flex-end;
    grid-column: 1 / -1;
}

.ahs-order-num-row .ahs-field {
    flex: 1;
}

.ahs-order-num-badge {
    display:       inline-flex;
    align-items:   center;
    padding:       10px 12px;
    background:    var(--ahs-blue-light);
    border:        1.5px solid var(--ahs-border);
    border-radius: var(--ahs-radius-sm);
    font-size:     13px;
    font-weight:   600;
    color:         var(--ahs-blue);
    white-space:   nowrap;
    min-width:     90px;
    height:        42px;
    box-sizing:    border-box;
}

/* ── Add Item Button ─────────────────────────────────────── */

.ahs-btn-add {
    display:         flex;
    align-items:     center;
    gap:             8px;
    background:      none;
    border:          2px dashed var(--ahs-border);
    border-radius:   var(--ahs-radius);
    color:           var(--ahs-blue);
    font-family:     inherit;
    font-size:       13px;
    font-weight:     600;
    padding:         12px 20px;
    width:           100%;
    cursor:          pointer;
    transition:      border-color var(--ahs-transition), background var(--ahs-transition), color var(--ahs-transition);
    justify-content: center;
    letter-spacing:  0.02em;
}

.ahs-btn-add:hover {
    border-color: var(--ahs-blue);
    background:   var(--ahs-blue-light);
}

/* ── Form Footer ─────────────────────────────────────────── */

.ahs-form-footer {
    display:         flex;
    align-items:     center;
    justify-content: space-between;
    padding-top:     20px;
    border-top:      1.5px solid var(--ahs-border);
    margin-top:      8px;
    flex-wrap:       wrap;
    gap:             12px;
}

.ahs-form-note {
    font-size:   13px;
    color:       var(--ahs-muted);
    margin:      0;
}

.ahs-form-note a {
    color:           var(--ahs-blue);
    text-decoration: none;
    font-weight:     600;
}

.ahs-form-note a:hover {
    text-decoration: underline;
}

/* ── Submit Button ───────────────────────────────────────── */

.ahs-btn-submit {
    display:       inline-flex;
    align-items:   center;
    gap:           10px;
    background:    var(--ahs-navy);
    color:         var(--ahs-white);
    font-family:   'Montserrat', sans-serif;
    font-size:     14px;
    font-weight:   700;
    letter-spacing: 0.04em;
    text-transform: uppercase;
    border:        none;
    border-radius: 50px;
    padding:       13px 28px;
    cursor:        pointer;
    transition:    background var(--ahs-transition), transform var(--ahs-transition), box-shadow var(--ahs-transition);
    box-shadow:    0 4px 14px rgba(26, 58, 92, 0.28);
}

.ahs-btn-submit:hover {
    background:  var(--ahs-blue);
    transform:   translateY(-1px);
    box-shadow:  0 6px 20px rgba(26, 107, 191, 0.35);
}

.ahs-btn-submit:active {
    transform: translateY(0);
}

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

.ahs-btn-submit__icon {
    display:    flex;
    transition: transform var(--ahs-transition);
}

.ahs-btn-submit:hover .ahs-btn-submit__icon {
    transform: translateX(3px);
}

/* ── Spinner (loading state) ─────────────────────────────── */

.ahs-btn-submit.ahs--loading .ahs-btn-submit__text::after {
    content:   ' ...';
    animation: ahsDots 1.2s steps(3, end) infinite;
}

@keyframes ahsDots {
    0%   { content: ' .'; }
    33%  { content: ' ..'; }
    66%  { content: ' ...'; }
    100% { content: ' .'; }
}

/* ── Messages ────────────────────────────────────────────── */

.ahs-message {
    margin-top:    16px;
    padding:       14px 18px;
    border-radius: var(--ahs-radius-sm);
    font-size:     14px;
    font-weight:   500;
    line-height:   1.5;
}

.ahs-message--success {
    background: rgba(26, 122, 74, 0.08);
    border:     1.5px solid rgba(26, 122, 74, 0.25);
    color:      var(--ahs-success);
}

.ahs-message--error {
    background: rgba(192, 57, 43, 0.07);
    border:     1.5px solid rgba(192, 57, 43, 0.22);
    color:      var(--ahs-error);
}

/* ── Responsive ──────────────────────────────────────────── */

@media (max-width: 600px) {
    .ahs-modal__body      { padding: 20px 16px; }
    .ahs-modal__header    { padding: 16px 18px; }
    .ahs-form-footer      { flex-direction: column; align-items: stretch; }
    .ahs-btn-submit       { justify-content: center; }
}
