/* ============================================================
   226ERS — Mismo sistema de diseño que el resto de herramientas
   del panel (Importador de Pedidos, Pricat, plantilla, etc.).
   ============================================================ */

:root {
    --font-sans: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;

    --bg-app: #f4f6f9;
    --bg-card: #ffffff;
    --text-main: #1e293b;
    --text-muted: #64748b;

    --brand: #2563eb;
    --brand-hover: #1d4ed8;
    --brand-light: #eff6ff;

    --danger: #ef4444;
    --danger-hover: #dc2626;

    --border-color: #e2e8f0;
    --shadow-sm: 0 2px 8px rgba(0, 0, 0, 0.04);
    --shadow-md: 0 12px 24px -4px rgba(0, 0, 0, 0.06), 0 4px 12px -2px rgba(0, 0, 0, 0.03);

    --r-lg: 16px;
    --r-md: 12px;
    --r-sm: 8px;

    --header-h: 100px;
}

* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

body {
    font-family: var(--font-sans);
    background-color: var(--bg-app);
    color: var(--text-main);
    min-height: 100vh;
    font-size: 14px;
    line-height: 1.5;
    -webkit-font-smoothing: antialiased;
}

/* ── HEADER ── */
.header {
    background: var(--bg-card);
    border-bottom: 1px solid var(--border-color);
    height: var(--header-h);
    display: flex;
    align-items: center;
    gap: 16px;
    padding: 0 32px;
    position: sticky;
    top: 0;
    z-index: 200;
}

.back-link {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 40px;
    height: 40px;
    border-radius: var(--r-md);
    background: var(--bg-app);
    color: var(--text-muted);
    transition: all 0.2s ease;
    text-decoration: none;
    flex-shrink: 0;
}

.back-link:hover {
    background: var(--border-color);
    color: var(--text-main);
}

.back-link svg {
    width: 20px;
    height: 20px;
}

.logo {
    height: 34px;
    width: auto;
    object-fit: contain;
    flex-shrink: 0;
}

.header-divider {
    width: 1px;
    height: 28px;
    background: var(--border-color);
    flex-shrink: 0;
}

.header-titles h1 {
    font-size: 1.4rem;
    font-weight: 700;
    line-height: 1.2;
}

.header-subtitle {
    font-size: 0.8rem;
    color: var(--text-muted);
    margin-top: 1px;
}

/* ── LAYOUT ── */
.container {
    width: 100%;
    max-width: 900px;
    margin: 0 auto;
    padding: 32px 20px 64px;
    display: flex;
    flex-direction: column;
    gap: 28px;
}

h2, h3 {
    font-size: 1.1rem;
    font-weight: 700;
    margin-bottom: 16px;
    color: var(--text-main);
}

/* Panels */
.premium-panel,
.files-panel {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--r-lg);
    padding: 24px;
    box-shadow: var(--shadow-sm);
}

/* File Grid */
.file-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
    gap: 16px;
}

.file-item {
    display: flex;
    flex-direction: column;
    background: var(--bg-app);
    border: 1px solid var(--border-color);
    border-radius: var(--r-md);
    padding: 16px;
    transition: all 0.15s ease;
}

.file-item:hover {
    border-color: var(--brand);
    box-shadow: var(--shadow-sm);
}

.file-btn {
    color: var(--text-main);
    text-decoration: none;
    display: flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 14px;
}

.file-btn .emoji {
    font-size: 1.6rem;
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    width: 44px;
    height: 44px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: var(--r-sm);
    flex-shrink: 0;
}

.file-btn .filename {
    font-size: 0.95rem;
    font-weight: 600;
    word-break: break-word;
}

.file-actions {
    display: flex;
    gap: 8px;
    border-top: 1px solid var(--border-color);
    padding-top: 12px;
}

.action-btn {
    flex: 1;
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    color: var(--text-muted);
    padding: 8px;
    border-radius: var(--r-sm);
    cursor: pointer;
    font-size: 0.82rem;
    font-weight: 600;
    font-family: inherit;
    transition: all 0.15s ease;
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 6px;
}

