/* 
 * Redeem OTP Viewer - Premium Isolated Styles
 * High specificity (#redeem-otp-container.redeem-otp-container) to dodge Woodmart overrides.
 */

#redeem-otp-container.redeem-otp-container {
    --primary-red: #eb1c24;
    --primary-red-hover: #d11218;
    --bg-gradient: radial-gradient(circle at top right, rgba(235, 28, 36, 0.08), transparent 400px), 
                   radial-gradient(circle at bottom left, rgba(59, 130, 246, 0.05), transparent 400px);
    --card-bg: rgba(255, 255, 255, 0.85);
    --border-color: rgba(255, 255, 255, 0.5);
    --text-main: #1e293b;
    --text-muted: #64748b;
    --input-bg: #f8fafc;
    --input-border: #cbd5e1;
    --transition-standard: all 0.4s cubic-bezier(0.16, 1, 0.3, 1);
    
    font-family: 'Noto Kufi Arabic', 'Inter', -apple-system, sans-serif;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 30px;
    padding: 30px 15px 60px; /* Increased bottom padding to prevent footer overlap safely */
    background: var(--bg-gradient);
    box-sizing: border-box;
    width: 100%;
}

/* Base resets for Woodmart avoidance */
#redeem-otp-container.redeem-otp-container * {
    box-sizing: border-box;
    transition: var(--transition-standard);
}

/* Card Styling */
#redeem-otp-container .redeem-otp-card {
    background: var(--card-bg) !important;
    backdrop-filter: blur(15px) !important;
    -webkit-backdrop-filter: blur(15px) !important;
    border-radius: 24px !important;
    width: 100% !important;
    max-width: 500px !important;
    padding: 45px 35px !important;
    box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.08) !important;
    border: 1px solid var(--border-color) !important;
    position: relative !important;
    z-index: 2 !important;
    margin: 0 auto !important;
}

/* Header */
#redeem-otp-container .redeem-otp-header {
    text-align: center !important;
    margin-bottom: 35px !important;
    width: 100% !important;
}

#redeem-otp-container .redeem-otp-icon {
    width: 54px !important;
    height: 54px !important;
    color: var(--primary-red) !important;
    margin: 0 auto 15px !important;
    background: rgba(235, 28, 36, 0.08) !important;
    padding: 12px !important;
    border-radius: 16px !important;
    display: block !important;
}

#redeem-otp-container .redeem-otp-title {
    font-size: 26px;
    font-weight: 800;
    margin: 0 0 8px 0;
    color: var(--text-main);
    line-height: 1.2;
}

#redeem-otp-container .redeem-otp-subtitle {
    font-size: 13px;
    color: var(--text-muted);
    margin: 0;
    line-height: 1.5;
    white-space: normal; /* Allow wrapping on mobile */
}

/* Form Controls */
#redeem-otp-container .redeem-form-group {
    margin-bottom: 25px;
}

#redeem-otp-container .redeem-form-group label {
    display: block;
    margin-bottom: 10px;
    font-size: 14px;
    font-weight: 600;
    color: #475569;
    clear: both;
}

#redeem-otp-container .redeem-input-wrapper {
    position: relative;
    display: flex;
    align-items: center;
}

#redeem-otp-container .input-icon {
    position: absolute;
    width: 20px;
    height: 20px;
    color: #94a3b8;
    z-index: 5;
}

/* Input specific resets for Woodmart */
#redeem-otp-container input.redeem-input {
    width: 100% !important;
    height: auto !important;
    background: var(--input-bg) !important;
    border: 1.5px solid var(--input-border) !important;
    color: var(--text-main) !important;
    border-radius: 12px !important;
    font-size: 16px !important;
    margin: 0 !important;
    box-shadow: none !important;
    line-height: 1.5 !important;
}

#redeem-otp-container input.redeem-input:focus {
    outline: none !important;
    border-color: var(--primary-red) !important;
    background: #fff !important;
    box-shadow: 0 0 0 4px rgba(235, 28, 36, 0.1) !important;
}

/* Submit Button reset for Woodmart */
#redeem-otp-container button.redeem-btn-submit {
    width: 100% !important;
    background: var(--primary-red) !important;
    color: #fff !important;
    border: none !important;
    padding: 16px 20px !important;
    border-radius: 12px !important;
    font-size: 16px !important;
    font-weight: 700 !important;
    cursor: pointer !important;
    display: flex !important;
    justify-content: center !important;
    align-items: center !important;
    gap: 10px !important;
    box-shadow: 0 8px 20px rgba(235, 28, 36, 0.2) !important;
    margin-top: 15px !important;
    text-transform: none !important;
}

