/* 
 * Letter Send - Frontend Styles 
 * Bootstrap-like clean design with RTL support
 */

/* Container & Layout */
.letter-send-wizard {
    max-width: 800px;
    margin: 40px auto;
    background: #fff;
    border-radius: 0.5rem;
    box-shadow: 0 0.5rem 1rem rgba(0, 0, 0, 0.15);
    padding: 2.5rem;
    font-family: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", "Noto Sans", "Liberation Sans", Arial, sans-serif, "Apple Color Emoji", "Segoe UI Emoji", "Segoe UI Symbol", "Noto Color Emoji";
    color: #212529;
    box-sizing: border-box;
}

.letter-send-wizard *,
.letter-send-wizard *::before,
.letter-send-wizard *::after {
    box-sizing: border-box;
}

/* RTL Support Base */
[dir="rtl"] .letter-send-wizard,
.rtl .letter-send-wizard {
    direction: rtl;
    text-align: right;
}

/* Progress Bar */
.wizard-progress {
    display: flex;
    justify-content: space-between;
    margin-bottom: 3rem;
    position: relative;
    padding: 0 10px;
}

.progress-step {
    display: flex;
    flex-direction: column;
    align-items: center;
    z-index: 2;
    background: #fff;
    width: 90px;
    position: relative;
}

/* RTL adjustment - Remove row-reverse to allow natural RTL flow (Right to Left) */
/* The previous row-reverse was actually flipping it back to LTR visuals in an RTL container */
/* Natural flex-direction: row handles RTL correctly */

.step-number {
    width: 40px;
    height: 40px;
    background: #e9ecef;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    color: #6c757d;
    margin-bottom: 0.5rem;
    border: 2px solid #dee2e6;
    transition: all 0.3s ease;
    font-size: 1.1rem;
    position: relative;
    /* Ensure z-index works relative to context */
    z-index: 2;
}


.progress-step.active .step-number {
    background: #0d6efd;
    /* Bootstrap Primary */
    color: #fff;
    border-color: #0d6efd;
    box-shadow: 0 0 0 0.25rem rgba(13, 110, 253, 0.25);
}

.progress-step.completed .step-number {
    background: #198754;
    /* Bootstrap Success */
    color: #fff;
    border-color: #198754;
}

.step-label {
    font-size: 0.875rem;
    font-weight: 500;
    color: #6c757d;
    text-align: center;
}

.progress-step.active .step-label {
    color: #0d6efd;
    font-weight: 700;
}

.progress-line {
    position: absolute;
    top: 20px;
    left: 45px;
    right: 45px;
    height: 3px;
    background: #e9ecef;
    z-index: 1;
}

.progress-fill {
    height: 100%;
    background: #0d6efd;
    width: 0%;
    transition: width 0.3s ease;
}

[dir="rtl"] .progress-fill,
.rtl .progress-fill {
    float: right;
    /* Or position absolute right: 0 if parent is relative and we want explicit control */
    /* Since parent .progress-line has direction: rtl inherited, standard flow usually starts from right. 
       But let's be safe if positioning is used. */
    margin-left: auto;
    margin-right: 0;
}

/* Steps Content */
.wizard-step {
    display: none;
    animation: fadeIn 0.4s ease;
}

.wizard-step.active {
    display: block;
}

@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(10px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.step-header {
    margin-bottom: 2rem;
    padding-bottom: 1rem;
    border-bottom: 1px solid #dee2e6;
    text-align: center;
}

.step-header h2 {
    margin: 0 0 0.5rem 0;
    font-size: 1.75rem;
    font-weight: 600;
    color: #212529;
}

.step-header p {
    margin: 0;
    color: #6c757d;
    font-size: 1.1rem;
}

/* Form Controls (Bootstrap-like) */
.letter-send-form-row {
    margin-bottom: 1.5rem;
}

.form-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 1.5rem;
}

label {
    display: inline-block;
    margin-bottom: 0.5rem;
    font-weight: 500;
    color: #212529;
}

.required {
    color: #dc3545;
}

input[type="text"],
input[type="email"],
input[type="tel"],
input[type="number"],
select,
textarea {
    display: block;
    width: 100%;
    padding: 0.5rem 0.75rem;
    /* Large comfy inputs */
    font-size: 1rem;
    font-weight: 400;
    line-height: 1.5;
    color: #212529;
    background-color: #fff;
    background-clip: padding-box;
    border: 1px solid #ced4da;
    border-radius: 0.375rem;
    transition: border-color 0.15s, box-shadow 0.15s;
    height: auto;
    /* Override WP defaults */
    box-shadow: none;
    /* Override WP defaults */
}

