/* ─── AI Eyeglass Recommender — Eynakchi UI (v1.1) ─────────────────────── */

#ear-app,
#ear-app * {
    box-sizing: border-box;
}

#ear-app {
    --ear-primary: #7C5CFC;
    --ear-primary-soft: #F7F5FF;
    --ear-white: #FFFFFF;
    --ear-text: #171421;
    --ear-muted: #727082;
    --ear-line: #E7E4EF;
    --ear-shadow: 0 22px 60px rgba(124, 92, 252, 0.09);
    --ear-shadow-sm: 0 8px 28px rgba(124, 92, 252, 0.07);
    --ear-radius: 24px;
    --ear-radius-sm: 14px;
    --ear-success: #19A35B;

    width: 100%;
    padding: 52px 16px 34px;
    font-family: inherit !important;
    color: var(--ear-text);
    direction: rtl;
    text-align: right;
    background: var(--ear-white);
}

#ear-app button,
#ear-app input,
#ear-app a,
#ear-app h1,
#ear-app h2,
#ear-app h3,
#ear-app h4,
#ear-app p,
#ear-app span,
#ear-app small,
#ear-app strong,
#ear-app li {
    font-family: inherit !important;
}

.ear-container {
    width: 100%;
    max-width: 1400px;
    margin: 0 auto;
}

.ear-hidden { display: none !important; }
.ear-step { width: 100%; }

/* ─── Top Grid: Hero (right) + Upload (left) ────────────────────────────── */

.ear-top-grid {
    display: grid;
    grid-template-columns: 1fr minmax(300px, 510px);
    gap: 46px;
    align-items: start;
}

/* ─── Hero Panel ────────────────────────────────────────────────────────── */

.ear-hero-panel {
    position: relative;
    padding: 14px 0 0;
}

.ear-hero-title {
    margin: 0 0 16px;
    font-size: clamp(30px, 4vw, 46px);
    font-weight: 900;
    letter-spacing: -1.2px;
    line-height: 1.35;
    color: var(--ear-text);
    display: flex;
    align-items: center;
    gap: 12px;
    flex-wrap: wrap;
}

.ear-sparkle {
    color: var(--ear-primary);
    font-size: clamp(36px, 4vw, 50px);
    line-height: 1;
    font-weight: 400;
}

.ear-hero-subtitle {
    margin: 0 0 31px;
    max-width: 660px;
    color: var(--ear-muted);
    font-size: 17px;
    line-height: 2;
}

/* ─── Progress Stepper ──────────────────────────────────────────────────── */

.ear-progress {
    display: flex;
    align-items: flex-start;
    gap: 14px;
    max-width: 485px;
    margin: 0 auto 32px;
}

.ear-progress-item {
    min-width: 78px;
    text-align: center;
    color: #B2ADBF;
    flex-shrink: 0;
}

.ear-progress-num {
    width: 27px;
    height: 27px;
    border-radius: 50%;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    background: #C7C3CF;
    color: #fff;
    font-size: 13px;
    font-weight: 800;
}

.ear-progress-label {
    display: block;
    margin-top: 9px;
    font-size: 12px;
    color: inherit;
}

