/* ═══ Image Generator Page — Modern UI ═══ */

@keyframes spin { to { transform: rotate(360deg); } }

/* ═══ Tab Bar ═══ */
.ig-tab-bar {
    display: flex;
    position: relative;
    background: #F3F4F6;
    border-radius: 12px;
    padding: 4px;
    margin-bottom: 20px;
    gap: 2px;
}
.ig-tab-btn {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    padding: 10px 16px;
    font-size: 0.85rem;
    font-weight: 500;
    color: #6B7280;
    background: transparent;
    border: none;
    border-radius: 10px;
    cursor: pointer;
    transition: all 0.25s ease;
    position: relative;
    z-index: 1;
    white-space: nowrap;
}
.ig-tab-btn:hover:not(.active) {
    color: #374151;
    background: rgba(255,255,255,0.5);
}
.ig-tab-btn.active {
    color: #1F2937;
    font-weight: 600;
    background: #fff;
    box-shadow: 0 1px 3px rgba(0,0,0,0.08), 0 1px 2px rgba(0,0,0,0.06);
}
.ig-tab-btn svg {
    flex-shrink: 0;
}
.ig-tab-count {
    font-size: 0.68rem;
    background: #E5E7EB;
    color: #6B7280;
    padding: 1px 7px;
    border-radius: 10px;
    margin-left: 4px;
}
.ig-tab-btn.active .ig-tab-count {
    background: #FEF3C7;
    color: #92400E;
}

/* ═══ Section Card (grouping container) ═══ */
.ig-section-card {
    background: #FAFAFA;
    border: 1px solid #EBEBEB;
    border-radius: 12px;
    padding: 16px 18px;
}
.ig-section-label {
    font-size: 0.7rem;
    font-weight: 700;
    color: #9CA3AF;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    margin-bottom: 10px;
    display: block;
}

/* ═══ Card Selector ═══ */
.ig-card-selector {
    position: relative;
    cursor: pointer;
    border-radius: 12px;
    padding: 12px 14px;
    border: 2px solid #E5E7EB;
    background: #fff;
    transition: all 0.2s ease;
    text-align: center;
}
.ig-card-selector:hover {
    border-color: #D1D5DB;
    box-shadow: 0 2px 8px rgba(0,0,0,0.04);
    transform: translateY(-1px);
}
.ig-card-selector.selected {
    border-color: #F59E0B;
    background: #FFFBEB;
    box-shadow: 0 2px 12px rgba(245,158,11,0.15);
}
.ig-card-selector.compact {
    padding: 10px 14px;
    flex: 1;
    min-width: 90px;
}
.ig-card-check {
    position: absolute;
    top: 6px;
    right: 6px;
    width: 20px;
    height: 20px;
    border-radius: 50%;
    background: #F59E0B;
    display: flex;
    align-items: center;
    justify-content: center;
}
.ig-card-grid-3 {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
    gap: 10px;
}

/* ═══ Segmented Control ═══ */
.ig-segmented-control {
    display: flex;
    background: #F3F4F6;
    border-radius: 10px;
    padding: 3px;
    gap: 2px;
    flex-wrap: wrap;
}
.ig-seg-btn {
    flex: 1;
    min-width: 0;
    padding: 7px 12px;
    font-size: 0.78rem;
    font-weight: 500;
    color: #6B7280;
    background: transparent;
    border: 1.5px solid transparent;
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.15s ease;
    white-space: nowrap;
    text-align: center;
}
.ig-seg-btn:hover:not(.active) {
    color: #374151;
    background: rgba(108, 99, 255, 0.06);
}
.ig-seg-btn.active {
    background: #EDE7FF;
    color: #6C63FF;
    font-weight: 600;
    border: 1.5px solid #6C63FF;
    box-shadow: none;
}

