/* Rira Payment Operations - Official Rira Languages Design System (RTL) */
@import url('https://fonts.googleapis.com/css2?family=Caveat:wght@700&display=swap');

@font-face {
    font-family: 'IRANSansX';
    font-style: normal;
    font-weight: 100;
    src: url('/font/IRANSansX-Thin.woff2') format('woff2');
}

@font-face {
    font-family: 'IRANSansX';
    font-style: normal;
    font-weight: 300;
    src: url('/font/IRANSansX-Light.woff2') format('woff2');
}

@font-face {
    font-family: 'IRANSansX';
    font-style: normal;
    font-weight: 400;
    src: url('/font/IRANSansX-Regular.woff2') format('woff2');
}

@font-face {
    font-family: 'IRANSansX';
    font-style: normal;
    font-weight: 500;
    src: url('/font/IRANSansX-Medium.woff2') format('woff2');
}

@font-face {
    font-family: 'IRANSansX';
    font-style: normal;
    font-weight: 600;
    src: url('/font/IRANSansX-DemiBold.woff2') format('woff2');
}

@font-face {
    font-family: 'IRANSansX';
    font-style: normal;
    font-weight: 700;
    src: url('/font/IRANSansX-Bold.woff2') format('woff2');
}

@font-face {
    font-family: 'IRANSansX';
    font-style: normal;
    font-weight: 800;
    src: url('/font/IRANSansX-ExtraBold.woff2') format('woff2');
}

@font-face {
    font-family: 'IRANSansX';
    font-style: normal;
    font-weight: 900;
    src: url('/font/IRANSansX-Black.woff2') format('woff2');
}

*, *::before, *::after {
    box-sizing: border-box;
    font-family: 'IRANSansX', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif !important;
}

:root {
    /* RIRA Languages Official Color Palette */
    --rira-magenta: #e6007e;
    --rira-navy: #0a0080;
    --rira-cobalt: #0055d4;
    --rira-skyblue: #4b96ff;
    
    --background: #fafafa;
    --foreground: #09090b;
    --card: #ffffff;
    --card-foreground: #09090b;
    --primary: #0055d4;
    --primary-hover: #0a0080;
    --primary-foreground: #ffffff;
    --secondary: #f4f4f5;
    --secondary-hover: #e4e4e7;
    --secondary-foreground: #09090b;
    --muted: #f4f4f5;
    --muted-foreground: #71717a;
    --accent: #e6007e;
    --destructive: #ef4444;
    --border: #e4e4e7;
    --input: #e4e4e7;
    --ring: #e6007e;
    --radius: 0.5rem;
    --shadow-sm: 0 1px 2px 0 rgba(0, 0, 0, 0.05);
}

@keyframes rpoFadeIn {
    0% {
        opacity: 0;
        transform: translateY(12px) scale(0.995);
    }
    100% {
        opacity: 1;
        transform: translateY(0) scale(1);
    }
}

body, html {
    margin: 0;
    padding: 0;
    background-color: var(--background);
    color: var(--foreground);
    direction: rtl;
    text-align: right;
    -webkit-font-smoothing: antialiased;
    overflow-x: hidden;
}

/* RIRA Official Logo Component (Top Centered) */
.rira-brand-logo-centered {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    margin: 0 auto 20px auto;
    text-align: center;
    direction: ltr;
}

.rira-logo-tiles {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    direction: ltr;
}

.rira-logo-tile {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 44px;
    height: 44px;
    border-radius: 4px;
    color: #ffffff;
    font-family: 'Caveat', 'Comic Sans MS', cursive, sans-serif !important;
    font-size: 2.2rem;
    font-weight: 700;
    line-height: 1;
    user-select: none;
}

.rira-tile-r1 { background-color: var(--rira-magenta); }
.rira-tile-i  { background-color: var(--rira-navy); }
.rira-tile-r2 { background-color: var(--rira-cobalt); }
.rira-tile-a  { background-color: var(--rira-skyblue); }

