/**
 * aFFirmFirst Gutenberg Blocks — Editor Styles
 */

/* =========================================================================
   Shared: Block placeholder (no image selected)
   ========================================================================= */

.affirm-block-placeholder {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 40px 24px;
    background: linear-gradient(135deg, #f0fdf4 0%, #f8fafc 100%);
    border: 2px dashed #10b981;
    border-radius: 12px;
    text-align: center;
}

/* =========================================================================
   Block 1: affirm/image — preview
   ========================================================================= */

.affirm-block-preview {
    position: relative;
    border-radius: 8px;
    overflow: hidden;
    border: 1px solid #e2e8f0;
    background: #f8fafc;
}

.affirm-block-preview img {
    display: block;
    width: 100%;
    height: auto;
}

.affirm-block-badge {
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    padding: 6px 12px;
    background: rgba(0, 0, 0, 0.6);
    color: #10b981;
    font-size: 12px;
    font-weight: 600;
}

.affirm-block-no-thumb {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 32px;
    color: #94a3b8;
}

.affirm-block-no-thumb .dashicons {
    font-size: 48px;
    width: 48px;
    height: 48px;
    color: #10b981;
    margin-bottom: 8px;
}

/* =========================================================================
   Block 2: affirm/gallery — grid preview
   ========================================================================= */

.affirm-block-gallery-grid {
    border-radius: 8px;
    overflow: hidden;
}

.affirm-block-gallery-item {
    position: relative;
    aspect-ratio: 1;
    background: #f1f5f9;
    border-radius: 4px;
    overflow: hidden;
    border: 1px solid #e2e8f0;
}

.affirm-block-gallery-item img {
    display: block;
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.affirm-block-gallery-badge {
    position: absolute;
    top: 4px;
    left: 4px;
    width: 20px;
    height: 20px;
    border-radius: 50%;
    background: #10b981;
    color: #fff;
    font-size: 10px;
    font-weight: 700;
    display: flex;
    align-items: center;
    justify-content: center;
    line-height: 1;
}

.affirm-block-gallery-footer {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 8px 0;
    font-size: 12px;
    color: #64748b;
}

/* Template selector cards */
.affirm-block-template-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 8px;
    width: 100%;
    max-width: 400px;
}

.affirm-block-template-card {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 2px;
    padding: 14px 10px;
    border: 2px solid #e2e8f0;
    border-radius: 10px;
    background: #fff;
    cursor: pointer;
    transition: all 0.2s;
    text-align: center;
}

.affirm-block-template-card:hover {
    border-color: #10b981;
    background: #f0fdf4;
}

.affirm-block-template-card--active {
    border-color: #10b981;
    background: #f0fdf4;
    box-shadow: 0 0 0 1px #10b981;
}

/* Gallery header bar */
.affirm-block-gallery-header {
    display: flex;
    align-items: center;
    padding: 8px 0;
    font-size: 13px;
    color: #1e293b;
    gap: 4px;
    margin-bottom: 4px;
}

.affirm-block-gallery-template-badge {
    display: inline-block;
    padding: 2px 8px;
    background: #f0fdf4;
    color: #10b981;
    border-radius: 4px;
    font-size: 11px;
    font-weight: 600;
    margin-left: 8px;
}

.affirm-block-gallery-feature-badge {
    display: inline-block;
    padding: 2px 8px;
    background: #eff6ff;
    color: #3b82f6;
    border-radius: 4px;
    font-size: 11px;
    font-weight: 600;
    margin-left: 4px;
}

/* Caption preview in editor */
.affirm-block-gallery-caption {
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    padding: 4px 6px;
    background: rgba(255, 255, 255, 0.9);
    font-size: 10px;
    color: #475569;
    text-align: center;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* Masonry preview in editor */
.affirm-block-gallery-grid--masonry .affirm-block-gallery-item {
    break-inside: avoid;
    aspect-ratio: auto;
}

.affirm-block-gallery-grid--masonry .affirm-block-gallery-item:nth-child(odd) {
    aspect-ratio: 3/4;
}

.affirm-block-gallery-grid--masonry .affirm-block-gallery-item:nth-child(even) {
    aspect-ratio: 4/3;
}

/* Gallery item controls in sidebar */
.affirm-block-gallery-item-control {
    display: flex;
    align-items: center;
    gap: 4px;
    padding: 4px 0;
    border-bottom: 1px solid #f1f5f9;
}

.affirm-block-gallery-item-control:last-child {
    border-bottom: none;
}

/* =========================================================================
   Image Picker Modal (used by blocks)
   ========================================================================= */

.affirm-block-picker-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.6);
    z-index: 100100;
    display: flex;
    align-items: center;
    justify-content: center;
}