/* ═══ Toggle Switch ═══ */
.ig-toggle-switch {
    position: relative;
    display: inline-flex;
    align-items: center;
    gap: 8px;
    cursor: pointer;
}
.ig-toggle-switch input {
    opacity: 0;
    width: 0;
    height: 0;
    position: absolute;
}
.ig-toggle-slider {
    position: relative;
    width: 44px;
    height: 24px;
    background: #D1D5DB;
    border-radius: 24px;
    transition: all 0.3s ease;
    flex-shrink: 0;
}
.ig-toggle-slider::after {
    content: '';
    position: absolute;
    width: 18px;
    height: 18px;
    left: 3px;
    bottom: 3px;
    background: white;
    border-radius: 50%;
    transition: transform 0.3s ease;
    box-shadow: 0 1px 3px rgba(0,0,0,0.15);
}
.ig-toggle-switch input:checked + .ig-toggle-slider {
    background: #F59E0B;
}
.ig-toggle-switch input:checked + .ig-toggle-slider::after {
    transform: translateX(20px);
}
.ig-toggle-label {
    font-size: 0.82rem;
    font-weight: 500;
    color: #6B7280;
}

/* ═══ Modern Input ═══ */
.ig-modern-input {
    width: 100%;
    padding: 10px 14px;
    font-size: 0.85rem;
    border: 1.5px solid #E2E8F0;
    border-radius: 8px;
    background: #fff;
    color: #374151;
    outline: none;
    transition: all 0.2s ease;
    font-family: inherit;
    box-sizing: border-box;
}
.ig-modern-input:focus {
    border-color: #F59E0B;
    box-shadow: 0 0 0 3px rgba(245,158,11,0.1);
}
.ig-modern-input::placeholder {
    color: #9CA3AF;
}
textarea.ig-modern-input {
    resize: vertical;
}

/* ═══ Topic Row ═══ */
.ig-topic-row {
    display: flex;
    gap: 10px;
    align-items: flex-start;
    margin-bottom: 0;
}
.ig-topic-row .ig-textarea {
    flex: 1;
    min-width: 0;
    min-height: 60px;
}
.ig-topic-row .ig-generate-btn {
    width: auto;
    min-width: 160px;
    margin-top: 0;
    padding: 13px 20px;
    flex-shrink: 0;
}

/* ═══ Textarea ═══ */
.ig-textarea {
    width: 100%;
    padding: 12px 16px;
    font-size: 0.9rem;
    border: 1.5px solid #D1D5DB;
    border-radius: 12px;
    background: white;
    outline: none;
    transition: all 0.15s ease;
    resize: none;
    font-family: inherit;
    color: #374151;
    box-sizing: border-box;
}
.ig-textarea:focus {
    border-color: #F59E0B;
    box-shadow: 0 0 0 3px rgba(245,158,11,0.1);
}
.ig-textarea::placeholder {
    color: #9CA3AF;
}