.rira-logo-text {
    font-family: 'Caveat', 'Comic Sans MS', cursive, sans-serif !important;
    font-size: 1.8rem;
    font-weight: 700;
    color: #000000;
    margin-top: 2px;
    letter-spacing: 0.5px;
    direction: ltr;
    line-height: 1;
}

.rpo-custom-logo-img {
    max-height: 64px;
    max-width: 240px;
    height: auto;
    object-fit: contain;
    margin: 0 auto;
    display: block;
}

.rpo-wrapper {
    max-width: 540px;
    /* On desktop give comfortable vertical centering */
    margin: 48px auto;
    padding: 0 16px;
    animation: rpoFadeIn 0.35s cubic-bezier(0.16, 1, 0.3, 1) forwards;
    box-sizing: border-box;
    width: 100%;
}

.rpo-card {
    background: var(--card);
    border-radius: var(--radius);
    box-shadow: var(--shadow-sm);
    border: 1px solid var(--border);
    padding: 32px;
}

.rpo-header {
    margin-bottom: 24px;
    padding-bottom: 20px;
    border-bottom: 1px solid var(--border);
    text-align: center;
}

.rpo-header h2 {
    color: var(--foreground);
    font-size: 1.35rem;
    font-weight: 700;
    margin: 0 0 6px 0;
    letter-spacing: -0.02em;
    word-break: break-word;
}

.rpo-header p {
    color: var(--muted-foreground);
    font-size: 0.875rem;
    margin: 0;
    word-break: break-word;
}

.rpo-form-group {
    margin-bottom: 20px;
}

.rpo-form-group label {
    display: block;
    font-weight: 600;
    color: #18181b;
    font-size: 0.875rem;
    margin-bottom: 8px;
    word-break: break-word;
}

.rpo-form-group label .required {
    color: var(--rira-magenta);
    margin-right: 4px;
}

