/* DiscountEngine Frontend Styles */

/* CSS variable defaults — overridden by Account Appearance settings via wp_add_inline_style */
:root {
    --de-color-primary: #2271b1;
    --de-color-accent:  #135e96;
    --de-color-bg:      #ffffff;
}

.de-discount-notice {
    margin: 8px 0 12px;
}

.de-discount-notice .de-badge {
    display: inline-block;
    padding: 4px 12px;
    border-radius: 12px;
    font-size: 13px;
    font-weight: 600;
    line-height: 1.5;
}

.de-badge--green {
    background: #edfaef;
    color: #1a7e2e;
}

/* ── Guest teaser ────────────────────────────────────────────────────────── */
.de-guest-teaser {
    display: flex;
    align-items: center;
    gap: 10px;
    flex-wrap: wrap;
    margin: 8px 0 12px;
}

.de-badge--blue {
    background: #eff6ff;
    color: #1d4ed8;
}

.de-guest-register-link {
    display: inline-block;
    padding: 3px 12px;
    font-size: 13px;
    font-weight: 600;
    border-radius: 12px;
    background: var(--de-color-primary, #2271b1);
    color: #fff !important;
    text-decoration: none;
    transition: background 0.15s;
}

.de-guest-register-link:hover {
    background: var(--de-color-accent, #135e96);
    color: #fff !important;
}

/* ── Gift badge in cart ──────────────────────────────────────────────── */
.de-gift-badge {
    display: inline-block;
    margin-left: 6px;
    padding: 2px 7px;
    font-size: 11px;
    font-weight: 600;
    line-height: 1.4;
    border-radius: 3px;
    background: #d1fae5;
    color: #065f46;
    vertical-align: middle;
}

.de-gift-free {
    font-weight: 600;
    color: #00a32a;
}

/* ==========================================================================
   DiscountEngine Account Button ([de_account_button])
   ========================================================================== */

.de-account-btn {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 6px 14px;
    border-radius: 6px;
    text-decoration: none !important;
    font-size: 14px;
    font-weight: 500;
    line-height: 1.4;
    transition: background 0.15s, border-color 0.15s;
    cursor: pointer;
}

/* Guest button */
.de-account-btn--guest {
    background: var(--de-color-primary, #2271b1);
    color: #fff !important;
    border: 1px solid transparent;
}
.de-account-btn--guest:hover {
    background: var(--de-color-accent, #135e96);
    color: #fff !important;
}

/* Logged-in user button */
.de-account-btn--user {
    background: #f6f7f7;
    color: #1d2327 !important;
    border: 1px solid #dcdcde;
}
.de-account-btn--user:hover {
    background: #f0f0f1;
    color: #1d2327 !important;
    border-color: #c3c4c7;
}

.de-account-avatar {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    object-fit: cover;
    flex-shrink: 0;
}

.de-account-name {
    max-width: 160px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.de-account-level-badge {
    display: inline-flex;
    align-items: center;
    padding: 2px 8px;
    border-radius: 20px;
    border: 1px solid;
    font-size: 12px;
    font-weight: 600;
    white-space: nowrap;
}

/* ==========================================================================
   DiscountEngine Account Page ([de_account_page])
   ========================================================================== */

.de-account-page {
    max-width: 860px;
    font-size: 15px;
    color: #1d2327;
}

/* ── Login notice (for guests) ─────────────────────────────────────────── */
.de-account-notice {
    padding: 32px 24px;
    background: #f6f7f7;
    border: 1px solid #dcdcde;
    border-radius: 8px;
    text-align: center;
}
.de-account-login-link {
    display: inline-block;
    margin-top: 12px;
}

/* ── Profile header ────────────────────────────────────────────────────── */
.de-account-header {
    display: flex;
    align-items: center;
    gap: 16px;
    padding: 20px 24px;
    background: var(--de-color-bg, #fff);
    border: 1px solid #dcdcde;
    border-radius: 8px;
    margin-bottom: 0;
    flex-wrap: wrap;
}

.de-account-header-avatar {
    width: 64px;
    height: 64px;
    border-radius: 50%;
    object-fit: cover;
    flex-shrink: 0;
}

.de-account-header-info {
    flex: 1;
    min-width: 160px;
}

.de-account-header-name {
    font-size: 18px;
    font-weight: 600;
    line-height: 1.3;
}

.de-account-header-email {
    color: #646970;
    font-size: 13px;
    margin-top: 2px;
}

.de-account-header-total {
    font-size: 13px;
    color: var(--de-color-primary, #2271b1);
    margin-top: 4px;
}

.de-account-logout {
    margin-left: auto;
    flex-shrink: 0;
    font-size: 13px;
    color: #646970;
    text-decoration: none;
    padding: 4px 0;
    border-bottom: 1px solid transparent;
    transition: color 0.15s, border-color 0.15s;
}

.de-account-logout:hover {
    color: #b91c1c;
    border-bottom-color: #b91c1c;
}

.de-account-header-level {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 8px 14px;
    border: 2px solid;
    border-radius: 8px;
    flex-shrink: 0;
}

.de-account-header-level-icon { font-size: 22px; }

.de-account-header-level-name {
    font-weight: 600;
    font-size: 15px;
}

.de-account-header-level-discount {
    font-size: 13px;
    opacity: 0.8;
}

/* ── Progress bar (header area) ─────────────────────────────────────────── */
.de-account-progress-wrap {
    padding: 12px 24px;
    background: var(--de-color-bg, #fff);
    border: 1px solid #dcdcde;
    border-top: none;
    border-radius: 0 0 8px 8px;
    margin-bottom: 20px;
}

.de-account-progress-label {
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-size: 13px;
    color: #50575e;
    margin-bottom: 6px;
}

.de-account-progress-pct {
    font-weight: 600;
    color: #1d2327;
    white-space: nowrap;
    margin-left: 8px;
}

.de-account-progress-bar {
    height: 8px;
    background: #f0f0f1;
    border-radius: 4px;
    overflow: hidden;
}

.de-account-progress-fill {
    height: 100%;
    border-radius: 4px;
    transition: width 0.5s ease;
    min-width: 4px;
}

.de-account-progress-wrap--top {
    text-align: center;
}

.de-account-top-level-msg {
    margin: 0;
    font-weight: 500;
    color: #1d2327;
}

/* ── Tab navigation ─────────────────────────────────────────────────────── */
.de-account-tabs {
    display: flex;
    gap: 0;
    border-bottom: 2px solid #dcdcde;
    margin-bottom: 0;
    flex-wrap: wrap;
}

.de-account-tab {
    padding: 10px 18px;
    background: none;
    border: none;
    border-bottom: 2px solid transparent;
    margin-bottom: -2px;
    font-size: 14px;
    font-weight: 500;
    color: #646970;
    cursor: pointer;
    transition: color 0.15s, border-color 0.15s;
    white-space: nowrap;
}

.de-account-tab:hover {
    color: var(--de-color-primary, #2271b1);
}

.de-account-tab--active {
    color: var(--de-color-primary, #2271b1);
    border-bottom-color: var(--de-color-primary, #2271b1);
}

/* ── Tab panels ─────────────────────────────────────────────────────────── */
.de-account-panels {
    background: var(--de-color-bg, #fff);
    border: 1px solid #dcdcde;
    border-top: none;
    border-radius: 0 0 8px 8px;
}

.de-account-panel {
    display: none;
    padding: 24px;
}

.de-account-panel--active {
    display: block;
}

/* ── Section titles ─────────────────────────────────────────────────────── */
.de-account-section {
    margin-bottom: 28px;
}
.de-account-section:last-child {
    margin-bottom: 0;
}

.de-account-section-title {
    font-size: 15px;
    font-weight: 600;
    margin: 0 0 12px;
    padding-bottom: 8px;
    border-bottom: 1px solid #f0f0f1;
    color: #1d2327;
}

/* ── Empty state ────────────────────────────────────────────────────────── */
.de-account-empty {
    text-align: center;
    padding: 32px 16px;
}
.de-account-empty-icon {
    font-size: 40px;
    line-height: 1;
    margin-bottom: 12px;
}
.de-account-empty-text {
    font-size: 15px;
    font-weight: 500;
    color: #1d2327;
    margin: 0 0 6px;
}
.de-account-empty-hint {
    font-size: 13px;
    color: #646970;
    margin: 0;
}

/* ── Generic table ──────────────────────────────────────────────────────── */
.de-account-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 14px;
}

.de-account-table th {
    text-align: left;
    padding: 8px 12px;
    font-weight: 600;
    font-size: 12px;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    color: #646970;
    background: #f6f7f7;
    border-bottom: 1px solid #dcdcde;
}

.de-account-table td {
    padding: 10px 12px;
    border-bottom: 1px solid #f0f0f1;
    vertical-align: middle;
}

.de-account-table tr:last-child td {
    border-bottom: none;
}

.de-account-table a {
    color: var(--de-color-primary, #2271b1);
    text-decoration: none;
}
.de-account-table a:hover {
    text-decoration: underline;
}

.de-account-table--muted {
    opacity: 0.7;
}

.de-account-discount-cell {
    font-weight: 600;
    color: #00a32a;
}

.de-account-no-disc { color: #646970; }

/* ── Global discount card ───────────────────────────────────────────────── */
.de-account-discount-card--global {
    display: flex;
    align-items: center;
    gap: 16px;
    padding: 16px 20px;
    background: #f0fdf4;
    border: 1px solid #bbf7d0;
    border-radius: 8px;
    flex-wrap: wrap;
}

.de-account-discount-value {
    font-size: 24px;
    font-weight: 700;
    color: #16a34a;
    line-height: 1.2;
}

.de-account-discount-label {
    display: block;
    font-size: 13px;
    font-weight: 400;
    color: #166534;
    margin-top: 2px;
}

.de-account-discount-meta {
    display: flex;
    flex-direction: column;
    gap: 2px;
    font-size: 13px;
    color: #166534;
}

/* ── Loyalty tab ────────────────────────────────────────────────────────── */
.de-account-loyalty-card {
    display: flex;
    align-items: flex-start;
    gap: 16px;
    padding: 16px 20px;
    background: #fff;
    border: 1px solid #dcdcde;
    border-left: 4px solid;
    border-radius: 8px;
    flex-wrap: wrap;
    margin-bottom: 0;
}

.de-account-loyalty-icon { font-size: 36px; line-height: 1; flex-shrink: 0; }

.de-account-loyalty-info { flex: 1; min-width: 140px; }

.de-account-loyalty-level-name {
    font-size: 17px;
    font-weight: 700;
    margin-bottom: 4px;
}

.de-account-loyalty-spent,
.de-account-loyalty-discount {
    font-size: 13px;
    color: #50575e;
    margin-top: 2px;
}

.de-account-loyalty-progress { flex: 1; min-width: 200px; }

.de-account-loyalty-progress-bar {
    height: 10px;
    background: #f0f0f1;
    border-radius: 5px;
    overflow: hidden;
    margin-bottom: 6px;
}

.de-account-loyalty-progress-fill {
    height: 100%;
    border-radius: 5px;
    transition: width 0.5s ease;
    min-width: 4px;
}

.de-account-loyalty-progress-text {
    font-size: 13px;
    color: #50575e;
}

.de-account-loyalty-top {
    font-size: 13px;
    font-weight: 600;
    color: var(--de-color-primary, #2271b1);
    align-self: center;
}

.de-account-loyalty-table .de-loyalty-level-name { font-weight: 600; }

.de-account-loyalty-current-row td {
    background: #f0f6fc;
}

.de-account-current-badge {
    display: inline-block;
    margin-left: 6px;
    padding: 1px 7px;
    background: var(--de-color-primary, #2271b1);
    color: #fff;
    font-size: 11px;
    font-weight: 600;
    border-radius: 10px;
    vertical-align: middle;
}

/* ── Coupons grid ───────────────────────────────────────────────────────── */
.de-account-coupons-grid {
    display: grid;
    grid-template-columns: repeat( auto-fill, minmax( 220px, 1fr ) );
    gap: 16px;
}

.de-account-coupon {
    padding: 16px;
    border: 2px dashed var(--de-color-primary, #2271b1);
    border-radius: 8px;
    background: #f0f6fc;
    position: relative;
}

.de-account-coupon-discount {
    font-size: 22px;
    font-weight: 700;
    color: var(--de-color-primary, #2271b1);
    margin-bottom: 10px;
}

.de-account-coupon-code-wrap {
    display: flex;
    align-items: center;
    gap: 6px;
    margin-bottom: 8px;
}

.de-account-coupon-code {
    flex: 1;
    padding: 4px 8px;
    background: #fff;
    border: 1px solid #c3c4c7;
    border-radius: 4px;
    font-size: 13px;
    font-family: monospace;
    letter-spacing: 0.05em;
    user-select: all;
    overflow: hidden;
    text-overflow: ellipsis;
}

.de-account-copy-btn {
    padding: 4px 8px;
    background: var(--de-color-primary, #2271b1);
    color: #fff;
    border: none;
    border-radius: 4px;
    cursor: pointer;
    font-size: 13px;
    flex-shrink: 0;
    transition: background 0.15s;
}
.de-account-copy-btn:hover { background: var(--de-color-accent, #135e96); }

.de-account-coupon-meta,
.de-account-coupon-expires {
    font-size: 12px;
    color: #50575e;
    margin-top: 2px;
}

.de-account-details summary.de-account-details-summary {
    cursor: pointer;
    font-size: 14px;
    font-weight: 500;
    color: #646970;
    padding: 8px 0;
    list-style: none;
}
.de-account-details summary.de-account-details-summary::before {
    content: '▶ ';
    font-size: 11px;
}
.de-account-details[open] summary.de-account-details-summary::before {
    content: '▼ ';
}
.de-account-details .de-account-table {
    margin-top: 12px;
}

/* ── History tab ────────────────────────────────────────────────────────── */
.de-account-saved-banner {
    padding: 12px 16px;
    background: #f0fdf4;
    border: 1px solid #bbf7d0;
    border-radius: 6px;
    font-size: 14px;
    color: #166534;
    margin-bottom: 20px;
}

.de-account-saved-badge {
    display: inline-block;
    padding: 2px 8px;
    background: #edfaef;
    color: #16a34a;
    font-weight: 600;
    font-size: 13px;
    border-radius: 4px;
}

.de-account-order-status {
    display: inline-block;
    padding: 2px 8px;
    border-radius: 4px;
    font-size: 12px;
    font-weight: 500;
    background: #f6f7f7;
    color: #50575e;
}
.de-account-order-status--completed { background: #edfaef; color: #166534; }
.de-account-order-status--processing { background: #eff6ff; color: #1d4ed8; }
.de-account-order-status--on-hold { background: #fefce8; color: #854d0e; }
.de-account-order-status--cancelled,
.de-account-order-status--refunded { background: #fef2f2; color: #b91c1c; }

.de-account-load-more-wrap {
    text-align: center;
    padding: 20px 0 4px;
}

.de-account-load-more {
    min-width: 140px;
}

.de-account-no-more {
    color: #646970;
    font-size: 13px;
    margin: 0;
}

/* ==========================================================================
   Profile tab
   ========================================================================== */

.de-profile-section {
    padding: 24px;
    background: var(--de-color-bg, #fff);
    border: 1px solid #dcdcde;
    border-radius: 8px;
    margin-bottom: 16px;
}

.de-profile-section-title {
    font-size: 14px;
    font-weight: 600;
    color: #1d2327;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    margin: 0 0 20px;
    padding-bottom: 12px;
    border-bottom: 1px solid #f0f0f1;
}

/* Avatar row */
.de-profile-avatar-row {
    display: flex;
    align-items: center;
    gap: 20px;
    flex-wrap: wrap;
}

.de-profile-avatar {
    width: 80px;
    height: 80px;
    border-radius: 50%;
    object-fit: cover;
    flex-shrink: 0;
    border: 2px solid #dcdcde;
}

.de-profile-avatar-hint {
    font-size: 13px;
    color: #646970;
    margin: 0;
    line-height: 1.6;
}

.de-profile-avatar-hint a {
    color: var(--de-color-primary, #2271b1);
}

/* Form layout */
.de-profile-form {
    display: flex;
    flex-direction: column;
    gap: 16px;
}

.de-profile-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 16px;
}

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

.de-profile-field label {
    font-size: 13px;
    font-weight: 600;
    color: #1d2327;
}

.de-profile-field input[type="text"],
.de-profile-field input[type="password"],
.de-profile-field input[type="date"] {
    width: 100%;
    padding: 8px 12px;
    font-size: 14px;
    border: 1px solid #c3c4c7;
    border-radius: 4px;
    background: #fff;
    color: #1d2327;
    box-sizing: border-box;
    transition: border-color 0.15s, box-shadow 0.15s;
}

.de-profile-field input:focus {
    border-color: var(--de-color-primary, #2271b1);
    box-shadow: 0 0 0 1px var(--de-color-primary, #2271b1);
    outline: none;
}

.de-profile-hint {
    font-size: 12px;
    color: #646970;
}

/* Actions row */
.de-profile-actions {
    display: flex;
    align-items: center;
    gap: 14px;
    flex-wrap: wrap;
    margin-top: 4px;
}

.de-profile-submit {
    padding: 8px 20px;
    font-size: 14px;
    font-weight: 600;
    background: var(--de-color-primary, #2271b1);
    color: #fff;
    border: none;
    border-radius: 4px;
    cursor: pointer;
    transition: background 0.15s;
}

.de-profile-submit:hover:not(:disabled) {
    background: var(--de-color-accent, #135e96);
}

.de-profile-submit:disabled {
    opacity: 0.65;
    cursor: not-allowed;
}

.de-profile-message {
    font-size: 13px;
    font-weight: 500;
}

.de-profile-message--ok    { color: #00a32a; }
.de-profile-message--error { color: #b91c1c; }

/* Address links */
.de-profile-address-links {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.de-profile-address-link {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 12px 16px;
    border: 1px solid #dcdcde;
    border-radius: 6px;
    text-decoration: none;
    color: #1d2327;
    font-size: 14px;
    transition: border-color 0.15s, background 0.15s;
}

.de-profile-address-link:hover {
    border-color: var(--de-color-primary, #2271b1);
    background: #f0f6fc;
    color: #1d2327;
}

.de-profile-address-icon { font-size: 18px; }

.de-profile-address-arrow {
    margin-left: auto;
    color: #646970;
}

/* ==========================================================================
   Auth form ([de_account_page] — guest view)
   ========================================================================== */

.de-account-auth {
    max-width: 440px;
    margin: 0 auto;
    padding: 32px 0 8px;
}

/* Tab row */
.de-auth-tabs {
    display: flex;
    border-bottom: 2px solid #dcdcde;
    margin-bottom: 28px;
}

.de-auth-tab {
    padding: 10px 22px;
    background: none;
    border: none;
    border-bottom: 2px solid transparent;
    margin-bottom: -2px;
    font-size: 15px;
    font-weight: 500;
    color: #646970;
    cursor: pointer;
    transition: color 0.15s, border-color 0.15s;
}

.de-auth-tab:hover {
    color: #1d2327;
}

.de-auth-tab--active {
    color: var(--de-color-primary, #2271b1);
    border-bottom-color: var(--de-color-primary, #2271b1);
}

/* Panels */
.de-auth-panel {
    display: none;
}

.de-auth-panel--active {
    display: block;
}

/* Form fields */
.de-auth-form {
    display: flex;
    flex-direction: column;
    gap: 18px;
}

.de-auth-field {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.de-auth-field label {
    font-size: 13px;
    font-weight: 600;
    color: #1d2327;
}

.de-auth-field input[type="text"],
.de-auth-field input[type="email"],
.de-auth-field input[type="password"] {
    width: 100%;
    padding: 9px 12px;
    font-size: 14px;
    border: 1px solid #c3c4c7;
    border-radius: 4px;
    background: #fff;
    color: #1d2327;
    box-sizing: border-box;
    transition: border-color 0.15s, box-shadow 0.15s;
}

.de-auth-field input[type="text"]:focus,
.de-auth-field input[type="email"]:focus,
.de-auth-field input[type="password"]:focus {
    border-color: var(--de-color-primary, #2271b1);
    box-shadow: 0 0 0 1px var(--de-color-primary, #2271b1);
    outline: none;
}

/* Remember me + forgot password row */
.de-auth-field--row {
    flex-direction: row;
    align-items: center;
    justify-content: space-between;
}

.de-auth-remember {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 13px;
    color: #646970;
    cursor: pointer;
    font-weight: 400;
}

.de-auth-remember input[type="checkbox"] {
    margin: 0;
}

.de-auth-lost-pw {
    font-size: 13px;
    color: var(--de-color-primary, #2271b1);
    text-decoration: none;
}

.de-auth-lost-pw:hover {
    text-decoration: underline;
}

/* Hint text */
.de-auth-hint {
    font-size: 12px;
    color: #646970;
    margin-top: -2px;
}

/* Submit button */
.de-auth-actions {
    margin-top: 4px;
}

.de-auth-submit {
    width: 100%;
    padding: 10px 20px;
    font-size: 15px;
    font-weight: 600;
    background: var(--de-color-primary, #2271b1);
    color: #fff;
    border: none;
    border-radius: 4px;
    cursor: pointer;
    transition: background 0.15s;
}

.de-auth-submit:hover:not(:disabled) {
    background: var(--de-color-accent, #135e96);
}

.de-auth-submit:disabled {
    opacity: 0.65;
    cursor: not-allowed;
}

/* Message area */
.de-auth-message {
    min-height: 20px;
    font-size: 13px;
    padding: 0;
    border-radius: 4px;
}

.de-auth-message--error {
    padding: 10px 14px;
    background: #fef2f2;
    border: 1px solid #fecaca;
    color: #b91c1c;
}

.de-auth-message--ok {
    padding: 10px 14px;
    background: #f0fdf4;
    border: 1px solid #bbf7d0;
    color: #166534;
}

/* ==========================================================================
   Responsive
   ========================================================================== */
@media ( max-width: 600px ) {
    .de-account-page { font-size: 14px; }

    .de-account-header { padding: 16px; gap: 12px; }
    .de-account-header-avatar { width: 48px; height: 48px; }
    .de-account-header-name { font-size: 16px; }
    .de-account-header-level { padding: 6px 10px; }

    .de-account-panel { padding: 16px; }

    .de-account-tab { padding: 8px 12px; font-size: 13px; }

    .de-account-table th,
    .de-account-table td { padding: 8px; }

    /* Tables with several columns (orders history, loyalty progress) don't
       fit a phone's width — their cells refuse to shrink below content's
       min-content size, which pushes the whole account page wider than the
       screen instead of just the table. Scroll the table itself instead. */
    .de-account-table {
        display: block;
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
        white-space: nowrap;
    }

    .de-account-coupons-grid { grid-template-columns: 1fr; }

    .de-account-discount-card--global { flex-direction: column; }

    .de-account-loyalty-card { flex-direction: column; }

    .de-account-auth { padding: 20px 0 8px; }
    .de-auth-tab { padding: 8px 14px; font-size: 14px; }
    .de-auth-field--row { flex-direction: column; align-items: flex-start; gap: 8px; }

    .de-profile-row { grid-template-columns: 1fr; }
    .de-profile-section { padding: 16px; }
}