.ear-progress-line {
    height: 2px;
    flex: 1;
    margin-top: 13px;
    background: linear-gradient(90deg, #DAD6E6, #B99CFF);
    min-width: 20px;
}

.ear-progress-item.active { color: var(--ear-primary); }
.ear-progress-item.active .ear-progress-num { background: var(--ear-primary); }

/* ─── Image Preview ─────────────────────────────────────────────────────── */

.ear-preview-frame {
    position: relative;
    border: 1px solid #CFC7BF;
    border-radius: 12px;
    overflow: hidden;
    background: #F5F3F1;
    min-height: 375px;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 12px 36px rgba(23, 20, 33, 0.07);
}

.ear-preview-frame img {
    width: 100%;
    height: 430px;
    object-fit: cover;
    display: block;
}

.ear-empty-preview {
    flex-direction: column;
    gap: 12px;
    background: linear-gradient(135deg, #FBF9FF, #fff);
    color: var(--ear-muted);
    border-color: var(--ear-line);
}

.ear-empty-icon {
    font-size: 54px;
    opacity: 0.75;
}

.ear-empty-preview strong {
    color: var(--ear-text);
    font-size: 19px;
    font-weight: 800;
}

.ear-empty-preview small {
    color: var(--ear-muted);
    font-size: 14px;
}

.ear-preview-actions {
    display: flex;
    gap: 12px;
    justify-content: center;
    flex-wrap: wrap;
    margin-top: 18px;
}

/* ─── Upload Card ───────────────────────────────────────────────────────── */

.ear-upload-card {
    background: rgba(255, 255, 255, 0.92);
    border: 1px solid var(--ear-line);
    border-radius: var(--ear-radius);
    box-shadow: var(--ear-shadow);
    padding: 34px 34px 28px;
    min-height: 585px;
}

.ear-upload-title {
    margin: 0 0 28px;
    text-align: center;
    font-size: 22px;
    font-weight: 800;
    color: var(--ear-text);
}

.ear-file-input {
    position: absolute;
    width: 1px;
    height: 1px;
    opacity: 0;
    pointer-events: none;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
}

.ear-upload-actions {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 24px;
}

.ear-upload-actions.dragover .ear-choice-card {
    border-color: var(--ear-primary);
    box-shadow: 0 18px 40px rgba(124, 92, 252, 0.13);
    transform: translateY(-2px);
    background: linear-gradient(180deg, #fff, #F7F2FF);
}

.ear-choice-card {
    min-height: 180px;
    border: 1px solid #D9D5E4;
    background: linear-gradient(180deg, #fff, #FDFBFF);
    border-radius: var(--ear-radius-sm);
    cursor: pointer;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 10px;
    padding: 18px;
    color: var(--ear-text);
    transition: transform 0.2s ease, border-color 0.2s ease, box-shadow 0.2s ease, background 0.2s ease;
}

.ear-choice-card:hover {
    border-color: var(--ear-primary);
    box-shadow: 0 18px 40px rgba(124, 92, 252, 0.13);
    transform: translateY(-2px);
    background: linear-gradient(180deg, #fff, #F7F2FF);
}

.ear-choice-icon {
    width: 54px;
    height: 54px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    color: var(--ear-primary);
}

.ear-choice-icon svg {
    width: 44px;
    height: 44px;
}

.ear-choice-card strong {
    font-size: 16px;
    font-weight: 800;
}

.ear-choice-card small {
    font-size: 13px;
    color: var(--ear-muted);
}

.ear-separator {
    display: flex;
    align-items: center;
    gap: 18px;
    color: #6E6A77;
    margin: 34px 0 22px;
    font-size: 14px;
}

.ear-separator::before,
.ear-separator::after {
    content: "";
    height: 1px;
    flex: 1;
    background: repeating-linear-gradient(to left, #D9D5E4 0 5px, transparent 5px 10px);
}

.ear-privacy-note {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    background: var(--ear-primary-soft);
    color: #4F4370;
    border-radius: 9px;
    padding: 13px 16px;
    font-size: 13px;
    line-height: 1.9;
    text-align: center;
}

.ear-privacy-lock {
    flex-shrink: 0;
    font-size: 14px;
}

.ear-tips-card {
    border-top: 1px solid var(--ear-line);
    margin-top: 24px;
    padding-top: 25px;
}

.ear-tips-card h4 {
    margin: 0 0 14px;
    font-size: 15px;
    font-weight: 800;
    text-align: center;
    color: var(--ear-text);
}

.ear-tips-card ul {
    margin: 0;
    padding: 0;
    list-style: none;
    display: grid;
    gap: 11px;
    color: #373140;
    font-size: 14px;
}

.ear-tips-card li::before {
    content: "✓";
    margin-left: 10px;
    color: #1D1B22;
    font-weight: 900;
}

/* ─── Buttons ───────────────────────────────────────────────────────────── */

.ear-btn,
.ear-link-btn {
    border: 0;
    border-radius: 12px;
    padding: 12px 22px;
    cursor: pointer;
    font-weight: 800;
    font-size: 14px;
    text-decoration: none !important;
    transition: transform 0.2s ease, box-shadow 0.2s ease, background 0.2s ease;
    display: inline-flex;
    align-items: center;
    justify-content: center;
}

.ear-btn:hover,
.ear-link-btn:hover { transform: translateY(-1px); }

.ear-btn-primary {
    background: var(--ear-primary);
    color: #fff !important;
    box-shadow: 0 14px 28px rgba(124, 92, 252, 0.24);
}

.ear-btn-outline {
    background: #fff;
    color: var(--ear-primary) !important;
    border: 1px solid #D7C9FF;
}

.ear-link-btn {
    background: transparent;
    color: var(--ear-primary) !important;
    padding: 7px 0;
    font-size: 14px;
}

/* ─── Loading ───────────────────────────────────────────────────────────── */

.ear-loading-panel {
    max-width: 760px;
    margin: 30px auto;
    padding: 40px;
    background: var(--ear-white);
    border: 1px solid var(--ear-line);
    border-radius: var(--ear-radius);
    box-shadow: var(--ear-shadow);
    text-align: center;
}

.ear-loading-visual {
    position: relative;
    width: 230px;
    height: 230px;
    border-radius: var(--ear-radius);
    overflow: hidden;
    margin: 0 auto 24px;
    background: #F2EEF8;
}

.ear-loading-visual img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.ear-loading-line {
    position: absolute;
    top: -10%;
    left: 0;
    right: 0;
    height: 4px;
    background: rgba(124, 92, 252, 0.8);
    box-shadow: 0 0 22px rgba(124, 92, 252, 0.8);
    animation: earScan 2.1s infinite ease-in-out;
}

@keyframes earScan {
    0%   { top: 0; }
    50%  { top: 100%; }
    100% { top: 0; }
}

.ear-loading-title {
    margin: 0 0 10px;
    font-size: 25px;
    font-weight: 900;
}

.ear-loading-desc {
    margin: 0 auto 24px;
    color: var(--ear-muted);
    line-height: 1.9;
}

.ear-loading-steps {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 10px;
}

.ear-loading-step {
    background: #FBF8FF;
    border: 1px solid var(--ear-line);
    border-radius: 12px;
    padding: 12px 10px;
    font-size: 13px;
    color: var(--ear-muted);
}

.ear-loading-dot {
    display: block;
    width: 9px;
    height: 9px;
    border-radius: 50%;
    background: #C8C1D5;
    margin: 0 auto 7px;
}

.ear-loading-step.active {
    color: var(--ear-primary);
    border-color: #CCB9FF;
}

.ear-loading-step.active .ear-loading-dot {
    background: var(--ear-primary);
    animation: earPulse 1s infinite;
}

.ear-loading-step.done { color: var(--ear-success); }
.ear-loading-step.done .ear-loading-dot { background: var(--ear-success); }

@keyframes earPulse {
    50% { transform: scale(1.45); opacity: 0.55; }
}

/* ─── Results Panel ─────────────────────────────────────────────────────── */

.ear-results-section {
    margin-bottom: 36px;
}

.ear-result-panel {
    background: var(--ear-primary-soft);
    border: 1px solid var(--ear-line);
    border-radius: var(--ear-radius);
    padding: 34px;
    box-shadow: var(--ear-shadow-sm);
}

.ear-result-grid {
    display: grid;
    grid-template-columns: 260px 1fr 260px;
    gap: 30px;
    align-items: center;
    margin-bottom: 28px;
}

.ear-result-summary h3 {
    margin: 0 0 18px;
    font-size: 21px;
    font-weight: 900;
    color: var(--ear-text);
}

.ear-face-card {
    border: 1px solid var(--ear-line);
    border-radius: var(--ear-radius-sm);
    padding: 28px 20px;
    min-height: 210px;
    display: flex;
    flex-direction: column;
    justify-content: center;
    background: #fff;
}

.ear-face-card h4 {
    margin: 0 0 15px;
    font-size: 18px;
    font-weight: 900;
    color: var(--ear-text);
}

.ear-face-card p {
    margin: 0 0 14px;
    color: #595465;
    line-height: 1.95;
    font-size: 14px;
}

.ear-guide-link {
    color: var(--ear-primary) !important;
    font-size: 13px;
    font-weight: 800;
    text-decoration: none !important;
}

.ear-guide-link:hover {
    text-decoration: underline !important;
}

.ear-face-illustration {
    width: 190px;
    height: 250px;
    margin: 0 auto;
    border: 2px solid var(--ear-line);
    border-radius: 50%;
    overflow: hidden;
    background: #fff;
    box-shadow: var(--ear-shadow-sm);
}

.ear-face-illustration img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
}

.ear-result-metrics {
    display: grid;
    grid-template-columns: 1fr;
    gap: 14px;
}

.ear-metric-card {
    background: #fff;
    border: 1px solid var(--ear-line);
    border-radius: 12px;
    padding: 14px 12px;
    min-height: 78px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 8px;
    text-align: center;
}

.ear-metric-icon {
    width: 28px;
    height: 28px;
    color: var(--ear-primary);
    display: flex;
    align-items: center;
    justify-content: center;
}

.ear-metric-icon svg {
    width: 22px;
    height: 22px;
}

.ear-metric-text {
    font-size: 13px;
    color: var(--ear-muted);
    line-height: 1.5;
}

.ear-metric-text strong {
    color: var(--ear-text);
    font-weight: 900;
}

.ear-style-section {
    margin-bottom: 20px;
}

.ear-style-section-title {
    text-align: center;
    margin: 0 0 14px;
    font-weight: 900;
    font-size: 15px;
    color: var(--ear-text);
}

.ear-style-tags {
    display: flex;
    gap: 9px;
    flex-wrap: wrap;
    justify-content: center;
}

.ear-style-tags span {
    border: 1px solid #C8B2FF;
    color: var(--ear-primary);
    background: #fff;
    border-radius: 999px;
    padding: 5px 18px;
    font-size: 13px;
    font-weight: 800;
}

.ear-advice-box {
    border: 1px solid var(--ear-line);
    border-radius: 12px;
    background: #fff;
    padding: 16px 18px;
    line-height: 1.9;
    color: #3D3748;
    font-size: 14px;
    text-align: center;
}

/* ─── Products ──────────────────────────────────────────────────────────── */

.ear-products-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin: 0 0 22px;
}

.ear-products-title {
    margin: 0;
    font-size: 23px;
    font-weight: 900;
    color: var(--ear-text);
}

.ear-products-grid {
    display: grid;
    grid-template-columns: repeat(5, minmax(0, 1fr));
    gap: 22px;
}

.ear-product-card {
    position: relative;
    background: #fff;
    border: 1px solid var(--ear-line);
    border-radius: 15px;
    min-height: 285px;
    padding: 16px;
    display: flex;
    flex-direction: column;
    text-align: center;
    transition: transform 0.2s ease, box-shadow 0.2s ease, border-color 0.2s ease;
}

.ear-product-card:hover {
    transform: translateY(-4px);
    border-color: #C7B5F7;
    box-shadow: 0 20px 42px rgba(124, 92, 252, 0.12);
}

.ear-wishlist {
    position: absolute;
    top: 16px;
    left: 16px;
    color: #AAB0BD;
    font-size: 22px;
    line-height: 1;
}

.ear-card-img-wrap {
    height: 118px;
    display: flex;
    align-items: center;
    justify-content: center;
    margin: 20px 0 12px;
}

.ear-card-img-wrap img {
    max-width: 100%;
    max-height: 112px;
    object-fit: contain;
    display: block;
}

.ear-card-img-placeholder {
    font-size: 56px;
}

.ear-card-name {
    min-height: 45px;
    margin: 0 0 8px;
    font-size: 15px;
    line-height: 1.6;
    font-weight: 800;
    color: var(--ear-text);
}

.ear-card-reason {
    display: none;
    margin: 0 0 10px;
    font-size: 12px;
    color: var(--ear-muted);
    line-height: 1.6;
}

.ear-card-price {
    display: block;
    min-height: 26px;
    margin-bottom: 13px;
    color: #0CA85F;
    font-size: 14px;
    font-weight: 900;
}

.ear-card-price ins { text-decoration: none; }

.ear-card-btn {
    display: block;
    width: 100%;
    margin-top: auto;
    border: 1px solid var(--ear-primary);
    color: var(--ear-primary) !important;
    border-radius: 9px;
    padding: 9px 12px;
    text-decoration: none !important;
    font-size: 13px;
    font-weight: 900;
    transition: background 0.2s ease, color 0.2s ease;
}

.ear-card-btn:hover {
    background: var(--ear-primary);
    color: #fff !important;
}

.ear-empty-products {
    grid-column: 1 / -1;
    text-align: center;
    color: var(--ear-muted);
    padding: 40px;
    border: 1px solid var(--ear-line);
    border-radius: 15px;
    background: #fff;
}

.ear-products-dots {
    display: flex;
    justify-content: center;
    gap: 8px;
    margin-top: 28px;
}

.ear-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: #D5D0E3;
}

.ear-dot.active {
    background: var(--ear-primary);
    width: 24px;
    border-radius: 999px;
}

.ear-disclaimer {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    margin-top: 30px;
    text-align: center;
    background: var(--ear-primary-soft);
    color: #655C77;
    border-radius: 12px;
    padding: 15px 22px;
    font-size: 13px;
    line-height: 1.9;
}

.ear-disclaimer-icon {
    flex-shrink: 0;
    font-size: 15px;
}

/* ─── Error ─────────────────────────────────────────────────────────────── */

.ear-error-box {
    max-width: 520px;
    margin: 40px auto;
    text-align: center;
    padding: 34px;
    background: #fff;
    border: 1px solid var(--ear-line);
    border-radius: var(--ear-radius);
    box-shadow: var(--ear-shadow);
}

.ear-error-icon {
    display: block;
    color: var(--ear-primary);
    margin-bottom: 12px;
}

.ear-error-box p {
    color: var(--ear-muted);
    line-height: 1.9;
    margin: 0 0 20px;
}

/* ─── Responsive ────────────────────────────────────────────────────────── */

@media (max-width: 1024px) {
    .ear-top-grid {
        grid-template-columns: 1fr;
        gap: 30px;
    }

    .ear-upload-card {
        min-height: auto;
        order: 2;
    }

    .ear-hero-panel {
        order: 1;
    }

    .ear-result-grid {
        grid-template-columns: 1fr;
        text-align: center;
    }

    .ear-face-illustration {
        margin: 0 auto;
    }

    .ear-result-metrics {
        max-width: 400px;
        margin: 0 auto;
    }

    .ear-products-grid {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }
}

@media (max-width: 700px) {
    #ear-app {
        padding: 28px 12px;
    }

    .ear-upload-card {
        padding: 24px 18px;
        border-radius: 20px;
    }

    .ear-upload-actions {
        grid-template-columns: 1fr;
        gap: 14px;
    }

    .ear-choice-card {
        min-height: 135px;
    }

    .ear-hero-title {
        font-size: 28px;
    }

    .ear-hero-subtitle {
        font-size: 14px;
        margin-bottom: 24px;
    }

    .ear-progress {
        gap: 8px;
    }

    .ear-progress-item {
        min-width: 56px;
    }

    .ear-progress-label {
        font-size: 10px;
    }

    .ear-preview-frame,
    .ear-empty-preview {
        min-height: 300px;
    }

    .ear-preview-frame img {
        height: 330px;
    }

    .ear-loading-panel {
        padding: 26px 16px;
    }

    .ear-loading-steps {
        grid-template-columns: 1fr;
    }

    .ear-result-panel {
        padding: 22px 16px;
    }

    .ear-result-metrics {
        grid-template-columns: 1fr;
        gap: 10px;
    }

    .ear-products-head {
        align-items: flex-start;
        gap: 10px;
    }

    .ear-products-grid {
        grid-template-columns: repeat(2, minmax(0, 1fr));
        gap: 12px;
    }

    .ear-product-card {
        padding: 12px;
        min-height: 260px;
    }

    .ear-card-img-wrap {
        height: 100px;
    }
}

@media (max-width: 430px) {
    .ear-products-grid {
        grid-template-columns: 1fr;
    }

    .ear-result-metrics {
        grid-template-columns: 1fr;
    }
}
