/**
 * WooCommerce Addresses
 *
 * Address cards, grid layout, and edit address form styles
 *
 * @package BadassNetwork
 */

/* ==========================================================================
   ADDRESSES PAGE
   Using high specificity to override WooCommerce defaults and base.css
   WooCommerce uses float-based .col2-set layout - we need to override this
   ========================================================================== */

/* Addresses description text */
body.woocommerce-account .addresses-description,
body.woocommerce-account p.addresses-description {
    color: var(--color-text-soft) !important;
    margin-bottom: 24px !important;
    font-size: 15px !important;
}

/* ==========================================================================
   ADDRESSES GRID LAYOUT
   ========================================================================== */

/* Override WooCommerce's float-based col2-set layout with flexbox instead of grid */
/* Flexbox is better here as it only affects actual child elements, not pseudo-elements */
body.woocommerce-account .woocommerce-Addresses,
body.woocommerce-account .col2-set.addresses,
body.woocommerce-account .u-columns.woocommerce-Addresses,
.woocommerce-account .woocommerce-Addresses {
    display: flex !important;
    flex-wrap: wrap !important;
    gap: 24px !important;
    width: 100% !important;
}

/* Hide all pseudo-elements completely */
body.woocommerce-account .woocommerce-Addresses::before,
body.woocommerce-account .woocommerce-Addresses::after,
body.woocommerce-account .col2-set.addresses::before,
body.woocommerce-account .col2-set.addresses::after {
    display: none !important;
    content: none !important;
    width: 0 !important;
    height: 0 !important;
}

/* Style the actual address cards - use flex basis for two columns */
body.woocommerce-account .woocommerce-Addresses > .woocommerce-Address,
body.woocommerce-account .woocommerce-Addresses > .col-1,
body.woocommerce-account .woocommerce-Addresses > .col-2,
body.woocommerce-account .woocommerce-Addresses > .u-column1,
body.woocommerce-account .woocommerce-Addresses > .u-column2,
body.woocommerce-account .col2-set.addresses > .col-1,
body.woocommerce-account .col2-set.addresses > .col-2 {
    float: none !important;
    flex: 1 1 calc(50% - 12px) !important; /* Half width minus half the gap */
    min-width: 280px !important; /* Minimum width before wrapping */
    max-width: 100% !important;
    margin: 0 !important;
}

@media (max-width: 700px) {
    body.woocommerce-account .woocommerce-Addresses > .woocommerce-Address,
    body.woocommerce-account .woocommerce-Addresses > .col-1,
    body.woocommerce-account .woocommerce-Addresses > .col-2,
    body.woocommerce-account .woocommerce-Addresses > .u-column1,
    body.woocommerce-account .woocommerce-Addresses > .u-column2,
    body.woocommerce-account .col2-set.addresses > .col-1,
    body.woocommerce-account .col2-set.addresses > .col-2 {
        flex: 1 1 100% !important;
    }
}

/* ==========================================================================
   ADDRESS CARD - Matches .address-card from HTML mockup
   ========================================================================== */

/* Address Card Container */
body.woocommerce-account .woocommerce-Address,
body.woocommerce-account .col-1.woocommerce-Address,
body.woocommerce-account .col-2.woocommerce-Address,
.woocommerce-account .woocommerce-Address {
    background: var(--color-surface) !important;
    border: 3px solid var(--color-border) !important;
    box-shadow: var(--shadow) !important;
    position: relative !important;
}

/* ==========================================================================
   ADDRESS HEADER - Matches .address-header from HTML mockup
   ========================================================================== */

/* Address Card Header - target both div and header elements */
body.woocommerce-account .woocommerce-Address-title,
body.woocommerce-account .woocommerce-Address-title.title,
body.woocommerce-account header.woocommerce-Address-title,
body.woocommerce-account .woocommerce-Address .title,
body.woocommerce-account .woocommerce-Address > header,
.woocommerce-account .woocommerce-Address-title {
    display: flex !important;
    justify-content: flex-start !important;
    align-items: center !important;
    padding: 20px 14px !important;
    border-bottom: 3px solid var(--color-border) !important;
    background: var(--color-bg) !important;
    margin: 0 !important;
    gap: 12px !important;
}

/* ==========================================================================
   ADDRESS TYPE TITLE - Matches .address-type from HTML mockup
   font-size: 14px, font-weight: 800, uppercase, with emoji icon
   ========================================================================== */