.rpo-control {
    width: 100%;
    height: 42px;
    padding: 8px 12px;
    font-size: 0.875rem;
    font-weight: 400;
    border: 1px solid var(--input);
    border-radius: var(--radius);
    background-color: #ffffff;
    color: var(--foreground);
    direction: rtl;
    text-align: right;
    transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

.rpo-control::placeholder {
    color: #a1a1aa;
    direction: rtl !important;
    text-align: right !important;
}

/* Force strict RTL orientation for mobile, tel, and numeric inputs and placeholders */
input[type="tel"].rpo-control,
input[name="mobile"].rpo-control,
input[inputmode="numeric"].rpo-control {
    direction: rtl !important;
    text-align: right !important;
}

input[type="tel"].rpo-control::placeholder,
input[name="mobile"].rpo-control::placeholder,
input[inputmode="numeric"].rpo-control::placeholder {
    direction: rtl !important;
    text-align: right !important;
}

/* Input Icon Wrapper System (RTL Compatible) */
.rpo-input-wrapper {
    position: relative;
    display: flex;
    align-items: center;
    width: 100%;
}

.rpo-input-wrapper .rpo-input-icon {
    position: absolute;
    right: 14px;
    top: 50%;
    transform: translateY(-50%);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    color: #a1a1aa;
    pointer-events: none;
    transition: color 0.2s cubic-bezier(0.16, 1, 0.3, 1), transform 0.2s cubic-bezier(0.16, 1, 0.3, 1);
    z-index: 2;
}

.rpo-input-wrapper .rpo-input-icon svg,
.rpo-input-wrapper .rpo-input-icon-svg {
    width: 18px;
    height: 18px;
    stroke-width: 2px;
    flex-shrink: 0;
}

.rpo-input-wrapper .rpo-control.rpo-has-icon {
    padding-right: 42px;
}

.rpo-input-wrapper.is-textarea .rpo-input-icon {
    top: 14px;
    transform: none;
}

/* Dynamic Focus & Hover state micro-interactions */
.rpo-input-wrapper:focus-within .rpo-input-icon {
    color: var(--rira-magenta);
}

.rpo-input-wrapper:hover .rpo-input-icon {
    color: #71717a;
}

.rpo-input-wrapper:focus-within:hover .rpo-input-icon {
    color: var(--rira-magenta);
}

select.rpo-control {
    height: 42px;
}

textarea.rpo-control {
    height: auto;
    min-height: 80px;
}

/* Subtle Rira Pink / Magenta Focus Border */
.rpo-control:focus {
    outline: none;
    border-color: rgba(230, 0, 126, 0.65);
    box-shadow: 0 0 0 3px rgba(230, 0, 126, 0.12);
}

.rpo-control::placeholder {
    color: #a1a1aa;
}

.rpo-amount-card {
    display: none;
    opacity: 0;
    transform: translateY(-6px) scale(0.99);
    background: #f0f7ff;
    border: 1px solid #cce3ff;
    border-radius: var(--radius);
    padding: 8px 12px;
    margin-top: 8px;
    text-align: center;
    width: 100%;
    transition: opacity 0.25s cubic-bezier(0.16, 1, 0.3, 1), transform 0.25s cubic-bezier(0.16, 1, 0.3, 1);
}

.rpo-amount-card.active {
    display: block;
    opacity: 1;
    transform: translateY(0) scale(1);
}

.rpo-amount-card .toman-val {
    font-size: 0.85rem;
    font-weight: 600;
    color: #0284c7;
    line-height: 1.3;
    word-break: break-word;
}

.rpo-amount-card .rial-val {
    font-size: 0.8rem;
    color: var(--rira-cobalt);
    margin-top: 2px;
    font-weight: 500;
    word-break: break-word;
}

.rpo-help-text {
    font-size: 0.8rem;
    color: var(--muted-foreground);
    margin-top: 6px;
    word-break: break-word;
}

/* Solid Buttons (No Gradient) */
.rpo-btn-primary {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    width: 100%;
    min-height: 44px;
    padding: 0 16px;
    font-size: 0.875rem;
    font-weight: 600;
    text-align: center;
    color: #ffffff;
    background-color: var(--rira-cobalt);
    border: 1px solid transparent;
    border-radius: var(--radius);
    cursor: pointer;
    box-shadow: var(--shadow-sm);
    transition: background-color 0.15s ease, transform 0.15s ease;
    text-decoration: none;
}

.rpo-btn-primary:hover {
    background-color: var(--rira-navy);
}

.rpo-btn-primary:active {
    transform: scale(0.98);
}

.rpo-btn-secondary {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    width: 100%;
    min-height: 44px;
    padding: 0 16px;
    font-size: 0.875rem;
    font-weight: 600;
    text-align: center;
    color: var(--secondary-foreground);
    background-color: var(--secondary);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    cursor: pointer;
    margin-top: 8px;
    transition: background-color 0.15s ease, transform 0.15s ease;
    text-decoration: none;
}

.rpo-btn-secondary:hover {
    background-color: var(--secondary-hover);
}

.rpo-btn-secondary:active {
    transform: scale(0.98);
}

.rpo-alert {
    padding: 14px 16px;
    border-radius: var(--radius);
    margin-bottom: 20px;
    font-size: 0.875rem;
    line-height: 1.5;
    border: 1px solid transparent;
    word-break: break-word;
}

.rpo-alert-danger {
    background-color: #fff0f6;
    border-color: #ffc0da;
    color: var(--rira-magenta);
}

.rpo-alert-success {
    background-color: #f0f7ff;
    border-color: #cce3ff;
    color: var(--rira-navy);
}

/* Outcome Receipt Circular Icon Badges */
.rpo-receipt-badge {
    width: 56px;
    height: 56px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    margin: 0 auto 16px auto;
}

.rpo-receipt-success {
    background-color: #f0fdf4;
    border: 1px solid #bbf7d0;
    color: #166534;
}

.rpo-receipt-failed {
    background-color: #fef2f2;
    border: 1px solid #fecaca;
    color: #991b1b;
}

/* Reference Code Box Styles (Green for Success, Red for Failed) */
.rpo-ref-box {
    border-radius: var(--radius);
    padding: 16px;
    margin-bottom: 20px;
    text-align: center;
    border: 1px dashed transparent;
    transition: all 0.2s ease;
}

.rpo-ref-box-success {
    background-color: #f0fdf4;
    border-color: #86efac;
    color: #166534;
}

.rpo-ref-box-success .rpo-ref-title {
    font-size: 0.775rem;
    color: #15803d;
    margin-bottom: 4px;
    font-weight: 600;
}

.rpo-ref-box-success .rpo-ref-value {
    font-size: 1.3rem;
    font-weight: 800;
    color: #166534;
    letter-spacing: 1px;
}

.rpo-ref-box-failed {
    background-color: #fef2f2;
    border-color: #fecaca;
    color: #991b1b;
}

.rpo-ref-box-failed .rpo-ref-title {
    font-size: 0.775rem;
    color: #b91c1c;
    margin-bottom: 4px;
    font-weight: 600;
}

.rpo-ref-box-failed .rpo-ref-value {
    font-size: 1.3rem;
    font-weight: 800;
    color: #991b1b;
    letter-spacing: 1px;
}

.rpo-ref-box .rpo-ref-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    height: 32px;
    padding: 0 14px;
    font-size: 0.775rem;
    font-weight: 600;
    border-radius: var(--radius);
    border: 1px solid var(--border);
    background-color: #ffffff;
    cursor: pointer;
    margin: 10px auto 0 auto;
    transition: all 0.15s ease;
}