input[type="text"]:focus,
input[type="email"]:focus,
input[type="tel"]:focus,
input[type="number"]:focus,
select:focus,
textarea:focus {
    color: #212529;
    background-color: #fff;
    border-color: #86b7fe;
    outline: 0;
    box-shadow: 0 0 0 0.25rem rgba(13, 110, 253, 0.25);
}

input.error,
select.error,
textarea.error {
    border-color: #dc3545 !important;
    padding-right: calc(1.5em + 0.75rem);
    background-image: url("data:image/svg+xml,%3csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 12 12' width='12' height='12' fill='none' stroke='%23dc3545'%3e%3ccircle cx='6' cy='6' r='4.5'/%3e%3cpath stroke-linejoin='round' d='M5.8 3.6h.4L6 6.5z'/%3e%3ccircle cx='6' cy='8.2' r='.6' fill='%23dc3545' stroke='none'/%3e%3c/svg%3e");
    background-repeat: no-repeat;
    background-position: right calc(0.375em + 0.1875rem) center;
    background-size: calc(0.75em + 0.375rem) calc(0.75em + 0.375rem);
}

[dir="rtl"] input.error,
.rtl input.error {
    padding-left: calc(1.5em + 0.75rem);
    padding-right: 0.75rem;
    background-position: left calc(0.375em + 0.1875rem) center;
}

/* Category Grid */
.category-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
    gap: 1rem;
}

.category-item input {
    position: absolute;
    clip: rect(0, 0, 0, 0);
    pointer-events: none;
}

.category-card {
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 1.5rem 1rem;
    background-color: #fff;
    border: 1px solid #dee2e6;
    border-radius: 0.5rem;
    cursor: pointer;
    transition: all 0.2s ease;
    text-align: center;
    height: 100%;
}

.category-card:hover {
    border-color: #0d6efd;
    background-color: #f8f9fa;
    transform: translateY(-2px);
}

.category-item input:checked+.category-card {
    background-color: #e7f1ff;
    border-color: #0d6efd;
    color: #0d6efd;
    font-weight: 600;
}

/* Upload Box */
.photo-upload-container {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 1.5rem;
}

.upload-box {
    border: 2px dashed #dee2e6;
    border-radius: 0.5rem;
    padding: 2.5rem 1.5rem;
    text-align: center;
    cursor: pointer;
    transition: all 0.2s ease;
    background: #f8f9fa;
    position: relative;
}

.upload-box.dragover {
    border-color: #0d6efd;
    background: #e7f1ff;
    transform: scale(1.02);
}

.upload-box:hover {
    border-color: #0d6efd;
    background: #e9ecef;
}

.upload-box label {
    cursor: pointer;
    display: flex;
    flex-direction: column;
    align-items: center;
    width: 100%;
    height: 100%;
}

.upload-box .dashicons {
    font-size: 3rem;
    width: 3rem;
    height: 3rem;
    color: #0d6efd;
    margin-bottom: 0.5rem;
}

.label-text {
    font-weight: 600;
    margin-bottom: 0.25rem;
}

.format-hint {
    font-size: 0.8rem;
    color: #6c757d;
}

/* Upload Progress Bar */
.upload-progress {
    width: 100%;
    height: 6px;
    background-color: #e9ecef;
    border-radius: 3px;
    margin-top: 1rem;
    overflow: hidden;
    display: none;
    /* hidden by default, toggled via JS class removal or style */
}

.upload-progress:not(.hidden) {
    display: block;
}

.progress-bar-inner {
    width: 0%;
    height: 100%;
    background-color: #198754;
    transition: width 0.4s ease;
}

.preview-area img {
    margin-top: 1rem;
    max-width: 100%;
    border-radius: 0.375rem;
    border: 1px solid #dee2e6;
    display: block;
    margin-left: auto;
    margin-right: auto;
}

/* Upload Box State: File Selected */
.upload-box.has-file {
    padding: 1rem;
    display: flex;
    align-items: center;
    justify-content: center;
    background: #fff;
    border-style: solid;
}

.upload-box.has-file label {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    opacity: 0;
    z-index: 10;
    cursor: pointer;
}

/* Hide default content when file is present */
.upload-box.has-file .dashicons,
.upload-box.has-file .label-text,
.upload-box.has-file .format-hint {
    display: none;
    /* Visually hidden, but label covers area so click works */
}

/* Preview Area in context */
.preview-area {
    position: relative;
    z-index: 5;
    width: 100%;
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: 0.5rem;
}

.preview-area img {
    max-height: 150px;
    /* Fit nicely */
    object-fit: contain;
    border-radius: 4px;
    box-shadow: 0 2px 5px rgba(0, 0, 0, 0.1);
    margin: 0;
    /* Reset previous margin */
}

