/**
 * TulBD Image Flipper Studio - Interactive CSS Styles
 */

.tb-flipper-container {
    max-width: 1200px;
    margin: 0 auto 40px auto;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
    color: #1e293b;
}

/* Header */
.tb-flipper-header {
    text-align: center;
    margin-bottom: 24px;
}

.tb-flipper-title {
    font-size: 28px;
    font-weight: 800;
    color: #0f172a;
    margin: 0 0 10px 0;
    line-height: 1.25;
}

.tb-flipper-lead {
    font-size: 15px;
    color: #64748b;
    max-width: 800px;
    margin: 0 auto 18px auto;
    line-height: 1.6;
}

.tb-flipper-pills-bar {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: 6px;
    margin-top: 14px;
}

.tb-flipper-pill {
    display: inline-flex;
    align-items: center;
    padding: 5px 11px;
    font-size: 11.5px;
    font-weight: 600;
    color: #475569;
    background: #f8fafc;
    border: 1px solid #e2e8f0;
    border-radius: 6px;
    text-decoration: none;
    transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
}

.tb-flipper-pill:hover {
    background: #dbeafe;
    border-color: #93c5fd;
    color: #1d4ed8;
    transform: translateY(-1px);
}

.tb-flipper-pill.active {
    background: #2563eb !important;
    color: #ffffff !important;
    border-color: #1d4ed8 !important;
    box-shadow: 0 3px 8px rgba(37, 99, 235, 0.35);
}

/* Hero Dropzone */
.tb-flipper-dropzone {
    position: relative;
    border: 2px dashed #94a3b8;
    background: linear-gradient(135deg, rgba(248, 250, 252, 0.9) 0%, rgba(241, 245, 249, 0.7) 100%);
    border-radius: 20px;
    padding: 44px 20px;
    text-align: center;
    cursor: pointer;
    transition: all 0.25s ease;
    box-shadow: 0 4px 20px -2px rgba(0, 0, 0, 0.04);
    margin-bottom: 24px;
}

.tb-flipper-dropzone:hover,
.tb-flipper-dropzone.dragover {
    border-color: #2563eb;
    background: #eff6ff;
    box-shadow: 0 10px 30px -5px rgba(37, 99, 235, 0.15);
    transform: scale(1.004);
}

.tb-flipper-file-input {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    opacity: 0;
    cursor: pointer;
}

.tb-flipper-dropzone-inner {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 12px;
}

.tb-flipper-dropzone-icon {
    width: 72px;
    height: 72px;
    border-radius: 50%;
    background: #dbeafe;
    color: #2563eb;
    display: flex;
    align-items: center;
    justify-content: center;
    margin-bottom: 4px;
    transition: transform 0.2s ease;
}

.tb-flipper-dropzone:hover .tb-flipper-dropzone-icon {
    transform: scale(1.1);
}

.tb-flipper-dropzone-main {
    font-size: 18px;
    font-weight: 700;
    color: #0f172a;
    display: block;
}

.tb-flipper-dropzone-sub {
    font-size: 13px;
    color: #64748b;
    display: block;
    margin-top: 4px;
}

.tb-flipper-browse-btn {
    margin-top: 6px;
    background: #2563eb;
    color: #ffffff;
    font-size: 14px;
    font-weight: 600;
    padding: 10px 24px;
    border-radius: 12px;
    border: none;
    cursor: pointer;
    box-shadow: 0 4px 14px rgba(37, 99, 235, 0.3);
    transition: background 0.15s ease;
}

.tb-flipper-browse-btn:hover {
    background: #1d4ed8;
}

.tb-flipper-paste-hint {
    margin-top: 14px;
    font-size: 12px;
    color: #64748b;
    font-weight: 500;
}

/* Studio Workspace Grid */
.tb-flipper-workspace {
    background: #ffffff;
    border-radius: 20px;
    border: 1px solid #e2e8f0;
    box-shadow: 0 10px 35px -5px rgba(0, 0, 0, 0.06);
    overflow: hidden;
}

.tb-flipper-grid {
    display: grid;
    grid-template-columns: 380px 1fr;
    min-height: 560px;
}

