/**
 * Frontend CSS for Gift Card Redemption
 * Classic checkout styles first, then block checkout overrides.
 */

/* ══════════════════════════════════════
   Classic checkout (shortcode)
   ══════════════════════════════════════ */

.wgcr-gift-card-section {
    background: #f8f9fa;
    border: 1px solid #e1e5e9;
    border-radius: 8px;
    padding: 20px;
    margin: 20px 0;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.05);
}

.wgcr-gift-card-section h3 {
    margin: 0 0 15px 0;
    color: #333;
    font-size: 18px;
    font-weight: 600;
}

.wgcr-gift-card-input {
    display: flex;
    gap: 10px;
    margin-bottom: 15px;
}

.wgcr-gift-card-input input[type="text"] {
    flex: 1;
    padding: 12px 15px;
    border: 2px solid #ddd;
    border-radius: 6px;
    font-size: 14px;
    transition: border-color 0.3s ease;
}

.wgcr-gift-card-input input[type="text"]:focus {
    outline: none;
    border-color: #0073aa;
    box-shadow: 0 0 0 3px rgba(0, 115, 170, 0.1);
}

.wgcr-gift-card-input input[type="text"].wgcr-invalid-code {
    border-color: #dc3232;
    box-shadow: 0 0 0 3px rgba(220, 50, 50, 0.1);
}

.wgcr-gift-card-input button {
    padding: 12px 20px;
    background: #0073aa;
    color: white;
    border: none;
    border-radius: 6px;
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    transition: background-color 0.3s ease;
    white-space: nowrap;
}

.wgcr-gift-card-input button:hover {
    background: #005a87;
}

.wgcr-gift-card-input button:disabled {
    background: #ccc;
    cursor: not-allowed;
}

.wgcr-message {
    padding: 12px 15px;
    border-radius: 6px;
    margin-bottom: 15px;
    font-size: 14px;
    font-weight: 500;
}

.wgcr-message-success {
    background: #d4edda;
    color: #155724;
    border: 1px solid #c3e6cb;
}

.wgcr-message-error {
    background: #f8d7da;
    color: #721c24;
    border: 1px solid #f5c6cb;
}

.wgcr-applied-cards {
    margin-top: 15px;
}

.wgcr-applied-cards-list {
    background: white;
    border: 1px solid #e1e5e9;
    border-radius: 6px;
    overflow: hidden;
}

.wgcr-applied-cards-list h4 {
    margin: 0;
    padding: 12px 15px;
    background: #f8f9fa;
    border-bottom: 1px solid #e1e5e9;
    font-size: 14px;
    font-weight: 600;
    color: #333;
}

.wgcr-applied-card {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 12px 15px;
    border-bottom: 1px solid #f1f3f4;
    transition: background-color 0.2s ease;
}

.wgcr-applied-card:last-child {
    border-bottom: none;
}

.wgcr-applied-card:hover {
    background: #f8f9fa;
}

.wgcr-card-code {
    font-family: 'Courier New', monospace;
    font-weight: 600;
    color: #333;
    font-size: 14px;
}

.wgcr-card-amount {
    font-weight: 600;
    color: #28a745;
    font-size: 14px;
}

.wgcr-remove-card {
    background: none;
    border: none;
    color: #dc3545;
    cursor: pointer;
    padding: 4px;
    border-radius: 4px;
    transition: background-color 0.2s ease;
    display: flex;
    align-items: center;
    justify-content: center;
}

.wgcr-remove-card:hover {
    background: #f8d7da;
}

.wgcr-remove-card .dashicons {
    font-size: 16px;
    width: 16px;
    height: 16px;
}

.wgcr-review-gift-cards {
    background: #f8f9fa;
    border: 1px solid #e1e5e9;
    border-radius: 6px;
    padding: 15px;
    margin-bottom: 20px;
}

.wgcr-review-gift-cards h3 {
    margin: 0 0 10px 0;
    font-size: 16px;
    font-weight: 600;
    color: #333;
}

.wgcr-review-card {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 8px 0;
    border-bottom: 1px solid #e1e5e9;
}

.wgcr-review-card:last-child {
    border-bottom: none;
}

.wgcr-review-code {
    font-family: 'Courier New', monospace;
    font-weight: 600;
    color: #333;
    font-size: 13px;
}

.wgcr-review-amount {
    font-weight: 600;
    color: #28a745;
    font-size: 13px;
}

.wgcr-gift-card-total span:first-child {
    color: #666;
}

.wgcr-gift-card-total span:last-child {
    color: #28a745;
    font-weight: 600;
}

/* ── Responsive (classic) ── */
@media (max-width: 768px) {
    .wgcr-gift-card-section {
        padding: 15px;
        margin: 15px 0;
    }

    .wgcr-gift-card-input {
        flex-direction: column;
        gap: 10px;
    }

    .wgcr-gift-card-input button {
        width: 100%;
    }

    .wgcr-applied-card {
        flex-direction: column;
        align-items: flex-start;
        gap: 8px;
    }

    .wgcr-applied-card .wgcr-remove-card {
        align-self: flex-end;
    }

    .wgcr-review-card {
        flex-direction: column;
        align-items: flex-start;
        gap: 4px;
    }
}

/* ── Loading ── */
.wgcr-loading {
    opacity: 0.6;
    pointer-events: none;
}