#redeem-otp-container button.redeem-btn-submit:hover:not(:disabled) {
    transform: translateY(-2px);
    box-shadow: 0 12px 25px rgba(235, 28, 36, 0.3) !important;
    background: var(--primary-red-hover) !important;
}

#redeem-otp-container button.redeem-btn-submit:disabled {
    opacity: 0.6;
    cursor: not-allowed;
    transform: none;
}

/* Spinner Animation (Premium Smooth Logic) */
#redeem-otp-container .spin-icon {
    width: 24px !important;
    height: 24px !important;
    animation: redeem-spin-anim 0.8s cubic-bezier(0.4, 0, 0.2, 1) infinite;
    stroke-dasharray: 40;
    color: #ffffff;
}

@keyframes redeem-spin-anim {
    from { transform: rotate(0deg); }
    to { transform: rotate(360deg); }
}

/* Controlled Visibility via parent class */
#redeem-otp-container .spinner {
    display: none;
    align-items: center;
    justify-content: center;
}

#redeem-otp-container .redeem-btn-submit.is-loading .spinner {
    display: flex;
}

#redeem-otp-container .redeem-btn-submit.is-loading .btn-text {
    display: none;
}

/* RTL / LTR Logic */
#redeem-otp-container[dir="rtl"] { text-align: right; }
#redeem-otp-container[dir="ltr"] { text-align: left; }

#redeem-otp-container[dir="rtl"] .redeem-otp-title,
#redeem-otp-container[dir="rtl"] .redeem-otp-subtitle,
#redeem-otp-container[dir="rtl"] .redeem-form-group label { text-align: right; }

#redeem-otp-container[dir="ltr"] .redeem-otp-title,
#redeem-otp-container[dir="ltr"] .redeem-otp-subtitle,
#redeem-otp-container[dir="ltr"] .redeem-form-group label { text-align: left; }

#redeem-otp-container[dir="rtl"] .input-icon { right: 16px; }
#redeem-otp-container[dir="ltr"] .input-icon { left:  16px; }

#redeem-otp-container[dir="rtl"] input.redeem-input { padding: 14px 48px 14px 16px !important; }
#redeem-otp-container[dir="ltr"] input.redeem-input { padding: 14px 16px 14px 48px !important; }

/* Message / Status Box */
#redeem-otp-container .redeem-msg-box {
    margin-top: 25px;
    padding: 15px 20px;
    border-radius: 12px;
    font-size: 14px;
    font-weight: 600;
    text-align: center;
}

#redeem-otp-container .redeem-msg-box.redeem-msg-error {
    background: rgba(239, 68, 68, 0.1);
    color: #ef4444;
    border: 1px solid rgba(239, 68, 68, 0.2);
}

/* Visibility Classes */
#redeem-otp-container .is-hidden {
    display: none;
    opacity: 0;
}

#redeem-otp-container .is-visible {
    display: block !important;
    animation: fadeInSlide 0.6s var(--transition-standard) forwards;
}

@keyframes fadeInSlide {
    0% { opacity: 0; transform: translateY(20px); }
    100% { opacity: 1; transform: translateY(0); }
}

/* ── Inbox Management ────────────────────────────────────────────────── */
#redeem-otp-container .redeem-inbox-viewer {
    width: 100%;
    max-width: 900px;
}

#redeem-otp-container .redeem-inbox-container {
    display: flex;
    flex-direction: column;
    gap: 15px;
}

#redeem-otp-container .redeem-inbox-item {
    background: rgba(255, 255, 255, 0.7);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border-radius: 20px;
    border: 1px solid var(--border-color);
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.03);
    overflow: hidden;
}

#redeem-otp-container .redeem-inbox-item:hover {
    box-shadow: 0 10px 25px rgba(0, 0, 0, 0.06);
    background: #fff;
}

#redeem-otp-container .redeem-inbox-row-header {
    padding: 24px 30px;
    display: flex;
    align-items: center;
    cursor: pointer;
    gap: 20px;
}

#redeem-otp-container .redeem-inbox-icon {
    width: 44px;
    height: 44px;
    background: var(--primary-red);
    color: #fff;
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 800;
    font-size: 18px;
    flex-shrink: 0;
}

#redeem-otp-container .redeem-inbox-info {
    flex: 1;
    min-width: 0;
}

#redeem-otp-container .redeem-inbox-subject {
    font-weight: 700;
    font-size: 16px;
    color: var(--text-main);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    margin-bottom: 4px;
}

#redeem-otp-container .redeem-inbox-meta {
    font-size: 13px;
    color: var(--text-muted);
    display: flex;
    flex-wrap: wrap;
    gap: 15px;
    align-items: center;
}

#redeem-otp-container .redeem-inbox-date {
    background: rgba(0,0,0,0.04);
    padding: 2px 8px;
    border-radius: 6px;
    font-size: 11px;
}

