/* ==========================================
   Generador de Stickers V2 - Soporte CG
   ========================================== */

@import url('https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600;700;800&display=swap');

:root {
    --bg-primary: #0f0f1a;
    --bg-secondary: #1a1a2e;
    --bg-card: rgba(30, 30, 50, 0.7);
    --border-glass: rgba(255, 255, 255, 0.08);
    --accent-brand: #004367;
    --accent-cyan: #00d4ff;
    --accent-cyan-dim: rgba(0, 212, 255, 0.15);
    --accent-purple: #7b2ff7;
    --accent-gradient: linear-gradient(135deg, #00d4ff, #7b2ff7);
    --text-primary: #ffffff;
    --text-secondary: #a0a0b8;
    --text-muted: #6a6a80;
    --success: #00e676;
    --danger: #ff4757;
    --radius: 16px;
    --radius-sm: 10px;
    --transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

*,
*::before,
*::after {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: 'Inter', sans-serif;
    background: var(--bg-primary);
    color: var(--text-primary);
    min-height: 100vh;
    overflow-x: hidden;
}

body::before {
    content: '';
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background:
        radial-gradient(ellipse at 20% 50%, rgba(0, 212, 255, 0.08) 0%, transparent 50%),
        radial-gradient(ellipse at 80% 20%, rgba(123, 47, 247, 0.08) 0%, transparent 50%),
        radial-gradient(ellipse at 50% 80%, rgba(0, 212, 255, 0.05) 0%, transparent 50%);
    pointer-events: none;
    z-index: 0;
}

/* ==========================================
   Header
   ========================================== */

.header {
    position: relative;
    z-index: 1;
    padding: 16px 28px;
    display: flex;
    align-items: center;
    gap: 16px;
    border-bottom: 1px solid var(--border-glass);
    background: rgba(15, 15, 26, 0.85);
    backdrop-filter: blur(20px);
}

.header-logo {
    width: 44px;
    height: 44px;
    border-radius: 10px;
    background: var(--accent-gradient);
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 800;
    font-size: 17px;
    color: #fff;
    flex-shrink: 0;
    box-shadow: 0 4px 20px rgba(0, 212, 255, 0.3);
}

.header-info h1 {
    font-size: 20px;
    font-weight: 700;
    background: var(--accent-gradient);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.header-info p {
    font-size: 12px;
    color: var(--text-muted);
    margin-top: 1px;
}

.header-actions {
    margin-left: auto;
    display: flex;
    gap: 8px;
}

.btn-header {
    padding: 8px 14px;
    border: 1px solid var(--border-glass);
    border-radius: 8px;
    background: rgba(255, 255, 255, 0.04);
    color: var(--text-secondary);
    font-family: 'Inter', sans-serif;
    font-size: 12px;
    font-weight: 500;
    cursor: pointer;
    transition: var(--transition);
    display: flex;
    align-items: center;
    gap: 6px;
}

.btn-header:hover {
    background: rgba(255, 255, 255, 0.08);
    color: var(--text-primary);
    border-color: rgba(255, 255, 255, 0.15);
}

.btn-header.btn-danger:hover {
    background: rgba(255, 71, 87, 0.15);
    border-color: rgba(255, 71, 87, 0.3);
    color: var(--danger);
}

/* ==========================================
   Main Layout
   ========================================== */

.app-container {
    position: relative;
    z-index: 1;
    display: grid;
    grid-template-columns: 360px 1fr;
    min-height: calc(100vh - 77px);
}

/* ==========================================
   Sidebar
   ========================================== */

.sidebar {
    padding: 20px 22px;
    border-right: 1px solid var(--border-glass);
    background: rgba(20, 20, 35, 0.5);
    backdrop-filter: blur(10px);
    display: flex;
    flex-direction: column;
    gap: 16px;
    overflow-y: auto;
}

.sidebar-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.section-title {
    font-size: 11px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 1.5px;
    color: var(--accent-cyan);
}

.section-title-sm {
    font-size: 10px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 1px;
    color: var(--text-muted);
    margin-bottom: 6px;
}

.editing-badge {
    padding: 4px 10px;
    border-radius: 20px;
    background: rgba(0, 212, 255, 0.12);
    border: 1px solid rgba(0, 212, 255, 0.25);
    font-size: 11px;
    font-weight: 600;
    color: var(--accent-cyan);
}

/* Upload Zone */
.upload-zone {
    position: relative;
    border: 2px dashed rgba(0, 212, 255, 0.25);
    border-radius: var(--radius-sm);
    padding: 24px 16px;
    text-align: center;
    cursor: pointer;
    transition: var(--transition);
    background: rgba(0, 212, 255, 0.03);
    overflow: hidden;
}

.upload-zone:hover {
    border-color: var(--accent-cyan);
    background: rgba(0, 212, 255, 0.06);
}

.upload-zone.has-image {
    padding: 8px;
    border-style: solid;
    border-color: rgba(0, 230, 118, 0.3);
    background: rgba(0, 230, 118, 0.03);
}

.upload-zone input[type="file"] {
    display: none;
}

.upload-icon {
    font-size: 32px;
    margin-bottom: 6px;
    opacity: 0.7;
}

.upload-text {
    font-size: 13px;
    font-weight: 500;
    color: var(--text-secondary);
}

.upload-text span {
    color: var(--accent-cyan);
    font-weight: 600;
}

.upload-hint {
    font-size: 10px;
    color: var(--text-muted);
    margin-top: 4px;
}

.upload-preview {
    display: none;
    width: 100%;
    max-height: 140px;
    object-fit: contain;
    border-radius: 6px;
}

.upload-zone.has-image .upload-placeholder {
    display: none;
}

.upload-zone.has-image .upload-preview {
    display: block;
}

.upload-zone.has-image .remove-image {
    display: flex;
}

.remove-image {
    display: none;
    position: absolute;
    top: 6px;
    right: 6px;
    width: 24px;
    height: 24px;
    border-radius: 50%;
    background: rgba(255, 71, 87, 0.85);
    border: none;
    color: white;
    font-size: 14px;
    cursor: pointer;
    align-items: center;
    justify-content: center;
    transition: var(--transition);
    z-index: 2;
}

.remove-image:hover {
    background: var(--danger);
    transform: scale(1.1);
}

/* Input Fields */
.input-group {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.input-group label {
    font-size: 11px;
    font-weight: 600;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.8px;
}

.input-group input {
    width: 100%;
    padding: 11px 14px;
    background: rgba(255, 255, 255, 0.04);
    border: 1px solid var(--border-glass);
    border-radius: 8px;
    color: var(--text-primary);
    font-family: 'Inter', sans-serif;
    font-size: 14px;
    font-weight: 500;
    transition: var(--transition);
    outline: none;
}

.input-group input::placeholder {
    color: var(--text-muted);
    font-weight: 400;
}

.input-group input:focus {
    border-color: var(--accent-cyan);
    background: rgba(0, 212, 255, 0.04);
    box-shadow: 0 0 0 3px rgba(0, 212, 255, 0.1);
}

/* Mini Preview */
.editor-preview-section {
    background: rgba(255, 255, 255, 0.02);
    border: 1px solid var(--border-glass);
    border-radius: var(--radius-sm);
    padding: 12px;
}

.sticker-mini-preview {
    width: 100%;
    height: 68px;
    background: #ffffff;
    border: 1px solid #ccc;
    border-radius: 4px;
    display: flex;
    overflow: hidden;
    position: relative;
}

.smp-img {
    width: 34%;
    height: 100%;
    background: #f8f8f8;
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
}

.smp-img img {
    width: 100%;
    height: 100%;
    object-fit: contain;
    padding: 4px;
}

.smp-placeholder {
    font-size: 22px;
    color: #ccc;
}

.smp-divider {
    width: 1px;
    background: #222;
    flex-shrink: 0;
}

.smp-data {
    flex: 1;
    padding: 8px 10px;
    display: flex;
    flex-direction: column;
    justify-content: center;
    gap: 6px;
    position: relative;
}

.smp-field {
    display: flex;
    flex-direction: column;
    gap: 0px;
}

.smp-label {
    font-size: 6px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.8px;
    color: #004367;
}

.smp-value {
    font-size: 11px;
    font-weight: 700;
    color: #222;
    line-height: 1.2;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.smp-value.smp-code {
    font-size: 9px;
    font-weight: 600;
    color: #444;
}

.smp-cg {
    position: absolute;
    bottom: 4px;
    right: 6px;
    font-size: 8px;
    font-weight: 800;
    color: #004367;
    opacity: 0.5;
}

/* Action Buttons */
.sidebar-actions {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.btn-add,
.btn-update {
    width: 100%;
    padding: 13px 20px;
    border: none;
    border-radius: 8px;
    font-family: 'Inter', sans-serif;
    font-size: 14px;
    font-weight: 700;
    cursor: pointer;
    transition: var(--transition);
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
}

.btn-add {
    background: var(--accent-gradient);
    color: #fff;
}

.btn-add:hover:not(:disabled) {
    transform: translateY(-2px);
    box-shadow: 0 6px 24px rgba(0, 212, 255, 0.3);
}

.btn-add:disabled {
    opacity: 0.35;
    cursor: not-allowed;
}

.btn-update {
    background: linear-gradient(135deg, #00c853, #00e676);
    color: #fff;
}

.btn-update:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 24px rgba(0, 200, 83, 0.3);
}

.btn-cancel {
    width: 100%;
    padding: 10px;
    border: 1px solid var(--border-glass);
    border-radius: 8px;
    background: transparent;
    color: var(--text-secondary);
    font-family: 'Inter', sans-serif;
    font-size: 13px;
    font-weight: 500;
    cursor: pointer;
    transition: var(--transition);
}

.btn-cancel:hover {
    background: rgba(255, 255, 255, 0.05);
    color: var(--text-primary);
}

/* ==========================================
   Grid Area
   ========================================== */

.grid-area {
    padding: 20px 28px;
    display: flex;
    flex-direction: column;
    overflow-y: auto;
}

.grid-toolbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 16px;
}

.grid-info {
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.grid-counter {
    font-size: 13px;
    color: var(--text-secondary);
    font-weight: 500;
}

.grid-counter span {
    color: var(--accent-cyan);
    font-weight: 700;
}

.btn-export-pdf {
    padding: 10px 20px;
    border: none;
    border-radius: 8px;
    background: var(--accent-gradient);
    color: #fff;
    font-family: 'Inter', sans-serif;
    font-size: 13px;
    font-weight: 700;
    cursor: pointer;
    transition: var(--transition);
    display: flex;
    align-items: center;
    gap: 8px;
}

.btn-export-pdf:hover:not(:disabled) {
    transform: translateY(-2px);
    box-shadow: 0 6px 24px rgba(0, 212, 255, 0.3);
}

.btn-export-pdf:disabled {
    opacity: 0.35;
    cursor: not-allowed;
}

/* A4 Sheet */
.a4-sheet-wrapper {
    flex: 1;
    display: flex;
    align-items: flex-start;
    justify-content: center;
    overflow: auto;
    padding: 10px 0;
}

.a4-sheet {
    /* Proportional A4: 210mm x 297mm -> scale for screen */
    width: 630px;
    height: 891px;
    background: #ffffff;
    border-radius: 4px;
    box-shadow: 0 8px 40px rgba(0, 0, 0, 0.4), 0 0 0 1px rgba(255, 255, 255, 0.05);
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    grid-template-rows: repeat(11, 1fr);
    padding: 15px;
    gap: 0;
    flex-shrink: 0;
    position: relative;
}

/* Slot */
.slot {
    border: 0.5px solid #ccc;
    display: flex;
    cursor: pointer;
    transition: var(--transition);
    position: relative;
    overflow: hidden;
    background: #fff;
}

.slot:hover {
    background: #f0faff;
    border-color: #004367;
    z-index: 2;
}

.slot.selected {
    border: 2px solid #00d4ff;
    z-index: 3;
    box-shadow: 0 0 0 2px rgba(0, 212, 255, 0.2);
}

.slot.empty {
    align-items: center;
    justify-content: center;
}

.slot.empty::after {
    content: '+';
    font-size: 16px;
    font-weight: 300;
    color: #ccc;
    transition: var(--transition);
}

.slot.empty:hover::after {
    color: #004367;
    transform: scale(1.3);
}

/* Slot with sticker content */
.slot-content {
    display: flex;
    width: 100%;
    height: 100%;
}

.slot-img {
    width: 34%;
    height: 100%;
    background: #f8f8f8;
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
}

.slot-img img {
    width: 100%;
    height: 100%;
    object-fit: contain;
    padding: 2px;
}

.slot-no-img {
    font-size: 12px;
    color: #ccc;
}

.slot-divider {
    width: 1px;
    background: #222;
    flex-shrink: 0;
}

.slot-data {
    flex: 1;
    padding: 3px 5px;
    display: flex;
    flex-direction: column;
    justify-content: center;
    gap: 3px;
    position: relative;
    overflow: hidden;
}

.slot-label {
    font-size: 4.5px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: #004367;
}

.slot-value {
    font-size: 7.5px;
    font-weight: 700;
    color: #222;
    line-height: 1.15;
    overflow: hidden;
    text-overflow: ellipsis;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
}

.slot-value.slot-code {
    font-size: 6px;
    font-weight: 600;
    color: #444;
    -webkit-line-clamp: 1;
}

.slot-cg {
    position: absolute;
    bottom: 2px;
    right: 3px;
    font-size: 5px;
    font-weight: 800;
    color: #004367;
    opacity: 0.5;
}

/* Delete button on slot hover */
.slot-delete {
    position: absolute;
    top: 1px;
    right: 1px;
    width: 14px;
    height: 14px;
    border-radius: 50%;
    background: rgba(255, 71, 87, 0.85);
    border: none;
    color: white;
    font-size: 9px;
    line-height: 14px;
    text-align: center;
    cursor: pointer;
    opacity: 0;
    transition: var(--transition);
    z-index: 5;
    padding: 0;
}

.slot:hover .slot-delete {
    opacity: 1;
}

.slot-delete:hover {
    background: var(--danger);
    transform: scale(1.15);
}

/* ==========================================
   Modal
   ========================================== */

.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.6);
    backdrop-filter: blur(4px);
    z-index: 100;
    display: flex;
    align-items: center;
    justify-content: center;
}

.modal-box {
    background: var(--bg-secondary);
    border: 1px solid var(--border-glass);
    border-radius: var(--radius);
    padding: 28px 32px;
    max-width: 400px;
    width: 90%;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.5);
}

.modal-text {
    font-size: 15px;
    font-weight: 500;
    color: var(--text-primary);
    margin-bottom: 24px;
    line-height: 1.5;
}

.modal-actions {
    display: flex;
    gap: 10px;
    justify-content: flex-end;
}

.btn-modal {
    padding: 9px 20px;
    border-radius: 8px;
    font-family: 'Inter', sans-serif;
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
    transition: var(--transition);
    border: none;
}

.btn-modal-cancel {
    background: rgba(255, 255, 255, 0.06);
    color: var(--text-secondary);
}

.btn-modal-cancel:hover {
    background: rgba(255, 255, 255, 0.1);
    color: var(--text-primary);
}

.btn-modal-confirm {
    background: var(--accent-gradient);
    color: #fff;
}

.btn-modal-confirm:hover {
    box-shadow: 0 4px 16px rgba(0, 212, 255, 0.3);
}

/* ==========================================
   Toast
   ========================================== */

.toast {
    position: fixed;
    bottom: 30px;
    right: 30px;
    padding: 12px 22px;
    border-radius: 8px;
    font-family: 'Inter', sans-serif;
    font-size: 13px;
    font-weight: 500;
    color: #fff;
    z-index: 9999;
    animation: toastIn 0.4s ease-out;
    box-shadow: 0 8px 30px rgba(0, 0, 0, 0.3);
}

.toast.success {
    background: linear-gradient(135deg, #00c853, #00e676);
}

.toast.error {
    background: linear-gradient(135deg, #d50000, #ff4757);
}

@keyframes toastIn {
    from {
        opacity: 0;
        transform: translateY(20px) scale(0.95);
    }

    to {
        opacity: 1;
        transform: translateY(0) scale(1);
    }
}

@keyframes toastOut {
    from {
        opacity: 1;
        transform: translateY(0) scale(1);
    }

    to {
        opacity: 0;
        transform: translateY(20px) scale(0.95);
    }
}

/* ==========================================
   Animations
   ========================================== */

@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(8px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.sidebar>* {
    animation: fadeIn 0.4s ease-out both;
}

.sidebar>*:nth-child(1) {
    animation-delay: 0.03s;
}

.sidebar>*:nth-child(2) {
    animation-delay: 0.06s;
}

.sidebar>*:nth-child(3) {
    animation-delay: 0.09s;
}

.sidebar>*:nth-child(4) {
    animation-delay: 0.12s;
}

.sidebar>*:nth-child(5) {
    animation-delay: 0.15s;
}

.sidebar>*:nth-child(6) {
    animation-delay: 0.18s;
}

.sidebar>*:nth-child(7) {
    animation-delay: 0.21s;
}

/* ==========================================
   Responsive
   ========================================== */

@media (max-width: 1100px) {
    .app-container {
        grid-template-columns: 320px 1fr;
    }
}

@media (max-width: 900px) {
    .app-container {
        grid-template-columns: 1fr;
    }

    .sidebar {
        border-right: none;
        border-bottom: 1px solid var(--border-glass);
    }

    .a4-sheet {
        width: 100%;
        height: auto;
        aspect-ratio: 210 / 297;
    }
}

@media (max-width: 600px) {
    .header {
        flex-wrap: wrap;
    }

    .header-actions {
        width: 100%;
        justify-content: flex-end;
    }
}