/* Address Card Title - Reset base.css h2/h3 styles completely */
body.woocommerce-account .woocommerce-Address-title h2,
body.woocommerce-account .woocommerce-Address-title h3,
body.woocommerce-account .woocommerce-Address-title.title h2,
body.woocommerce-account .woocommerce-Address-title.title h3,
body.woocommerce-account header.woocommerce-Address-title h2,
body.woocommerce-account header.woocommerce-Address-title h3,
body.woocommerce-account .entry-content .woocommerce-Address-title h2,
body.woocommerce-account .entry-content .woocommerce-Address-title h3,
body.woocommerce-account .woocommerce-Address .title h2,
body.woocommerce-account .woocommerce-Address .title h3,
body.woocommerce-account .woocommerce-Address > header h2,
body.woocommerce-account .woocommerce-Address > header h3,
.woocommerce-account .woocommerce-Address-title h2,
.woocommerce-account .woocommerce-Address-title h3 {
    font-family: var(--font-main) !important;
    font-size: 14px !important;
    font-weight: 800 !important;
    text-transform: uppercase !important;
    letter-spacing: 0 !important;
    line-height: 1.4 !important;
    margin: 0 !important;
    padding: 0 !important;
    border: none !important;
    border-bottom: none !important;
    display: flex !important;
    align-items: center !important;
    gap: 8px !important;
    background: none !important;
    color: var(--color-text) !important;
}

/* Address Card Title Icon - Matches .address-type-icon from HTML mockup (18px) */
body.woocommerce-account .woocommerce-Address-title h2::before,
body.woocommerce-account .woocommerce-Address-title h3::before,
body.woocommerce-account header.woocommerce-Address-title h2::before,
body.woocommerce-account header.woocommerce-Address-title h3::before,
body.woocommerce-account .woocommerce-Address > header h2::before,
body.woocommerce-account .woocommerce-Address > header h3::before,
.woocommerce-account .woocommerce-Address-title h2::before,
.woocommerce-account .woocommerce-Address-title h3::before {
    font-size: 18px !important;
    line-height: 1 !important;
}

/* Billing address icon */
body.woocommerce-account .woocommerce-Address--billing .woocommerce-Address-title h2::before,
body.woocommerce-account .woocommerce-Address--billing .woocommerce-Address-title h3::before,
body.woocommerce-account .woocommerce-Address--billing > header h2::before,
body.woocommerce-account .woocommerce-Address--billing > header h3::before,
body.woocommerce-account .col-1 .woocommerce-Address-title h2::before,
body.woocommerce-account .col-1 .woocommerce-Address-title h3::before,
body.woocommerce-account .col-1 > header h2::before,
body.woocommerce-account .col-1 > header h3::before,
body.woocommerce-account .u-column1 .woocommerce-Address-title h2::before,
body.woocommerce-account .u-column1 .woocommerce-Address-title h3::before,
.woocommerce-account .woocommerce-Address--billing .woocommerce-Address-title h2::before,
.woocommerce-account .woocommerce-Address--billing .woocommerce-Address-title h3::before {
    content: '🏠' !important;
}

/* Shipping address icon */
body.woocommerce-account .woocommerce-Address--shipping .woocommerce-Address-title h2::before,
body.woocommerce-account .woocommerce-Address--shipping .woocommerce-Address-title h3::before,
body.woocommerce-account .woocommerce-Address--shipping > header h2::before,
body.woocommerce-account .woocommerce-Address--shipping > header h3::before,
body.woocommerce-account .col-2 .woocommerce-Address-title h2::before,
body.woocommerce-account .col-2 .woocommerce-Address-title h3::before,
body.woocommerce-account .col-2 > header h2::before,
body.woocommerce-account .col-2 > header h3::before,
body.woocommerce-account .u-column2 .woocommerce-Address-title h2::before,
body.woocommerce-account .u-column2 .woocommerce-Address-title h3::before,
.woocommerce-account .woocommerce-Address--shipping .woocommerce-Address-title h2::before,
.woocommerce-account .woocommerce-Address--shipping .woocommerce-Address-title h3::before {
    content: '📦' !important;
}

/* ==========================================================================
   EDIT BUTTON - Matches .btn.btn-secondary.btn-small from HTML mockup
   ========================================================================== */

/* Edit Link - Styled as a neo-brutalist button */
body.woocommerce-account .woocommerce-Address-title a.edit,
body.woocommerce-account .woocommerce-Address-title a,
body.woocommerce-account .woocommerce-Address-title .edit,
body.woocommerce-account header.woocommerce-Address-title a.edit,
body.woocommerce-account .entry-content .woocommerce-Address-title a.edit,
body.woocommerce-account .entry-content .woocommerce-Address-title a,
.woocommerce-account .woocommerce-Address-title a.edit {
    display: inline-flex !important;
    align-items: center !important;
    justify-content: center !important;
    gap: 8px !important;
    padding: 8px 14px !important;
    font-family: var(--font-main) !important;
    font-size: 11px !important;
    font-weight: 700 !important;
    text-transform: uppercase !important;
    letter-spacing: 0.5px !important;
    text-decoration: none !important;
    border: 3px solid var(--color-border) !important;
    margin-left: auto !important;
    flex-shrink: 0 !important;
    background: var(--color-bg) !important;
    color: var(--color-text) !important;
    box-shadow: 3px 3px 0 var(--color-border) !important;
    cursor: pointer !important;
    transition: all 0.15s ease !important;
    white-space: nowrap !important;
}