/* ── Accessibility ── */
.wgcr-remove-card:focus {
    outline: 2px solid #0073aa;
    outline-offset: 2px;
}

/* ── Reduced Motion ── */
@media (prefers-reduced-motion: reduce) {
    .wgcr-gift-card-input input[type="text"],
    .wgcr-gift-card-input button,
    .wgcr-applied-card,
    .wgcr-remove-card {
        transition: none;
    }
}

/* ── Print ── */
@media print {
    .wgcr-gift-card-section {
        background: white;
        border: 1px solid #000;
        box-shadow: none;
    }

    .wgcr-gift-card-input button,
    .wgcr-remove-card {
        display: none;
    }
}

/* ══════════════════════════════════════
   Block checkout overrides
   Must come LAST to win over classic styles.
   ══════════════════════════════════════ */

.wc-block-checkout .wgcr-gift-card-section {
    background: transparent;
    border: none;
    border-radius: 0;
    border-top: 1px solid color-mix(in srgb, currentColor 20%, transparent);
    padding: 16px;
    margin: 0;
    box-shadow: none;
    font-size: inherit;
    line-height: 1.4;
}

.wc-block-checkout .wgcr-gift-card-section h3 {
    margin: 0 0 12px;
    padding: 0;
    color: inherit;
    font-family: inherit;
    font-size: 1em;
    font-weight: 400;
    line-height: inherit;
}

.wc-block-checkout .wgcr-gift-card-input {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-bottom: 0;
    width: 100%;
}

.wc-block-checkout .wgcr-gift-card-input input[type="text"] {
    flex: 3 1 120px;
    margin: 0;
    padding: 8px 16px;
    border: 1px solid color-mix(in srgb, currentColor 20%, transparent);
    border-radius: 4px;
    background: transparent;
    color: inherit;
    font-family: inherit;
    font-size: inherit;
    line-height: 1.4;
    box-sizing: border-box;
    min-height: 3em;
    box-shadow: none;
}

.wc-block-checkout .wgcr-gift-card-input input[type="text"]:focus {
    outline: none;
    border-color: currentColor;
    box-shadow: 0 0 0 1px currentColor;
}

.wc-block-checkout .wgcr-gift-card-input input[type="text"].wgcr-invalid-code {
    border-color: #cc1818;
    box-shadow: none;
}

.wc-block-checkout .wgcr-gift-card-input button {
    flex: 1 1 auto;
    margin: 0;
    padding: 8px 16px;
    min-height: 3em;
    background: transparent;
    color: currentColor;
    border: none;
    border-radius: 4px;
    font-family: inherit;
    font-size: inherit;
    font-weight: 400;
    cursor: pointer;
    white-space: nowrap;
    box-shadow: inset 0 0 0 1px currentColor;
}

.wc-block-checkout .wgcr-gift-card-input button:hover {
    background: #1e1e1e;
    color: #fff;
}

.wc-block-checkout .wgcr-gift-card-input button:focus {
    box-shadow: inset 0 0 0 1px #fff, 0 0 0 2px #0675c4;
    outline: 3px solid transparent;
}

.wc-block-checkout .wgcr-gift-card-input button:disabled {
    opacity: 0.5;
    cursor: not-allowed;
    background: transparent;
    color: currentColor;
}

.wc-block-checkout .wgcr-message {
    padding: 12px 16px;
    border-radius: 4px;
    margin: 8px 0 0;
    font-size: inherit;
    font-weight: 400;
}

.wc-block-checkout .wgcr-message-success {
    background: color-mix(in srgb, #4ab866 12%, transparent);
    color: inherit;
    border: 1px solid color-mix(in srgb, #4ab866 30%, transparent);
}

.wc-block-checkout .wgcr-message-error {
    background: color-mix(in srgb, #cc1818 10%, transparent);
    color: inherit;
    border: 1px solid color-mix(in srgb, #cc1818 25%, transparent);
}

.wc-block-checkout .wgcr-applied-cards {
    margin-top: 12px;
}

.wc-block-checkout .wgcr-applied-cards-list {
    background: transparent;
    border: none;
    border-radius: 0;
    overflow: visible;
}

.wc-block-checkout .wgcr-applied-cards-list h4 {
    display: none;
}

.wc-block-checkout .wgcr-applied-card {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    padding: 6px 0;
    border: none;
    transition: none;
}

.wc-block-checkout .wgcr-applied-card:hover {
    background: transparent;
}

.wc-block-checkout .wgcr-card-code {
    font-family: inherit;
    font-weight: 400;
    font-size: inherit;
    color: inherit;
    opacity: 0.8;
}

.wc-block-checkout .wgcr-card-amount {
    font-weight: 400;
    font-size: inherit;
    color: inherit;
    margin-left: auto;
    margin-right: 8px;
}

.wc-block-checkout .wgcr-remove-card {
    background: none;
    border: none;
    color: inherit;
    opacity: 0.5;
    cursor: pointer;
    padding: 2px;
    border-radius: 2px;
    font-size: 1.1em;
    line-height: 1;
    display: flex;
    align-items: center;
    justify-content: center;
}

.wc-block-checkout .wgcr-remove-card:hover {
    opacity: 1;
    background: transparent;
}

.wc-block-checkout .wgcr-remove-card:focus {
    outline: 2px solid #0675c4;
    outline-offset: 2px;
}
