/* BeforeAfter jQuery Component Styles - nhance.com Theme */

.ba-container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 2rem;
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    background: #f8f9fa;
}

.ba-header-card {
    background: linear-gradient(135deg, #ffffff 0%, #f8f9fa 100%);
    border: none;
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.08);
    text-align: center;
    /* Reduce excess vertical whitespace above the title (especially when logo isn't shown) */
    padding: 1.75rem 1.5rem;
}

.ba-logo-container {
    /* Keep this compact so it doesn't create a big empty gap when logo is hidden */
    margin-bottom: 0.75rem;
    display: flex;
    justify-content: center;
    align-items: center;
    min-height: 0;
}

.ba-logo {
    max-width: 250px;
    height: auto;
    margin: 0 auto;
    display: block;
    max-height: 80px;
    width: auto;
}

.ba-logo-text {
    text-align: center;
    display: block;
}

.ba-logo-title {
    font-size: 2.5rem;
    font-weight: 700;
    color: #1a5490;
    margin: 0;
    letter-spacing: -1px;
}

.ba-logo-subtitle {
    font-size: 1rem;
    color: #6c757d;
    margin: 0.25rem 0 0 0;
    font-weight: 500;
    text-transform: uppercase;
    letter-spacing: 2px;
}

.ba-header-content h1 {
    background: linear-gradient(135deg, #1a5490 0%, #0d3a6b 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    margin-bottom: 1rem;
}

.ba-subtitle {
    font-size: 1.1rem;
    line-height: 1.6;
    max-width: 600px;
    margin: 0 auto;
}

/* Share actions (share/vote page) */
.ba-share-actions {
    margin-top: 1.25rem;
    display: flex;
    flex-wrap: wrap;
    gap: 0.6rem;
    align-items: center;
    justify-content: center;
}

.ba-share-actions .ba-btn {
    padding: 0.6rem 1rem;
    font-size: 0.95rem;
}

.ba-share-status {
    margin-top: 0.65rem;
    text-align: center;
    color: #2c3e50;
    font-size: 0.9rem;
    min-height: 1.2em;
}

.ba-card {
    background: #ffffff;
    border-radius: 8px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.08);
    padding: 2rem;
    margin-bottom: 1.5rem;
    border: 1px solid #e9ecef;
}

.ba-maintenance-card {
    text-align: center;
    padding: 3rem 2rem;
}

.ba-btn {
    display: inline-block;
    padding: 0.75rem 1.5rem;
    font-size: 1rem;
    font-weight: 500;
    text-align: center;
    border: none;
    border-radius: 0.375rem;
    cursor: pointer;
    transition: all 0.2s;
    text-decoration: none;
}

