/* Inter Regular (400) */
@font-face {
  font-family: 'Inter';
  font-style: normal;
  font-weight: 400;
  font-display: swap;
  src: url('../fonts/inter-v20-latin-regular.woff2') format('woff2');
}

/* Inter Medium (500) */
@font-face {
  font-family: 'Inter';
  font-style: normal;
  font-weight: 500;
  font-display: swap;
  src: url('../fonts/inter-v20-latin-500.woff2') format('woff2');
}

/* Inter Semi-Bold (600) */
@font-face {
  font-family: 'Inter';
  font-style: normal;
  font-weight: 600;
  font-display: swap;
  src: url('../fonts/inter-v20-latin-600.woff2') format('woff2');
}

/* Inter Bold (700) */
@font-face {
  font-family: 'Inter';
  font-style: normal;
  font-weight: 700;
  font-display: swap;
  src: url('../fonts/inter-v20-latin-700.woff2') format('woff2');
}

/* Inter Extra-Bold (800) */
@font-face {
  font-family: 'Inter';
  font-style: normal;
  font-weight: 800;
  font-display: swap;
  src: url('../fonts/inter-v20-latin-800.woff2') format('woff2');
}

/* Inter Black (900) */
@font-face {
  font-family: 'Inter';
  font-style: normal;
  font-weight: 900;
  font-display: swap;
  src: url('../fonts/inter-v20-latin-900.woff2') format('woff2');
}

