/* ===== CARTONES — cartones.php ===== */

body {
    background: var(--bg);
}

/* ===== PAGE LAYOUT ===== */
.cartones-page {
    padding: 40px 20px 60px;
}

/* ===== CONFIG SECTION ===== */
.cartones-config {
    background: var(--white);
    border-radius: 20px;
    padding: 32px;
    max-width: 1400px;
    margin: 0 auto;
    border: 2px solid #e5e7eb;
    box-shadow:
        0 5px 0 #d1d5db,
        0 7px 16px rgba(0, 0, 0, 0.08);
}

/* cartonesArea ya esta dentro de la columna principal */

.config-options {
    margin-top: 28px;
    display: flex;
    flex-direction: column;
    gap: 20px;
}

/* ===== CONFIG GROUP ===== */
.config-group label {
    font-weight: 600;
    font-size: var(--text-base);
    color: var(--gray-dark);
    margin-bottom: 8px;
    display: block;
}

/* ===== FORMAT TOGGLE ===== */
.config-toggle {
    display: flex;
    gap: 8px;
}

.format-btn {
    padding: 12px 24px;
    border-radius: 14px;
    border: 1px solid rgba(0, 0, 0, 0.08);
    background: linear-gradient(to bottom, #ffffff, #f1f5f9);
    font-family: inherit;
    font-size: var(--text-base);
    font-weight: 600;
    cursor: pointer;
    transition: all 0.15s;
    position: relative;
    top: 0;
    color: var(--gray-dark);
    box-shadow:
        0 4px 0 #d1d5db,
        0 6px 10px rgba(0, 0, 0, 0.06),
        inset 0 1px 0 rgba(255, 255, 255, 0.9);
}

.format-btn:hover {
    top: 2px;
    color: var(--blue-dark);
    box-shadow:
        0 2px 0 #d1d5db,
        0 3px 6px rgba(0, 0, 0, 0.05),
        inset 0 1px 0 rgba(255, 255, 255, 0.9);
}

.format-btn:active {
    top: 4px;
    box-shadow:
        0 0px 0 #d1d5db,
        0 1px 3px rgba(0, 0, 0, 0.03);
}

.format-btn.active {
    background: linear-gradient(to bottom, #2dd4f0, #0ea5e9);
    color: var(--white);
    border-color: transparent;
    box-shadow:
        0 4px 0 #0b7bb5,
        0 6px 10px rgba(26, 188, 245, 0.25);
}

.format-btn.active:hover {
    top: 2px;
    box-shadow:
        0 2px 0 #0b7bb5,
        0 3px 6px rgba(26, 188, 245, 0.2);
}

.format-btn.active:active {
    top: 4px;
    box-shadow:
        0 0px 0 #0b7bb5,
        0 1px 3px rgba(26, 188, 245, 0.15);
}

/* ===== THEME SELECTOR ===== */
.theme-selector {
    display: grid;
    grid-template-columns: repeat(5, 1fr);
    gap: 12px;
}

.theme-option {
    display: flex;
    flex-direction: column;
    align-items: stretch;
    padding: 0;
    border: 2px solid var(--t-border, #e5e7eb);
    border-radius: 16px;
    background: var(--white);
    font-family: inherit;
    cursor: pointer;
    transition: all 0.2s;
    position: relative;
    top: 0;
    overflow: hidden;
    box-shadow:
        0 4px 0 var(--t-relief, #d1d5db),
        0 6px 12px rgba(0, 0, 0, 0.06);
}

.theme-option:hover {
    top: -3px;
    box-shadow:
        0 7px 0 var(--t-relief, #d1d5db),
        0 10px 20px rgba(0, 0, 0, 0.1);
}

.theme-option:active {
    top: 4px;
    box-shadow:
        0 0px 0 var(--t-relief, #d1d5db),
        0 1px 3px rgba(0, 0, 0, 0.04);
}

.theme-option.active {
    box-shadow:
        0 4px 0 var(--t-relief, #d1d5db),
        0 6px 14px rgba(0, 0, 0, 0.12);
    outline: 3px solid #ec4899;
    outline-offset: -1px;
}

.theme-option.active:hover {
    top: -3px;
    box-shadow:
        0 7px 0 var(--t-relief, #d1d5db),
        0 10px 20px rgba(0, 0, 0, 0.15);
}

.theme-option.active:active {
    top: 4px;
    box-shadow:
        0 0px 0 var(--t-relief, #d1d5db),
        0 1px 3px rgba(0, 0, 0, 0.04);
}

/* Mini card preview */
.theme-preview {
    width: 100%;
    aspect-ratio: 4 / 3;
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
    transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    background: rgba(0, 0, 0, 0.03);
}

.theme-preview img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.theme-preview-dot {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    display: block;
}

.theme-option:hover .theme-preview {
    transform: scale(1.04);
}

.theme-preview-header {
    height: 18%;
    background: var(--t-header);
    border-bottom: 1px solid var(--t-border);
    flex-shrink: 0;
}

.theme-preview-grid {
    flex: 1;
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    grid-template-rows: repeat(3, 1fr);
    gap: 1px;
    padding: 3px;
}

.tp-empty {
    background: var(--t-empty);
    border-radius: 2px;
}

.tp-num {
    background: var(--t-bg);
    border-radius: 2px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--t-num);
    font-size: 10px;
    font-weight: 700;
    line-height: 1;
}

.tp-marked {
    background: var(--t-marked);
    border-radius: 2px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #fff;
    font-size: 10px;
    font-weight: 700;
    line-height: 1;
}

/* Theme name label */
.theme-option-name {
    font-size: var(--text-xs);
    font-weight: 600;
    color: var(--gray-dark);
    padding: 6px 6px 8px;
    text-align: center;
    line-height: 1.2;
}

.theme-option.active .theme-option-name {
    color: #ec4899;
    font-weight: 700;
}

/* Check badge */
.theme-option-check {
    position: absolute;
    top: 6px;
    right: 6px;
    width: 24px;
    height: 24px;
    background: #ec4899;
    border-radius: 50%;
    display: none;
    align-items: center;
    justify-content: center;
    box-shadow: 0 3px 10px rgba(236, 72, 153, 0.4);
    z-index: 1;
    animation: themeCheckPop 0.3s ease;
}

@keyframes themeCheckPop {
    0% { transform: scale(0); }
    50% { transform: scale(1.2); }
    100% { transform: scale(1); }
}

.theme-option.active .theme-option-check {
    display: flex;
}

.theme-option-check svg {
    width: 14px;
    height: 14px;
    color: white;
}

/* ===== QUANTITY SELECTOR ===== */
.quantity-selector {
    display: flex;
    gap: 8px;
}

.qty-btn {
    width: 48px;
    height: 48px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-family: inherit;
    font-weight: 700;
    font-size: var(--text-lg);
    border: 1px solid rgba(0, 0, 0, 0.08);
    background: linear-gradient(to bottom, #ffffff, #f1f5f9);
    cursor: pointer;
    transition: all 0.15s;
    position: relative;
    top: 0;
    color: var(--gray-dark);
    box-shadow:
        0 4px 0 #d1d5db,
        0 6px 10px rgba(0, 0, 0, 0.06),
        inset 0 1px 0 rgba(255, 255, 255, 0.9);
}

.qty-btn:hover {
    top: 2px;
    color: var(--blue-dark);
    box-shadow:
        0 2px 0 #d1d5db,
        0 3px 6px rgba(0, 0, 0, 0.05),
        inset 0 1px 0 rgba(255, 255, 255, 0.9);
}

.qty-btn:active {
    top: 4px;
    box-shadow:
        0 0px 0 #d1d5db,
        0 1px 3px rgba(0, 0, 0, 0.03);
}

.qty-btn.active {
    background: linear-gradient(to bottom, #2dd4f0, #0ea5e9);
    color: var(--white);
    border-color: transparent;
    box-shadow:
        0 4px 0 #0b7bb5,
        0 6px 10px rgba(26, 188, 245, 0.25);
}

.qty-btn.active:hover {
    top: 2px;
    box-shadow:
        0 2px 0 #0b7bb5,
        0 3px 6px rgba(26, 188, 245, 0.2);
}

.qty-btn.active:active {
    top: 4px;
    box-shadow:
        0 0px 0 #0b7bb5,
        0 1px 3px rgba(26, 188, 245, 0.15);
}

/* ===== GENERATE BUTTON ===== */
.btn-generate {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    width: 100%;
    max-width: 300px;
    margin: 12px auto 0;
    padding: 16px 32px;
    border-radius: 50px;
    font-family: inherit;
    font-size: var(--text-lg);
    font-weight: 600;
    border: none;
    cursor: pointer;
    transition: all 0.15s;
    position: relative;
    top: 0;
    background: linear-gradient(to bottom, #f472b6, #ec4899);
    color: var(--white);
    box-shadow:
        0 5px 0 #be185d,
        0 7px 12px rgba(255, 29, 186, 0.3);
    overflow: hidden;
}

.btn-generate::before {
    content: '';
    position: absolute;
    top: 0;
    left: -100%;
    width: 100%;
    height: 100%;
    background: linear-gradient(90deg, transparent, rgba(255,255,255,0.3), transparent);
    transition: left 0.5s;
}

.btn-generate:hover::before {
    left: 100%;
}

.btn-generate:hover {
    top: 3px;
    box-shadow:
        0 2px 0 #be185d,
        0 3px 6px rgba(255, 29, 186, 0.2);
}

.btn-generate:active {
    top: 5px;
    box-shadow:
        0 0px 0 #be185d,
        0 1px 3px rgba(255, 29, 186, 0.15);
}

.btn-generate svg {
    width: 22px;
    height: 22px;
    flex-shrink: 0;
}

/* ===== CARDS AREA ===== */
#cartonesArea {
    max-width: 1400px;
    margin: 40px auto 0;
}

/* ===== ACTION BUTTONS ===== */
.cartones-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    justify-content: center;
    margin-bottom: 24px;
}

.btn-action {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    color: var(--gray-dark);
    font-family: inherit;
    font-size: var(--text-base);
    font-weight: 500;
    text-decoration: none;
    padding: 14px 24px;
    border-radius: 50px;
    background: var(--white);
    border: none;
    cursor: pointer;
    position: relative;
    top: 0;
    box-shadow:
        0 4px 0 #d1d5db,
        0 6px 10px rgba(0, 0, 0, 0.06);
    transition: all 0.15s;
}

.btn-action:hover {
    top: 2px;
    box-shadow:
        0 2px 0 #d1d5db,
        0 3px 6px rgba(0, 0, 0, 0.05);
}

.btn-action:active {
    top: 4px;
    box-shadow:
        0 0px 0 #d1d5db,
        0 1px 3px rgba(0, 0, 0, 0.03);
}

.btn-action svg {
    width: 20px;
    height: 20px;
    flex-shrink: 0;
}

.btn-action.btn-pdf {
    color: #0ea5e9;
}

.btn-action.btn-pdf:hover {
    background: #f0f9ff;
}

/* ===== PAGE HEADER ===== */
.cartones-page-header {
    max-width: 1400px;
    margin: 0 auto 24px;
    text-align: center;
}

.cartones-page-header h1 {
    font-size: var(--text-3xl);
    font-weight: 800;
    background: linear-gradient(135deg, var(--pink), var(--blue));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.cartones-page-header p {
    color: var(--gray);
    margin-top: 8px;
    font-size: var(--text-xl);
    line-height: 1.5;
}

/* ===== 2-COLUMN LAYOUT ===== */
.cartones-layout {
    max-width: 1400px;
    margin: 0 auto;
    display: flex;
    gap: 20px;
    align-items: flex-start;
}

.cartones-layout-main {
    flex: 1;
    min-width: 0;
}

.cartones-layout-sidebar {
    flex: 0 0 30%;
    display: flex;
    flex-direction: column;
    gap: 14px;
    position: sticky;
    top: 24px;
    background: var(--white);
    border-radius: 20px;
    padding: 20px;
    border: 2px solid #e5e7eb;
    box-shadow:
        0 5px 0 #d1d5db,
        0 7px 16px rgba(0, 0, 0, 0.08);
}

/* ===== BATCH CARDS ===== */
.batch-card {
}

.batch-card-header {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-bottom: 14px;
}

.batch-flag {
    width: 28px;
    height: 28px;
    border-radius: 50%;
    object-fit: cover;
    flex-shrink: 0;
}

.batch-card-title {
    font-size: var(--text-base);
    font-weight: 700;
    color: var(--gray-dark);
}

.batch-card-sub {
    font-size: var(--text-xs);
    color: var(--gray);
}

/* ===== BATCH BUTTONS ===== */
.batch-buttons {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.batch-btn {
    display: flex;
    align-items: center;
    justify-content: space-between;
    width: 100%;
    padding: 12px 14px;
    border-radius: 12px;
    border: none;
    font-family: inherit;
    cursor: pointer;
    transition: all 0.2s;
    position: relative;
    top: 0;
    background: linear-gradient(to bottom, #2dd4f0, #0ea5e9);
    color: var(--white);
    box-shadow:
        0 3px 0 #0b7bb5,
        0 5px 10px rgba(26, 188, 245, 0.2);
}

.batch-btn:hover {
    top: 2px;
    box-shadow:
        0 1px 0 #0b7bb5,
        0 2px 6px rgba(26, 188, 245, 0.15);
}

.batch-btn:active {
    top: 3px;
    box-shadow:
        0 0px 0 #0b7bb5,
        0 1px 3px rgba(26, 188, 245, 0.1);
}

.batch-btn-dot {
    width: 22px;
    height: 22px;
    border-radius: 50%;
    flex-shrink: 0;
    background: #000000;
    box-shadow: 0 0 0 2px rgba(255, 255, 255, 0.4);
    margin-left: auto;
    margin-right: 10px;
}

.batch-btn.locked .batch-btn-dot {
    opacity: 0.4;
}

.batch-btn-info {
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    gap: 1px;
}

.batch-btn-pages {
    font-size: var(--text-sm);
    font-weight: 700;
}

.batch-btn-cards {
    font-size: 11px;
    opacity: 0.85;
}

.batch-btn-icon {
    width: 26px;
    height: 26px;
    flex-shrink: 0;
}

.batch-btn-lock {
    display: none;
}

/* Locked state */
.batch-btn.locked {
    background: #e5e7eb;
    color: #9ca3af;
    box-shadow:
        0 3px 0 #d1d5db,
        0 5px 10px rgba(0, 0, 0, 0.04);
}

.batch-btn.locked:hover {
    box-shadow:
        0 1px 0 #d1d5db,
        0 2px 6px rgba(0, 0, 0, 0.03);
}

.batch-btn.locked .batch-btn-icon {
    display: none;
}

.batch-btn.locked .batch-btn-lock {
    display: block;
    width: 18px;
    height: 18px;
    flex-shrink: 0;
}

/* Generating state */
.batch-btn.generating {
    pointer-events: none;
    opacity: 0.7;
}

/* ===== SIDEBAR HEADER ===== */
.batch-sidebar-header {
    text-align: center;
}

.batch-sidebar-header::after {
    content: '';
    display: block;
    height: 1px;
    background: linear-gradient(90deg, transparent, rgba(255, 29, 186, 0.3), var(--blue), rgba(255, 29, 186, 0.3), transparent);
    margin-top: 14px;
}

.batch-sidebar-title {
    font-size: var(--text-base);
    font-weight: 700;
    color: var(--gray-dark);
}

.batch-sidebar-sub {
    font-size: var(--text-xs);
    color: var(--gray);
    line-height: 1.5;
    margin-top: 4px;
}

.batch-sidebar-sub a {
    color: var(--blue);
    text-decoration: none;
    font-weight: 600;
}

.batch-sidebar-sub a:hover {
    text-decoration: underline;
}

/* ===== PREMIUM MODAL ===== */
.batch-modal {
    position: fixed;
    inset: 0;
    z-index: 9999;
    display: flex;
    align-items: center;
    justify-content: center;
}

.batch-modal-backdrop {
    position: absolute;
    inset: 0;
    background: rgba(0, 0, 0, 0.5);
    backdrop-filter: blur(4px);
}

.batch-modal-content {
    position: relative;
    background: var(--white);
    border-radius: 20px;
    padding: 40px 32px;
    max-width: 420px;
    width: 90%;
    text-align: center;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.2);
    animation: batchModalIn 0.25s ease-out;
}

@keyframes batchModalIn {
    from { opacity: 0; transform: scale(0.9) translateY(10px); }
    to { opacity: 1; transform: scale(1) translateY(0); }
}

.batch-modal-close {
    position: absolute;
    top: 14px;
    right: 14px;
    background: none;
    border: none;
    color: var(--gray);
    cursor: pointer;
    padding: 4px;
    border-radius: 8px;
    transition: background 0.15s;
}

.batch-modal-close:hover {
    background: #f3f4f6;
}

.batch-modal-icon {
    width: 64px;
    height: 64px;
    border-radius: 50%;
    background: linear-gradient(135deg, #fef3c7, #fde68a);
    display: flex;
    align-items: center;
    justify-content: center;
    margin: 0 auto 16px;
    color: #f59e0b;
}

.batch-modal-content h3 {
    font-size: var(--text-xl);
    font-weight: 700;
    color: var(--gray-dark);
    margin-bottom: 8px;
}

.batch-modal-content p {
    font-size: var(--text-sm);
    color: var(--gray);
    line-height: 1.6;
    margin-bottom: 20px;
}

.batch-modal-btn {
    display: inline-block;
    padding: 14px 32px;
    background: linear-gradient(to bottom, #f472b6, #ec4899);
    color: var(--white);
    border-radius: 50px;
    font-size: var(--text-base);
    font-weight: 600;
    text-decoration: none;
    box-shadow:
        0 4px 0 #be185d,
        0 6px 10px rgba(255, 29, 186, 0.25);
    transition: all 0.15s;
    position: relative;
    top: 0;
}

.batch-modal-btn:hover {
    top: 2px;
    box-shadow:
        0 2px 0 #be185d,
        0 3px 6px rgba(255, 29, 186, 0.2);
}

/* ===== CONFIRM MODAL ===== */
.confirm-modal {
    position: fixed;
    inset: 0;
    z-index: 9999;
    display: flex;
    align-items: center;
    justify-content: center;
}

.confirm-modal-backdrop {
    position: absolute;
    inset: 0;
    background: rgba(0, 0, 0, 0.5);
    backdrop-filter: blur(4px);
}

.confirm-modal-content {
    position: relative;
    background: var(--white);
    border-radius: 20px;
    padding: 32px 28px 24px;
    max-width: 380px;
    width: 90%;
    text-align: center;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.2);
    animation: batchModalIn 0.25s ease-out;
}

.confirm-modal-icon {
    width: 56px;
    height: 56px;
    border-radius: 50%;
    background: linear-gradient(135deg, #fef3c7, #fde68a);
    display: flex;
    align-items: center;
    justify-content: center;
    margin: 0 auto 14px;
    color: #f59e0b;
}

.confirm-modal-content h3 {
    font-size: var(--text-lg);
    font-weight: 700;
    color: var(--gray-dark);
    margin-bottom: 6px;
}

.confirm-modal-content p {
    font-size: var(--text-sm);
    color: var(--gray);
    line-height: 1.6;
    margin-bottom: 20px;
}

.confirm-modal-actions {
    display: flex;
    gap: 10px;
    justify-content: center;
}

.confirm-btn-cancel,
.confirm-btn-ok {
    padding: 12px 28px;
    border-radius: 50px;
    font-family: inherit;
    font-size: var(--text-sm);
    font-weight: 600;
    border: none;
    cursor: pointer;
    transition: all 0.15s;
    position: relative;
    top: 0;
}

.confirm-btn-cancel {
    background: var(--white);
    color: var(--gray-dark);
    box-shadow:
        0 3px 0 #d1d5db,
        0 5px 10px rgba(0, 0, 0, 0.06);
}

.confirm-btn-cancel:hover {
    top: 2px;
    box-shadow:
        0 1px 0 #d1d5db,
        0 2px 6px rgba(0, 0, 0, 0.04);
}

.confirm-btn-ok {
    background: linear-gradient(to bottom, #f472b6, #ec4899);
    color: var(--white);
    box-shadow:
        0 3px 0 #be185d,
        0 5px 10px rgba(255, 29, 186, 0.25);
}

.confirm-btn-ok:hover {
    top: 2px;
    box-shadow:
        0 1px 0 #be185d,
        0 2px 6px rgba(255, 29, 186, 0.2);
}

/* ===== RESPONSIVE ===== */

/* Mobile: < 480px */
@media (max-width: 479px) {
    .cartones-page {
        padding: 20px 12px 40px;
    }

    .cartones-config {
        padding: 24px 16px;
        border-radius: 16px;
    }

    .config-toggle {
        flex-direction: column;
    }

    .format-btn {
        text-align: center;
    }

    .theme-selector {
        grid-template-columns: repeat(2, 1fr);
        gap: 8px;
    }

    .tp-num,
    .tp-marked {
        font-size: 8px;
    }

    .qty-btn {
        width: 42px;
        height: 42px;
        font-size: var(--text-base);
    }

    .btn-generate {
        max-width: 100%;
    }

    .cartones-actions {
        flex-direction: column;
        align-items: stretch;
    }

    .btn-action {
        justify-content: center;
    }

    .cartones-layout {
        flex-direction: column;
    }

    .cartones-layout-sidebar {
        flex: none;
        width: 100%;
        position: static;
    }
}

/* Tablet: 480-767px */
@media (min-width: 480px) and (max-width: 767px) {
    .cartones-page {
        padding: 28px 16px 50px;
    }

    .cartones-config {
        padding: 28px 24px;
    }

    .theme-selector {
        grid-template-columns: repeat(3, 1fr);
        gap: 10px;
    }

    .cartones-layout {
        flex-direction: column;
    }

    .cartones-layout-sidebar {
        flex: none;
        width: 100%;
        position: static;
        flex-direction: row;
        flex-wrap: wrap;
    }

    .cartones-layout-sidebar .batch-card {
        flex: 1;
        min-width: 240px;
    }

    .cartones-layout-sidebar .batch-sidebar-header {
        flex-basis: 100%;
    }
}

/* Small desktop: 768-1023px */
@media (min-width: 768px) and (max-width: 1023px) {
    .cartones-page {
        padding: 40px 24px 60px;
    }

    .cartones-config {
        padding: 32px;
    }

    .config-options {
        gap: 24px;
    }

    .theme-selector {
        grid-template-columns: repeat(5, 1fr);
        gap: 10px;
    }

    .cartones-layout {
        flex-direction: column;
    }

    .cartones-layout-sidebar {
        flex: none;
        width: 100%;
        position: static;
        flex-direction: row;
        flex-wrap: wrap;
    }

    .cartones-layout-sidebar .batch-card {
        flex: 1;
        min-width: 240px;
    }

    .cartones-layout-sidebar .batch-sidebar-header {
        flex-basis: 100%;
    }
}

/* Desktop: 1024px+ */
@media (min-width: 1024px) {
    .cartones-page {
        padding: 50px 40px 70px;
    }

    .cartones-config {
        padding: 40px 48px;
    }

    .config-options {
        gap: 24px;
    }
}
