/**
 * Zakat Calculator — RTL-first, professional UI
 *
 * @package yCharitable
 * @since   3.0.0
 */


/* ════════════════════════════════════════
   TOKEN LAYER
   ════════════════════════════════════════ */

.ych-zakat-calculator {
    --yz-primary: var(--color-primary, #1a3a5c);
    --yz-primary-rgb: 26, 58, 92;
    --yz-accent: var(--color-secondary, #c9a227);
    --yz-accent-rgb: 201, 162, 39;
    --yz-dark: var(--color-dark, #0d1b2a);
    --yz-dark-rgb: 13, 27, 42;
    --yz-success: #16a34a;
    --yz-success-rgb: 22, 163, 74;
    --yz-surface: var(--color-white, #ffffff);
    --yz-surface-alt: #f8fafc;
    --yz-border: rgba(var(--yz-dark-rgb), 0.08);
    --yz-border-focus: rgba(var(--yz-accent-rgb), 0.5);
    --yz-text: var(--color-text, #1f2937);
    --yz-muted: var(--color-text-light, #6b7280);
    --yz-radius-sm: 10px;
    --yz-radius-md: 16px;
    --yz-radius-lg: 24px;
    --yz-radius-full: 999px;
    --yz-shadow-sm: 0 2px 8px rgba(0, 0, 0, 0.04);
    --yz-shadow-md: 0 8px 32px rgba(0, 0, 0, 0.08);
    --yz-shadow-lg: 0 20px 56px rgba(0, 0, 0, 0.12);
    --yz-transition: 0.3s cubic-bezier(0.25, 0.8, 0.25, 1);
    --yz-transition-fast: 0.15s ease-in-out;

    max-width: 760px;
    margin-inline: auto;
    padding: clamp(1.5rem, 4vw, 3rem);
    font-family: var(--font-primary, 'Cairo', sans-serif);
    color: var(--yz-text);
    isolation: isolate;
}


/* ════════════════════════════════════════
   INTRO TEXT
   ════════════════════════════════════════ */

.ych-zakat-intro {
    margin-block-end: clamp(1rem, 3vw, 2rem);
    padding: clamp(1rem, 2.5vw, 1.5rem);
    background: rgba(var(--yz-accent-rgb), 0.06);
    border: 1px solid rgba(var(--yz-accent-rgb), 0.15);
    border-radius: var(--yz-radius-md);
    text-align: center;
    line-height: 1.8;
    font-size: clamp(0.92rem, 1.8vw, 1.05rem);
    color: var(--yz-muted);
}

.ych-zakat-intro p {
    margin: 0;
}


/* ════════════════════════════════════════
   TAB BAR
   ════════════════════════════════════════ */

.ych-zakat-tabs {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    padding: 6px;
    margin-block-end: clamp(1.25rem, 3vw, 2rem);
    background: rgba(var(--yz-dark-rgb), 0.03);
    border: 1px solid var(--yz-border);
    border-radius: var(--yz-radius-md);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
}

.ych-zakat-tab {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    flex: 1 1 0;
    min-width: 0;
    padding: clamp(0.6rem, 1.5vw, 0.85rem) clamp(0.5rem, 1vw, 0.75rem);
    border: none;
    border-radius: var(--yz-radius-sm);
    background: transparent;
    color: var(--yz-muted);
    font-family: inherit;
    font-size: clamp(0.72rem, 1.5vw, 0.85rem);
    font-weight: 600;
    cursor: pointer;
    transition: all var(--yz-transition-fast);
    white-space: nowrap;
    text-align: center;
}

.ych-zakat-tab svg {
    flex-shrink: 0;
    width: 18px;
    height: 18px;
    opacity: 0.6;
    transition: opacity var(--yz-transition-fast);
}

.ych-zakat-tab:hover {
    background: rgba(var(--yz-accent-rgb), 0.08);
    color: var(--yz-text);
}

.ych-zakat-tab:hover svg {
    opacity: 0.8;
}

.ych-zakat-tab:focus-visible {
    outline: 2px solid var(--yz-accent);
    outline-offset: -2px;
}

.ych-zakat-tab.active {
    background: var(--yz-accent);
    color: #fff;
    box-shadow: 0 4px 16px rgba(var(--yz-accent-rgb), 0.35);
}

.ych-zakat-tab.active svg {
    opacity: 1;
    color: #fff;
    stroke: #fff;
}


/* ════════════════════════════════════════
   PANELS
   ════════════════════════════════════════ */

.ych-zakat-panel {
    display: none;
    animation: ychFadeSlideUp 0.4s ease-out;
}

.ych-zakat-panel.active {
    display: block;
}

@keyframes ychFadeSlideUp {
    from {
        opacity: 0;
        transform: translateY(12px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}


/* ════════════════════════════════════════
   GLASSMORPHISM CARD
   ════════════════════════════════════════ */

.ych-zakat-panel .ych-zakat-form {
    position: relative;
    padding: clamp(1.5rem, 3.5vw, 2.5rem);
    background: rgba(255, 255, 255, 0.7);
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
    border: 1px solid rgba(255, 255, 255, 0.5);
    border-radius: var(--yz-radius-lg);
    box-shadow: var(--yz-shadow-md);
    overflow: hidden;
}

.ych-zakat-panel .ych-zakat-form::before {
    content: '';
    position: absolute;
    inset-block-start: 0;
    inset-inline: 0;
    height: 3px;
    background: linear-gradient(
        90deg,
        var(--yz-accent),
        color-mix(in srgb, var(--yz-accent) 55%, #fff),
        rgba(var(--yz-accent-rgb), 0.2)
    );
    border-radius: var(--yz-radius-lg) var(--yz-radius-lg) 0 0;
    pointer-events: none;
}


/* ════════════════════════════════════════
   FORM FIELDS
   ════════════════════════════════════════ */

.ych-zakat-field {
    margin-block-end: clamp(0.85rem, 2vw, 1.25rem);
}

.ych-zakat-field:last-child {
    margin-block-end: 0;
}

.ych-zakat-field > label {
    display: block;
    margin-block-end: 0.4rem;
    font-size: clamp(0.82rem, 1.5vw, 0.9rem);
    font-weight: 700;
    color: var(--yz-text);
    letter-spacing: 0.01em;
}

.ych-input-wrap {
    position: relative;
    display: flex;
    align-items: center;
}

.ych-input-wrap input[type="number"] {
    width: 100%;
    padding: clamp(0.7rem, 1.5vw, 0.9rem) clamp(0.9rem, 2vw, 1.2rem);
    padding-inline-start: clamp(0.9rem, 2vw, 1.2rem);
    padding-inline-end: 4.5rem;
    border: 1px solid var(--yz-border);
    border-radius: var(--yz-radius-sm);
    background: color-mix(in srgb, var(--yz-surface) 96%, var(--yz-dark) 4%);
    color: var(--yz-text);
    font-family: inherit;
    font-size: clamp(0.92rem, 1.8vw, 1rem);
    font-weight: 500;
    transition: border-color var(--yz-transition-fast), box-shadow var(--yz-transition-fast);
    -moz-appearance: textfield;
}

.ych-input-wrap input[type="number"]::-webkit-inner-spin-button,
.ych-input-wrap input[type="number"]::-webkit-outer-spin-button {
    -webkit-appearance: none;
    margin: 0;
}

.ych-input-wrap input[type="number"]::placeholder {
    color: var(--yz-muted);
    opacity: 0.5;
}

.ych-input-wrap input[type="number"]:focus {
    border-color: var(--yz-accent);
    box-shadow: 0 0 0 3px rgba(var(--yz-accent-rgb), 0.12);
    outline: none;
}

.ych-input-currency {
    position: absolute;
    inset-inline-end: 12px;
    padding: 4px 10px;
    font-size: 0.78rem;
    font-weight: 700;
    color: var(--yz-muted);
    background: rgba(var(--yz-dark-rgb), 0.04);
    border-radius: 6px;
    pointer-events: none;
    white-space: nowrap;
}

.ych-input-wrap--select select {
    width: 100%;
    padding: clamp(0.7rem, 1.5vw, 0.9rem) clamp(0.9rem, 2vw, 1.2rem);
    border: 1px solid var(--yz-border);
    border-radius: var(--yz-radius-sm);
    background: color-mix(in srgb, var(--yz-surface) 96%, var(--yz-dark) 4%);
    color: var(--yz-text);
    font-family: inherit;
    font-size: clamp(0.92rem, 1.8vw, 1rem);
    font-weight: 500;
    cursor: pointer;
    transition: border-color var(--yz-transition-fast), box-shadow var(--yz-transition-fast);
    appearance: none;
    -webkit-appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%236b7280' stroke-width='2'%3E%3Cpolyline points='6 9 12 15 18 9'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: left 14px center;
    padding-inline-start: 2.5rem;
}

html[dir="ltr"] .ych-input-wrap--select select {
    background-position: right 14px center;
    padding-inline-start: 1.2rem;
    padding-inline-end: 2.5rem;
}

.ych-input-wrap--select select:focus {
    border-color: var(--yz-accent);
    box-shadow: 0 0 0 3px rgba(var(--yz-accent-rgb), 0.12);
    outline: none;
}


/* ════════════════════════════════════════
   RESULT AREA
   ════════════════════════════════════════ */

.ych-zakat-result {
    margin-block-start: clamp(1rem, 2.5vw, 1.5rem);
    min-height: 0;
    transition: min-height var(--yz-transition);
}

.ych-zakat-result:empty {
    min-height: 0;
    margin-block-start: 0;
}

.ych-result-animate {
    animation: ychResultPop 0.45s cubic-bezier(0.22, 1, 0.36, 1);
}

@keyframes ychResultPop {
    0% {
        opacity: 0;
        transform: translateY(10px) scale(0.97);
    }
    100% {
        opacity: 1;
        transform: translateY(0) scale(1);
    }
}


/* ── Result Details Table ── */

.ych-result-details {
    padding: clamp(1rem, 2.5vw, 1.5rem);
    background: var(--yz-surface-alt);
    border: 1px solid var(--yz-border);
    border-radius: var(--yz-radius-md);
    margin-block-end: 1rem;
}

.ych-result-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding-block: 0.55rem;
    border-bottom: 1px dashed var(--yz-border);
}

.ych-result-row:last-child {
    border-bottom: none;
    padding-block-end: 0;
}

.ych-result-row-label {
    font-size: clamp(0.82rem, 1.5vw, 0.9rem);
    color: var(--yz-muted);
}

.ych-result-row-value {
    font-size: clamp(0.88rem, 1.6vw, 0.95rem);
    font-weight: 700;
    color: var(--yz-text);
}


/* ── Progress Bar ── */

.ych-progress-wrap {
    margin-block-end: 1rem;
}

.ych-progress-labels {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-block-end: 0.5rem;
}

.ych-progress-label {
    font-size: clamp(0.72rem, 1.3vw, 0.8rem);
    font-weight: 600;
    color: var(--yz-muted);
}

.ych-progress-bar {
    position: relative;
    height: 10px;
    background: rgba(var(--yz-dark-rgb), 0.06);
    border-radius: var(--yz-radius-full);
    overflow: visible;
}

.ych-progress-fill {
    height: 100%;
    border-radius: var(--yz-radius-full);
    background: linear-gradient(90deg, var(--yz-accent), color-mix(in srgb, var(--yz-accent) 70%, #e67e22));
    transition: width 0.5s cubic-bezier(0.25, 0.8, 0.25, 1);
    min-width: 0;
}

.ych-progress-fill.above-nisab {
    background: linear-gradient(90deg, var(--yz-success), #22c55e);
}

.ych-progress-nisab-marker {
    position: absolute;
    top: -4px;
    width: 2px;
    height: 18px;
    background: rgba(var(--yz-dark-rgb), 0.25);
    border-radius: 1px;
    pointer-events: none;
}


/* ── Main Result Display ── */

.ych-result-main {
    padding: clamp(1.25rem, 3vw, 2rem);
    background: linear-gradient(
        135deg,
        rgba(var(--yz-success-rgb), 0.08),
        rgba(var(--yz-success-rgb), 0.03)
    );
    border: 2px solid rgba(var(--yz-success-rgb), 0.25);
    border-radius: var(--yz-radius-lg);
    text-align: center;
    position: relative;
    overflow: hidden;
}

.ych-result-main::before {
    content: '';
    position: absolute;
    inset: 0;
    background: radial-gradient(
        ellipse 60% 40% at 50% 20%,
        rgba(var(--yz-success-rgb), 0.06),
        transparent
    );
    pointer-events: none;
}

.ych-result-amount-label {
    position: relative;
    z-index: 1;
    font-size: clamp(0.9rem, 1.8vw, 1.05rem);
    font-weight: 700;
    color: rgba(var(--yz-success-rgb), 0.8);
    margin-block-end: 0.5rem;
}

.ych-result-amount {
    position: relative;
    z-index: 1;
    font-size: clamp(1.75rem, 4.5vw, 2.5rem);
    font-weight: 900;
    color: var(--yz-success);
    letter-spacing: -0.02em;
    line-height: 1.2;
}


/* ── No Zakat Required ── */

.ych-result-none {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    padding: clamp(1rem, 2.5vw, 1.5rem);
    background: rgba(var(--yz-dark-rgb), 0.03);
    border: 1px dashed rgba(var(--yz-dark-rgb), 0.15);
    border-radius: var(--yz-radius-md);
    text-align: center;
    color: var(--yz-muted);
    font-size: clamp(0.95rem, 2vw, 1.1rem);
    font-weight: 600;
}

.ych-result-none svg {
    flex-shrink: 0;
    opacity: 0.5;
}


/* ── Result Note ── */

.ych-result-note {
    margin-block-start: 0.75rem;
    padding: 0.7rem 1rem;
    background: rgba(var(--yz-accent-rgb), 0.06);
    border-radius: var(--yz-radius-sm);
    font-size: clamp(0.78rem, 1.4vw, 0.85rem);
    line-height: 1.7;
    color: var(--yz-muted);
    text-align: center;
}


/* ── Result Actions (WhatsApp / Print) ── */

.ych-result-actions {
    display: flex;
    gap: 10px;
    margin-block-start: 1rem;
}

.ych-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    flex: 1;
    padding: clamp(0.6rem, 1.5vw, 0.8rem) clamp(0.8rem, 2vw, 1.2rem);
    border: none;
    border-radius: var(--yz-radius-full);
    font-family: inherit;
    font-size: clamp(0.78rem, 1.4vw, 0.85rem);
    font-weight: 700;
    cursor: pointer;
    transition: all var(--yz-transition-fast);
    white-space: nowrap;
}

.ych-btn:focus-visible {
    outline: 2px solid var(--yz-accent);
    outline-offset: 3px;
}

.ych-btn-whatsapp {
    background: linear-gradient(135deg, #25d366, #128c4e);
    color: #fff;
    box-shadow: 0 4px 16px rgba(37, 211, 102, 0.3);
}

.ych-btn-whatsapp:hover {
    filter: brightness(1.08);
    transform: translateY(-2px);
    box-shadow: 0 8px 24px rgba(37, 211, 102, 0.4);
}

.ych-btn-whatsapp svg {
    color: #fff;
    stroke: #fff;
}

.ych-btn-print {
    background: rgba(var(--yz-dark-rgb), 0.06);
    color: var(--yz-text);
    border: 1px solid var(--yz-border);
}

.ych-btn-print:hover {
    background: rgba(var(--yz-dark-rgb), 0.12);
    transform: translateY(-2px);
}

.ych-btn-print svg {
    color: var(--yz-muted);
    stroke: var(--yz-muted);
}


/* ════════════════════════════════════════
   RESPONSIVE
   ════════════════════════════════════════ */

@media (max-width: 640px) {
    .ych-zakat-calculator {
        padding: clamp(1rem, 3vw, 1.5rem);
    }

    .ych-zakat-tabs {
        gap: 4px;
        padding: 4px;
    }

    .ych-zakat-tab {
        flex: 0 0 auto;
        min-width: calc(50% - 4px);
        padding: 0.6rem 0.5rem;
        font-size: 0.75rem;
    }

    .ych-zakat-tab svg {
        display: none;
    }

    .ych-result-actions {
        flex-direction: column;
    }

    .ych-result-amount {
        font-size: clamp(1.4rem, 5vw, 1.8rem);
    }
}

@media (max-width: 400px) {
    .ych-zakat-tab {
        min-width: calc(50% - 4px);
        font-size: 0.7rem;
    }

    .ych-input-wrap input[type="number"] {
        padding-inline-end: 3.5rem;
    }

    .ych-input-currency {
        font-size: 0.7rem;
        padding: 3px 7px;
    }
}


/* ════════════════════════════════════════
   PRINT STYLES
   ════════════════════════════════════════ */

@media print {
    .ych-zakat-calculator {
        max-width: 100%;
        padding: 0;
    }

    .ych-zakat-tabs {
        display: none;
    }

    .ych-zakat-panel .ych-zakat-form {
        background: #fff;
        backdrop-filter: none;
        -webkit-backdrop-filter: none;
        box-shadow: none;
        border: 1px solid #ddd;
        padding: 1rem;
    }

    .ych-zakat-panel .ych-zakat-form::before {
        display: none;
    }

    .ych-result-actions {
        display: none;
    }

    .ych-result-main {
        border-width: 1px;
        padding: 1rem;
    }

    .ych-result-amount {
        font-size: 1.5rem;
    }

    .ych-progress-bar {
        print-color-adjust: exact;
        -webkit-print-color-adjust: exact;
    }
}


/* ════════════════════════════════════════
   REDUCED MOTION
   ════════════════════════════════════════ */

@media (prefers-reduced-motion: reduce) {
    .ych-zakat-panel,
    .ych-result-animate,
    .ych-progress-fill {
        animation: none;
        transition: none;
    }

    .ych-zakat-tab,
    .ych-input-wrap input[type="number"],
    .ych-input-wrap--select select,
    .ych-btn {
        transition: none;
    }

    .ych-btn:hover,
    .ych-btn-whatsapp:hover,
    .ych-btn-print:hover {
        transform: none;
    }
}
