/* PNG to BMP Converter - mobile-first, sleek */

:root {
    --p2b-bg: var(--bs-body-bg, #fff);
    --p2b-surface: var(--bs-secondary-bg, #f6f8fa);
    --p2b-border: var(--bs-border-color, #e1e4e8);
    --p2b-text: var(--bs-body-color, #1a1d21);
    --p2b-muted: var(--text-muted, #6e7681);
    --p2b-radius: 16px;
    --p2b-radius-sm: 10px;
    --p2b-shadow: 0 2px 8px rgba(0, 0, 0, 0.06);
    --p2b-shadow-lg: 0 8px 24px rgba(0, 0, 0, 0.08);
    --p2b-accent: #0969da;
    --p2b-accent-hover: #0550ae;
    --p2b-success: #1a7f37;
    --p2b-success-bg: rgba(26, 127, 55, 0.1);
    --p2b-upload-bg: linear-gradient(165deg, #f0f4f8 0%, #e8eef4 100%);
    --p2b-upload-border: #c5d0dc;
    --p2b-upload-active: #0969da;
}

/* --- Converter shell --- */
.p2b-converter {
    width: 100%;
    margin: 0rem auto 2rem;
}

/* --- Upload card (mobile-first) --- */
.p2b-upload-card {
    position: relative;
    min-height: 200px;
    padding: 2rem 1.5rem;
    background: var(--p2b-upload-bg);
    border: 2px dashed var(--p2b-upload-border);
    border-radius: var(--p2b-radius);
    cursor: pointer;
    transition: border-color 0.2s, background 0.2s, box-shadow 0.2s;
    -webkit-tap-highlight-color: transparent;
}

.p2b-upload-card:hover,
.p2b-upload-card:focus-visible {
    border-color: var(--p2b-accent);
    outline: none;
    box-shadow: 0 0 0 3px rgba(9, 105, 218, 0.15);
}

.p2b-upload-card.p2b-dragover {
    border-color: var(--p2b-upload-active);
    background: rgba(9, 105, 218, 0.06);
}

.p2b-file-input {
    position: absolute;
    width: 0;
    height: 0;
    opacity: 0;
    pointer-events: none;
}

.p2b-upload-inner {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    min-height: 160px;
    text-align: center;
}

.p2b-upload-icon {
    width: 56px;
    height: 56px;
    margin-bottom: 1rem;
    background: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%236e7681' stroke-width='1.5' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M21 15v4a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2v-4'/%3E%3Cpolyline points='17 8 12 3 7 8'/%3E%3Cline x1='12' y1='3' x2='12' y2='15'/%3E%3C/svg%3E") no-repeat center;
    background-size: 100%;
}

.p2b-upload-card:hover .p2b-upload-icon,
.p2b-upload-card:focus-visible .p2b-upload-icon {
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%230969da' stroke-width='1.5' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M21 15v4a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2v-4'/%3E%3Cpolyline points='17 8 12 3 7 8'/%3E%3Cline x1='12' y1='3' x2='12' y2='15'/%3E%3C/svg%3E");
}

.p2b-upload-title {
    font-size: 1.125rem;
    font-weight: 600;
    color: var(--p2b-text);
    margin: 0 0 0.25rem 0;
}

.p2b-upload-hint {
    font-size: 0.875rem;
    color: var(--p2b-muted);
    margin: 0;
}

/* --- Workspace (after file selected) --- */
.p2b-workspace {
    margin-top: 1.5rem;
    padding: 1.5rem;
    background: var(--p2b-bg);
    border: 1px solid var(--p2b-border);
    border-radius: var(--p2b-radius);
    box-shadow: var(--p2b-shadow);
}

@media (min-width: 576px) {
    .p2b-workspace {
        padding: 2rem;
    }
}

/* --- Display row: 2 columns — left PNG, right BMP --- */
.p2b-display-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 1rem 1.25rem;
    margin-bottom: 1.5rem;
}

@media (min-width: 600px) {
    .p2b-display-row {
        gap: 1.5rem 2rem;
        margin-bottom: 2rem;
    }
}

.p2b-col {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    min-width: 0;
}

.p2b-col-png {
    grid-column: 1;
}

.p2b-col-bmp {
    grid-column: 2;
}

.p2b-preview-label {
    font-size: 0.75rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--p2b-muted);
}

.p2b-preview-frame {
    position: relative;
    aspect-ratio: 1;
    max-height: 220px;
    background: var(--p2b-surface);
    border-radius: var(--p2b-radius-sm);
    overflow: hidden;
    border: 1px solid var(--p2b-border);
}

@media (min-width: 600px) {
    .p2b-preview-frame {
        max-height: 280px;
    }
}

.p2b-preview-img {
    width: 100%;
    height: 100%;
    object-fit: contain;
    display: block;
}

.p2b-preview-img[src=""] {
    visibility: hidden;
}

.p2b-meta {
    font-size: 0.8125rem;
    color: var(--p2b-muted);
    margin: 0;
}

/* --- Options --- */
.p2b-options {
    display: flex;
    flex-wrap: wrap;
    gap: 1rem 1.5rem;
    margin-bottom: 1.5rem;
    padding: 1.25rem 0;
    border-top: 1px solid var(--p2b-border);
    border-bottom: 1px solid var(--p2b-border);
}

.p2b-option {
    flex: 1 1 100%;
    min-width: 0;
}

@media (min-width: 480px) {
    .p2b-option {
        flex: 1 1 calc(50% - 0.75rem);
    }
}

@media (min-width: 640px) {
    .p2b-option {
        flex: 0 1 auto;
    }
}

.p2b-label {
    display: block;
    font-size: 0.875rem;
    font-weight: 500;
    color: var(--p2b-text);
    margin-bottom: 0.375rem;
}

.p2b-select {
    display: block;
    width: 100%;
    max-width: 240px;
    padding: 0.5rem 2rem 0.5rem 0.75rem;
    font-size: 0.9375rem;
    color: var(--p2b-text);
    background: var(--p2b-bg);
    border: 1px solid var(--p2b-border);
    border-radius: var(--p2b-radius-sm);
    appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'%3E%3Cpath fill='%236e7681' d='M6 8L1 3h10z'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 0.75rem center;
}

.p2b-select:focus {
    border-color: var(--p2b-accent);
    outline: none;
    box-shadow: 0 0 0 2px rgba(9, 105, 218, 0.2);
}

.p2b-hint {
    display: block;
    font-size: 0.75rem;
    color: var(--p2b-muted);
    margin-top: 0.25rem;
}

.p2b-color-row {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    flex-wrap: wrap;
}

.p2b-color {
    width: 44px;
    height: 44px;
    padding: 2px;
    border: 1px solid var(--p2b-border);
    border-radius: var(--p2b-radius-sm);
    background: var(--p2b-bg);
    cursor: pointer;
}

.p2b-color:focus {
    outline: none;
    border-color: var(--p2b-accent);
    box-shadow: 0 0 0 2px rgba(9, 105, 218, 0.2);
}

.p2b-hex {
    font-size: 0.875rem;
    
    color: var(--p2b-muted);
}

.p2b-option-check {
    display: flex;
    align-items: center;
}

.p2b-checkbox {
    width: 1.125rem;
    height: 1.125rem;
    margin: 0 0.5rem 0 0;
    accent-color: var(--p2b-accent);
    cursor: pointer;
}

.p2b-check-label {
    font-size: 0.9375rem;
    color: var(--p2b-text);
    cursor: pointer;
    margin: 0;
}

/* --- Actions --- */
.p2b-actions {
    margin-bottom: 1rem;
}

.p2b-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-height: 44px;
    padding: 0.625rem 1.25rem;
    font-size: 0.9375rem;
    font-weight: 600;
    border: none;
    border-radius: var(--p2b-radius-sm);
    cursor: pointer;
    transition: background 0.2s, color 0.2s, box-shadow 0.2s;
    -webkit-tap-highlight-color: transparent;
}

.p2b-btn:disabled {
    opacity: 0.6;
    cursor: not-allowed;
}

.p2b-btn-primary {
    background: var(--p2b-accent);
    color: #fff;
}

.p2b-btn-primary:hover:not(:disabled) {
    background: var(--p2b-accent-hover);
}

.p2b-btn-primary:focus-visible {
    outline: none;
    box-shadow: 0 0 0 3px rgba(9, 105, 218, 0.35);
}

.p2b-btn-success {
    background: var(--p2b-success);
    color: #fff;
}

.p2b-btn-success:hover {
    background: #166534;
}

.p2b-btn-ghost {
    background: transparent;
    color: var(--p2b-text);
    border: 1px solid var(--p2b-border);
}

.p2b-btn-ghost:hover {
    background: var(--p2b-surface);
}

.p2b-result {
    padding: 1.25rem;
    background: var(--p2b-success-bg);
    border-radius: var(--p2b-radius-sm);
    border: 1px solid rgba(26, 127, 55, 0.25);
}

.p2b-result-title {
    font-size: 1rem;
    font-weight: 600;
    color: var(--p2b-success);
    margin: 0 0 1rem 0;
}

.p2b-result-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 0.75rem;
}

/* --- Toast --- */
.p2b-toast {
    position: fixed;
    bottom: 1.5rem;
    left: 50%;
    transform: translateX(-50%);
    max-width: calc(100vw - 2rem);
    padding: 0.75rem 1.25rem;
    font-size: 0.9375rem;
    background: var(--p2b-text);
    color: var(--p2b-bg);
    border-radius: var(--p2b-radius-sm);
    box-shadow: var(--p2b-shadow-lg);
    z-index: 9999;
}

.p2b-toast[hidden] {
    display: none;
}

.p2b-toast.p2b-toast-error {
    background: #cf222e;
    color: #fff;
}

/* Loading state on convert button */
.p2b-btn-primary.p2b-loading .p2b-btn-text {
    visibility: hidden;
}

.p2b-btn-primary.p2b-loading::after {
    content: "";
    position: absolute;
    width: 1rem;
    height: 1rem;
    border: 2px solid rgba(255, 255, 255, 0.4);
    border-top-color: #fff;
    border-radius: 50%;
    animation: p2b-spin 0.7s linear infinite;
}

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

.p2b-btn-primary {
    position: relative;
}