.affirm-block-picker-modal {
    background: #fff;
    border-radius: 12px;
    width: 720px;
    max-width: 90vw;
    max-height: 80vh;
    display: flex;
    flex-direction: column;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
    overflow: hidden;
}

.affirm-block-picker-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 16px 20px;
    border-bottom: 1px solid #e2e8f0;
}

.affirm-block-picker-close {
    background: none;
    border: none;
    font-size: 24px;
    cursor: pointer;
    color: #94a3b8;
    padding: 0 4px;
    line-height: 1;
}

.affirm-block-picker-close:hover {
    color: #1e293b;
}

.affirm-block-picker-toolbar {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 20px;
    border-bottom: 1px solid #f1f5f9;
}

.affirm-block-picker-search {
    flex: 1;
    padding: 8px 12px;
    border: 1px solid #e2e8f0;
    border-radius: 6px;
    font-size: 13px;
    outline: none;
}

.affirm-block-picker-search:focus {
    border-color: #10b981;
    box-shadow: 0 0 0 2px rgba(16, 185, 129, 0.15);
}

.affirm-block-picker-count {
    font-size: 12px;
    color: #94a3b8;
    white-space: nowrap;
}

.affirm-block-picker-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(120px, 1fr));
    gap: 8px;
    padding: 16px 20px;
    overflow-y: auto;
    flex: 1;
    min-height: 200px;
}

.affirm-block-picker-item {
    position: relative;
    cursor: pointer;
    border-radius: 8px;
    border: 2px solid transparent;
    overflow: hidden;
    background: #f8fafc;
    transition: all 0.15s;
}

.affirm-block-picker-item:hover {
    border-color: #cbd5e1;
    background: #f1f5f9;
}

.affirm-block-picker-item-selected {
    border-color: #10b981 !important;
    box-shadow: 0 0 0 1px #10b981;
    background: #f0fdf4;
}

.affirm-block-picker-thumb {
    width: 100%;
    aspect-ratio: 1;
    background: #e2e8f0;
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
}

.affirm-block-picker-thumb img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.affirm-block-picker-label {
    padding: 4px 6px;
    font-size: 11px;
    color: #475569;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    text-align: center;
}

.affirm-block-picker-badge {
    position: absolute;
    top: 6px;
    right: 6px;
    z-index: 2;
    width: 22px;
    height: 22px;
    border-radius: 50%;
    background: #10b981;
    color: #fff;
    font-size: 11px;
    font-weight: 700;
    display: flex;
    align-items: center;
    justify-content: center;
    line-height: 1;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.2);
    pointer-events: none;
}

.affirm-block-picker-footer {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 12px 20px;
    border-top: 1px solid #e2e8f0;
    background: #f8fafc;
}

.affirm-block-picker-selected-count {
    font-size: 13px;
    color: #10b981;
    font-weight: 600;
}

.affirm-block-picker-insert {
    background: #10b981 !important;
    border-color: #10b981 !important;
    color: #fff !important;
}

.affirm-block-picker-insert:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.affirm-block-picker-insert:hover:not(:disabled) {
    background: #059669 !important;
    border-color: #059669 !important;
}