.ba-btn-primary {
    background: linear-gradient(135deg, #1a5490 0%, #0d3a6b 100%);
    color: white;
    font-weight: 600;
    box-shadow: 0 2px 4px rgba(26, 84, 144, 0.2);
}

.ba-btn-primary:hover:not(:disabled) {
    background: linear-gradient(135deg, #0d3a6b 0%, #08284d 100%);
    box-shadow: 0 4px 8px rgba(26, 84, 144, 0.3);
    transform: translateY(-1px);
}

.ba-btn-primary:disabled {
    opacity: 0.6;
    cursor: not-allowed;
}

.ba-btn-secondary {
    background-color: #6c757d;
    color: white;
    font-weight: 600;
}

.ba-btn-secondary:hover:not(:disabled) {
    background-color: #5a6268;
    transform: translateY(-1px);
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
}

.ba-input-group {
    margin-bottom: 1rem;
}

.ba-label {
    display: block;
    font-weight: 600;
    margin-bottom: 0.5rem;
    color: #2c3e50;
    font-size: 0.95rem;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.ba-input {
    width: 100%;
    padding: 0.875rem;
    border: 2px solid #dee2e6;
    border-radius: 6px;
    font-size: 1rem;
    transition: all 0.2s;
    box-sizing: border-box;
    background: #ffffff;
    color: #212529;
}

.ba-input:focus {
    outline: none;
    border-color: #1a5490;
    box-shadow: 0 0 0 3px rgba(26, 84, 144, 0.1);
    background: #ffffff;
}

.ba-input::placeholder {
    color: #adb5bd;
}

.ba-error {
    color: #ef4444;
    font-size: 0.875rem;
    margin-top: 0.25rem;
}

.ba-success {
    color: #10b981;
    font-size: 0.875rem;
    margin-top: 0.25rem;
}

.ba-loading {
    display: inline-block;
    width: 1rem;
    height: 1rem;
    border: 2px solid rgba(255, 255, 255, 0.3);
    border-radius: 50%;
    border-top-color: white;
    animation: ba-spin 0.6s linear infinite;
}

@keyframes ba-spin {
    to { transform: rotate(360deg); }
}

.ba-image-container {
    position: relative;
    width: 100%;
    margin-bottom: 1rem;
}

.ba-image-preview {
    width: 100%;
    max-width: 100%;
    height: auto;
    border-radius: 8px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
    border: 1px solid #e9ecef;
}

.ba-text-center {
    text-align: center;
}

.ba-text-secondary {
    color: #6c757d;
    font-size: 0.95rem;
}

.ba-mb-2 {
    margin-bottom: 1rem;
}

.ba-mt-2 {
    margin-top: 1rem;
}

.ba-grid {
    display: grid;
    gap: 1.5rem;
}

.ba-grid-2 {
    grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
}

h1 {
    font-size: 2.5rem;
    font-weight: 700;
    margin-bottom: 0.5rem;
    color: #1a1a1a;
    letter-spacing: -0.5px;
}

h2 {
    font-size: 1.75rem;
    font-weight: 600;
    margin-bottom: 1rem;
    color: #2c3e50;
}

h3 {
    font-size: 1.25rem;
    font-weight: 600;
    color: #34495e;
}

/* Color Selector Styles */
.ba-selected-preview {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 1rem;
    background: linear-gradient(135deg, #f8f9fa 0%, #e9ecef 100%);
    border-radius: 8px;
    margin-bottom: 1rem;
    border: 1px solid #dee2e6;
}

.ba-color-swatch-large {
    width: 3rem;
    height: 3rem;
    border-radius: 0.25rem;
    border: 2px solid #e2e8f0;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
}

.ba-selected-label {
    font-weight: 500;
    color: #1e293b;
}

.ba-color-selector,
.ba-style-selector {
    max-height: 400px;
    overflow-y: auto;
    padding: 1rem;
    border: 2px solid #e9ecef;
    border-radius: 8px;
    background-color: #f8f9fa;
}

.ba-color-group,
.ba-style-group {
    margin-bottom: 1.5rem;
}

.ba-color-group:last-child,
.ba-style-group:last-child {
    margin-bottom: 0;
}

.ba-color-group-title,
.ba-style-group-title {
    font-size: 0.875rem;
    font-weight: 700;
    color: #495057;
    text-transform: uppercase;
    letter-spacing: 1px;
    margin-bottom: 1rem;
    padding-bottom: 0.75rem;
    border-bottom: 2px solid #dee2e6;
}

.ba-color-swatches {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(100px, 1fr));
    gap: 0.75rem;
}

.ba-color-option {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.5rem;
    padding: 1rem;
    border: 2px solid #dee2e6;
    border-radius: 8px;
    background-color: white;
    cursor: pointer;
    transition: all 0.3s ease;
}

.ba-color-option:hover {
    border-color: #1a5490;
    transform: translateY(-3px);
    box-shadow: 0 8px 16px rgba(26, 84, 144, 0.15);
}

.ba-color-option.selected {
    border-color: #1a5490;
    background: linear-gradient(135deg, #e8f0f7 0%, #d1e1ef 100%);
    box-shadow: 0 0 0 3px rgba(26, 84, 144, 0.2), 0 4px 12px rgba(26, 84, 144, 0.15);
}

.ba-color-swatch {
    width: 3rem;
    height: 3rem;
    border-radius: 0.25rem;
    border: 1px solid rgba(0, 0, 0, 0.1);
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
}

.ba-color-name {
    font-size: 0.75rem;
    text-align: center;
    color: #1e293b;
    font-weight: 500;
}

.ba-style-options {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(120px, 1fr));
    gap: 0.75rem;
}

.ba-style-option {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.5rem;
    padding: 1.25rem;
    border: 2px solid #dee2e6;
    border-radius: 8px;
    background-color: white;
    cursor: pointer;
    transition: all 0.3s ease;
}

.ba-style-option:hover {
    border-color: #1a5490;
    transform: translateY(-3px);
    box-shadow: 0 8px 16px rgba(26, 84, 144, 0.15);
}

.ba-style-option.selected {
    border-color: #1a5490;
    background: linear-gradient(135deg, #e8f0f7 0%, #d1e1ef 100%);
    box-shadow: 0 0 0 3px rgba(26, 84, 144, 0.2), 0 4px 12px rgba(26, 84, 144, 0.15);
}

.ba-style-icon {
    font-size: 2rem;
    color: #1e293b;
    line-height: 1;
}

.ba-style-name {
    font-size: 0.875rem;
    text-align: center;
    color: #1e293b;
    font-weight: 500;
}

/* Scrollbar styling */
.ba-color-selector::-webkit-scrollbar,
.ba-style-selector::-webkit-scrollbar {
    width: 8px;
}

.ba-color-selector::-webkit-scrollbar-track,
.ba-style-selector::-webkit-scrollbar-track {
    background: #f1f1f1;
    border-radius: 4px;
}

.ba-color-selector::-webkit-scrollbar-thumb,
.ba-style-selector::-webkit-scrollbar-thumb {
    background: #cbd5e1;
    border-radius: 4px;
}

.ba-color-selector::-webkit-scrollbar-thumb:hover,
.ba-style-selector::-webkit-scrollbar-thumb:hover {
    background: #94a3b8;
}

/* Image Clickable Style */
.ba-image-clickable {
    cursor: pointer;
    transition: opacity 0.2s;
}

.ba-image-clickable:hover {
    opacity: 0.9;
}

/* Generation History (all generated images) */
.ba-history-section {
    margin-top: 2rem;
    padding-top: 1.5rem;
    border-top: 1px solid #e9ecef;
}

/* Gallery tiles (more gallery-like than full cards) */
.ba-gallery-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    gap: 1rem;
}

.ba-gallery-tile {
    display: block;
    width: 100%;
    text-align: left;
    border: 1px solid #e9ecef;
    border-radius: 10px;
    background: #ffffff;
    padding: 0;
    overflow: hidden;
    cursor: pointer;
    transition: transform 0.15s ease, box-shadow 0.15s ease, border-color 0.15s ease;
}

.ba-gallery-tile:hover {
    transform: translateY(-2px);
    border-color: rgba(26, 84, 144, 0.35);
    box-shadow: 0 8px 18px rgba(0, 0, 0, 0.10);
}

.ba-gallery-thumb-wrap {
    position: relative;
    background: #f8f9fa;
}

.ba-gallery-thumb {
    width: 100%;
    height: 180px;
    object-fit: cover;
    display: block;
}

.ba-gallery-badge {
    position: absolute;
    top: 0.5rem;
    left: 0.5rem;
    background: rgba(0, 0, 0, 0.65);
    color: #fff;
    font-size: 0.8rem;
    font-weight: 700;
    padding: 0.25rem 0.5rem;
    border-radius: 999px;
}

.ba-gallery-tile-meta {
    padding: 0.75rem 0.85rem;
    display: grid;
    gap: 0.35rem;
}

.ba-gallery-tile-line {
    font-size: 0.9rem;
    color: #212529;
    word-break: break-word;
}

.ba-gallery-tile-time {
    margin-top: 0.25rem;
    font-size: 0.8rem;
    color: #6c757d;
}

.ba-gallery-label {
    font-weight: 800;
    color: #34495e;
}

/* Gallery modal */
.ba-gallery-modal-content {
    max-width: 1400px;
    width: min(1400px, 96vw);
    max-height: 92vh;
    padding: 1rem; /* override base modal padding to maximize image area */
    /* Override base modal flex row so the image doesn't get squeezed by side text */
    display: flex;
    flex-direction: column;
    align-items: stretch;
    justify-content: flex-start;
    background: rgba(255, 255, 255, 0.96);
    border-radius: 14px;
    box-shadow: 0 20px 25px -5px rgb(0 0 0 / 0.30), 0 10px 10px -5px rgb(0 0 0 / 0.20);
}

.ba-gallery-modal-content .ba-compare {
    /* Shrink-wrap to the image so we don't get stretched black bars */
    display: inline-block;
    width: auto;
    max-width: 100%;
    margin: 0 auto;
    background: transparent;
}

.ba-gallery-modal-content .ba-compare-img {
    width: auto;
    height: auto;
    max-width: 100%;
    max-height: calc(92vh - 260px);
    object-fit: contain;
}

/* Ensure the overlay (after) matches the computed compare container width */
.ba-gallery-modal-content .ba-compare-after {
    width: 100%;
    height: auto;
}

.ba-gallery-modal-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: 1rem;
    margin-bottom: 0.75rem;
}

.ba-gallery-modal-title {
    font-weight: 800;
    font-size: 1.1rem;
    color: #2c3e50;
}

.ba-gallery-modal-meta {
    font-size: 0.9rem;
    color: #6c757d;
}

.ba-gallery-modal-details {
    margin-top: 0.75rem;
    display: grid;
    gap: 0.35rem;
}

.ba-gallery-modal-detail {
    font-size: 0.95rem;
    color: #212529;
    word-break: break-word;
}

/* Share page vote row */
.ba-share-vote-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.75rem;
    margin-top: 0.5rem;
}

.ba-share-vote-count {
    font-size: 0.9rem;
    color: #6c757d;
    white-space: nowrap;
}

.ba-share-enlarge-btn {
    position: absolute;
    top: 1rem;
    right: 1rem;
    padding: 0.45rem 0.75rem;
    font-size: 0.85rem;
    border-radius: 999px;
    box-shadow: 0 6px 14px rgba(0,0,0,0.18);
    z-index: 6;
    opacity: 0.92;
}

.ba-share-enlarge-btn:hover {
    opacity: 1;
}

/* Before/After compare slider */
.ba-compare {
    position: relative;
    width: 100%;
    overflow: hidden;
    border-radius: 10px;
    border: 1px solid #e9ecef;
    background: #000;
    touch-action: none; /* allow smooth dragging on touch */
}

/* Share page "large compare" modal */
body.ba-modal-open {
    overflow: hidden;
}

.ba-share-modal-content {
    width: min(1200px, 96vw);
    max-width: min(1200px, 96vw);
    max-height: 92vh;
    padding: 1.25rem;
    align-items: stretch;
}

.ba-share-modal-inner {
    width: 100%;
    height: 100%;
    display: grid;
    gap: 0.75rem;
}

.ba-share-compare-large {
    width: 100%;
    max-height: calc(92vh - 120px);
}

.ba-share-compare-large .ba-compare-img {
    width: 100%;
    height: auto;
    max-height: calc(92vh - 160px);
    object-fit: contain;
}

.ba-compare-img {
    width: 100%;
    height: auto;
    object-fit: initial;
    display: block;
    background: transparent;
}

.ba-compare-after {
    position: absolute;
    top: 0;
    left: 0;
    z-index: 2;
    /* clip-path is controlled by JS to reveal the desired portion */
    clip-path: inset(0 0 0 50%);
}

/* Vertical divider + handle */
.ba-compare-divider {
    position: absolute;
    top: 0;
    bottom: 0;
    left: 50%;
    transform: translateX(-50%);
    width: 0;
    z-index: 4;
    pointer-events: none; /* handle will capture */
}

.ba-compare-divider::before {
    content: "";
    position: absolute;
    top: 0;
    bottom: 0;
    left: -1px;
    width: 2px;
    background: rgba(255, 255, 255, 0.85);
    box-shadow: 0 2px 10px rgba(0,0,0,0.35);
}

.ba-compare-handle {
    position: absolute;
    top: 50%;
    left: 0;
    transform: translate(-50%, -50%);
    width: 42px;
    height: 42px;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.95);
    border: 3px solid #1a5490;
    box-shadow: 0 8px 18px rgba(0,0,0,0.25);
    pointer-events: auto;
    cursor: ew-resize;
    display: grid;
    place-items: center;
}