body.woocommerce-account .woocommerce-Address-title a.edit:hover,
body.woocommerce-account .woocommerce-Address-title a:hover,
body.woocommerce-account .woocommerce-Address-title .edit:hover,
body.woocommerce-account header.woocommerce-Address-title a.edit:hover,
body.woocommerce-account .entry-content .woocommerce-Address-title a.edit:hover,
body.woocommerce-account .entry-content .woocommerce-Address-title a:hover,
.woocommerce-account .woocommerce-Address-title a.edit:hover {
    background: var(--color-sun) !important;
    transform: translate(2px, 2px) !important;
    box-shadow: 1px 1px 0 var(--color-border) !important;
    text-decoration: none !important;
    color: var(--color-text) !important;
}

/* ==========================================================================
   ADDRESS BODY - Matches .address-body from HTML mockup
   ========================================================================== */

/* Address Card Body */
body.woocommerce-account .woocommerce-Address address,
body.woocommerce-account .entry-content .woocommerce-Address address,
.woocommerce-account .woocommerce-Address address {
    padding: 24px !important;
    font-style: normal !important;
    line-height: 1.8 !important;
    margin: 0 !important;
    font-size: 15px !important;
}

/* Individual address lines */
body.woocommerce-account .woocommerce-Address address p,
body.woocommerce-account .woocommerce-Address address br + br,
.woocommerce-account .woocommerce-Address address p {
    margin-bottom: 8px !important;
}

body.woocommerce-account .woocommerce-Address address p:last-child,
.woocommerce-account .woocommerce-Address address p:last-child {
    margin-bottom: 0 !important;
}

/* Name styling (strong/bold) */
body.woocommerce-account .woocommerce-Address address strong,
.woocommerce-account .woocommerce-Address address strong {
    font-weight: 700 !important;
}

/* Address empty state - "You have not set up this type of address yet." */
body.woocommerce-account .woocommerce-Address address .woocommerce-Address-info,
.woocommerce-account .woocommerce-Address address .woocommerce-Address-info {
    color: var(--color-text-soft) !important;
    font-style: italic !important;
}

/* ==========================================================================
   EDIT ADDRESS PAGE HEADER
   ========================================================================== */

/* Style the back link if present */
body.woocommerce-account .woocommerce-MyAccount-content > p:first-child a {
    display: inline-flex !important;
    align-items: center !important;
    gap: 8px !important;
    font-weight: 600 !important;
    color: var(--color-text) !important;
    text-decoration: none !important;
    margin-bottom: 20px !important;
}

body.woocommerce-account .woocommerce-MyAccount-content > p:first-child a:hover {
    color: var(--color-electric) !important;
}

body.woocommerce-account .woocommerce-MyAccount-content > p:first-child a::before {
    content: '←' !important;
    font-size: 18px !important;
}

/* ==========================================================================
   EDIT ADDRESS FORM - Specific Structure
   WooCommerce wraps address forms in .woocommerce-address-fields
   IMPORTANT: WooCommerce uses <p class="form-row"> for EACH field, not as containers
   ========================================================================== */

/* Reset ALL p.form-row elements to NOT be grids */
body.woocommerce-account p.form-row,
body.woocommerce-account .woocommerce p.form-row,
.woocommerce p.form-row,
.woocommerce-page p.form-row {
    display: block !important;
    grid-template-columns: none !important;
    gap: 0 !important;
}

/* The main form container */
body.woocommerce-account form.woocommerce-EditAddressForm,
body.woocommerce-account .woocommerce-MyAccount-content > form {
    background: var(--color-surface) !important;
    border: 3px solid var(--color-border) !important;
    box-shadow: var(--shadow) !important;
    overflow: hidden !important;
}

/* Address fields wrapper - remove the extra padding */
body.woocommerce-account .woocommerce-address-fields {
    background: transparent !important;
    border: none !important;
    box-shadow: none !important;
}

/* The field wrapper is the GRID CONTAINER - not individual form-rows */
body.woocommerce-account .woocommerce-address-fields__field-wrapper {
    display: grid !important;
    grid-template-columns: repeat(2, 1fr) !important;
    gap: 20px !important;
    padding: 28px !important;
}