@media (max-width: 900px) {
    .tb-flipper-grid {
        grid-template-columns: 1fr;
    }
}

/* Controls Column */
.tb-flipper-controls-panel {
    padding: 24px 26px;
    border-right: 1px solid #e2e8f0;
    display: flex;
    flex-direction: column;
    gap: 18px;
    background: #ffffff;
}

@media (max-width: 900px) {
    .tb-flipper-controls-panel {
        border-right: none;
        border-bottom: 1px solid #e2e8f0;
        padding: 20px 16px;
    }
}

/* File info bar */
.tb-flipper-file-info {
    display: flex;
    align-items: center;
    gap: 12px;
    background: #f8fafc;
    border: 1px solid #e2e8f0;
    border-radius: 14px;
    padding: 10px 14px;
}

.tb-flipper-file-thumb {
    width: 44px;
    height: 44px;
    border-radius: 8px;
    background-size: cover;
    background-position: center;
    border: 1px solid #cbd5e1;
    flex-shrink: 0;
}

.tb-flipper-file-meta {
    flex-grow: 1;
    overflow: hidden;
}

.tb-flipper-file-name {
    font-size: 13.5px;
    font-weight: 700;
    color: #0f172a;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.tb-flipper-file-stats {
    font-size: 11.5px;
    color: #64748b;
    margin-top: 2px;
}

.tb-flipper-btn-change {
    background: transparent;
    border: 1px solid #cbd5e1;
    color: #475569;
    font-size: 12px;
    font-weight: 600;
    padding: 6px 10px;
    border-radius: 8px;
    cursor: pointer;
    white-space: nowrap;
    transition: all 0.15s ease;
}

.tb-flipper-btn-change:hover {
    background: #e2e8f0;
    color: #0f172a;
}

.tb-flipper-section-title {
    font-size: 13px;
    font-weight: 700;
    color: #334155;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-top: 4px;
}

/* Big Flip Toggle Buttons */
.tb-flipper-buttons-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 10px;
}

.tb-btn-flip {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 14px 12px;
    background: #f8fafc;
    border: 2px solid #e2e8f0;
    border-radius: 14px;
    font-size: 13px;
    font-weight: 700;
    color: #334155;
    cursor: pointer;
    transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
    min-height: 48px;
    touch-action: manipulation;
}

.tb-btn-flip:hover {
    border-color: #93c5fd;
    background: #eff6ff;
    transform: translateY(-1px);
}

.tb-btn-flip.active {
    background: #2563eb;
    color: #ffffff;
    border-color: #2563eb;
    box-shadow: 0 4px 14px rgba(37, 99, 235, 0.3);
}

.tb-btn-flip.active svg {
    stroke: #ffffff;
}

/* Secondary Tools (Rotate & Reset) */
.tb-flipper-buttons-grid.mini {
    grid-template-columns: 1fr 1fr 1.2fr;
    gap: 8px;
}

.tb-btn-sub-tool {
    padding: 8px 10px;
    background: #f1f5f9;
    border: 1px solid #e2e8f0;
    border-radius: 10px;
    font-size: 12px;
    font-weight: 600;
    color: #475569;
    cursor: pointer;
    transition: all 0.15s ease;
    min-height: 40px;
}

.tb-btn-sub-tool:hover {
    background: #e2e8f0;
    color: #0f172a;
}

.tb-btn-sub-tool.reset {
    color: #dc2626;
    background: #fef2f2;
    border-color: #fecaca;
}

.tb-btn-sub-tool.reset:hover {
    background: #fee2e2;
}

/* Toggle Group for View Mode */
.tb-flipper-field {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.tb-flipper-field label {
    font-size: 13px;
    font-weight: 600;
    color: #334155;
}

.tb-flipper-toggle-group {
    display: flex;
    background: #f1f5f9;
    padding: 4px;
    border-radius: 12px;
    border: 1px solid #e2e8f0;
}

.tb-toggle-btn {
    flex: 1;
    padding: 8px 12px;
    border: none;
    background: transparent;
    font-size: 12.5px;
    font-weight: 600;
    color: #64748b;
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.15s ease;
    min-height: 38px;
}

.tb-toggle-btn.active {
    background: #ffffff;
    color: #0f172a;
    font-weight: 700;
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.08);
}

