/* ==========================================================================
   AgriPoint Selector Styles
   ========================================================================== */

:root {
    --agri-color-old: #e53935;
    --agri-color-up: #2e7d32;
    --agri-pulse-radius: 22px;
}

.agri-viewer {
    position: relative;
    max-width: 1080px;
    margin: 0 auto;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
    color: #1d2327;
    box-sizing: border-box;
}

.agri-viewer *,
.agri-viewer *::before,
.agri-viewer *::after {
    box-sizing: border-box;
}

/* Header & Legend */
.agri-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-end;
    flex-wrap: wrap;
    gap: 12px;
    margin-bottom: 14px;
}

.agri-brand-badge {
    display: inline-block;
    background: #e8f5e9;
    color: #1b5e20;
    font-size: 12px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    padding: 3px 8px;
    border-radius: 4px;
    margin-bottom: 4px;
}

.agri-title {
    margin: 0;
    font-size: 24px;
    font-weight: 700;
    line-height: 1.25;
    color: #111;
}

.agri-model {
    font-size: 14px;
    color: #646970;
    margin-top: 2px;
}

.agri-legend {
    display: flex;
    gap: 16px;
    background: #fff;
    padding: 6px 12px;
    border-radius: 20px;
    border: 1px solid #dcdcde;
    font-size: 13px;
    font-weight: 500;
}

.agri-legend-item {
    display: flex;
    align-items: center;
    gap: 6px;
}

.agri-dot-sample {
    width: 12px;
    height: 12px;
    border-radius: 50%;
}