.ba-compare-handle::before {
    /* Center grip bar */
    content: "";
    width: 3px;
    height: 18px;
    background: #1a5490;
    border-radius: 2px;
    opacity: 0.95;
}

.ba-compare-handle::after {
    /* Left/right chevrons (pure CSS, avoids unicode glyph issues) */
    content: "";
    position: absolute;
    inset: 0;
    margin: auto;
    width: 24px;
    height: 14px;
    background:
        linear-gradient(135deg, transparent 50%, #1a5490 51%) left center/7px 7px no-repeat,
        linear-gradient(225deg, transparent 50%, #1a5490 51%) left center/7px 7px no-repeat,
        linear-gradient(45deg, transparent 50%, #1a5490 51%) right center/7px 7px no-repeat,
        linear-gradient(315deg, transparent 50%, #1a5490 51%) right center/7px 7px no-repeat;
    opacity: 0.95;
    pointer-events: none;
}

/* In enlarged compare views: remove only the left/right chevrons (they read like "text"),
   but keep the center grip bar so the handle doesn't look empty. */
.ba-gallery-modal-content .ba-compare-handle::after,
.ba-share-modal-content .ba-compare-handle::after {
    display: none;
    content: none;
}

.ba-compare-slider {
    position: absolute;
    left: 0;
    bottom: 0;
    width: 100%;
    margin: 0;
    padding: 0.75rem 0.85rem;
    box-sizing: border-box;
    background: linear-gradient(to top, rgba(0,0,0,0.75), rgba(0,0,0,0));
    -webkit-appearance: none;
    appearance: none;
    height: 2.5rem;
    z-index: 5;
    opacity: 0; /* keep for keyboard accessibility, hide visually */
}

.ba-compare-slider:focus {
    outline: none;
}

.ba-compare-slider::-webkit-slider-thumb {
    -webkit-appearance: none;
    appearance: none;
    width: 18px;
    height: 18px;
    border-radius: 50%;
    background: #ffffff;
    border: 3px solid #1a5490;
    box-shadow: 0 2px 6px rgba(0,0,0,0.35);
    cursor: ew-resize;
}

.ba-compare-slider::-webkit-slider-runnable-track {
    height: 4px;
    background: rgba(255,255,255,0.45);
    border-radius: 999px;
}

.ba-compare-slider::-moz-range-thumb {
    width: 18px;
    height: 18px;
    border-radius: 50%;
    background: #ffffff;
    border: 3px solid #1a5490;
    box-shadow: 0 2px 6px rgba(0,0,0,0.35);
    cursor: ew-resize;
}

.ba-compare-slider::-moz-range-track {
    height: 4px;
    background: rgba(255,255,255,0.45);
    border-radius: 999px;
}

/* Image Modal Styles */
.ba-modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    /* Ensure modals appear above host-site headers/navbars */
    z-index: 2147483640;
    display: flex;
    align-items: center;
    justify-content: center;
}

/* Gallery "enlarge" modal: anchor to top with safe padding so bottom details remain visible */
#ba-gallery-modal.ba-modal {
    align-items: flex-start;
    padding-top: 80px;
    padding-bottom: 24px;
    box-sizing: border-box;
}

.ba-modal-overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.85);
    backdrop-filter: blur(4px);
}

