/**
 * ALD Business Tools Hub — Frontend Styles
 */

/* === CSS Variables (inherit from theme) === */
.bth-tool-wrapper,
.bth-tools-grid,
.bth-tool-single,
.bth-tools-archive {
    --bth-primary: var(--color-primary, #D60000);
    --bth-bg: var(--color-bg, #ffffff);
    --bth-bg-alt: var(--color-bg-alt, #f5f5f5);
    --bth-text: var(--color-text, #1a1a1a);
    --bth-text-muted: var(--color-text-muted, #737373);
    --bth-border: var(--color-border, #e5e5e5);
    --bth-radius: 8px;
    --bth-shadow: 0 1px 3px rgba(0,0,0,0.08);
    --bth-font: var(--font-sans, 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif);
}

/* === Tool Wrapper === */
.bth-tool-wrapper {
    max-width: 800px;
    margin: 0 auto;
    font-family: var(--bth-font);
    color: var(--bth-text);
}

.bth-tool-header {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 8px;
}

.bth-tool-icon {
    font-size: 28px;
    line-height: 1;
}

.bth-tool-title {
    font-size: 22px;
    font-weight: 700;
    margin: 0;
}

.bth-tool-description {
    color: var(--bth-text-muted);
    font-size: 14px;
    margin-bottom: 20px;
}

.bth-tool-body {
    background: var(--bth-bg);
    border: 1px solid var(--bth-border);
    border-radius: var(--bth-radius);
    padding: 24px;
    box-shadow: var(--bth-shadow);
}

/* === Form Elements === */
.bth-form-group {
    margin-bottom: 16px;
}

.bth-form-label {
    display: block;
    font-size: 13px;
    font-weight: 600;
    margin-bottom: 4px;
    color: var(--bth-text);
}

.bth-form-input,
.bth-form-select,
.bth-form-textarea {
    width: 100%;
    padding: 10px 12px;
    border: 1px solid var(--bth-border);
    border-radius: 6px;
    font-size: 14px;
    font-family: var(--bth-font);
    color: var(--bth-text);
    background: var(--bth-bg);
    transition: border-color 0.2s, box-shadow 0.2s;
    box-sizing: border-box;
}

.bth-form-input:focus,
.bth-form-select:focus,
.bth-form-textarea:focus {
    outline: none;
    border-color: var(--bth-primary);
    box-shadow: 0 0 0 3px color-mix(in srgb, var(--bth-primary) 10%, transparent);
}

.bth-form-textarea {
    min-height: 80px;
    resize: vertical;
}

.bth-form-select {
    appearance: auto;
    cursor: pointer;
}

.bth-char-counter {
    font-size: 11px;
    color: var(--bth-text-muted);
    text-align: right;
    margin-top: 2px;
}

.bth-char-counter.warning { color: #f59e0b; }
.bth-char-counter.danger { color: #ef4444; }

/* === Buttons === */
.bth-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    padding: 10px 20px;
    border: none;
    border-radius: 6px;
    font-size: 14px;
    font-weight: 600;
    font-family: var(--bth-font);
    cursor: pointer;
    transition: background 0.2s, transform 0.1s;
    text-decoration: none;
}

.bth-btn:active { transform: scale(0.98); }

.bth-btn-primary {
    background: var(--bth-primary);
    color: #fff;
}
.bth-btn-primary:hover { background: color-mix(in srgb, var(--bth-primary) 80%, black); }
.bth-btn-primary:disabled { opacity: 0.5; cursor: not-allowed; }

.bth-btn-secondary {
    background: var(--bth-bg-alt);
    color: var(--bth-text);
    border: 1px solid var(--bth-border);
}
.bth-btn-secondary:hover { background: var(--bth-border); }

.bth-form-actions {
    display: flex;
    gap: 10px;
    margin-top: 20px;
}

/* === Result Box === */
.bth-result-box {
    margin-top: 20px;
    padding: 16px;
    background: var(--bth-bg-alt);
    border: 1px solid var(--bth-border);
    border-radius: var(--bth-radius);
    font-size: 14px;
}

/* === Dropzone === */
.bth-dropzone {
    border: 2px dashed var(--bth-border);
    border-radius: var(--bth-radius);
    padding: 32px 20px;
    text-align: center;
    cursor: pointer;
    transition: border-color 0.2s, background 0.2s;
    background: var(--bth-bg-alt);
}

.bth-dropzone:hover {
    border-color: var(--bth-primary);
    background: color-mix(in srgb, var(--bth-primary) 3%, transparent);
}

.bth-dropzone-text {
    font-size: 14px;
    color: var(--bth-text-muted);
}

/* === Tools Grid (Archive) === */
.bth-tools-grid {
    display: grid;
    gap: 20px;
    margin: 20px 0;
}

.bth-col-2 { grid-template-columns: repeat(2, 1fr); }
.bth-col-3 { grid-template-columns: repeat(3, 1fr); }
.bth-col-4 { grid-template-columns: repeat(4, 1fr); }

.bth-tool-card {
    background: var(--bth-bg);
    border: 1px solid var(--bth-border);
    border-radius: var(--bth-radius);
    padding: 20px;
    transition: box-shadow 0.2s, transform 0.15s;
    box-shadow: var(--bth-shadow);
}

.bth-tool-card:hover {
    box-shadow: 0 4px 12px rgba(0,0,0,0.1);
    transform: translateY(-2px);
}

.bth-tool-card-link {
    text-decoration: none;
    color: inherit;
    display: block;
}

.bth-tool-card-icon {
    font-size: 32px;
    display: block;
    margin-bottom: 10px;
}

.bth-tool-card-title {
    font-size: 16px;
    font-weight: 700;
    margin: 0 0 6px;
    color: var(--bth-text);
}

.bth-tool-card-desc {
    font-size: 13px;
    color: var(--bth-text-muted);
    margin: 0;
}

.bth-tool-card-cats {
    margin-top: 12px;
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
}

.bth-cat-badge {
    font-size: 11px;
    padding: 2px 8px;
    background: var(--bth-bg-alt);
    border: 1px solid var(--bth-border);
    border-radius: 20px;
    color: var(--bth-text-muted);
}

/* === Profit Calculator === */
.bth-profit-positive { color: #16a34a; font-weight: 700; }
.bth-profit-negative { color: #dc2626; font-weight: 700; }
.bth-profit-row {
    display: flex;
    justify-content: space-between;
    padding: 8px 0;
    border-bottom: 1px solid var(--bth-border);
}
.bth-profit-row:last-child { border-bottom: none; }
.bth-profit-label { font-weight: 600; }
.bth-profit-value { font-weight: 700; }

/* === Color Palette === */
.bth-color-palette {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
    margin: 16px 0;
}

.bth-color-swatch {
    width: 80px;
    text-align: center;
    cursor: pointer;
    transition: transform 0.15s;
}

.bth-color-swatch:hover { transform: scale(1.05); }

.bth-color-swatch-preview {
    width: 80px;
    height: 80px;
    border-radius: var(--bth-radius);
    border: 1px solid var(--bth-border);
    margin-bottom: 4px;
}

.bth-color-hex {
    font-size: 11px;
    font-family: monospace;
    color: var(--bth-text-muted);
}

/* === Image Tools Preview === */
.bth-resize-preview,
.bth-image-preview {
    display: flex;
    gap: 20px;
    flex-wrap: wrap;
}

.bth-resize-preview-item,
.bth-image-preview-item {
    flex: 1;
    min-width: 200px;
    text-align: center;
}

.bth-resize-preview-item canvas,
.bth-resize-preview-item img,
.bth-image-preview-item canvas,
.bth-image-preview-item img {
    max-width: 100%;
    border: 1px solid var(--bth-border);
    border-radius: 6px;
    margin: 8px 0;
}

.bth-invoice-wrap .bth-inv-totals-box hr {
    border: none;
    border-top: 1px solid var(--bth-border);
    margin: 8px 0;
}

.bth-invoice-wrap h3 {
    font-size: 16px;
    font-weight: 700;
    margin: 0 0 12px;
    color: var(--bth-text);
}

.bth-table {
    width: 100%;
    border-collapse: collapse;
}

.bth-table th,
.bth-table td {
    padding: 8px;
    border: 1px solid var(--bth-border);
    text-align: left;
    font-size: 13px;
}

.bth-table th {
    background: var(--bth-bg-alt);
    font-weight: 60;
}

/* === Invoice === */
.bth-invoice-wrap .bth-inv-row {
    display: flex;
    gap: 24px;
    margin-bottom: 20px;
}

.bth-invoice-wrap .bth-inv-col {
    flex: 1;
    min-width: 0;
}

.bth-invoice-wrap .bth-inv-col-right {
    flex: 1;
    min-width: 0;
}

.bth-invoice-wrap .bth-inv-totals-box {
    background: var(--bth-bg-alt);
    border: 1px solid var(--bth-border);
    border-radius: var(--bth-radius);
    padding: 16px;
}

.bth-invoice-wrap .bth-inv-total-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 8px;
    gap: 12px;
}

.bth-invoice-wrap .bth-inv-total-row:last-child {
    margin-bottom: 0;
}

.bth-invoice-wrap .bth-inv-total-input {
    width: 120px;
    text-align: right;
    padding: 4px 8px;
    font-size: 13px;
}

.bth-invoice-wrap .bth-inv-grand-total-row {
    font-size: 16px;
    font-weight: 700;
}

.bth-invoice-wrap .bth-inv-balance-row {
    font-size: 15px;
    font-weight: 700;
    color: #dc2626;
}

.bth-invoice-wrap .bth-inv-remove-row {
    background: none;
    border: none;
    color: #dc2626;
    font-size: 20px;
    cursor: pointer;
    padding: 0 8px;
    line-height: 1;
}

.bth-invoice-wrap .bth-logo-upload {
    display: flex;
    align-items: center;
}

.bth-invoice-wrap .bth-inv-items-table {
    width: 100%;
    border-collapse: collapse;
    margin: 12px 0;
}

.bth-invoice-wrap .bth-inv-items-table th,
.bth-invoice-wrap .bth-inv-items-table td {
    padding: 8px;
    border: 1px solid var(--bth-border);
    text-align: left;
    font-size: 13px;
}

.bth-invoice-wrap .bth-inv-items-table th {
    background: var(--bth-bg-alt);
    font-weight: 600;
}

.bth-invoice-wrap .bth-inv-items-table input {
    border: none;
    padding: 4px;
    font-size: 13px;
}

/* === Invoice Preview / PDF === */
.bth-invoice-preview {
    margin-top: 24px;
    background: #fff;
    color: #1a1a1a;
    padding: 32px;
    border: 1px solid #ddd;
    border-radius: var(--bth-radius);
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
    font-size: 13px;
    line-height: 1.5;
}

.bth-inv-pdf-wrap {
    max-width: 100%;
    padding: 10px 15px;
    box-sizing: border-box;
}

.bth-inv-pdf-row {
    display: flex;
    gap: 32px;
    margin-bottom: 20px;
}

.bth-inv-pdf-col {
    flex: 1;
    min-width: 0;
}

.bth-inv-pdf-right {
    text-align: right;
}

.bth-inv-pdf-right .bth-inv-pdf-summary {
    margin-left: auto;
}

.bth-inv-pdf-logo {
    max-height: 60px;
    max-width: 200px;
}

.bth-inv-pdf-title {
    font-size: 28px;
    font-weight: 800;
    margin: 0 0 4px;
    color: #1a1a1a;
    letter-spacing: 2px;
}

.bth-inv-pdf-number {
    font-size: 14px;
    color: #555;
    margin: 0;
}

.bth-inv-pdf-dates p {
    margin: 0 0 4px;
    font-size: 13px;
}

.bth-inv-pdf h4 {
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: 1px;
    color: #888;
    margin: 0 0 6px;
}

.bth-inv-pdf p {
    margin: 0 0 3px;
    font-size: 13px;
}

.bth-inv-pdf-table {
    width: 100%;
    border-collapse: collapse;
    margin: 16px 0;
}

.bth-inv-pdf-table th {
    background: #f5f5f5;
    padding: 10px 12px;
    text-align: left;
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    border-bottom: 2px solid #ddd;
}

.bth-inv-pdf-table td {
    padding: 10px 12px;
    border-bottom: 1px solid #eee;
    font-size: 13px;
}

.bth-inv-pdf-summary {
    width: 240px;
    margin-left: auto;
    border-collapse: collapse;
}

.bth-inv-pdf-summary td {
    padding: 6px 0;
    font-size: 13px;
    border: none;
}

.bth-inv-pdf-summary td:last-child {
    text-align: right;
}

.bth-inv-pdf-grand-total td {
    font-size: 16px;
    font-weight: 700;
    border-top: 2px solid #1a1a1a;
    padding-top: 10px;
}

.bth-inv-pdf-balance td {
    font-size: 15px;
    font-weight: 700;
    color: #dc2626;
    border-top: 1px solid #ddd;
    padding-top: 8px;
}

.bth-inv-pdf-notes,
.bth-inv-pdf-terms {
    margin-top: 8px;
}

.bth-inv-pdf-notes p,
.bth-inv-pdf-terms p {
    font-size: 12px;
    color: #555;
}

@media (max-width: 768px) {
    .bth-invoice-wrap .bth-inv-row {
        flex-direction: column;
        gap: 0;
    }
    .bth-inv-pdf-row {
        flex-direction: column;
        gap: 12px;
    }
    .bth-inv-pdf-right {
        text-align: left;
    }
    .bth-inv-pdf-summary {
        width: 100%;
    }
}

/* === Invoice Preview (old override) === */

/* === UTM History === */
.bth-utm-history {
    margin-top: 20px;
}

.bth-utm-history-item {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 0;
    border-bottom: 1px solid var(--bth-border);
    font-size: 12px;
}

.bth-utm-history-url {
    flex: 1;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    color: var(--bth-text-muted);
}

/* === QR Code === */
.bth-qr-result {
    margin-top: 20px;
    text-align: center;
}

.bth-qr-result canvas,
.bth-qr-result img {
    max-width: 100%;
    height: auto;
    border: 1px solid var(--bth-border);
    border-radius: var(--bth-radius);
}

/* === Loading Spinner === */
.bth-loading {
    display: inline-block;
    width: 18px;
    height: 18px;
    border: 2px solid var(--bth-border);
    border-top-color: var(--bth-primary);
    border-radius: 50%;
    animation: bth-spin 0.6s linear infinite;
}

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

/* === Error === */
.bth-error {
    color: #dc2626;
    padding: 12px;
    background: #fef2f2;
    border: 1px solid #fecaca;
    border-radius: 6px;
    font-size: 14px;
}

/* === Color Palette === */
.bth-color-palette {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
    margin: 16px 0;
}

.bth-color-swatch {
    width: 120px;
    text-align: center;
    cursor: pointer;
    transition: transform 0.15s;
}

.bth-color-swatch:hover { transform: scale(1.05); }

.bth-color-swatch-preview {
    width: 120px;
    height: 120px;
    border-radius: var(--bth-radius);
    border: 1px solid var(--bth-border);
    margin-bottom: 4px;
}

.bth-color-hex,
.bth-color-rgba,
.bth-color-cmyk {
    display: block;
    font-size: 11px;
    color: var(--bth-text-muted);
    font-family: monospace;
    word-break: break-all;
    line-height: 1.3;
}

.bth-color-hex {
    font-weight: 700;
    color: var(--bth-text);
    font-size: 12px;
}

.bth-color-formats {
    display: flex;
    flex-direction: column;
    gap: 6px;
    margin-top: 8px;
}

.bth-color-format-row {
    display: flex;
    align-items: center;
    gap: 8px;
}

.bth-color-format-label {
    width: 48px;
    font-size: 11px;
    font-weight: 700;
    color: var(--bth-text-muted);
    text-transform: uppercase;
    flex-shrink: 0;
}

.bth-color-format-input {
    flex: 1;
    font-family: monospace;
    font-size: 13px;
    padding: 6px 8px;
}

/* === Color Picker === */
.bth-color-picker-wrap {
    display: flex;
    align-items: center;
    gap: 10px;
}

.bth-color-input {
    width: 48px;
    height: 48px;
    padding: 0;
    border: 2px solid var(--bth-border);
    border-radius: 8px;
    cursor: pointer;
    background: none;
    flex-shrink: 0;
}

.bth-color-input::-webkit-color-swatch-wrapper {
    padding: 2px;
}

.bth-color-input::-webkit-color-swatch {
    border: none;
    border-radius: 4px;
}

.bth-color-hex-input {
    flex: 1;
    min-width: 100px;
    font-family: monospace;
    font-size: 15px;
    text-transform: uppercase;
}

/* === Image Compressor === */
.bth-image-wrap .bth-form-row {
    display: flex;
    gap: 16px;
}

.bth-image-wrap .bth-form-col {
    flex: 1;
    min-width: 0;
}

.bth-dropzone {
    border: 2px dashed var(--bth-border);
    border-radius: var(--bth-radius);
    padding: 40px 20px;
    text-align: center;
    cursor: pointer;
    transition: border-color 0.2s, background 0.2s;
    background: var(--bth-bg-alt);
    position: relative;
}

.bth-dropzone:hover,
.bth-dropzone.bth-dropzone-dragover {
    border-color: var(--bth-primary);
    background: color-mix(in srgb, var(--bth-primary) 3%, transparent);
}

.bth-dropzone-icon {
    color: var(--bth-text-muted);
    margin-bottom: 12px;
}

.bth-dropzone-text {
    font-size: 14px;
    color: var(--bth-text);
    margin: 0 0 4px;
}

.bth-dropzone-hint {
    font-size: 12px;
    color: var(--bth-text-muted);
    margin: 0;
}

.bth-dropzone-input {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    opacity: 0;
    cursor: pointer;
}

.bth-image-preview {
    display: flex;
    gap: 20px;
    flex-wrap: wrap;
    margin: 16px 0;
}

.bth-preview-panel {
    flex: 1;
    min-width: 200px;
    text-align: center;
}

.bth-preview-panel h4 {
    font-size: 13px;
    font-weight: 600;
    margin: 0 0 8px;
    color: var(--bth-text-muted);
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.bth-preview-panel canvas {
    max-width: 100%;
    border: 1px solid var(--bth-border);
    border-radius: 6px;
    margin: 8px 0;
}

.bth-preview-size {
    font-size: 12px;
    color: var(--bth-text-muted);
    margin: 4px 0 0;
}

.bth-image-stats {
    display: flex;
    gap: 24px;
    flex-wrap: wrap;
    padding: 16px;
    background: var(--bth-bg-alt);
    border: 1px solid var(--bth-border);
    border-radius: var(--bth-radius);
    margin: 16px 0;
}

.bth-stat {
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.bth-stat-label {
    font-size: 11px;
    color: var(--bth-text-muted);
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.bth-stat-value {
    font-size: 16px;
    font-weight: 700;
    color: var(--bth-text);
}

/* === Background Remover === */
.bth-bg-hint {
    font-size: 12px;
    color: var(--bth-text-muted);
    margin: 4px 0 0;
}

#bth-bg-original-canvas {
    cursor: crosshair;
}

/* === Pagination === */
.bth-pagination {
    margin-top: 32px;
    text-align: center;
}

.bth-pagination .nav-links {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    flex-wrap: wrap;
    justify-content: center;
}

.bth-pagination a,
.bth-pagination span {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 36px;
    height: 36px;
    padding: 0 8px;
    border: 1px solid var(--bth-border);
    border-radius: 6px;
    font-size: 14px;
    color: var(--bth-text);
    text-decoration: none;
    transition: background 0.2s, border-color 0.2s;
}

.bth-pagination a:hover {
    background: var(--bth-bg-alt);
    border-color: var(--bth-primary);
    color: var(--bth-primary);
}

.bth-pagination .current {
    background: var(--bth-primary);
    border-color: var(--bth-primary);
    color: #fff;
    font-weight: 600;
}

.bth-pagination .dots {
    border: none;
    background: none;
    color: var(--bth-text-muted);
}

/* === Breadcrumbs === */
.bth-breadcrumbs {
    font-size: 13px;
    color: var(--bth-text-muted);
    margin-bottom: 16px;
    padding: 10px 14px;
    background: var(--bth-bg-alt);
    border-radius: 6px;
    display: flex;
    align-items: center;
    gap: 6px;
    flex-wrap: wrap;
}

.bth-breadcrumbs a {
    color: var(--bth-text-secondary, #525252);
    text-decoration: none;
    transition: color 0.2s;
}

.bth-breadcrumbs a:hover {
    color: var(--bth-primary);
    text-decoration: underline;
}

.bth-breadcrumb-sep {
    color: var(--bth-text-muted);
    font-size: 14px;
}

.bth-breadcrumb-current {
    color: var(--bth-text);
    font-weight: 600;
}

/* === Responsive === */
@media (max-width: 768px) {
    .bth-col-3 { grid-template-columns: repeat(2, 1fr); }
    .bth-col-4 { grid-template-columns: repeat(2, 1fr); }
    .bth-tool-body { padding: 16px; }
    .bth-resize-preview { flex-direction: column; }
    .bth-color-swatch { width: 100px; }
    .bth-color-swatch-preview { width: 100px; height: 100px; }
}

@media (max-width: 480px) {
    .bth-col-2, .bth-col-3, .bth-col-4 { grid-template-columns: 1fr; }
    .bth-form-actions { flex-direction: column; }
    .bth-btn { width: 100%; }
    .bth-color-swatch { width: 80px; }
    .bth-color-swatch-preview { width: 80px; height: 80px; }
}