.agri-dot-sample--old {
    background: var(--agri-color-old, #e53935);
}

.agri-dot-sample--up {
    background: var(--agri-color-up, #2e7d32);
}

/* Stage */
.agri-stage-wrap {
    position: relative;
    background: #fff;
    border-radius: 12px;
    box-shadow: 0 4px 20px rgba(0,0,0,0.06);
    border: 1px solid #e1e4e8;
    overflow: hidden;
}

.agri-stage {
    position: relative;
    width: 100%;
    user-select: none;
    line-height: 0;
}

.agri-main-img {
    width: 100%;
    height: auto;
    display: block;
    pointer-events: none;
}

.agri-hotspots-layer {
    position: absolute;
    inset: 0;
    pointer-events: none;
}

.agri-hint {
    position: absolute;
    top: 12px;
    left: 50%;
    transform: translateX(-50%);
    background: rgba(0, 0, 0, 0.65);
    backdrop-filter: blur(4px);
    color: #fff;
    font-size: 12px;
    padding: 5px 14px;
    border-radius: 20px;
    pointer-events: none;
    line-height: 1.4;
    white-space: nowrap;
    z-index: 5;
    opacity: 0.9;
}

/* Hotspot Dots */
.agri-dot {
    position: absolute;
    width: 28px;
    height: 28px;
    transform: translate(-50%, -50%);
    border-radius: 50%;
    border: 2px solid #fff;
    cursor: pointer;
    pointer-events: auto;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0;
    box-shadow: 0 2px 10px rgba(0,0,0,0.35);
    transition: transform 0.2s ease, background 0.25s ease, box-shadow 0.2s ease;
    z-index: 10;
}

.agri-dot:hover {
    transform: translate(-50%, -50%) scale(1.15);
    box-shadow: 0 4px 14px rgba(0,0,0,0.5);
    z-index: 15;
}

.agri-dot:focus-visible {
    outline: 3px solid #2271b1;
    outline-offset: 3px;
}

.agri-dot--selected {
    transform: translate(-50%, -50%) scale(1.2) !important;
    outline: 3px solid #fff;
    outline-offset: 2px;
    z-index: 20 !important;
}

/* Red State: "Лишаємо старе" */
.agri-dot--old {
    background: var(--agri-color-old, #e53935);
}

.agri-dot--old .agri-dot-inner {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: #fff;
}

.agri-dot--old::after {
    content: "";
    position: absolute;
    left: 50%;
    top: 50%;
    width: calc(var(--agri-pulse-radius, 22px) * 2);
    height: calc(var(--agri-pulse-radius, 22px) * 2);
    border: 1px solid var(--agri-color-old, #e53935);
    border-radius: 50%;
    transform: translate(-50%, -50%);
    pointer-events: none;
    animation: agri-pulse 1.8s infinite;
}

/* Green State: "Апгрейд" */
.agri-dot--upgrade {
    background: var(--agri-color-up, #2e7d32);
    box-shadow: 0 2px 12px rgba(46, 125, 50, 0.45);
}

.agri-dot--upgrade .agri-dot-icon {
    color: #fff;
    font-size: 14px;
    font-weight: 800;
    line-height: 1;
}

.agri-dot--upgrade::after {
    content: "";
    position: absolute;
    left: 50%;
    top: 50%;
    width: calc(var(--agri-pulse-radius, 22px) * 2);
    height: calc(var(--agri-pulse-radius, 22px) * 2);
    border: 1px solid var(--agri-color-up, #2e7d32);
    border-radius: 50%;
    transform: translate(-50%, -50%);
    pointer-events: none;
    animation: agri-pulse 1.8s infinite;
}

@keyframes agri-pulse {
    0% {
        transform: translate(-50%, -50%) scale(0.6);
        opacity: 0.9;
    }
    100% {
        transform: translate(-50%, -50%) scale(1);
        opacity: 0;
    }
}

/* Desktop Popup Card (поверх або збоку) */
.agri-popup-card {
    position: absolute;
    top: 20px;
    right: 20px;
    width: 360px;
    max-width: calc(100% - 40px);
    max-height: calc(100% - 40px);
    background: #fff;
    border-radius: 12px;
    box-shadow: 0 10px 35px rgba(0,0,0,0.22);
    border: 1px solid #e1e4e8;
    z-index: 25;
    padding: 20px;
    overflow-y: auto;
    animation: agri-pop-in 0.2s cubic-bezier(0.16, 1, 0.3, 1);
    line-height: 1.5;
}

@keyframes agri-pop-in {
    from { opacity: 0; transform: translateY(-8px) scale(0.97); }
    to { opacity: 1; transform: translateY(0) scale(1); }
}

.agri-popup-close {
    position: absolute;
    top: 12px;
    right: 12px;
    width: 28px;
    height: 28px;
    border: none;
    background: #f0f0f1;
    color: #50575e;
    border-radius: 50%;
    font-size: 18px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.15s;
    line-height: 1;
}

.agri-popup-close:hover {
    background: #dcdcde;
    color: #111;
}

.agri-popup-state-badge,
.agri-sheet-state-badge {
    display: inline-block;
    font-size: 11px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    padding: 3px 8px;
    border-radius: 4px;
    margin-bottom: 6px;
}

.agri-badge--old {
    background: #ffebee;
    color: #c62828;
}

.agri-badge--upgrade {
    background: #e8f5e9;
    color: #2e7d32;
}

.agri-popup-title,
.agri-sheet-title {
    margin: 0 0 4px;
    font-size: 18px;
    font-weight: 700;
    color: #111;
    padding-right: 24px;
}

.agri-popup-subtitle,
.agri-sheet-subtitle {
    font-size: 13px;
    color: #2e7d32;
    font-weight: 600;
    margin-bottom: 12px;
}

/* Media (Відео, YouTube, GIF) */
.agri-media-frame {
    margin: 12px 0;
    border-radius: 8px;
    overflow: hidden;
    background: #000;
    position: relative;
}

.agri-media-frame img,
.agri-media-frame video {
    width: 100%;
    height: auto;
    display: block;
}

.agri-media-frame--embed {
    aspect-ratio: 16 / 9;
}

.agri-media-frame--embed iframe {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
}

.agri-popup-usp,
.agri-sheet-usp {
    font-size: 14px;
    line-height: 1.6;
    color: #3c434a;
    margin-bottom: 18px;
}

.agri-popup-usp p,
.agri-sheet-usp p {
    margin: 0 0 8px;
}

/* Action Buttons (Апгрейд vs Лишаємо старе) */
.agri-popup-actions,
.agri-sheet-actions {
    display: flex;
    gap: 10px;
}

.agri-btn-action {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    padding: 12px 14px;
    border-radius: 8px;
    font-size: 14px;
    font-weight: 700;
    cursor: pointer;
    border: 2px solid transparent;
    transition: all 0.15s ease;
    user-select: none;
}

.agri-action-icon {
    font-size: 15px;
    font-weight: 900;
}

/* Button: Лишаємо старе */
.agri-btn-action--old {
    background: #f6f7f7;
    color: #50575e;
    border-color: #dcdcde;
}

.agri-btn-action--old:hover {
    background: #ffebee;
    color: #c62828;
    border-color: #ffcdd2;
}

.agri-btn-action--old.agri-btn-action--active {
    background: #ffebee;
    color: #c62828;
    border-color: #e53935;
    box-shadow: 0 0 0 2px rgba(229, 57, 53, 0.2);
}

/* Button: Апгрейд */
.agri-btn-action--upgrade {
    background: #e8f5e9;
    color: #2e7d32;
    border-color: #a5d6a7;
}

.agri-btn-action--upgrade:hover {
    background: #2e7d32;
    color: #fff;
    border-color: #2e7d32;
}

.agri-btn-action--upgrade.agri-btn-action--active {
    background: #2e7d32;
    color: #fff;
    border-color: #1b5e20;
    box-shadow: 0 0 0 2px rgba(46, 125, 50, 0.25);
}

/* Mobile Bottom Sheet (Шторка) */
.agri-bottom-sheet {
    position: fixed;
    inset: 0;
    z-index: 99999;
}

.agri-sheet-overlay {
    position: absolute;
    inset: 0;
    background: rgba(0, 0, 0, 0.5);
    backdrop-filter: blur(2px);
    opacity: 0;
    transition: opacity 0.3s ease;
}

.agri-sheet-container {
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    background: #fff;
    border-radius: 20px 20px 0 0;
    max-height: 85vh;
    display: flex;
    flex-direction: column;
    transform: translateY(100%);
    transition: transform 0.3s cubic-bezier(0.16, 1, 0.3, 1);
    box-shadow: 0 -8px 32px rgba(0,0,0,0.25);
    padding-bottom: max(16px, env(safe-area-inset-bottom));
}

.agri-bottom-sheet.agri-sheet-open .agri-sheet-overlay {
    opacity: 1;
}

.agri-bottom-sheet.agri-sheet-open .agri-sheet-container {
    transform: translateY(0);
}

.agri-sheet-handle-bar {
    width: 100%;
    padding: 12px 0 6px;
    display: flex;
    justify-content: center;
    cursor: grab;
    touch-action: pan-y;
}

.agri-sheet-handle {
    width: 44px;
    height: 5px;
    background: #dcdcde;
    border-radius: 999px;
}

.agri-sheet-close {
    position: absolute;
    top: 14px;
    right: 14px;
    width: 32px;
    height: 32px;
    border-radius: 50%;
    background: #f0f0f1;
    border: none;
    font-size: 20px;
    color: #50575e;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    line-height: 1;
}

.agri-sheet-scrollable {
    overflow-y: auto;
    padding: 0 20px 16px;
    -webkit-overflow-scrolling: touch;
}

.agri-sheet-actions {
    padding: 12px 20px 8px;
    border-top: 1px solid #f0f0f1;
    background: #fff;
}

/* Sticky Bottom Bar */
.agri-sticky-bar {
    margin-top: 16px;
    background: #1d2327;
    color: #fff;
    border-radius: 12px;
    padding: 14px 20px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: 14px;
    box-shadow: 0 4px 16px rgba(0,0,0,0.12);
}

.agri-bar-info {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 15px;
}

.agri-bar-label {
    color: #c3c4c7;
}

.agri-bar-counter {
    font-size: 16px;
}

.agri-bar-counter strong {
    color: #46b450;
    font-size: 18px;
}

.agri-btn-get-quote {
    background: #2e7d32;
    color: #fff;
    border: none;
    border-radius: 8px;
    padding: 12px 24px;
    font-size: 15px;
    font-weight: 700;
    cursor: pointer;
    display: flex;
    align-items: center;
    transition: transform 0.15s, background 0.15s, box-shadow 0.15s;
    box-shadow: 0 2px 8px rgba(46, 125, 50, 0.4);
}

.agri-btn-get-quote:hover {
    background: #1b5e20;
    transform: translateY(-1px);
    box-shadow: 0 4px 14px rgba(46, 125, 50, 0.6);
}

.agri-btn-get-quote.agri-btn--has-selection {
    background: #2e7d32;
    animation: agri-pulse-btn 2.5s infinite;
}

@keyframes agri-pulse-btn {
    0%, 100% { box-shadow: 0 0 0 0 rgba(46, 125, 50, 0.5); }
    50% { box-shadow: 0 0 0 8px rgba(46, 125, 50, 0); }
}

/* Modal Lead Form */
.agri-lead-modal {
    position: fixed;
    inset: 0;
    z-index: 100000;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 16px;
}

.agri-lead-modal-overlay {
    position: absolute;
    inset: 0;
    background: rgba(0, 0, 0, 0.6);
    backdrop-filter: blur(4px);
    opacity: 0;
    transition: opacity 0.2s ease;
}

.agri-lead-modal-container {
    position: relative;
    width: 100%;
    max-width: 520px;
    max-height: 90vh;
    overflow-y: auto;
    background: #fff;
    border-radius: 16px;
    padding: 24px;
    box-shadow: 0 16px 48px rgba(0,0,0,0.3);
    transform: scale(0.94);
    opacity: 0;
    transition: transform 0.2s cubic-bezier(0.16, 1, 0.3, 1), opacity 0.2s ease;
}

.agri-lead-modal.agri-modal-open .agri-lead-modal-overlay {
    opacity: 1;
}

.agri-lead-modal.agri-modal-open .agri-lead-modal-container {
    transform: scale(1);
    opacity: 1;
}

.agri-lead-modal-close {
    position: absolute;
    top: 16px;
    right: 16px;
    width: 32px;
    height: 32px;
    border-radius: 50%;
    border: none;
    background: #f0f0f1;
    color: #50575e;
    font-size: 20px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    line-height: 1;
}

.agri-lead-modal-title {
    margin: 0 0 6px;
    font-size: 22px;
    font-weight: 700;
    color: #111;
}

.agri-lead-modal-desc {
    margin: 0 0 16px;
    font-size: 13px;
    color: #646970;
    line-height: 1.4;
}

/* Summary Box */
.agri-lead-summary {
    background: #f6f7f7;
    border-radius: 8px;
    padding: 12px 14px;
    margin-bottom: 18px;
    border: 1px solid #dcdcde;
}

.agri-summary-aggregate {
    font-size: 14px;
    margin-bottom: 8px;
}

.agri-summary-label {
    color: #646970;
}

.agri-summary-points-title {
    font-size: 12px;
    font-weight: 600;
    text-transform: uppercase;
    color: #50575e;
    margin-bottom: 6px;
}

.agri-summary-pills {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
}

.agri-pill {
    display: inline-flex;
    align-items: center;
    padding: 4px 10px;
    border-radius: 20px;
    font-size: 12px;
    font-weight: 600;
}

.agri-pill--upgrade {
    background: #e8f5e9;
    color: #2e7d32;
    border: 1px solid #c8e6c9;
}

.agri-pill--none {
    background: #fff;
    color: #646970;
    font-weight: normal;
    border: 1px dashed #c3c4c7;
}

/* Form inputs */
.agri-form-row {
    margin-bottom: 14px;
}

.agri-form-row--two {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 12px;
}

.agri-form-label {
    display: block;
    font-size: 13px;
    font-weight: 600;
    color: #2c3338;
    margin-bottom: 4px;
}

.agri-input,
.agri-textarea {
    width: 100%;
    padding: 10px 12px;
    border: 1px solid #8c8f94;
    border-radius: 6px;
    font-size: 14px;
    color: #1d2327;
    background: #fff;
    margin-top: 4px;
    transition: border-color 0.15s, box-shadow 0.15s;
}

.agri-input:focus,
.agri-textarea:focus {
    border-color: #2e7d32;
    outline: none;
    box-shadow: 0 0 0 2px rgba(46, 125, 50, 0.2);
}

.agri-quick-sections {
    display: flex;
    gap: 6px;
    margin: 6px 0;
    flex-wrap: wrap;
}

.agri-quick-btn {
    padding: 6px 12px;
    background: #f0f0f1;
    border: 1px solid #dcdcde;
    border-radius: 6px;
    font-size: 13px;
    font-weight: 600;
    color: #2c3338;
    cursor: pointer;
    transition: all 0.15s;
}

.agri-quick-btn:hover {
    background: #e0e0e0;
}

.agri-quick-btn--active {
    background: #2e7d32;
    color: #fff;
    border-color: #1b5e20;
}

.agri-input-hint {
    display: block;
    font-size: 11px;
    color: #646970;
    margin-top: 4px;
}

.agri-hp-field {
    display: none !important;
}

.agri-submit-btn {
    width: 100%;
    padding: 14px 20px;
    background: #2e7d32;
    color: #fff;
    border: none;
    border-radius: 8px;
    font-size: 16px;
    font-weight: 700;
    cursor: pointer;
    transition: background 0.15s, transform 0.15s;
    margin-top: 8px;
}

.agri-submit-btn:hover {
    background: #1b5e20;
}

.agri-submit-btn:disabled {
    opacity: 0.7;
    cursor: not-allowed;
}

.agri-form-alert {
    padding: 10px 14px;
    border-radius: 6px;
    font-size: 13px;
    margin-bottom: 12px;
}

.agri-alert--error {
    background: #ffebee;
    color: #c62828;
    border: 1px solid #ffcdd2;
}

.agri-lead-success-view {
    text-align: center;
    padding: 24px 0 12px;
}

.agri-success-icon {
    width: 60px;
    height: 60px;
    border-radius: 50%;
    background: #e8f5e9;
    color: #2e7d32;
    font-size: 32px;
    font-weight: 800;
    display: flex;
    align-items: center;
    justify-content: center;
    margin: 0 auto 16px;
}

/* ==========================================================================
   Catalog Grid Styles
   ========================================================================== */

.agri-catalog-wrap {
    max-width: 1200px;
    margin: 0 auto;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
}

.agri-catalog-heading {
    text-align: center;
    font-size: 26px;
    font-weight: 700;
    margin-bottom: 24px;
}

.agri-brand-tabs {
    display: flex;
    justify-content: center;
    gap: 8px;
    flex-wrap: wrap;
    margin-bottom: 28px;
}

.agri-brand-tab {
    padding: 8px 18px;
    border-radius: 24px;
    border: 1px solid #dcdcde;
    background: #fff;
    color: #50575e;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.15s;
}

.agri-brand-tab:hover {
    background: #f6f7f7;
    border-color: #8c8f94;
}

.agri-brand-tab--active {
    background: #1d2327;
    color: #fff;
    border-color: #1d2327;
}

.agri-catalog-grid {
    display: grid;
    grid-template-columns: repeat(var(--agri-cols, 3), 1fr);
    gap: 24px;
}

.agri-card {
    background: #fff;
    border-radius: 12px;
    overflow: hidden;
    border: 1px solid #e1e4e8;
    box-shadow: 0 4px 16px rgba(0,0,0,0.04);
    display: flex;
    flex-direction: column;
    transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.agri-card:hover {
    transform: translateY(-4px);
    box-shadow: 0 10px 24px rgba(0,0,0,0.08);
}

.agri-card-media {
    position: relative;
    aspect-ratio: 16 / 10;
    background: #f6f7f7;
    overflow: hidden;
    display: flex;
    align-items: center;
    justify-content: center;
}

.agri-card-media img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
}

.agri-card-brand {
    position: absolute;
    top: 12px;
    left: 12px;
    background: rgba(255, 255, 255, 0.92);
    backdrop-filter: blur(4px);
    color: #1b5e20;
    font-size: 11px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    padding: 3px 8px;
    border-radius: 4px;
}

.agri-card-body {
    padding: 18px;
    display: flex;
    flex-direction: column;
    flex: 1;
}

.agri-card-title {
    margin: 0 0 4px;
    font-size: 18px;
    font-weight: 700;
    color: #111;
}

.agri-card-model {
    font-size: 13px;
    color: #646970;
    margin-bottom: 12px;
}

.agri-card-meta {
    margin-top: auto;
    padding: 10px 0;
    border-top: 1px solid #f0f0f1;
    font-size: 13px;
    color: #2e7d32;
    font-weight: 600;
}

.agri-meta-points {
    display: flex;
    align-items: center;
    gap: 6px;
}

.agri-meta-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: #2e7d32;
}

.agri-card-footer {
    margin-top: 8px;
}

.agri-btn-select {
    display: block;
    width: 100%;
    text-align: center;
    padding: 10px;
    background: #f6f7f7;
    color: #1d2327;
    text-decoration: none;
    font-weight: 700;
    font-size: 14px;
    border-radius: 6px;
    transition: background 0.15s, color 0.15s;
}

.agri-btn-select:hover {
    background: #2e7d32;
    color: #fff;
}

/* ==========================================================================
   Responsive Adaptations
   ========================================================================== */

@media (max-width: 960px) {
    .agri-catalog-grid {
        grid-template-columns: repeat(2, 1fr) !important;
    }
}

@media (max-width: 768px) {
    .agri-popup-card {
        display: none !important; /* На смартфонах працює Bottom Sheet */
    }

    .agri-header {
        flex-direction: column;
        align-items: flex-start;
    }

    .agri-sticky-bar {
        flex-direction: column;
        align-items: stretch;
        text-align: center;
    }

    .agri-bar-info {
        justify-content: center;
    }

    .agri-btn-get-quote {
        justify-content: center;
        width: 100%;
    }

    .agri-form-row--two {
        grid-template-columns: 1fr;
    }
}

@media (max-width: 600px) {
    .agri-catalog-grid {
        grid-template-columns: 1fr !important;
    }

    .agri-title {
        font-size: 20px;
    }

    .agri-hint {
        font-size: 11px;
        padding: 4px 10px;
    }
}
