/* ===== FIRMADOR DE FOTOS v4.0 ===== */

:root {
    --f-primary: #1a73e8;
    --f-primary-hover: #1557b0;
    --f-success: #34a853;
    --f-error: #d93025;
    --f-bg: #ffffff;
    --f-bg-section: #f8f9fa;
    --f-border: #dadce0;
    --f-text: #202124;
    --f-text-secondary: #5f6368;
    --f-radius: 12px;
    --f-radius-sm: 8px;
}

#firmadorApp {
    max-width: 1000px;
    margin: 0 auto;
    padding: 12px;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
    color: var(--f-text);
    -webkit-text-size-adjust: 100%;
}

/* Steps */
.firmador-step {
    margin-bottom: 20px;
    padding: 16px;
    background: var(--f-bg-section);
    border: 1px solid var(--f-border);
    border-radius: var(--f-radius);
}

.firmador-step h3 {
    margin: 0 0 14px;
    font-size: 17px;
    font-weight: 600;
    color: var(--f-text);
}

/* ===== SELECTS ===== */
.firmador-selects {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
    gap: 12px;
}

.firmador-select-group > label {
    display: block;
    font-weight: 600;
    margin-bottom: 4px;
    font-size: 13px;
    color: var(--f-text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.3px;
}

.firmador-select-group select {
    width: 100%;
    padding: 10px 12px;
    font-size: 16px;
    border: 1px solid var(--f-border);
    border-radius: var(--f-radius-sm);
    background: var(--f-bg);
    min-height: 48px;
    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='%235f6368' d='M6 8L1 3h10z'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 12px center;
}

.firmador-thumb {
    margin-top: 6px;
    min-height: 36px;
    display: flex;
    align-items: center;
    gap: 8px;
}

.firmador-thumb-img {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    background: #e8eaed;
    background-image:
        linear-gradient(45deg, #d0d0d0 25%, transparent 25%),
        linear-gradient(-45deg, #d0d0d0 25%, transparent 25%),
        linear-gradient(45deg, transparent 75%, #d0d0d0 75%),
        linear-gradient(-45deg, transparent 75%, #d0d0d0 75%);
    background-size: 10px 10px;
    background-position: 0 0, 0 5px, 5px -5px, -5px 0;
    border-radius: 4px;
    border: 1px solid var(--f-border);
    padding: 4px;
}

.firmador-thumb img {
    max-height: 40px;
    display: block;
}

.firmador-thumb-name {
    font-size: 13px;
    font-weight: 500;
    color: var(--f-text);
}

/* ===== PREVIEW LAYOUT ===== */
.firmador-preview-layout {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 16px;
    align-items: start;
}

.firmador-preview-box {
    background: #e8eaed;
    border: 2px dashed var(--f-border);
    border-radius: var(--f-radius);
    min-height: 220px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    overflow: hidden;
    position: relative;
    cursor: crosshair;
    transition: border-color 0.2s;
}

.firmador-preview-box.drag-over {
    border-color: var(--f-primary);
    background: #e8f0fe;
}

.firmador-preview-box canvas {
    max-width: 100%;
    max-height: 500px;
    display: block;
    touch-action: none; /* for drag on canvas */
}

.firmador-placeholder {
    color: #999;
    font-size: 14px;
    text-align: center;
    padding: 24px;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 10px;
}

.firmador-placeholder p {
    margin: 0;
}

.firmador-photo-actions {
    margin-top: 10px;
    display: flex;
    gap: 8px;
}

/* ===== CONTROL SECTIONS (colapsables) ===== */
.firmador-control-section {
    border: 1px solid var(--f-border);
    border-radius: var(--f-radius-sm);
    padding: 0;
    margin-bottom: 8px;
    background: var(--f-bg);
    overflow: hidden;
    transition: box-shadow 0.2s;
}

.firmador-control-section[data-collapsed="false"] {
    box-shadow: 0 1px 4px rgba(0,0,0,0.08);
}

.firmador-section-header {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 10px 14px;
    cursor: pointer;
    user-select: none;
    -webkit-user-select: none;
    min-height: 48px;
    font-weight: 600;
    font-size: 14px;
    margin: 0;
    width: 100%;
    box-sizing: border-box;
}

.firmador-section-header:hover {
    background: #f1f3f4;
}

.firmador-section-title {
    display: flex;
    align-items: center;
    gap: 6px;
    flex: 1;
    min-width: 0;
}

.firmador-section-icon {
    font-size: 16px;
    flex-shrink: 0;
}

.firmador-section-summary {
    font-weight: 400;
    font-size: 12px;
    color: var(--f-text-secondary);
    margin-left: 4px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.firmador-chevron {
    font-size: 10px;
    color: var(--f-text-secondary);
    transition: transform 0.25s;
    flex-shrink: 0;
    margin-left: 6px;
}

.firmador-control-section[data-collapsed="false"] .firmador-chevron {
    transform: rotate(180deg);
}

.firmador-section-body {
    max-height: 0;
    overflow: hidden;
    transition: max-height 0.3s ease, padding 0.3s ease;
    padding: 0 14px;
}

.firmador-control-section[data-collapsed="false"] .firmador-section-body {
    max-height: 500px;
    padding: 0 14px 14px;
}

/* Position grid */
.firmador-quick-pos {
    margin-bottom: 10px;
}

.firmador-quick-label {
    font-size: 12px;
    color: var(--f-text-secondary);
    display: block;
    margin-bottom: 4px;
}

.firmador-pos-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 3px;
    width: 108px;
}

.firmador-pos-btn {
    width: 34px;
    height: 34px;
    border: 1px solid var(--f-border);
    border-radius: 4px;
    background: var(--f-bg);
    cursor: pointer;
    font-size: 14px;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0;
    transition: background 0.15s;
    color: var(--f-text-secondary);
    line-height: 1;
}

.firmador-pos-btn:hover,
.firmador-pos-btn:active {
    background: #e8f0fe;
    border-color: var(--f-primary);
    color: var(--f-primary);
}

.firmador-pos-btn.active {
    background: var(--f-primary);
    color: #fff;
    border-color: var(--f-primary);
}

/* Sliders */
.firmador-sliders label {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 13px;
    margin-bottom: 2px;
    min-height: 32px;
    color: var(--f-text-secondary);
}

.firmador-sliders label span {
    min-width: 28px;
    text-align: right;
    font-variant-numeric: tabular-nums;
}

.firmador-slider {
    flex: 1;
    min-width: 60px;
    height: 32px;
    cursor: pointer;
    accent-color: var(--f-primary);
}

/* ===== TOGGLE ===== */
.firmador-toggle {
    position: relative;
    display: inline-block;
    width: 44px;
    height: 24px;
    flex-shrink: 0;
}

.firmador-toggle input {
    opacity: 0;
    width: 0;
    height: 0;
    position: absolute;
}

.firmador-toggle-slider {
    position: absolute;
    cursor: pointer;
    top: 0; left: 0; right: 0; bottom: 0;
    background: #bdc1c6;
    border-radius: 24px;
    transition: 0.25s;
}

.firmador-toggle-slider:before {
    content: "";
    position: absolute;
    height: 18px;
    width: 18px;
    left: 3px;
    bottom: 3px;
    background: #fff;
    border-radius: 50%;
    transition: 0.25s;
    box-shadow: 0 1px 2px rgba(0,0,0,0.2);
}

.firmador-toggle input:checked + .firmador-toggle-slider {
    background: var(--f-success);
}

.firmador-toggle input:checked + .firmador-toggle-slider:before {
    transform: translateX(20px);
}

/* ===== BUTTONS ===== */
.firmador-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    padding: 10px 18px;
    font-size: 14px;
    font-weight: 500;
    border-radius: var(--f-radius-sm);
    cursor: pointer;
    border: 1px solid var(--f-border);
    background: var(--f-bg);
    color: var(--f-text);
    text-align: center;
    min-height: 44px;
    box-sizing: border-box;
    transition: background 0.15s, box-shadow 0.15s;
    text-decoration: none;
    white-space: nowrap;
}

.firmador-btn:hover {
    background: #f1f3f4;
}

.firmador-btn-primary {
    background: var(--f-primary);
    color: #fff;
    border-color: var(--f-primary);
}

.firmador-btn-primary:hover {
    background: var(--f-primary-hover);
}

.firmador-btn-primary:disabled {
    background: #94b8e0;
    border-color: #94b8e0;
    cursor: not-allowed;
}

.firmador-btn-secondary {
    background: var(--f-bg);
    color: var(--f-text-secondary);
}

.firmador-btn-sm {
    padding: 8px 14px;
    font-size: 13px;
    min-height: 36px;
}

/* ===== DROP ZONE ===== */
.firmador-drop-zone {
    border: 2px dashed var(--f-border);
    border-radius: var(--f-radius);
    padding: 24px;
    text-align: center;
    color: var(--f-text-secondary);
    transition: all 0.2s;
    margin-bottom: 12px;
    cursor: pointer;
}

.firmador-drop-zone p {
    margin: 8px 0 0;
    font-size: 14px;
}

.firmador-drop-zone.drag-over {
    border-color: var(--f-primary);
    background: #e8f0fe;
    color: var(--f-primary);
}

.firmador-file-count {
    display: inline-block;
    margin-top: 6px;
    font-size: 13px;
    font-weight: 600;
    color: var(--f-success);
}

.firmador-file-count:empty {
    display: none;
}

.firmador-batch-actions {
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
}

/* ===== PROGRESS ===== */
.firmador-progress-bar {
    width: 100%;
    height: 8px;
    background: #e0e0e0;
    border-radius: 4px;
    overflow: hidden;
    margin: 14px 0 8px;
}

.firmador-progress-fill {
    height: 100%;
    background: var(--f-primary);
    width: 0%;
    transition: width 0.3s;
    border-radius: 4px;
}

.firmador-progress-info {
    display: flex;
    justify-content: space-between;
    font-size: 13px;
    color: var(--f-text-secondary);
}

/* ===== STATUS ===== */
#firmadorStatus .firmador-msg {
    padding: 10px 14px;
    border-radius: var(--f-radius-sm);
    margin-top: 10px;
    font-size: 14px;
}

#firmadorStatus .firmador-msg.error {
    background: #fce8e6;
    color: var(--f-error);
    border: 1px solid #f5c6c2;
}

#firmadorStatus .firmador-msg.success {
    background: #e6f4ea;
    color: #137333;
    border: 1px solid #a8dab5;
}

#firmadorStatus .firmador-msg.info {
    background: #e8f0fe;
    color: #1967d2;
    border: 1px solid #aecbfa;
}