.rpo-ref-box-success .rpo-ref-btn {
    color: #166534;
    border-color: #bbf7d0;
}

.rpo-ref-box-success .rpo-ref-btn:hover {
    background-color: #dcfce7;
    border-color: #86efac;
}

.rpo-ref-box-failed .rpo-ref-btn {
    color: #991b1b;
    border-color: #fecaca;
}

.rpo-ref-box-failed .rpo-ref-btn:hover {
    background-color: #fee2e2;
    border-color: #fca5a5;
}

.rpo-detail-table {
    width: 100%;
    border-collapse: collapse;
    margin: 20px 0;
}

.rpo-detail-table th, .rpo-detail-table td {
    padding: 12px 14px;
    border-bottom: 1px solid var(--border);
    font-size: 0.875rem;
    word-break: break-word;
}

.rpo-detail-table th {
    color: var(--muted-foreground);
    font-weight: 500;
    text-align: right;
    width: 40%;
}

.rpo-detail-table td {
    color: var(--foreground);
    font-weight: 600;
}

/* Single Line Price & LTR Card Number Helpers */
.rpo-price-single-line {
    display: inline-block;
    direction: rtl;
    /* Allow wrapping on narrow screens - don't force nowrap */
    word-break: keep-all;
    overflow-wrap: break-word;
}

.rpo-card-ltr {
    direction: ltr !important;
    display: inline-block;
    font-family: 'IRANSansX', sans-serif !important;
    letter-spacing: 1px;
    font-weight: 600;
}

/* Payment Gateway Selection Option Cards */
.rpo-gw-option {
    display: flex;
    align-items: center;
    gap: 14px;
    padding: 14px 16px;
    border: 1.5px solid var(--border);
    border-radius: var(--radius);
    background-color: #ffffff;
    cursor: pointer;
    transition: all 0.2s cubic-bezier(0.16, 1, 0.3, 1);
}

.rpo-gw-option:hover {
    background-color: #fafafa;
    border-color: var(--rira-skyblue);
}