#redeem-otp-container .redeem-inbox-arrow {
    width: 20px;
    height: 20px;
    color: #94a3b8;
}

#redeem-otp-container .redeem-inbox-item.is-expanded .redeem-inbox-arrow {
    transform: rotate(180deg);
    color: var(--primary-red);
}

#redeem-otp-container .redeem-inbox-row-content {
    max-height: 0;
    overflow: hidden;
    transition: max-height 0.8s cubic-bezier(0.16, 1, 0.3, 1);
    background: #ffffff;
}

#redeem-otp-container .redeem-inbox-item.is-expanded .redeem-inbox-row-content {
    max-height: 2000px;
    border-top: 1px solid rgba(0,0,0,0.05);
}

#redeem-otp-container .redeem-iframe-viewer {
    width: 100%;
    min-height: 450px;
    border: none;
}

/* ── Woodmart Native Tile Support ────────────────────────────────────── */
/* Perfectly match Woodmart design system variables provided in CSS source */
.wd-my-acc-inbox .wd-nav-icon:before {
    content: "" !important;
    display: inline-block;
    width: 55px; /* Matched to --nav-icon-size from Woodmart CSS */
    height: 55px;
    background-image: url('data:image/svg+xml;utf8,<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" fill="none" stroke="%23767676" stroke-width="1.2" stroke-linecap="round" stroke-linejoin="round"><path d="M4 4h16c1.1 0 2 .9 2 2v12c0 1.1-.9 2-2 2H4c-1.1 0-2-.9-2-2V6c0-1.1.9-2 2-2z"></path><polyline points="22,6 12,13 2,6"></polyline></svg>');
    background-size: contain;
    background-repeat: no-repeat;
    background-position: center;
    transition: all 0.3s ease;
}

/* Hover state: use primary red from theme config */
.wd-my-acc-inbox:hover .wd-nav-icon:before {
    background-image: url('data:image/svg+xml;utf8,<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" fill="none" stroke="%23EB1C24" stroke-width="1.2" stroke-linecap="round" stroke-linejoin="round"><path d="M4 4h16c1.1 0 2 .9 2 2v12c0 1.1-.9 2-2 2H4c-1.1 0-2-.9-2-2V6c0-1.1.9-2 2-2z"></path><polyline points="22,6 12,13 2,6"></polyline></svg>');
}

/* Ensure the text label matches the theme's link color and typography */
.wd-my-acc-inbox .nav-link-text {
    color: #333333 !important; /* Matched to --wd-link-color */
    font-family: inherit !important;
    font-size: 14px !important;
    font-weight: 500 !important;
}





/* ── Cloudflare Turnstile Specifics ──────────────────────────────────── */
#redeem-otp-container .redeem-turnstile-wrapper {
    margin-top: 15px;
    min-height: 65px;
    width: 100% !important;
    overflow: hidden;
}

#redeem-otp-container .cf-turnstile {
    width: 100% !important;
    margin: 0 !important;
    display: block !important;
}

#redeem-otp-container .cf-turnstile > iframe {
    width: 100% !important;
    margin: 0 !important;
}

/* Responsive Overrides */
@media (max-width: 1089px) {
    #redeem-otp-container.redeem-otp-container {
        padding: 40px 15px;
    }
    #redeem-otp-container .redeem-otp-card {
        padding: 35px 25px;
    }
}

@media (max-width: 480px) {
    #redeem-otp-container.redeem-otp-container {
        padding: 20px 10px;
    }
    #redeem-otp-container .redeem-otp-card {
        padding: 30px 20px !important;
        border-radius: 20px !important;
    }
    #redeem-otp-container .redeem-otp-title {
        font-size: 22px;
    }
}

@media (min-width: 1090px) {
    /* Only apply two-column layout if NOT inside WooCommerce My Account, 
       as the account sidebar takes up too much room for column layout. */
    body:not(.woocommerce-account) #redeem-otp-container.redeem-otp-container {
        flex-direction: row;
        align-items: flex-start;
        justify-content: center;
        max-width: 1300px;
        margin: 0 auto;
        gap: 40px;
    }
    
    body:not(.woocommerce-account) #redeem-otp-container .redeem-otp-card {
        flex: 0 0 420px;
    }

    body:not(.woocommerce-account) #redeem-otp-container .redeem-inbox-viewer {
        flex: 1;
    }
}

/* Force column layout and full width inside WooCommerce for better responsiveness */
.woocommerce-account #redeem-otp-container.redeem-otp-container {
    padding: 20px 0;
    background: transparent; /* Inherit Woodmart background */
}

.woocommerce-account #redeem-otp-container .redeem-otp-card {
    max-width: 100%;
}