/* ===== MOBILE ===== */
@media (max-width: 768px) {
    .firmador-preview-layout {
        grid-template-columns: 1fr;
    }

    /* Sticky preview on mobile */
    .firmador-preview-col {
        position: sticky;
        top: 0;
        z-index: 10;
        background: var(--f-bg-section);
        padding-bottom: 8px;
        margin: -16px -16px 0;
        padding: 8px 16px;
        border-bottom: 1px solid var(--f-border);
    }

    .firmador-preview-box {
        min-height: 160px;
        max-height: 40vh;
    }

    .firmador-preview-box canvas {
        max-height: 38vh;
    }

    .firmador-btn {
        width: 100%;
        padding: 14px 20px;
        min-height: 48px;
    }

    .firmador-btn-sm {
        min-height: 40px;
    }

    .firmador-batch-actions {
        flex-direction: column;
    }

    .firmador-slider {
        height: 44px;
    }

    .firmador-select-group select {
        font-size: 16px;
    }

    .firmador-pos-btn {
        width: 40px;
        height: 40px;
    }

    .firmador-pos-grid {
        width: 130px;
    }

    .firmador-drop-zone {
        padding: 20px 16px;
    }
}

/* Small phones */
@media (max-width: 380px) {
    #firmadorApp {
        padding: 6px;
    }

    .firmador-step {
        padding: 12px;
    }

    .firmador-preview-col {
        margin: -12px -12px 0;
        padding: 6px 12px;
    }
}