/* Row & Inputs */
.tb-flipper-row {
    display: flex;
    gap: 12px;
}

.tb-flipper-col {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.tb-flipper-col label {
    font-size: 12.5px;
    font-weight: 600;
    color: #334155;
    display: flex;
    justify-content: space-between;
}

.tb-flipper-select {
    width: 100%;
    padding: 9px 12px;
    font-size: 13px;
    border: 1.5px solid #cbd5e1;
    border-radius: 10px;
    background: #ffffff;
    color: #0f172a;
    cursor: pointer;
    min-height: 42px;
    box-sizing: border-box;
}

.tb-flipper-range {
    width: 100%;
    height: 6px;
    border-radius: 3px;
    background: #e2e8f0;
    accent-color: #2563eb;
    margin-top: 14px;
    cursor: pointer;
}

/* Actions */
.tb-flipper-actions {
    display: flex;
    gap: 10px;
    margin-top: 6px;
}

.tb-btn-download {
    flex: 1;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    background: #2563eb;
    color: #ffffff;
    font-size: 14px;
    font-weight: 700;
    padding: 13px 20px;
    border-radius: 12px;
    border: none;
    cursor: pointer;
    box-shadow: 0 4px 14px rgba(37, 99, 235, 0.35);
    transition: all 0.2s ease;
    min-height: 48px;
}

.tb-btn-download:hover {
    background: #1d4ed8;
    transform: translateY(-1px);
    box-shadow: 0 6px 18px rgba(37, 99, 235, 0.4);
}

.tb-btn-copy {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    background: #f8fafc;
    border: 1.5px solid #cbd5e1;
    color: #334155;
    font-size: 13px;
    font-weight: 600;
    padding: 12px 16px;
    border-radius: 12px;
    cursor: pointer;
    transition: all 0.15s ease;
    min-height: 48px;
}

.tb-btn-copy:hover {
    background: #e2e8f0;
    color: #0f172a;
}

/* Preview Panel */
.tb-flipper-preview-panel {
    background: #f8fafc;
    display: flex;
    flex-direction: column;
}

.tb-flipper-preview-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 14px 20px;
    background: #ffffff;
    border-bottom: 1px solid #e2e8f0;
}

.tb-preview-title {
    font-size: 14px;
    font-weight: 700;
    color: #0f172a;
}

.tb-preview-badges {
    display: flex;
    gap: 6px;
}

.tb-badge {
    font-size: 11.5px;
    font-weight: 700;
    padding: 4px 8px;
    border-radius: 6px;
}

.tb-badge-state {
    background: #eff6ff;
    color: #2563eb;
    border: 1px solid #bfdbfe;
}

.tb-badge-size {
    background: #dbeafe;
    color: #1e40af;
}

.tb-badge-dim {
    background: #f1f5f9;
    color: #475569;
}