.action-btn:hover { color: var(--text-main); border-color: #cbd5e1; }
.edit-btn:hover   { border-color: var(--brand); color: var(--brand); background: var(--brand-light); }
.delete-btn:hover { border-color: var(--danger); color: var(--danger-hover); background: #fef2f2; }

.loading { text-align: center; color: var(--text-muted); padding: 32px; }

/* Upload Form */
.upload-panel { display: flex; flex-direction: column; }
#upload-form { display: flex; flex-direction: column; gap: 18px; margin-top: 4px; }

.file-input-wrapper {
    display: flex;
    align-items: center;
    gap: 16px;
    background: var(--bg-app);
    padding: 14px;
    border-radius: var(--r-md);
    border: 1px dashed #cbd5e1;
    transition: all 0.15s;
}

.file-input-wrapper:hover { border-color: var(--brand); background: var(--brand-light); }

#file-name-display { color: var(--text-muted); font-size: 0.88rem; overflow: hidden; text-overflow: ellipsis; }

.custom-fields { display: flex; gap: 20px; flex-wrap: wrap; }
.form-group { display: flex; flex-direction: column; gap: 6px; flex: 1; min-width: 180px; }

.form-group label { font-size: 0.82rem; color: var(--text-muted); font-weight: 600; }

.form-group input {
    padding: 9px 12px;
    border: 1px solid var(--border-color);
    border-radius: var(--r-sm);
    background: var(--bg-card);
    color: var(--text-main);
    font-family: inherit;
    font-size: 0.9rem;
    transition: all 0.15s;
}

.form-group input:focus {
    outline: none;
    border-color: var(--brand);
    box-shadow: 0 0 0 3px var(--brand-light);
}

.emoji-picker {
    display: flex;
    gap: 6px;
    flex-wrap: wrap;
    margin-top: 2px;
}

.emoji-option {
    font-size: 1.3rem;
    cursor: pointer;
    padding: 4px 6px;
    border-radius: var(--r-sm);
    background: var(--bg-app);
    border: 1px solid var(--border-color);
    transition: all 0.15s;
    user-select: none;
}

.emoji-option:hover { background: var(--brand-light); border-color: var(--brand); }

.emoji-option.selected {
    background: var(--brand-light);
    border-color: var(--brand);
}

.btn-primary, .btn-secondary, .btn-danger {
    border: none;
    padding: 10px 20px;
    border-radius: var(--r-sm);
    cursor: pointer;
    font-family: inherit;
    font-size: 0.9rem;
    font-weight: 600;
    transition: all 0.15s ease;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
}

.btn-primary {
    background: var(--brand);
    color: white;
}

.btn-primary:hover:not(:disabled) { background: var(--brand-hover); }

.btn-primary:disabled { background: #cbd5e1; color: #f8fafc; cursor: not-allowed; }

.btn-secondary { background: var(--bg-app); color: var(--text-main); border: 1px solid var(--border-color) !important; }
.btn-secondary:hover { background: var(--border-color); }

.btn-danger { background: var(--danger); color: white; }
.btn-danger:hover { background: var(--danger-hover); }

#upload-status { text-align: center; font-size: 0.9rem; margin-top: 10px; font-weight: 600; }
.status-success { color: #16a34a; }
.status-error { color: var(--danger-hover); }

/* Modals */
.modal-overlay {
    position: fixed;
    top: 0; left: 0; width: 100vw; height: 100vh;
    background: rgba(15, 23, 42, 0.45);
    display: flex; justify-content: center; align-items: center;
    z-index: 1000;
    opacity: 0; pointer-events: none;
    transition: opacity 0.2s ease;
}

.modal-overlay.active { opacity: 1; pointer-events: all; }

.modal-content {
    width: 90%; max-width: 420px;
    transform: scale(0.96);
    transition: transform 0.2s ease;
}

.modal-overlay.active .modal-content { transform: scale(1); }

.modal-actions {
    display: flex; justify-content: flex-end; gap: 10px; margin-top: 20px;
}

@media (max-width: 600px) {
    .header { padding: 0 16px; }
    .header-subtitle { display: none; }
    .file-input-wrapper { flex-direction: column; align-items: stretch; text-align: center; }
    .custom-fields { flex-direction: column; }
}