@media (max-width: 600px) {
    body.woocommerce-account .woocommerce-address-fields__field-wrapper {
        grid-template-columns: 1fr !important;
    }
}

/* Each form row in address form - these are GRID ITEMS, not containers */
body.woocommerce-account .woocommerce-address-fields .form-row {
    margin: 0 !important;
    display: block !important;
}

/* Wide rows span both columns */
body.woocommerce-account .woocommerce-address-fields .form-row-wide {
    grid-column: 1 / -1 !important;
}

/* First and last name rows */
body.woocommerce-account .woocommerce-address-fields .form-row-first {
    grid-column: 1 !important;
}

body.woocommerce-account .woocommerce-address-fields .form-row-last {
    grid-column: 2 !important;
}

@media (max-width: 600px) {
    body.woocommerce-account .woocommerce-address-fields .form-row-first,
    body.woocommerce-account .woocommerce-address-fields .form-row-last {
        grid-column: 1 !important;
    }
}

/* Save button row */
body.woocommerce-account .woocommerce-address-fields > p {
    padding: 20px 28px !important;
    border-top: 3px solid var(--color-border) !important;
    background: var(--color-bg) !important;
    margin: 0 !important;
    text-align: right !important;
    display: block !important;
}

/* ==========================================================================
   EDIT ACCOUNT FORM - Specific Structure
   WooCommerce uses form.woocommerce-EditAccountForm
   ========================================================================== */

/* Account form container */
body.woocommerce-account form.woocommerce-EditAccountForm {
    background: var(--color-surface) !important;
    border: 3px solid var(--color-border) !important;
    box-shadow: var(--shadow) !important;
    overflow: hidden !important;
}

/* Add a header before the form fields using a pseudo-element on the form */
body.woocommerce-account form.woocommerce-EditAccountForm::before {
    content: 'Personal Information' !important;
    display: block !important;
    padding: 20px 28px !important;
    border-bottom: 3px solid var(--color-border) !important;
    background: var(--color-bg) !important;
    font-size: 16px !important;
    font-weight: 800 !important;
    text-transform: uppercase !important;
}

/* Form fields wrapper */
body.woocommerce-account form.woocommerce-EditAccountForm > p.form-row {
    margin: 0 !important;
    padding: 0 28px 20px !important;
}

body.woocommerce-account form.woocommerce-EditAccountForm > p.form-row:first-of-type {
    padding-top: 28px !important;
}

/* First/last name fields - full width */
body.woocommerce-account form.woocommerce-EditAccountForm > p.woocommerce-form-row--first,
body.woocommerce-account form.woocommerce-EditAccountForm > p.woocommerce-form-row--last {
    display: block !important;
    width: 100% !important;
    margin: 0 !important;
}

/* Fieldset for password section */
body.woocommerce-account form.woocommerce-EditAccountForm fieldset {
    margin: 0 !important;
    padding: 0 !important;
    border: none !important;
    border-top: 3px solid var(--color-border) !important;
}

body.woocommerce-account form.woocommerce-EditAccountForm fieldset legend {
    display: block !important;
    width: 100% !important;
    padding: 20px 28px !important;
    margin: 0 !important;
    background: var(--color-bg) !important;
    font-size: 16px !important;
    font-weight: 800 !important;
    text-transform: uppercase !important;
    border-bottom: 3px solid var(--color-border) !important;
    float: none !important;
}

/* Password fields inside fieldset - all full width */
body.woocommerce-account form.woocommerce-EditAccountForm fieldset > p.form-row {
    margin: 0 !important;
    padding: 0 28px 20px !important;
    display: block !important;
    width: 100% !important;
    float: none !important;
}

body.woocommerce-account form.woocommerce-EditAccountForm fieldset > p.form-row-first,
body.woocommerce-account form.woocommerce-EditAccountForm fieldset > p.form-row-last {
    display: block !important;
    width: 100% !important;
    float: none !important;
}

body.woocommerce-account form.woocommerce-EditAccountForm fieldset > p.form-row:first-of-type {
    padding-top: 28px !important;
}

/* Submit button row */
body.woocommerce-account form.woocommerce-EditAccountForm > p:last-of-type {
    padding: 20px 28px !important;
    border-top: 3px solid var(--color-border) !important;
    background: var(--color-bg) !important;
    margin: 0 !important;
    text-align: right !important;
}

/* Clear floats that WooCommerce might add - scoped to account content */
body.woocommerce-account .woocommerce-MyAccount-content form .clear {
    display: none !important;
}