.rpo-gw-option:has(input[type="radio"]:checked) {
    border-color: var(--rira-cobalt);
    background-color: #f0f7ff;
    box-shadow: 0 0 0 1px var(--rira-cobalt);
}

.rpo-gw-option input[type="radio"] {
    accent-color: var(--rira-cobalt);
    width: 18px;
    height: 18px;
    cursor: pointer;
    flex-shrink: 0;
}

.rpo-gw-logo {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 44px;
    height: 44px;
    flex-shrink: 0;
    border-radius: 8px;
    overflow: hidden;
    background-color: #fafafa;
    border: 1px solid var(--border);
    padding: 2px;
}

.rpo-gw-logo img,
.rpo-gw-logo svg {
    width: 38px;
    height: 38px;
    object-fit: contain;
    display: block;
}

.rpo-gw-info {
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.rpo-gw-info strong {
    font-size: 0.875rem;
    color: #09090b;
}

.rpo-gw-info span {
    font-size: 0.775rem;
    color: var(--muted-foreground);
}

/* Mobile Breakpoints */
@media (max-width: 640px) {
    body, html {
        /* Respect the notch/status-bar safe area */
        padding-top: env(safe-area-inset-top, 0px);
    }

    .rpo-wrapper {
        /*
         * env(safe-area-inset-top) already equals the notch height exactly:
         *   iPhone X / 11 / 12 / 13  → ~44px notch
         *   iPhone 14 Pro Dynamic Island → ~59px notch
         *   Android punch-hole / status bar → ~24-32px
         * We add only 8px extra breathing room above that.
         * Minimum 20px for flat-screen devices with no notch at all.
         */
        margin: max(20px, calc(env(safe-area-inset-top, 0px) + 8px)) auto 24px;
        padding: 0 20px;
        width: 100%;
    }

    .rpo-card {
        padding: 20px 14px;
        border-radius: 10px;
        width: 100%;
        box-sizing: border-box;
    }

    .rpo-header h2 {
        font-size: 1.1rem;
        word-break: break-word;
    }

    .rpo-header p {
        font-size: 0.825rem;
        word-break: break-word;
    }

    /* Form controls full width */
    .rpo-control, select.rpo-control {
        font-size: 16px; /* Prevents iOS zoom-in on focus */
        width: 100%;
        box-sizing: border-box;
    }

    /* Detail table on receipt pages */
    .rpo-detail-table th {
        width: 42%;
        font-size: 0.8rem;
        padding: 10px 10px;
    }

    .rpo-detail-table td {
        font-size: 0.82rem;
        padding: 10px 10px;
        word-break: break-word;
        overflow-wrap: anywhere;
    }

    /* Reference code box on receipt */
    .rpo-ref-box {
        padding: 14px 10px;
    }

    .rpo-ref-box-success .rpo-ref-value,
    .rpo-ref-box-failed .rpo-ref-value {
        font-size: 1rem;
        letter-spacing: 0.5px;
        word-break: break-all;
    }

    /* Prevent price overflow on narrow screens */
    .rpo-price-single-line {
        white-space: normal;
        word-break: break-word;
    }

    /* Gateway selection */
    .rpo-gw-option {
        padding: 12px 12px;
        gap: 10px;
    }

    .rpo-gw-logo {
        width: 36px;
        height: 36px;
    }

    .rpo-gw-logo img, .rpo-gw-logo svg {
        width: 30px;
        height: 30px;
    }

    /* Buttons */
    .rpo-btn-primary, .rpo-btn-secondary {
        font-size: 0.9rem;
        min-height: 48px; /* Larger tap target on mobile */
    }

    /* Confirmation page receipt badge */
    .rpo-receipt-badge {
        width: 52px;
        height: 52px;
    }

    /* Alert messages */
    .rpo-alert {
        font-size: 0.825rem;
        padding: 12px 12px;
    }
}

/* ─── Print Stylesheet for Official Receipts ─── */
@media print {
    body {
        background: #ffffff !important;
        margin: 0 !important;
        padding: 0 !important;
    }
    .demo-nav, .rpo-no-print, .rpo-ref-btn {
        display: none !important;
    }
    .rpo-wrapper {
        margin: 0 !important;
        padding: 0 !important;
        width: 100% !important;
        max-width: 100% !important;
    }
    .rpo-card {
        box-shadow: none !important;
        border: 2px solid #cbd5e1 !important;
        max-width: 650px !important;
        margin: 20px auto !important;
        padding: 30px !important;
        border-radius: 8px !important;
    }
    .rpo-ref-box {
        border-style: solid !important;
        background: #f8fafc !important;
    }
}

/* ─── Jalali Datepicker Popover Styles (Frontend) ─── */
.rpo-datepicker-popover {
    position: absolute;
    z-index: 99999;
    width: 280px;
    background: #ffffff;
    border: 1px solid #e2e8f0;
    border-radius: 12px;
    box-shadow: 0 10px 25px -5px rgba(0, 0, 0, 0.1), 0 8px 10px -6px rgba(0, 0, 0, 0.1);
    padding: 14px;
    font-family: inherit;
    direction: rtl;
    user-select: none;
}
.rpo-dp-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 12px;
    gap: 6px;
}
.rpo-dp-nav {
    background: #f1f5f9;
    border: 1px solid #e2e8f0;
    border-radius: 6px;
    width: 28px;
    height: 28px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.2rem;
    cursor: pointer;
    color: #334155;
    transition: all 0.15s;
}
.rpo-dp-nav:hover {
    background: #e2e8f0;
    color: #0f172a;
}
.rpo-dp-title {
    display: flex;
    gap: 6px;
}
.rpo-dp-month-select, .rpo-dp-year-select {
    border: 1px solid #cbd5e1;
    border-radius: 6px;
    padding: 3px 6px;
    font-size: 0.82rem;
    font-family: inherit;
    background: #ffffff;
    color: #1e293b;
    outline: none;
    cursor: pointer;
}
.rpo-dp-weekdays {
    display: grid;
    grid-template-columns: repeat(7, 1fr);
    text-align: center;
    font-size: 0.75rem;
    font-weight: 600;
    color: #64748b;
    margin-bottom: 6px;
    padding-bottom: 4px;
    border-bottom: 1px solid #f1f5f9;
}
.rpo-dp-days {
    display: grid;
    grid-template-columns: repeat(7, 1fr);
    gap: 2px;
}
.rpo-dp-empty {
    height: 32px;
}
.rpo-dp-day {
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: none;
    border: none;
    border-radius: 6px;
    font-size: 0.82rem;
    font-family: inherit;
    color: #1e293b;
    cursor: pointer;
    transition: all 0.15s;
}
.rpo-dp-day:hover {
    background: #f1f5f9;
    color: #0055d4;
    font-weight: 700;
}
.rpo-dp-day.today {
    border: 1px solid #93c5fd;
    color: #0055d4;
    font-weight: 700;
}
.rpo-dp-day.selected {
    background: #0055d4 !important;
    color: #ffffff !important;
    font-weight: 700;
}
.rpo-dp-footer {
    display: flex;
    justify-content: space-between;
    margin-top: 10px;
    padding-top: 8px;
    border-top: 1px solid #f1f5f9;
}
.rpo-dp-btn {
    background: none;
    border: none;
    font-size: 0.78rem;
    font-family: inherit;
    font-weight: 600;
    color: #0055d4;
    cursor: pointer;
    padding: 3px 8px;
    border-radius: 4px;
}
.rpo-dp-btn:hover {
    background: #eff6ff;
}
.rpo-dp-clear-btn {
    color: #ef4444;
}
.rpo-dp-clear-btn:hover {
    background: #fef2f2;
}