.ba-modal-content {
    position: relative;
    z-index: 10001;
    max-width: 90%;
    max-height: 90%;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 2rem;
}

/* IMPORTANT: override base `.ba-modal-content` (defined above) so gallery "enlarge" view
   uses a vertical layout and the details don't squeeze the image. */
.ba-modal-content.ba-gallery-modal-content {
    /* Use grid so details can never sit beside the image (even if flex styles leak in) */
    display: grid !important;
    grid-template-rows: auto 1fr auto;
    align-items: stretch !important;
    justify-content: stretch !important;
    /* Slightly smaller overall modal so it doesn't feel overwhelming */
    max-width: 1200px;
    width: min(1200px, 92vw);
    /* Keep the enlarged view safely below any fixed host-site header */
    max-height: calc(100vh - 160px);
    margin-top: 0;
    margin-bottom: 0;
    padding: 1rem; /* maximize image area */
    background: rgba(255, 255, 255, 0.96);
    border-radius: 14px;
    box-shadow: 0 20px 25px -5px rgb(0 0 0 / 0.30), 0 10px 10px -5px rgb(0 0 0 / 0.20);
}

.ba-modal-content.ba-gallery-modal-content .ba-gallery-modal-header {
    width: 100%;
}

.ba-modal-content.ba-gallery-modal-content .ba-compare {
    justify-self: center;
    align-self: center;
}