/* ============================================
   RESET Y BASE
   ============================================ */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body { 
    font-family: 'Inter', sans-serif; 
    background: #cbd5e1; 
    height: 100vh; 
    overflow: hidden; 
    touch-action: none;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

button {
    font-family: 'Inter', sans-serif;
    border: none;
    background: none;
    cursor: pointer;
}

input, textarea {
    font-family: 'Inter', sans-serif;
}

/* ============================================
   UTILIDADES DE LAYOUT (Flexbox)
   ============================================ */
.flex { display: flex; }
.flex-col { flex-direction: column; }
.flex-1 { flex: 1; }
.items-center { align-items: center; }
.justify-center { justify-content: center; }
.justify-between { justify-content: space-between; }
.justify-around { justify-content: space-around; }
.gap-1 { gap: 4px; }
.gap-1\.5 { gap: 6px; }
.gap-2 { gap: 8px; }
.gap-3 { gap: 12px; }
.gap-4 { gap: 16px; }
.h-screen { height: 100vh; }
.h-full { height: 100%; }
.w-full { width: 100%; }
.h-2 { height: 8px; }
.h-8 { height: 32px; }
.w-8 { width: 32px; }
.h-12 { height: 48px; }
.w-12 { width: 48px; }
.h-16 { height: 64px; }
.h-20 { height: 80px; }
.w-20 { width: 80px; }
.h-32 { height: 128px; }
.w-52 { width: 208px; }

/* ============================================
   POSICIONAMIENTO
   ============================================ */
.fixed { position: fixed; }
.absolute { position: absolute; }
.relative { position: relative; }
.inset-0 { top: 0; right: 0; bottom: 0; left: 0; }
.top-4 { top: 16px; }
.right-4 { right: 16px; }
.top-16 { top: 64px; }
.left-16 { left: 64px; }
.-top-1 { top: -4px; }
.-right-1 { right: -4px; }

/* ============================================
   MÁRGENES Y PADDING
   ============================================ */
.p-1 { padding: 4px; }
.p-3 { padding: 12px; }
.p-4 { padding: 16px; }
.p-8 { padding: 32px; }
.px-5 { padding-left: 20px; padding-right: 20px; }
.py-2 { padding-top: 8px; padding-bottom: 8px; }
.py-3 { padding-top: 12px; padding-bottom: 12px; }
.py-4 { padding-top: 16px; padding-bottom: 16px; }
.py-5 { padding-top: 20px; padding-bottom: 20px; }
.pr-1 { padding-right: 4px; }
.pr-2 { padding-right: 8px; }
.mr-1 { margin-right: 4px; }
.mr-2 { margin-right: 8px; }
.ml-auto { margin-left: auto; }
.mt-1 { margin-top: 4px; }
.mt-2 { margin-top: 8px; }
.mt-3 { margin-top: 12px; }
.mt-4 { margin-top: 16px; }
.mt-6 { margin-top: 24px; }
.mt-auto { margin-top: auto; }
.mb-1 { margin-bottom: 4px; }
.mb-2 { margin-bottom: 8px; }
.mb-3 { margin-bottom: 12px; }
.mb-4 { margin-bottom: 16px; }
.mb-6 { margin-bottom: 24px; }
.mb-10 { margin-bottom: 40px; }

/* ============================================
   Z-INDEX
   ============================================ */
.z-\[50\] { z-index: 50; }
.z-\[90\] { z-index: 90; }
.z-\[100\] { z-index: 100; }
.z-\[200\] { z-index: 200; }
.z-\[300\] { z-index: 300; }
.z-\[500\] { z-index: 500; }
.z-\[1000\] { z-index: 1000; }
.z-\[2000\] { z-index: 2000; }

/* ============================================
   COLORES DE FONDO
   ============================================ */
.bg-white { background-color: #ffffff; }
.bg-black { background-color: #000000; }
.bg-slate-50 { background-color: #f8fafc; }
.bg-slate-100 { background-color: #f1f5f9; }
.bg-slate-300 { background-color: #cbd5e1; }
.bg-slate-900 { background-color: #0f172a; }
.bg-blue-600 { background-color: #2563eb; }
.bg-emerald-50 { background-color: #ecfdf5; }
.bg-emerald-600 { background-color: #10b981; }
.bg-red-600 { background-color: #dc2626; }
.bg-green-600 { background-color: #16a34a; }
.bg-white\/90 { background-color: rgba(255, 255, 255, 0.9); }

/* Hovers */
.hover\:bg-slate-50:hover { background-color: #f8fafc; }
.hover\:bg-slate-100:hover { background-color: #f1f5f9; }
.hover\:bg-slate-800:hover { background-color: #1e293b; }
.hover\:bg-blue-700:hover { background-color: #1d4ed8; }
.hover\:bg-emerald-700:hover { background-color: #059669; }
.hover\:bg-red-700:hover { background-color: #b91c1c; }

/* Active */
.active\:bg-slate-100:active { background-color: #f1f5f9; }

/* ============================================
   COLORES DE TEXTO
   ============================================ */
.text-white { color: #ffffff; }
.text-slate-300 { color: #cbd5e1; }
.text-slate-400 { color: #94a3b8; }
.text-slate-500 { color: #64748b; }
.text-slate-600 { color: #475569; }
.text-slate-700 { color: #334155; }
.text-slate-800 { color: #1e293b; }
.text-slate-900 { color: #0f172a; }
.text-blue-600 { color: #2563eb; }
.text-emerald-400 { color: #34d399; }
.text-emerald-600 { color: #10b981; }
.text-emerald-800 { color: #065f46; }
.text-red-400 { color: #f87171; }
.text-red-500 { color: #ef4444; }
.text-\[9px\] { color: inherit; font-size: 9px; }
.text-\[10px\] { font-size: 10px; }
.text-\[11px\] { font-size: 11px; }
.text-\[8px\] { font-size: 8px; }

/* Hovers */
.hover\:text-slate-600:hover { color: #475569; }
.hover\:text-red-500:hover { color: #ef4444; }
.hover\:text-red-600:hover { color: #b91c1c; }
.hover\:text-red-700:hover { color: #b91c1c; }
.hover\:text-blue-800:hover { color: #1e40af; }

/* ============================================
   BORDES
   ============================================ */
.border { border-width: 1px; }
.border-2 { border-width: 2px; }
.border-4 { border-width: 4px; }
.border-t { border-top-width: 1px; }
.border-r { border-right-width: 1px; }
.border-slate-100 { border-color: #f1f5f9; }
.border-slate-200 { border-color: #e2e8f0; }
.border-slate-300 { border-color: #cbd5e1; }
.border-emerald-100 { border-color: #d1fae5; }
.border-t-transparent { border-top-color: transparent; }

/* ============================================
   BORDER RADIUS
   ============================================ */
.rounded { border-radius: 4px; }
.rounded-lg { border-radius: 8px; }
.rounded-xl { border-radius: 12px; }
.rounded-full { border-radius: 9999px; }
.rounded-none { border-radius: 0; }

/* ============================================
   TAMAÑOS DE FUENTE
   ============================================ */
.text-xs { font-size: 12px; line-height: 16px; }
.text-sm { font-size: 14px; line-height: 20px; }
.text-xl { font-size: 20px; line-height: 28px; }
.text-4xl { font-size: 36px; line-height: 40px; }

/* ============================================
   PESO DE FUENTE
   ============================================ */
.font-medium { font-weight: 500; }
.font-bold { font-weight: 700; }
.font-black { font-weight: 900; }

/* ============================================
   MAYÚSCULAS Y ESPACIADO
   ============================================ */
.uppercase { text-transform: uppercase; }
.tracking-wider { letter-spacing: 0.05em; }
.tracking-widest { letter-spacing: 0.1em; }
.italic { font-style: italic; }
.leading-tight { line-height: 1.25; }

/* ============================================
   ALINEACIÓN DE TEXTO
   ============================================ */
.text-center { text-align: center; }
.text-left { text-align: left; }

/* ============================================
   SOMBRAS
   ============================================ */
.shadow-lg { box-shadow: 0 10px 15px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -2px rgba(0, 0, 0, 0.05); }
.shadow-2xl { box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.25); }

/* ============================================
   TRANSICIONES
   ============================================ */
.transition { transition-property: all; transition-timing-function: cubic-bezier(0.4, 0, 0.2, 1); transition-duration: 150ms; }

/* ============================================
   ROTACIÓN
   ============================================ */
.rotate-12 { transform: rotate(12deg); }
.-rotate-12 { transform: rotate(-12deg); }

/* ============================================
   OVERFLOW
   ============================================ */
.overflow-hidden { overflow: hidden; }
.overflow-y-auto { overflow-y: auto; }
.resize-none { resize: none; }

/* ============================================
   OUTLINE
   ============================================ */
.outline-none { outline: none; }

/* ============================================
   CURSOR
   ============================================ */
.cursor-default { cursor: default; }
.cursor-pointer { cursor: pointer; }

/* ============================================
   DISPLAY Y VISIBILIDAD
   ============================================ */
.hidden { display: none !important; }

/* ============================================
   ANIMACIONES
   ============================================ */
/* Definición de la animación para que el spinner gire */
.animate-spin {
    animation: spin 1s linear infinite;
}

@keyframes spin {
    from { transform: rotate(0deg); }
    to { transform: rotate(360deg); }
}

/* ============================================
   MAX HEIGHT/WIDTH
   ============================================ */
.max-h-\[85vh\] { max-height: 85vh; }
.max-w-xs { max-width: 320px; }

/* ============================================
   COMPONENTES PRINCIPALES
   ============================================ */

/* HEADER */
.top-ui { 
    background: white; 
    padding: 10px 16px; 
    display: flex; 
    justify-content: space-between; 
    align-items: center; 
    border-bottom: 1px solid #e2e8f0; 
    z-index: 50; 
    position: relative; 
    height: 60px;
}

.header-icon-btn { 
    width: 44px; 
    height: 44px; 
    display: flex; 
    align-items: center; 
    justify-content: center; 
    border-radius: 4px; 
    background: #f8fafc; 
    color: #334155; 
    border: 1px solid #f1f5f9; 
    transition: all 0.2s; 
    cursor: pointer; 
}

.header-icon-btn i {
    font-size: 20px;
}

.header-icon-btn:hover { 
    background: #e2e8f0; 
}

.header-icon-btn:active {
    transform: scale(0.95);
}

.header-icon-btn:disabled {
    color: #cbd5e1;
    cursor: not-allowed;
}

.zoom-active { 
    background: #ecfdf5 !important; 
    color: #10b981 !important; 
    border-color: #10b981 !important; 
}

.pages-active { 
    background: #ecfdf5 !important; 
    color: #10b981 !important; 
    border-color: #10b981 !important; 
}

/* VIEWPORT */
#viewport { 
    flex: 1; 
    position: relative; 
    display: block; 
    overflow-y: auto; 
    overflow-x: hidden;
    background: #cbd5e1; 
    width: 100%;
    height: calc(100vh - 60px - 85px); 
    -webkit-overflow-scrolling: touch;
}

/* PANEL DE PÁGINAS */
#page-nav-panel {
    position: fixed;
    bottom: 100px; 
    left: 0;
    width: 100%;
    height: 95px; 
    background: rgba(255, 255, 255, 0.95);
    backdrop-filter: blur(5px);
    -webkit-backdrop-filter: blur(5px);
    border-top: 1px solid #cbd5e1;
    border-bottom: 1px solid #cbd5e1;
    z-index: 90;
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 0 15px;
    overflow-x: auto;
    box-shadow: 0 -4px 6px -1px rgba(0, 0, 0, 0.05);
}

#page-nav-panel::-webkit-scrollbar {
    height: 4px;
}

#page-nav-panel::-webkit-scrollbar-thumb {
    background: #cbd5e1;
    border-radius: 2px;
}

.page-thumb {
    flex-shrink: 0;
    width: 60px;
    height: 70px;
    border: 2px solid #e2e8f0;
    border-radius: 4px;
    cursor: pointer;
    position: relative;
    background: white;
    transition: all 0.2s;
}

.page-thumb:hover {
    border-color: #94a3b8;
    transform: translateY(-2px);
}

.page-thumb.active {
    border-color: #2563eb;
    border-width: 3px;
    box-shadow: 0 4px 6px rgba(37, 99, 235, 0.2);
}

.thumb-preview {
    width: 100%;
    height: 100%;
    background-size: cover;
    background-position: center;
    background-repeat: no-repeat;
    border-radius: 2px;
}

.thumb-label {
    position: absolute;
    bottom: -20px;
    left: 50%;
    transform: translateX(-50%);
    font-size: 10px;
    font-weight: 700;
    color: #64748b;
    white-space: nowrap;
}

.page-thumb.active .thumb-label {
    color: #2563eb;
}

.add-page-btn {
    flex-shrink: 0;
    width: 60px;
    height: 70px;
    border: 2px dashed #cbd5e1;
    border-radius: 4px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    background: #f8fafc;
    transition: all 0.2s;
    color: #94a3b8;
    font-size: 20px;
}

.add-page-btn:hover {
    border-color: #2563eb;
    background: #eff6ff;
    color: #2563eb;
    transform: translateY(-2px);
}

/* BARRA INFERIOR DE HERRAMIENTAS */
.bottom-nav { 
    position: fixed; 
    bottom: 0; 
    left: 0; 
    width: 100%; 
    background: #ffffff; 
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    padding: 8px 6px 12px 6px; 
    display: flex; 
    justify-content: flex-start; 
    align-items: flex-end;
    overflow-x: auto; 
    box-shadow: 0 -2px 10px rgba(0,0,0,0.08); 
    z-index: 100; 
    border-top: none;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
    height: auto;
    gap: 5px;
}

.bottom-nav::-webkit-scrollbar { 
    display: none; 
}

.btn-tool { 
    display: flex; 
    flex-direction: column; 
    align-items: center;
    justify-content: center;
    gap: 4px;
    color: #64748b; 
    font-weight: 700; 
    font-size: 9px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    flex-shrink: 0; 
    width: auto;
    min-width: 50px;
    cursor: pointer;
    transition: all 0.2s;
    background: transparent;
    border: none;
    padding: 3px 5px;
}

.btn-tool:hover { 
    color: #334155; 
}

.btn-tool:active {
    transform: scale(0.92);
}

.btn-tool i { 
    width: 40px;
    height: 40px;
    display: flex; 
    align-items: center; 
    justify-content: center; 
    border-radius: 12px;
    font-size: 21px;
    background: rgba(248, 250, 252, 0.9); 
    transition: all 0.2s; 
    box-shadow: 0 2px 4px rgba(0,0,0,0.08);
    border: 1px solid rgba(226, 232, 240, 0.5);
}

.btn-tool:hover i { 
    background: rgba(226, 232, 240, 0.95); 
    box-shadow: 0 4px 6px rgba(0,0,0,0.1);
}

/* MODALES */
.modal-overlay { 
    position: fixed; 
    inset: 0; 
    background: rgba(15, 23, 42, 0.8); 
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
    z-index: 1000; 
    display: none; 
    justify-content: center; 
    align-items: center; 
    padding: 20px; 
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
}

.modal-card { 
    background: white; 
    width: 95%; 
    max-width: 480px; /* Más ancho en pantallas grandes */
    border-radius: 12px; 
    padding: 24px 20px; /* Menos padding vertical para aprovechar espacio */
    box-shadow: 0 25px 50px -12px rgba(0,0,0,0.5); 
    position: relative;
    max-height: 90vh; /* Más alto */
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
}
/* ============================================
   AJUSTES ESPECÍFICOS PARA MODALES
   ============================================ */

/* ✅ TODOS LOS MODALES EN LA PARTE SUPERIOR */
.modal-overlay {
    align-items: flex-start !important; /* Cambia de center a flex-start */
    padding-top: 2vh !important; /* Espaciado desde arriba */
}

/* Modal de texto: posición superior fija */
.modal-text-fixed {
    margin-top: 0;
    transform: none !important;
    max-height: none !important;
}


/* Modal de firma: aprovecha más espacio vertical */
.modal-signature-compact {
    max-height: 92vh; /* Más alto */
    max-width: 520px; /* Más ancho en tablets/PC */
    overflow-y: visible !important;
    padding: 20px 18px !important;
}

.modal-signature-compact #sig-wrapper {
    height: 200px !important; /* Canvas más grande para firmar mejor */
}

.modal-signature-compact #saved-sigs-container {
    height: 70px !important; /* Slots de firmas guardadas más grandes */
}

/* En pantallas muy pequeñas (móviles en vertical), ajustamos */
@media (max-width: 400px) {
    .modal-signature-compact #sig-wrapper {
        height: 160px !important;
    }
    
    .modal-signature-compact #saved-sigs-container {
        height: 60px !important;
    }
}

/* En tablets y PC, aprovechamos aún más espacio */
@media (min-width: 768px) {
    .modal-signature-compact {
        max-width: 550px;
    }
    
    .modal-signature-compact #sig-wrapper {
        height: 240px !important;
    }
    
    .modal-signature-compact #saved-sigs-container {
        height: 80px !important;
    }
}

/* ✅ MODALES DE AVISOS Y CONFIRMACIONES TAMBIÉN ARRIBA */
#limit-modal .modal-card,
#delete-page-modal .modal-card,
#exit-modal .modal-card,
#quick-stamps-modal .modal-card,
#tippex-modal .modal-card,
#manual-color-modal .modal-card {
    margin-top: 0;
}

/* Ajuste automático para móviles con teclado visible */
@media (max-height: 650px) {
    .modal-overlay {
        padding-top: 2vh !important;
    }
    
    .modal-signature-compact {
        max-height: 85vh;
        padding: 16px 14px !important;
    }
    
    .modal-signature-compact #sig-wrapper {
        height: 150px !important;
    }
}

@media (max-height: 550px) {
    .modal-overlay {
        padding-top: 1vh !important;
    }
    
    .modal-signature-compact {
        max-height: 80vh;
        padding: 12px !important;
    }
    
    .modal-signature-compact #sig-wrapper {
        height: 130px !important;
    }
    
    .modal-signature-compact #saved-sigs-container {
        height: 55px !important;
    }
}

/* PANEL DE AJUSTE DE COLOR */
#live-adjust-panel { 
    position: fixed; 
    top: 100px; 
    right: 20px; 
    width: 280px; 
    background: white; 
    border: 2px solid #0f172a; 
    z-index: 300; 
    display: none; 
    flex-direction: column; 
    padding: 15px;
    box-shadow: 0 20px 25px -5px rgba(0,0,0,0.2);
    cursor: move;
    touch-action: none;
    border-radius: 4px;
}

.range-group { 
    margin-bottom: 12px; 
}

.range-header { 
    display: flex; 
    justify-content: space-between; 
    margin-bottom: 3px; 
    font-size: 11px; 
    font-weight: 700; 
    color: #475569; 
}

.range-value { 
    color: #2563eb; 
    font-family: 'Courier New', monospace; 
}

input[type=range] { 
    width: 100%; 
    accent-color: #2563eb; 
    height: 5px; 
    background: #e2e8f0; 
    border-radius: 4px; 
    outline: none; 
    cursor: pointer; 
}

/* FIRMA DIGITAL */
#sig-wrapper { 
    width: 100%; 
    height: 180px; 
    background: #f8fafc; 
    border: 2px solid #e2e8f0; 
    border-radius: 4px; 
    margin: 10px 0; 
    touch-action: none; 
}

#saved-sigs-container {
    display: flex;
    gap: 12px;
    height: 80px;
    margin-bottom: 24px;
}

/* SELECTORES DE COLOR */
.color-opt { 
    width: 34px; 
    height: 34px; 
    border-radius: 50%; 
    border: 3px solid #f1f5f9; 
    cursor: pointer; 
    transition: transform 0.1s; 
}

.color-opt.selected { 
    border-color: #2563eb; 
    transform: scale(1.1); 
}

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

/* SELECTORES DE FORMA */
.stamp-shape-btn { 
    width: 50px; 
    height: 50px; 
    border-radius: 4px; 
    display: flex; 
    align-items: center; 
    justify-content: center; 
    font-size: 32px; 
    background: #f8fafc; 
    color: #cbd5e1; 
    border: 2px solid #e2e8f0; 
    cursor: pointer; 
    transition: all 0.2s;
}

.stamp-shape-btn.selected { 
    border-color: #2563eb; 
    color: #2563eb; 
    background: #eff6ff; 
}

.stamp-shape-btn:hover {
    background: #e2e8f0;
}

/* TOAST / NOTIFICACIONES */
#custom-toast {
    position: fixed; 
    top: 15px; 
    left: 15px;
    transform: translateX(-200%);
    background: #0f172a; 
    color: white; 
    padding: 12px 20px; 
    border-radius: 4px;
    font-weight: 700; 
    z-index: 2000; 
    transition: transform 0.4s cubic-bezier(0.175, 0.885, 0.32, 1.275);
    display: flex; 
    align-items: flex-start;
    gap: 10px; 
    box-shadow: 0 10px 15px -3px rgba(0, 0, 0, 0.3);
    max-width: calc(100vw - 30px);
    word-wrap: break-word;
    white-space: normal;
}

#custom-toast.show { 
    transform: translateX(0);
}

/* Estilos para el mensaje interno */
#toast-message {
    flex: 1;
    word-wrap: break-word;
    overflow-wrap: break-word;
    line-height: 1.4;
    color: #ffffff; /* ✅ VERDE ESMERALDA */
    font-weight: 600; /* Más legible */
}

/* Icono fijo (no se corta) */
#toast-icon {
    flex-shrink: 0;
    margin-top: 2px;
}

/* LOADER */
#loader {
    position: fixed;
    inset: 0;
    background: rgba(255, 255, 255, 0.95);
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
    z-index: 1000;
    display: none;
    flex-direction: column;
    justify-content: center;
    align-items: center;
}

#loader.show,
#loader:not(.hidden) {
    display: flex !important;
}

/* LANDING PAGE */
#landing {
    position: fixed;
    inset: 0;
    background: white;
    z-index: 500;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: flex-start;
    padding: 40px 32px 20px 32px;
    text-align: center;
    transition: opacity 0.2s ease-in-out;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
}

/* Ajuste para móviles */
@media screen and (max-width: 768px) {
    #landing {
        padding: 20px 24px calc(20px + env(safe-area-inset-bottom, 10px)) 24px;
    }
}

#landing.hidden {
    opacity: 0;
    pointer-events: none;
}

#editor-ui {
    z-index: 400;
}

/* MENÚ EXTRA */
#extra-menu {
    position: absolute;
    right: 16px;
    top: 64px;
    width: 208px;
    background: white;
    box-shadow: 0 20px 25px -5px rgba(0, 0, 0, 0.1);
    z-index: 200;
    border: 1px solid #e2e8f0;
    border-radius: 8px;
    overflow: hidden;
}

/* TEXTAREAS E INPUTS */
textarea {
    width: 100%;
    border: 2px solid #e2e8f0;
    padding: 16px;
    margin-bottom: 16px;
    outline: none;
    resize: none;
    height: 128px;
    border-radius: 4px;
    font-family: 'Inter', sans-serif;
    font-size: 14px;
}

textarea:focus {
    border-color: #2563eb;
}

textarea::placeholder {
    color: #94a3b8;
}

/* GRUPOS PERSONALIZADOS */
.group:hover .group-hover\:text-blue-700 {
    color: #1d4ed8;
}

.group:hover .group-hover\:border-blue-200 {
    border-color: #bfdbfe;
}

.group:hover .group-hover\:shadow-sm {
    box-shadow: 0 1px 2px 0 rgba(0, 0, 0, 0.05);
}

/* RESPONSIVE */
@media (min-width: 768px) {
    .md\:flex {
        display: flex;
    }
    
    .bottom-nav { 
        justify-content: center; 
        gap: 15px; 
        padding: 10px 20px; 
    }
    
    .btn-tool { 
        width: 80px !important; 
    }
    
    #viewport { 
        height: calc(100vh - 60px - 95px - 85px); 
    }
}

/* BACKDROP BLUR (Safari fix) */
@supports ((-webkit-backdrop-filter: none) or (backdrop-filter: none)) {
    .backdrop-blur { 
        backdrop-filter: blur(8px);
        -webkit-backdrop-filter: blur(8px);
    }
}
/* Botón de eliminar firma - más visible */
.w-9 { width: 22px; }
.h-9 { height: 22px; }
.-top-3 { top: -7px; }
.-right-3 { right: -3px; }
.text-base { font-size: 16px; }
.z-10 { z-index: 10; }
.overflow-visible { overflow: visible !important; }
/* Icono de advertencia en modal de límites */
.bg-red-100 {
    background-color: #fee2e2;
}

.text-red-600 {
    color: #dc2626;
}

/* BADGE MINIMALISTA */
.security-badge-mini {
    display: flex;
    align-items: center;
    gap: 10px;
    background: white;
    border: 2px solid #a7f3d0;
    border-radius: 50px;
    padding: 10px 18px;
    margin-top: 20px;
    cursor: pointer;
    transition: all 0.2s;
    width: fit-content;
    max-width: none;
    box-shadow: 0 2px 8px rgba(16, 185, 129, 0.15);
}

.security-badge-mini:hover {
    background: #ecfdf5;
    transform: translateY(-2px);
    box-shadow: 0 6px 12px rgba(16, 185, 129, 0.25);
    border-color: #6ee7b7;
}

.security-badge-mini:active {
    transform: translateY(0);
}

/* Clases adicionales necesarias */
.flex-shrink-0 {
    flex-shrink: 0;
}

.text-emerald-500 {
    color: #10b981;
}

/* MODAL DE SEGURIDAD */
.space-y-4 > * + * {
    margin-top: 16px;
}

.security-feature {
    display: flex;
    gap: 12px;
    padding: 12px;
    background: #f8fafc;
    border-radius: 8px;
    border-left: 3px solid #10b981;
}

.security-feature-icon {
    width: 36px;
    height: 36px;
    background: #ecfdf5;
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    color: #10b981;
    font-size: 16px;
}

/* Ajuste específico para modal de seguridad */
#security-modal .modal-card {
    max-height: 80vh;
}

#security-modal .space-y-4 {
    overflow-y: auto;
    max-height: 50vh;
    padding-right: 5px;
}

#security-modal .space-y-4::-webkit-scrollbar {
    width: 4px;
}

#security-modal .space-y-4::-webkit-scrollbar-thumb {
    background: #cbd5e1;
    border-radius: 2px;
}

#security-modal .space-y-4::-webkit-scrollbar-track {
    background: #f1f5f9;
}
/* Estilos para el carrusel de páginas */
#pages-grid {
    display: flex !important; /* Cambiamos grid por flex para el carrusel */
    flex-wrap: nowrap;
    overflow-x: auto;
    scroll-snap-type: x mandatory; /* Efecto imán */
    gap: 20px;
    padding: 20px 40px;
    -webkit-overflow-scrolling: touch; /* Suavidad en iOS */
}

/* Ocultar barra de scroll para que se vea limpio */
#pages-grid::-webkit-scrollbar {
    display: none;
}

.page-card {
    flex: 0 0 70%; /* Cada página ocupa el 70% del ancho para ver un trozo de la siguiente */
    scroll-snap-align: center;
    max-width: 300px;
    min-height: 350px;
    position: relative;
    transition: transform 0.3s;
}

/* Si es una pantalla más grande (tablet/PC), mostramos más */
@media (min-width: 768px) {
    .page-card {
        flex: 0 0 40%;
    }
}

/* Estilos para el icono de eliminar en la página */
.w-7 {
    width: 28px;
}

.h-7 {
    height: 28px;
}

/* ============================================
   TOGGLE SWITCH PARA ELIMINAR FONDO
   ============================================ */
.toggle-switch {
    position: relative;
    display: inline-block;
    width: 48px;
    height: 24px;
}

.toggle-switch input {
    opacity: 0;
    width: 0;
    height: 0;
}

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

.toggle-slider:before {
    position: absolute;
    content: "";
    height: 18px;
    width: 18px;
    left: 3px;
    bottom: 3px;
    background-color: white;
    transition: 0.3s;
    border-radius: 50%;
}

.toggle-switch input:checked + .toggle-slider {
    background-color: #8b5cf6;
}

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

.text-purple-600 {
    color: #9333ea;
}

/* ============================================
   MODAL DE TRANSPARENCIA
   ============================================ */
#transparency-preview {
    background-image: 
        linear-gradient(45deg, #e2e8f0 25%, transparent 25%),
        linear-gradient(-45deg, #e2e8f0 25%, transparent 25%),
        linear-gradient(45deg, transparent 75%, #e2e8f0 75%),
        linear-gradient(-45deg, transparent 75%, #e2e8f0 75%);
    background-size: 20px 20px;
    background-position: 0 0, 0 10px, 10px -10px, -10px 0px;
    border-radius: 4px;
}

.accent-color-blue {
    accent-color: #2563eb;
}

.bg-blue-50 {
    background-color: #eff6ff;
}

.border-blue-200 {
    border-color: #bfdbfe;
}

.text-blue-800 {
    color: #1e40af;
}

.mt-0\.5 {
    margin-top: 2px;
}

/* ============================================
   SLIDERS DEL EDITOR DE FIRMA
   ============================================ */

/* Colores de acento nativos (funciona en Chrome, Edge, Firefox modernos) */
.accent-color-blue {
    accent-color: #2563eb;
}

.accent-color-purple {
    accent-color: #9333ea;
}

/* Estilización base de los inputs range */
input[type=range] {
    -webkit-appearance: none; /* Necesario para personalizar en WebKit */
    width: 100%;
    background: transparent; /* El fondo lo define la clase bg-slate-200 del HTML */
}

input[type=range]:focus {
    outline: none;
}

/* Personalización del "thumb" (la bolita que arrastras) para Chrome/Safari/Edge */
input[type=range]::-webkit-slider-thumb {
    -webkit-appearance: none;
    height: 18px;
    width: 18px;
    border-radius: 50%;
    background: white;
    border: 2px solid currentColor; /* Toma el color del texto o acento */
    margin-top: -6px; /* Centrar verticalmente */
    box-shadow: 0 2px 4px rgba(0,0,0,0.2);
    cursor: pointer;
    transition: transform 0.1s;
}

/* Ajuste específico para que el borde de la bolita tome el color correcto */
.accent-color-blue::-webkit-slider-thumb {
    border-color: #2563eb;
}

.accent-color-purple::-webkit-slider-thumb {
    border-color: #9333ea;
}

/* Efecto hover en la bolita */
input[type=range]::-webkit-slider-thumb:hover {
    transform: scale(1.1);
}

/* Ajuste del "track" (la línea) para Chrome */
input[type=range]::-webkit-slider-runnable-track {
    width: 100%;
    height: 6px;
    cursor: pointer;
    background: #e2e8f0;
    border-radius: 4px;
}

/* ============================================
   AJUSTE DE PREVISUALIZACIÓN (CANVAS)
   ============================================ */
#transparency-preview {
    /* Patrón de ajedrez para visualizar transparencia */
    background-image: 
        linear-gradient(45deg, #e2e8f0 25%, transparent 25%), 
        linear-gradient(-45deg, #e2e8f0 25%, transparent 25%),
        linear-gradient(45deg, transparent 75%, #e2e8f0 75%), 
        linear-gradient(-45deg, transparent 75%, #e2e8f0 75%);
    background-size: 20px 20px;
    background-position: 0 0, 0 10px, 10px -10px, -10px 0px;
    
    border-radius: 4px;
    box-shadow: inset 0 2px 4px rgba(0,0,0,0.05); /* Sombra interna sutil */
}

.text-slate-500 {
    color: #64748b;
}

/* Utilidades para los botones de Zoom en PC */

/* Mostrar solo en pantallas medianas/grandes (simulación de md:flex) */
@media (min-width: 768px) {
    .md\:flex {
        display: flex !important;
    }
}



/* Borde derecho para separar los botones de zoom del resto */
.border-r {
    border-right-width: 1px;
    border-right-style: solid;
}

.pr-2 {
    padding-right: 8px;
}

.mr-2 {
    margin-right: 8px;
}

/* ============================================
   CORRECCIÓN Z-INDEX MODAL LÍMITES
   ============================================ */
#limit-modal {
    z-index: 1500 !important; /* Superior al 1000 de .modal-overlay normal */
}

/* ============================================
   MODAL DE RENOMBRAR ARCHIVO
   ============================================ */
#filename-input {
    font-family: 'Inter', sans-serif;
    font-size: 16px;
    color: #1e293b;
    background: white;
}

#filename-input:focus {
    border-color: #2563eb;
    box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.1);
}

#filename-input::placeholder {
    color: #cbd5e1;
}

/* Prevenir zoom en iOS al hacer focus en inputs */
@media screen and (max-width: 768px) {
    #filename-input {
        font-size: 16px !important;
    }
}

.bg-blue-100 {
    background-color: #dbeafe;
}

.text-blue-600 {
    color: #2563eb;
}

/* ============================================
   ESTILOS PARA LA HERRAMIENTA DE DIBUJO
   ============================================ */

.draw-tool-btn {
    transition: all 0.2s;
}

.draw-tool-btn.selected {
    background-color: #dbeafe !important;
    color: #2563eb !important;
    border-color: #2563eb !important;
}

.draw-color-opt {
    width: 44px;
    height: 44px;
    border-radius: 50%;
    border: 3px solid transparent;
    cursor: pointer;
    transition: all 0.2s;
}

.draw-color-opt.selected {
    border-color: #2563eb;
    transform: scale(1.1);
}

.draw-color-opt:hover {
    transform: scale(1.05);
}

#draw-preview-canvas {
    touch-action: none;
}

.btn-tool.draw-active i {
    background: #10b981 !important;
    color: white !important;
}

input[type="range"] {
    -webkit-appearance: none;
    appearance: none;
    height: 6px;
    background: #e2e8f0;
    border-radius: 3px;
    outline: none;
}



input[type="range"]::-webkit-slider-thumb {
    -webkit-appearance: none;
    appearance: none;
    width: 20px;
    height: 20px;
    background: #474343;       /* Color de fondo (el centro) */
    border-radius: 50%;
    cursor: pointer;
    
    /* --- CAMBIA ESTO --- */
    border: 3px solid #2c2e2e;  /* Grosor, estilo y COLOR DEL BORDE */
    /* ------------------- */
    
    box-shadow: 0 2px 4px rgba(0,0,0,0.2);
}

input[type="range"]::-moz-range-thumb {
    width: 20px;
    height: 20px;
    background: #2563eb;
    border-radius: 50%;
    cursor: pointer;
    border: none;
}

/* Mejoras visuales para botones de herramienta de dibujo */
.draw-tool-btn {
    transition: all 0.2s ease;
    position: relative;
}

.draw-tool-btn.selected {
    transform: scale(1.02);
    box-shadow: 0 2px 8px rgba(37, 99, 235, 0.3);
}

.draw-tool-btn:not(.selected) {
    opacity: 0.7;
}

.draw-tool-btn:not(.selected):hover {
    opacity: 1;
    background-color: #e2e8f0 !important;
}

/* ============================================
   EVITAR FLASH DEL LANDING DURANTE EDICIÓN
   ============================================ */
#landing {
    position: fixed;
    inset: 0;
    background: white;
    z-index: 500;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 80px 32px 32px 32px;
    text-align: center;
    transition: opacity 0.2s ease-in-out; /* Transición suave */
}

/* =========================================
   ESTILOS DEL TUTORIAL (ONBOARDING)
   ========================================= */
.tutorial-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.6); /* Fondo oscuro semitransparente */
    backdrop-filter: blur(4px);
    z-index: 9999;
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0;
    animation: fadeIn 0.3s forwards;
}

@keyframes fadeIn { to { opacity: 1; } }

.tutorial-card {
    background: white;
    width: 90%;
    max-width: 400px;
    border-radius: 20px;
    padding: 30px 20px;
    position: relative;
    text-align: center;
    box-shadow: 0 10px 25px rgba(0,0,0,0.2);
    display: flex;
    flex-direction: column;
    gap: 20px;
}

/* Botón cerrar X */
.tutorial-close {
    position: absolute;
    top: 8px;
    right: 8px;
    background: transparent;
    border: none;
    font-size: 24px;
    color: #94a3b8;
    cursor: pointer;
    padding: 16px;
    min-width: 56px;
    min-height: 56px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: none;  /* ← Sin transiciones */
    -webkit-tap-highlight-color: transparent;
    user-select: none;
    z-index: 10;  /* ← Nuevo */
}

/* Solo efecto al presionar - SIN HOVER */
.tutorial-close:active {
    color: #94a3b8;
    transform: scale(0.92);  /* ← Más evidente */
}

/* Slider y Slides */
.tutorial-slider {
    position: relative;
    overflow: hidden;
    min-height: 220px; /* Altura para el contenido */
}

.tutorial-slide {
    display: none; /* Ocultos por defecto */
    flex-direction: column;
    align-items: center;
    animation: slideIn 0.3s ease;
}

.tutorial-slide.active {
    display: flex;
}

@keyframes slideIn {
    from { opacity: 0; transform: translateX(20px); }
    to { opacity: 1; transform: translateX(0); }
}

/* Icono grande en cada slide */
.slide-icon {
    width: 70px;
    height: 70px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 28px;
    margin-bottom: 20px;
}

.tutorial-slide h3 {
    font-size: 20px;
    color: #1e293b;
    margin-bottom: 10px;
    font-weight: 700;
}

.tutorial-slide p {
    font-size: 14px;
    color: #64748b;
    line-height: 1.5;
}

/* Controles (Flechas y Puntos) */
.tutorial-controls {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 10px;
}

.nav-btn {
    background: #f1f5f9;
    border: none;
    width: 36px;
    height: 36px;
    border-radius: 50%;
    color: #475569;
    cursor: pointer;
    transition: all 0.2s;
    display: flex;
    align-items: center;
    justify-content: center;
}
.nav-btn:hover { background: #e2e8f0; color: #0f172a; }

.slide-indicators {
    display: flex;
    gap: 8px;
}

.indicator {
    width: 8px;
    height: 8px;
    background: #e2e8f0;
    border-radius: 50%;
    cursor: pointer;
    transition: all 0.3s;
}
.indicator.active {
    background: #2563eb;
    width: 20px;
    border-radius: 10px;
}

/* Footer */
.tutorial-footer {
    display: flex;
    flex-direction: column;
    gap: 15px;
    margin-top: 10px;
    padding-top: 20px;
    border-top: 1px solid #f1f5f9;
}

.btn-primary {
    background: #2563eb;
    color: white;
    border: none;
    padding: 12px;
    border-radius: 10px;
    font-weight: 600;
    cursor: pointer;
    width: 100%;
    font-size: 15px;
}
.btn-primary:hover { background: #1d4ed8; }

.link-tips {
    font-size: 13px;
    color: #64748b;
    text-decoration: none;
    font-weight: 500;
}
.link-tips:hover { color: #2563eb; text-decoration: underline; }

/* ============================================
   MODAL DE DONACIÓN
   ============================================ */

.donation-card {
    text-align: center;
    max-width: 400px !important;
    padding: 32px 24px !important;
}

.donation-close {
    position: absolute;
    top: 16px;
    right: 16px;
    width: 32px;
    height: 32px;
    border-radius: 50%;
    background: #f1f5f9;
    color: #64748b;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s;
    font-size: 14px;
}

.donation-close:hover {
    background: #e2e8f0;
    color: #334155;
}

.donation-icon {
    width: 64px;
    height: 64px;
    margin: 0 auto 20px;
    background: linear-gradient(135deg, #10b981 0%, #059669 100%);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 4px 14px rgba(16, 185, 129, 0.3);
}

.donation-icon i {
    font-size: 32px;
    color: white;
}

.donation-title {
    font-size: 24px;
    font-weight: 900;
    color: #1e293b;
    margin-bottom: 16px;
    letter-spacing: -0.02em;
}

.donation-text {
    font-size: 15px;
    color: #475569;
    line-height: 1.6;
    margin-bottom: 28px;
}

.donation-text strong {
    color: #1e293b;
    font-weight: 700;
}

.donation-buttons {
    display: flex;
    flex-direction: column;
    gap: 12px;
    width: 100%;
}

.btn-donate {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 4px;
    background: #fbbf24;
    color: #1a0a00;
    padding: 16px 24px;
    border-radius: 10px;
    font-weight: 700;
    font-size: 18px;
    text-decoration: none;
    transition: all 0.3s;
    width: 100%;
}

.btn-donate-top {
    display: flex;
    align-items: center;
    gap: 10px;
}


.btn-donate i {
    font-size: 18px;
}

.btn-later {
    width: 100%;
    padding: 16px 24px;
    border-radius: 8px;
    border: 2px solid #e2e8f0;
    background: white;
    color: #64748b;
    font-weight: 600;
    font-size: 15px;
    transition: all 0.2s;
    margin-top: 4px;
}

.btn-later:hover {
    background: #f1f5f9;
    color: #334155;
    border-color: #cbd5e1;
}

/* Responsive */
@media (max-width: 400px) {
    .donation-card {
        padding: 28px 20px !important;
    }
    
    .donation-title {
        font-size: 22px;
    }
    
    .donation-text {
        font-size: 14px;
    }
}

.btn-donate-kofi-icon {
    width: 36px;
    height: 36px;
    object-fit: contain;
    flex-shrink: 0;
    position: relative;
    top: -4px;
}

.btn-donate-content {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 2px;
}

.btn-donate-via {
    font-size: 11px;
    font-weight: 500;
    color: rgba(0, 0, 0, 0.45);
}