/* Footer Buttons */
.wizard-footer {
    border-top: 1px solid #dee2e6;
    margin-top: 2.5rem;
    padding-top: 1.5rem;
    display: flex;
    justify-content: space-between;
}

[dir="rtl"] .wizard-footer,
.rtl .wizard-footer {
    flex-direction: row-reverse;
    /* Just to ensure logical "Next" is better positioned if needed, but flex-start/end works */
}

.btn-next,
.btn-submit,
.btn-prev {
    display: inline-block;
    font-weight: 500;
    line-height: 1.5;
    text-align: center;
    text-decoration: none;
    vertical-align: middle;
    cursor: pointer;
    user-select: none;
    background-color: transparent;
    border: 1px solid transparent;
    padding: 0.5rem 1.25rem;
    font-size: 1rem;
    border-radius: 0.375rem;
    transition: color 0.15s ease, background-color 0.15s ease, border-color 0.15s ease;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.btn-next,
.btn-submit {
    color: #fff;
    background-color: #0d6efd;
    border-color: #0d6efd;
}

.btn-next:hover,
.btn-submit:hover {
    background-color: #0b5ed7;
    border-color: #0a58ca;
}

.btn-next:disabled,
.btn-submit:disabled {
    pointer-events: none;
    opacity: 0.5 !important;
    background-color: #6c757d !important;
    border-color: #6c757d !important;
    color: #fff !important;
    cursor: not-allowed !important;
}

.btn-prev {
    color: #212529;
    background-color: #fff;
    border-color: #ced4da;
}

.btn-prev:hover {
    background-color: #e9ecef;
    border-color: #c4c8cb;
}

.btn-prev:disabled {
    pointer-events: none;
    opacity: 0.65;
}

/* RTL Dashicons Fix */
[dir="rtl"] .dashicons-arrow-right-alt2::before,
.rtl .dashicons-arrow-right-alt2::before {
    content: "\f341";
    /* Left arrow for next in RTL? Or keep right? Usually logical next is left in RTL flow but icon might need flip */
    /* WP Dashicons: 
       arrow-left-alt2: f341
       arrow-right-alt2: f345
    */
}

[dir="rtl"] .btn-next .dashicons-arrow-right-alt2,
.rtl .btn-next .dashicons-arrow-right-alt2 {
    transform: rotate(180deg);
    /* Simplest way to flip arrow */
}

[dir="rtl"] .btn-prev .dashicons-arrow-left-alt2,
.rtl .btn-prev .dashicons-arrow-left-alt2 {
    transform: rotate(180deg);
}

.hidden {
    display: none !important;
}

.hidden-input {
    display: none;
}

/* Signature Pad */
.signature-wrap {
    max-width: 600px;
    margin: 0 auto;
    text-align: center;
}

.signature-pad-container {
    border: 2px dashed #dee2e6;
    border-radius: 0.5rem;
    background: #fff;
    cursor: crosshair;
    margin-bottom: 1rem;
    overflow: hidden;
    position: relative;
    touch-action: none;
    /* Prevent scrolling while signing on touch devices */
}

.signature-pad-container:hover {
    border-color: #ced4da;
}

.signature-pad-container.active {
    border-color: #0d6efd;
}

.signature-pad-container canvas {
    display: block;
    width: 100%;
    height: auto;
}

.signature-controls {
    text-align: right;
}

.btn-clear {
    position: absolute;
    top: 10px;
    right: 10px;
    background: rgba(255, 255, 255, 0.9);
    border: 1px solid #dee2e6;
    color: #6c757d;
    padding: 0.25rem 0.5rem;
    border-radius: 0.25rem;
    cursor: pointer;
    font-size: 0.75rem;
    transition: all 0.2s;
    z-index: 10;
}

.btn-clear:hover {
    background: #fff;
    color: #dc3545;
    border-color: #dc3545;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
}

.verification-wrap {
    text-align: center;
    max-width: 400px;
    margin: 0 auto;
}

.verification-icon .dashicons {
    font-size: 4rem;
    width: 4rem;
    height: 4rem;
    color: #0d6efd;
    margin-bottom: 1.5rem;
}

.resend-btn {
    background: none;
    border: none;
    color: #0d6efd;
    text-decoration: underline;
    cursor: pointer;
    font-weight: 500;
    margin-top: 1rem;
}

/* Responsive */
@media (max-width: 768px) {

    .form-grid,
    .photo-upload-container {
        grid-template-columns: 1fr;
    }

    .wizard-progress {
        overflow-x: auto;
        padding-bottom: 10px;
    }

    .progress-step {
        min-width: 70px;
    }

    .letter-send-wizard {
        padding: 1.5rem;
    }
}