.ba-modal-content.ba-gallery-modal-content .ba-compare-img {
    /* Give the image more room; details will scroll in a small strip below */
    max-height: calc(100vh - 160px - 170px);
}

.ba-modal-content.ba-gallery-modal-content .ba-gallery-modal-details {
    margin-top: 0.75rem;
    max-height: 120px;
    overflow: auto;
    background: #f8f9fa;
    border: 1px solid #e9ecef;
    border-radius: 10px;
    padding: 0.65rem 0.75rem;
    color: #0f172a;
}

.ba-modal-content.ba-gallery-modal-content .ba-gallery-modal-detail {
    font-size: 0.9rem;
    line-height: 1.3;
    white-space: normal;
}

.ba-modal-image {
    max-width: 100%;
    max-height: 90vh;
    object-fit: contain;
    border-radius: 0.5rem;
    box-shadow: 0 20px 25px -5px rgb(0 0 0 / 0.3), 0 10px 10px -5px rgb(0 0 0 / 0.2);
}

.ba-modal-close {
    position: absolute;
    top: 1rem;
    right: 1rem;
    background: rgba(255, 255, 255, 0.9);
    border: none;
    border-radius: 50%;
    width: 40px;
    height: 40px;
    font-size: 24px;
    line-height: 1;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 10002;
    transition: all 0.2s;
    color: #1e293b;
}

.ba-modal-close:hover {
    background: white;
    transform: scale(1.1);
}