/* Viewport with Checkerboard pattern for transparency */
.tb-flipper-viewport {
    flex-grow: 1;
    position: relative;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 24px;
    overflow: hidden;
    background-color: #f1f5f9;
    background-image: linear-gradient(45deg, #e2e8f0 25%, transparent 25%),
                      linear-gradient(-45deg, #e2e8f0 25%, transparent 25%),
                      linear-gradient(45deg, transparent 75%, #e2e8f0 75%),
                      linear-gradient(-45deg, transparent 75%, #e2e8f0 75%);
    background-size: 16px 16px;
    background-position: 0 0, 0 8px, 8px -8px, -8px 0px;
    min-height: 420px;
}

.tb-flipper-canvas-wrap {
    position: relative;
    max-width: 100%;
    max-height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.12);
    border-radius: 8px;
    overflow: hidden;
    background: transparent;
}

.tb-output-flip-canvas {
    max-width: 100%;
    max-height: 460px;
    height: auto;
    display: block;
    object-fit: contain;
}

/* Split Side-by-Side View */
.tb-flipper-split-wrap {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 16px;
    width: 100%;
    max-width: 900px;
}

.tb-split-pane {
    position: relative;
    background: rgba(255, 255, 255, 0.95);
    border: 1px solid #cbd5e1;
    border-radius: 12px;
    padding: 12px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.05);
}

.tb-split-tag {
    position: absolute;
    top: 8px;
    left: 8px;
    font-size: 10.5px;
    font-weight: 700;
    padding: 3px 8px;
    border-radius: 4px;
    background: #334155;
    color: #ffffff;
    z-index: 2;
}

.tb-split-tag.accent {
    background: #2563eb;
}

.tb-split-pane img,
.tb-split-pane canvas {
    max-width: 100%;
    max-height: 360px;
    height: auto;
    object-fit: contain;
    border-radius: 6px;
}

/* Spinner */
.tb-flipper-spinner {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(255, 255, 255, 0.75);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 10px;
    z-index: 10;
}

.tb-spin-circle {
    width: 38px;
    height: 38px;
    border: 3.5px solid #e2e8f0;
    border-top-color: #2563eb;
    border-radius: 50%;
    animation: tbFlipperSpin 0.7s linear infinite;
}

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

/* ============================================================
   STICKY MOBILE ACTION BAR & RESPONSIVE POLISH (<= 900px)
   ============================================================ */
.tb-flipper-mobile-bar {
    display: none;
}

@media (max-width: 900px) {
    .tb-flipper-container {
        padding-bottom: 74px;
    }

    .tb-flipper-mobile-bar {
        display: none;
        position: fixed;
        bottom: 0;
        left: 0;
        right: 0;
        background: rgba(255, 255, 255, 0.95);
        backdrop-filter: blur(14px);
        -webkit-backdrop-filter: blur(14px);
        border-top: 1px solid #e2e8f0;
        padding: 10px 16px;
        padding-bottom: calc(10px + env(safe-area-inset-bottom, 0px));
        box-shadow: 0 -4px 20px rgba(0, 0, 0, 0.08);
        z-index: 999;
        align-items: center;
        justify-content: space-between;
        gap: 12px;
        animation: tbSlideUpMobile 0.25s cubic-bezier(0.16, 1, 0.3, 1);
    }

    .tb-flipper-mobile-bar.active {
        display: flex;
    }

    .tb-mobile-bar-meta {
        display: flex;
        flex-direction: column;
        gap: 2px;
    }

    .tb-mobile-bar-size {
        font-size: 15px;
        font-weight: 800;
        color: #2563eb;
    }

    .tb-mobile-bar-dim {
        font-size: 11.5px;
        font-weight: 600;
        color: #64748b;
    }

    .tb-mobile-btn-download {
        display: inline-flex;
        align-items: center;
        justify-content: center;
        gap: 8px;
        background: #2563eb;
        color: #ffffff;
        font-size: 14px;
        font-weight: 700;
        padding: 11px 20px;
        border-radius: 12px;
        border: none;
        cursor: pointer;
        box-shadow: 0 4px 14px rgba(37, 99, 235, 0.35);
        transition: transform 0.15s ease, background 0.15s ease;
        min-height: 44px;
        touch-action: manipulation;
    }

    .tb-mobile-btn-download:active {
        transform: scale(0.97);
        background: #1d4ed8;
    }
}

@media (max-width: 600px) {
    .tb-flipper-title {
        font-size: 22px;
    }

    .tb-flipper-lead {
        font-size: 13.5px;
    }

    .tb-flipper-dropzone {
        padding: 30px 14px;
        border-radius: 16px;
    }

    .tb-flipper-buttons-grid.mini {
        grid-template-columns: 1fr 1fr;
    }

    .tb-flipper-split-wrap {
        grid-template-columns: 1fr;
    }

    .tb-split-pane img,
    .tb-split-pane canvas {
        max-height: 240px;
    }

    .tb-flipper-viewport {
        min-height: 280px;
        padding: 12px;
    }

    .tb-output-flip-canvas {
        max-height: 320px;
    }
}