/* ═══ Generate Button ═══ */
.ig-generate-btn {
    padding: 12px 24px;
    font-size: 0.9rem;
    font-weight: 600;
    border-radius: 12px;
    background: linear-gradient(135deg, #F97316, #EA580C);
    color: white;
    border: none;
    cursor: pointer;
    transition: all 0.2s ease;
    box-shadow: 0 2px 8px rgba(249,115,22,0.3);
    white-space: nowrap;
}
.ig-generate-btn:hover:not(:disabled) {
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(249,115,22,0.4);
    background: linear-gradient(135deg, #EA580C, #DC4E08);
}
.ig-generate-btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
    transform: none;
    box-shadow: none;
    background: #D1D5DB;
}

/* ═══ Suggestion Chips ═══ */
.ig-chip {
    padding: 5px 12px;
    font-size: 0.73rem;
    border-radius: 16px;
    border: 1px solid #E5E7EB;
    background: white;
    color: #6B7280;
    cursor: pointer;
    transition: all 0.15s ease;
    display: inline-block;
    margin: 0;
}
.ig-chip:hover {
    border-color: #F59E0B;
    color: #EA580C;
    background: #FFF7ED;
}
.ig-chip.selected {
    border-color: #F59E0B;
    color: #92400E;
    background: #FEF3C7;
    font-weight: 500;
}

/* ═══ AI Suggest Button ═══ */
.ig-ai-suggest {
    font-size: 0.73rem;
    padding: 5px 14px;
    border-radius: 16px;
    border: 1.5px dashed #F59E0B;
    background: none;
    color: #F59E0B;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    gap: 4px;
}
.ig-ai-suggest:hover {
    background: #FFFBEB;
}

/* ═══ Advanced Toggle ═══ */
.ig-advanced-toggle {
    font-size: 0.8rem;
    color: #9CA3AF;
    cursor: pointer;
    background: none;
    border: none;
    padding: 0;
}
.ig-advanced-toggle:hover {
    color: #6B7280;
}

/* ═══ Preview Panel ═══ */
.ig-preview-panel {
    border: 1.5px solid #E5E7EB;
    border-radius: 16px;
    overflow: hidden;
    min-height: 280px;
    display: flex;
    flex-direction: column;
    background: #F9FAFB;
    position: relative;
    margin-bottom: 0;
}
.ig-preview-panel img {
    max-width: 100%;
    max-height: 500px;
    border-radius: 8px;
    box-shadow: 0 4px 16px rgba(0,0,0,0.08);
}
.ig-preview-empty {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 40px 20px;
    text-align: center;
    min-height: 280px;
}
.ig-preview-empty p {
    color: #9CA3AF;
    font-size: 0.88rem;
}
.ig-preview-empty-icon {
    width: 56px;
    height: 56px;
    background: #F3F4F6;
    border-radius: 14px;
    display: flex;
    align-items: center;
    justify-content: center;
    margin-bottom: 14px;
    opacity: 0.6;
}

/* ═══ Action Bar ═══ */
.ig-action-bar {
    padding: 12px;
    border-top: 1px solid #E5E7EB;
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
}
.ig-action-btn {
    flex: 1;
    min-width: 80px;
    padding: 9px 12px;
    border-radius: 8px;
    border: none;
    font-size: 0.78rem;
    font-weight: 600;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 5px;
    color: #fff;
    transition: opacity 0.15s;
}
.ig-action-btn:hover { opacity: 0.9; }
.ig-action-btn.post { background: #059669; }
.ig-action-btn.schedule { background: #2563EB; }
.ig-action-btn.ad { background: #EA580C; }
.ig-action-btn.download {
    background: #F3F4F6;
    color: #6B7280;
    flex: 0;
    min-width: auto;
    padding: 9px 14px;
}

/* ═══ Regen Pills ═══ */
.ig-regen-pill {
    font-size: 0.72rem;
    padding: 4px 12px;
    border-radius: 16px;
    border: 1px solid #E5E7EB;
    background: #fff;
    color: #6B7280;
    cursor: pointer;
    transition: all 0.15s;
}
.ig-regen-pill:hover {
    border-color: #D1D5DB;
    background: #F9FAFB;
}

/* ═══ Gallery — Full Tab ═══ */
.ig-gallery-grid-full {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
    gap: 14px;
}
.ig-gallery-card {
    border-radius: 12px;
    overflow: hidden;
    background: #fff;
    border: 1px solid #E5E7EB;
    transition: all 0.2s ease;
    cursor: pointer;
}
.ig-gallery-card:hover {
    box-shadow: 0 4px 16px rgba(0,0,0,0.08);
    transform: translateY(-2px);
}
.ig-gallery-card-img {
    position: relative;
    aspect-ratio: 1 / 1;
    overflow: hidden;
    background: #F3F4F6;
}
.ig-gallery-card-img img {
    width: 100%;
    aspect-ratio: 1 / 1;
    object-fit: contain;
    display: block;
    border-radius: 0;
    box-shadow: none;
    background: #F3F4F6;
}
.ig-gallery-card-info {
    padding: 10px 12px;
}
.ig-gallery-card-topic {
    font-size: 0.78rem;
    font-weight: 500;
    color: #374151;
    margin: 0 0 2px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.ig-gallery-card-date {
    font-size: 0.68rem;
    color: #9CA3AF;
}

/* Gallery overlay */
.ig-gallery-overlay {
    position: absolute;
    inset: 0;
    background: rgba(0,0,0,0.55);
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    opacity: 0;
    transition: opacity 0.2s;
}
.ig-gallery-card:hover .ig-gallery-overlay,
.ig-gallery-item:hover .ig-gallery-overlay {
    opacity: 1;
}
.ig-gallery-circle-btn {
    width: 36px;
    height: 36px;
    border: none;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    font-size: 14px;
    color: #fff;
    transition: transform 0.15s;
}
.ig-gallery-circle-btn:hover {
    transform: scale(1.1);
}
.ig-gallery-fav {
    position: absolute;
    top: 8px;
    right: 8px;
    background: none;
    border: none;
    cursor: pointer;
    font-size: 18px;
    filter: drop-shadow(0 1px 2px rgba(0,0,0,0.5));
    transition: opacity 0.2s;
    opacity: 0;
    color: #fff;
}
.ig-gallery-fav.is-fav {
    opacity: 1;
    color: #EF4444;
}
.ig-gallery-card:hover .ig-gallery-fav {
    opacity: 1;
}

/* Recent images grid (generate tab) */
.ig-gallery-item {
    position: relative;
    border-radius: 10px;
    overflow: hidden;
    aspect-ratio: 1 / 1;
    background: #F3F4F6;
    cursor: pointer;
}
.ig-gallery-item img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
}

/* ═══ Form Card (legacy compat) ═══ */
.ig-form-card {
    background: #FAFAFA;
    border: 1px solid #EBEBEB;
    border-radius: 14px;
    padding: 22px;
}

/* ═══ Pill (legacy compat) ═══ */
.ig-pill {
    padding: 6px 14px;
    font-size: 0.78rem;
    font-weight: 500;
    border-radius: 20px;
    border: 1.5px solid #D1D5DB;
    background: white;
    color: #4B5563;
    cursor: pointer;
    transition: all 0.15s ease;
    white-space: nowrap;
}
.ig-pill:hover:not(.active) {
    border-color: #F97316;
    color: #F97316;
    background: #FFF7ED;
}
.ig-pill.active {
    background: #F97316;
    color: white;
    border-color: #F97316;
    font-weight: 600;
    box-shadow: 0 2px 4px rgba(249,115,22,0.3);
}

/* ═══ Mobile Responsive ═══ */
@media (max-width: 768px) {
    .ig-tab-bar {
        border-radius: 10px;
        padding: 3px;
    }
    .ig-tab-btn {
        padding: 8px 10px;
        font-size: 0.78rem;
        gap: 4px;
    }
    .ig-tab-btn svg {
        display: none;
    }
    .ig-card-grid-3 {
        grid-template-columns: repeat(2, 1fr);
    }
    .ig-topic-row {
        flex-direction: column;
    }
    .ig-topic-row .ig-generate-btn {
        width: 100%;
        min-width: unset;
    }
    .ig-gallery-grid-full {
        grid-template-columns: repeat(2, 1fr);
        gap: 10px;
    }
    .ig-segmented-control {
        flex-wrap: wrap;
    }
    .ig-section-card {
        padding: 12px 14px;
    }
    div[style*="grid-template-columns: 1fr 1fr"] {
        grid-template-columns: 1fr !important;
    }
}

@media (max-width: 480px) {
    .ig-gallery-grid-full {
        grid-template-columns: repeat(2, 1fr);
        gap: 8px;
    }
    .ig-card-grid-3 {
        grid-template-columns: 1fr 1fr;
    }
}

/* Gallery Detail Drawer */
.ig-gallery-wrapper {
    display: flex;
    gap: 0;
    transition: all 0.25s ease;
}
.ig-gallery-wrapper .ig-gallery-grid-full {
    flex: 1;
    min-width: 0;
}
.ig-drawer {
    width: 340px;
    min-width: 340px;
    max-height: calc(100vh - 160px);
    overflow-y: auto;
    background: #fff;
    border: 1px solid #E5E7EB;
    border-radius: 14px;
    margin-left: 16px;
    padding: 0;
    box-shadow: 0 4px 24px rgba(0,0,0,0.06);
    position: sticky;
    top: 80px;
}
.ig-drawer-img {
    position: relative;
    width: 100%;
    background: #F3F4F6;
    border-radius: 14px 14px 0 0;
    overflow: hidden;
}
.ig-drawer-img img {
    width: 100%;
    display: block;
    object-fit: contain;
    max-height: 320px;
    background: #F3F4F6;
}
.ig-drawer-close {
    position: absolute;
    top: 10px;
    right: 10px;
    width: 30px;
    height: 30px;
    background: rgba(0,0,0,0.5);
    color: #fff;
    border: none;
    border-radius: 50%;
    font-size: 1.1rem;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 5;
}
.ig-drawer-body {
    padding: 16px;
}
.ig-drawer-topic {
    font-size: 0.95rem;
    font-weight: 700;
    color: #1F2937;
    margin: 0 0 8px;
    line-height: 1.3;
}
.ig-drawer-meta {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    margin-bottom: 12px;
}
.ig-drawer-pill {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    font-size: 0.68rem;
    font-weight: 600;
    padding: 3px 10px;
    border-radius: 20px;
    border: 1px solid;
}
.ig-drawer-section-label {
    font-size: 0.7rem;
    font-weight: 600;
    color: #9CA3AF;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin: 14px 0 6px;
}
.ig-drawer-prompt-box {
    background: #F9FAFB;
    border: 1px solid #E5E7EB;
    border-radius: 8px;
    padding: 10px 12px;
    font-size: 0.72rem;
    color: #374151;
    line-height: 1.6;
    max-height: 160px;
    overflow-y: auto;
    white-space: pre-wrap;
    word-break: break-word;
}
.ig-drawer-versions {
    display: flex;
    gap: 8px;
    overflow-x: auto;
    padding: 4px 0;
}
.ig-drawer-version-thumb {
    width: 56px;
    min-width: 56px;
    border-radius: 8px;
    overflow: hidden;
    border: 2px solid #E5E7EB;
    cursor: pointer;
    text-align: center;
    transition: border-color 0.15s;
}
.ig-drawer-version-thumb.active {
    border-color: #F59E0B;
    box-shadow: 0 0 0 2px rgba(245,158,11,0.2);
}
.ig-drawer-version-thumb img {
    width: 100%;
    aspect-ratio: 1;
    object-fit: cover;
    display: block;
}
.ig-drawer-version-thumb span {
    font-size: 0.58rem;
    color: #9CA3AF;
    display: block;
    padding: 2px 0;
}
.ig-drawer-actions {
    display: flex;
    gap: 8px;
    margin-top: 16px;
    padding-top: 12px;
    border-top: 1px solid #F3F4F6;
}
.ig-drawer-actions button {
    flex: 1;
    padding: 8px 0;
    border-radius: 8px;
    border: 1px solid #E5E7EB;
    background: #fff;
    font-size: 0.75rem;
    font-weight: 500;
    cursor: pointer;
    transition: background 0.15s;
}
.ig-drawer-actions button:hover {
    background: #F9FAFB;
}
@media (max-width: 768px) {
    .ig-drawer {
        width: 100%;
        min-width: 100%;
        margin-left: 0;
        margin-top: 16px;
        position: static;
    }
    .ig-gallery-wrapper {
        flex-direction: column;
    }
}

/* ═══ Video Generator Gallery Grid ═══ */
@media (max-width: 768px) {
    .vg-gallery-grid {
        grid-template-columns: repeat(2, 1fr) !important;
        gap: 10px !important;
    }
}
@media (max-width: 480px) {
    .vg-gallery-grid {
        grid-template-columns: 1fr !important;
        gap: 8px !important;
    }
}
.vg-generating-thumb {
    border: 2px dashed #F97316 !important;
}
