/* Estilos Premium para la Administración de Catálogos (Dark Mode) */

:root {
    --bg-main: #0b0f19;
    --bg-card: rgba(17, 24, 39, 0.7);
    --bg-card-solid: #111827;
    --border-color: rgba(255, 255, 255, 0.08);
    --border-color-focus: rgba(56, 189, 248, 0.4);
    
    --text-primary: #f3f4f6;
    --text-secondary: #9ca3af;
    --text-muted: #6b7280;
    
    --accent-color: #38bdf8;
    --accent-glow: 0 0 15px rgba(56, 189, 248, 0.5);
    --accent-hover: #0ea5e9;
    
    --success-color: #10b981;
    --danger-color: #ef4444;
    --warning-color: #f59e0b;
    
    --font-sans: 'Outfit', sans-serif;
    --transition-smooth: all 0.25s cubic-bezier(0.4, 0, 0.2, 1);
}

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

body {
    background-color: var(--bg-main);
    color: var(--text-primary);
    font-family: var(--font-sans);
    line-height: 1.5;
    min-height: 100vh;
    background-image: 
        radial-gradient(at 0% 0%, rgba(56, 189, 248, 0.05) 0px, transparent 50%),
        radial-gradient(at 100% 100%, rgba(79, 70, 229, 0.05) 0px, transparent 50%);
    background-attachment: fixed;
}

/* --- SECCIÓN DE AUTENTICACIÓN (LOGIN/REGISTRO) --- */

.auth-container {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    min-height: 100vh;
    padding: 20px;
}

.auth-card {
    background: var(--bg-card);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border: 1px solid var(--border-color);
    border-radius: 20px;
    width: 100%;
    max-width: 450px;
    padding: 40px;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.3);
}

.auth-header {
    text-align: center;
    margin-bottom: 30px;
}

.logo {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    font-size: 24px;
    font-weight: 700;
    color: var(--text-primary);
    margin-bottom: 10px;
}

.logo i {
    color: var(--accent-color);
}

.accent-glow {
    text-shadow: var(--accent-glow);
    filter: drop-shadow(0 0 8px rgba(56, 189, 248, 0.4));
}

.logo span span {
    color: var(--accent-color);
}

.auth-header p {
    color: var(--text-secondary);
    font-size: 14px;
}

/* Selector de Pestañas */
.tab-selector {
    display: flex;
    background: rgba(0, 0, 0, 0.2);
    border: 1px solid var(--border-color);
    border-radius: 12px;
    padding: 4px;
    margin-bottom: 25px;
}

.tab-btn {
    flex: 1;
    background: transparent;
    border: none;
    color: var(--text-secondary);
    padding: 10px;
    font-family: var(--font-sans);
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    border-radius: 8px;
    transition: var(--transition-smooth);
}

.tab-btn.active {
    background: var(--accent-color);
    color: #000;
    box-shadow: var(--accent-glow);
}

/* Formularios y Controles */
.auth-form {
    display: flex;
    flex-direction: column;
    gap: 20px;
}

.input-group {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.input-group label {
    font-size: 13px;
    font-weight: 500;
    color: var(--text-secondary);
    display: flex;
    align-items: center;
    gap: 6px;
}

.input-group label i {
    color: var(--accent-color);
}

.input-group input, 
.input-group select, 
.input-group textarea {
    background: rgba(0, 0, 0, 0.15);
    border: 1px solid var(--border-color);
    border-radius: 10px;
    padding: 12px 16px;
    color: var(--text-primary);
    font-family: var(--font-sans);
    font-size: 14px;
    transition: var(--transition-smooth);
    outline: none;
    width: 100%;
}

.input-group input:focus, 
.input-group select:focus, 
.input-group textarea:focus {
    border-color: var(--accent-color);
    box-shadow: 0 0 10px rgba(56, 189, 248, 0.2);
    background: rgba(0, 0, 0, 0.3);
}

.input-group select option {
    background-color: var(--bg-card-solid);
    color: var(--text-primary);
}

.helper-text {
    font-size: 11px;
    color: var(--text-muted);
    margin-top: 2px;
}

.submit-btn {
    background: var(--accent-color);
    color: #000;
    border: none;
    border-radius: 10px;
    padding: 14px;
    font-family: var(--font-sans);
    font-size: 15px;
    font-weight: 600;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    transition: var(--transition-smooth);
    width: 100%;
    margin-top: 10px;
}

.submit-btn:hover:not(:disabled) {
    background: var(--accent-hover);
    box-shadow: var(--accent-glow);
}

.submit-btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.checkbox-group {
    flex-direction: row;
    align-items: center;
    gap: 10px;
    cursor: pointer;
}

.checkbox-group input[type="checkbox"] {
    width: auto;
    cursor: pointer;
}

.checkbox-group label {
    cursor: pointer;
    user-select: none;
}

/* Alertas */
.alert {
    padding: 12px 16px;
    border-radius: 10px;
    font-size: 13px;
    margin-bottom: 20px;
    border: 1px solid transparent;
}

.alert.error {
    background: rgba(239, 68, 68, 0.1);
    color: #fca5a5;
    border-color: rgba(239, 68, 68, 0.2);
}

.alert.success {
    background: rgba(16, 185, 129, 0.1);
    color: #a7f3d0;
    border-color: rgba(16, 185, 129, 0.2);
}

.hidden {
    display: none !important;
}

.auth-footer {
    margin-top: 25px;
    font-size: 12px;
    color: var(--text-muted);
}

.auth-footer a {
    color: var(--accent-color);
    text-decoration: none;
}

/* --- DASHBOARD LAYOUT --- */

.dashboard-body {
    display: flex;
    flex-direction: column;
    height: 100vh;
    overflow: hidden;
}

.topbar {
    background: rgba(17, 24, 39, 0.8);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border-bottom: 1px solid var(--border-color);
    height: 70px;
    padding: 0 30px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    z-index: 10;
    flex-shrink: 0;
}

.user-menu {
    display: flex;
    align-items: center;
    gap: 20px;
}

.comercio-title-display {
    font-weight: 600;
    font-size: 15px;
    color: var(--text-primary);
}

.logout-btn {
    background: rgba(239, 68, 68, 0.15);
    color: #fca5a5;
    border: 1px solid rgba(239, 68, 68, 0.3);
    padding: 8px 16px;
    border-radius: 8px;
    font-family: var(--font-sans);
    font-size: 13px;
    font-weight: 500;
    cursor: pointer;
    transition: var(--transition-smooth);
    display: flex;
    align-items: center;
    gap: 6px;
}

.logout-btn:hover {
    background: var(--danger-color);
    color: #fff;
}

.dashboard-wrapper {
    display: flex;
    flex: 1;
    overflow: hidden;
}

/* Sidebar */
.sidebar {
    width: 260px;
    background: rgba(11, 15, 25, 0.6);
    border-right: 1px solid var(--border-color);
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    padding: 30px 15px;
    flex-shrink: 0;
}

.sidebar-nav {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.nav-item {
    background: transparent;
    border: none;
    color: var(--text-secondary);
    padding: 12px 18px;
    border-radius: 10px;
    font-family: var(--font-sans);
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 12px;
    transition: var(--transition-smooth);
    text-align: left;
    width: 100%;
}

.nav-item:hover {
    background: rgba(255, 255, 255, 0.03);
    color: var(--text-primary);
}

.nav-item.active {
    background: rgba(56, 189, 248, 0.1);
    color: var(--accent-color);
    border-left: 3px solid var(--accent-color);
    border-top-left-radius: 0;
    border-bottom-left-radius: 0;
}

.sidebar-footer {
    font-size: 11px;
    color: var(--text-muted);
    padding: 0 10px;
}

.user-email-display {
    color: var(--text-secondary);
    font-weight: 500;
    word-break: break-all;
}

/* Area Principal */
.main-content {
    flex: 1;
    overflow-y: auto;
    padding: 40px;
}

.dashboard-section {
    display: none;
    animation: fadeIn 0.3s ease-out;
}

.dashboard-section.active {
    display: block;
}

.section-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 30px;
    gap: 20px;
}

.section-header h2 {
    font-size: 26px;
    font-weight: 700;
    color: var(--text-primary);
    margin-bottom: 6px;
}

.section-header p {
    color: var(--text-secondary);
    font-size: 14px;
}

.action-btn {
    background: var(--accent-color);
    color: #000;
    border: none;
    border-radius: 8px;
    padding: 10px 18px;
    font-family: var(--font-sans);
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 8px;
    transition: var(--transition-smooth);
}

.action-btn:hover {
    background: var(--accent-hover);
    box-shadow: var(--accent-glow);
}

.action-btn.secondary-btn {
    background: rgba(255, 255, 255, 0.08);
    color: var(--text-primary);
    border: 1px solid var(--border-color);
}

.action-btn.secondary-btn:hover {
    background: rgba(255, 255, 255, 0.15);
    box-shadow: none;
}

.action-btn.danger-btn {
    background: rgba(239, 68, 68, 0.15);
    color: #fca5a5;
    border: 1px solid rgba(239, 68, 68, 0.3);
}

.action-btn.danger-btn:hover {
    background: var(--danger-color);
    color: #fff;
    box-shadow: none;
}

/* Catalog Grid & Cards */
.catalog-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
    gap: 25px;
}

.loading-state {
    grid-column: 1 / -1;
    text-align: center;
    padding: 50px 0;
    color: var(--text-secondary);
    font-size: 15px;
}

.catalog-card {
    background: var(--bg-card);
    backdrop-filter: blur(12px);
    border: 1px solid var(--border-color);
    border-radius: 16px;
    padding: 24px;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    gap: 20px;
    transition: var(--transition-smooth);
}

.catalog-card:hover {
    transform: translateY(-4px);
    border-color: rgba(56, 189, 248, 0.25);
    box-shadow: 0 10px 25px rgba(0, 0, 0, 0.2);
}

.catalog-card-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
}

.catalog-badge {
    background: rgba(56, 189, 248, 0.1);
    color: var(--accent-color);
    font-size: 10px;
    font-weight: 700;
    padding: 4px 8px;
    border-radius: 6px;
    text-transform: uppercase;
}

.catalog-badge.pdf-badge {
    background: rgba(239, 68, 68, 0.1);
    color: #fca5a5;
}

.catalog-badge.excel-badge {
    background: rgba(16, 185, 129, 0.1);
    color: #a7f3d0;
}

.catalog-card-body h4 {
    font-size: 18px;
    font-weight: 600;
    margin: 8px 0 6px 0;
}

.catalog-card-body p {
    font-size: 13px;
    color: var(--text-secondary);
    min-height: 40px;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.catalog-actions-primary {
    display: flex;
    gap: 10px;
}

.catalog-actions-primary button {
    flex: 1;
}

.catalog-downloads {
    display: flex;
    gap: 10px;
    border-top: 1px solid var(--border-color);
    padding-top: 15px;
}

.download-link {
    flex: 1;
    background: rgba(255, 255, 255, 0.04);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    color: var(--text-secondary);
    padding: 8px;
    font-size: 12px;
    text-decoration: none;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    transition: var(--transition-smooth);
    font-weight: 500;
}

.download-link:hover {
    background: rgba(255, 255, 255, 0.1);
    color: var(--text-primary);
}

.download-link i.fa-file-pdf {
    color: #ef4444;
}

.download-link i.fa-file-excel {
    color: #10b981;
}

/* Divisor de secciones */
.section-divider {
    border: 0;
    border-top: 1px solid var(--border-color);
    margin: 40px 0;
}

.back-link-btn {
    background: transparent;
    border: none;
    color: var(--text-secondary);
    cursor: pointer;
    font-family: var(--font-sans);
    font-size: 13px;
    font-weight: 500;
    display: flex;
    align-items: center;
    gap: 6px;
    margin-bottom: 8px;
    transition: var(--transition-smooth);
}

.back-link-btn:hover {
    color: var(--accent-color);
}

.sub-section-title span {
    color: var(--accent-color);
}

/* Products Grid */
.products-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: 20px;
}

.product-card {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: 12px;
    overflow: hidden;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    transition: var(--transition-smooth);
}

.product-card:hover {
    border-color: rgba(255, 255, 255, 0.15);
}

.product-card.inactive {
    opacity: 0.6;
}

.product-card-img-wrapper {
    height: 160px;
    background: rgba(0, 0, 0, 0.2);
    position: relative;
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
}

.product-card-img-wrapper img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.product-card-img-wrapper .placeholder-icon {
    font-size: 40px;
    color: var(--text-muted);
}

.product-status-tag {
    position: absolute;
    top: 10px;
    right: 10px;
    background: rgba(0, 0, 0, 0.7);
    color: #fff;
    padding: 3px 8px;
    border-radius: 6px;
    font-size: 9px;
    font-weight: 700;
    text-transform: uppercase;
}

.product-status-tag.active-tag {
    background: rgba(16, 185, 129, 0.85);
}

.product-status-tag.inactive-tag {
    background: rgba(239, 68, 68, 0.85);
}

.product-card-info {
    padding: 16px;
    flex-grow: 1;
}

.product-card-info h5 {
    font-size: 15px;
    font-weight: 600;
    margin-bottom: 4px;
    color: var(--text-primary);
}

.product-card-info .price {
    font-weight: 700;
    font-size: 16px;
    color: var(--text-primary);
    margin-bottom: 8px;
}

.product-card-info p {
    font-size: 12px;
    color: var(--text-secondary);
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.product-card-info .stock-info {
    font-size: 11px;
    color: var(--text-muted);
    margin-top: 8px;
}

.product-card-actions {
    padding: 12px 16px;
    background: rgba(0, 0, 0, 0.15);
    border-top: 1px solid var(--border-color);
    display: flex;
    gap: 8px;
}

.product-card-actions button {
    flex: 1;
}

/* Modales */
.modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(5, 8, 16, 0.8);
    backdrop-filter: blur(8px);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 100;
    opacity: 1;
    transition: var(--transition-smooth);
}

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

.modal-content {
    width: 90%;
    max-width: 500px;
    position: relative;
    animation: modalScaleUp 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
}

.modal.hidden .modal-content {
    animation: none;
}

.close-btn {
    position: absolute;
    top: 15px;
    right: 20px;
    font-size: 28px;
    font-weight: 300;
    color: var(--text-muted);
    cursor: pointer;
    transition: var(--transition-smooth);
}

.close-btn:hover {
    color: var(--text-primary);
}

.modal-content h3 {
    margin-bottom: 20px;
    font-size: 20px;
    font-weight: 700;
    display: flex;
    align-items: center;
    gap: 10px;
}

.modal-content h3 i {
    color: var(--accent-color);
}

.product-form-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 15px;
}

/* Subidores de imagen en modales */
.product-image-uploader-preview, 
.logo-preview-wrapper {
    width: 100px;
    height: 100px;
    border-radius: 12px;
    background: rgba(0, 0, 0, 0.3);
    border: 1px dashed var(--border-color);
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
    margin-bottom: 10px;
}

.product-image-uploader-preview img, 
.logo-preview-wrapper img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.product-image-uploader-controls, 
.logo-upload-controls {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-bottom: 10px;
}

.upload-file-btn {
    background: rgba(255, 255, 255, 0.08);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    padding: 8px 16px;
    font-size: 13px;
    font-weight: 500;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    gap: 6px;
    transition: var(--transition-smooth);
}

.upload-file-btn:hover {
    background: rgba(255, 255, 255, 0.15);
    color: var(--text-primary);
}

.delete-btn {
    background: rgba(239, 68, 68, 0.15);
    color: #fca5a5;
    border: 1px solid rgba(239, 68, 68, 0.3);
    padding: 8px 16px;
    border-radius: 8px;
    font-size: 13px;
    font-weight: 500;
    cursor: pointer;
    transition: var(--transition-smooth);
}

.delete-btn:hover {
    background: var(--danger-color);
    color: #fff;
}

.file-rules {
    font-size: 11px;
    color: var(--text-muted);
}

/* Modal QR */
.qr-modal-content {
    text-align: center;
}

.qr-code-wrapper {
    background: white;
    padding: 15px;
    border-radius: 16px;
    display: inline-block;
    margin: 20px 0;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.15);
}

.qr-code-image {
    width: 200px;
    height: 200px;
    display: block;
}

.qr-details {
    text-align: left;
    margin-top: 15px;
}

.copy-url-group {
    display: flex;
    gap: 8px;
    margin: 8px 0 20px 0;
}

.copy-url-group input {
    background: rgba(0, 0, 0, 0.2);
}

.copy-url-group button {
    flex-shrink: 0;
    width: auto;
}

.qr-actions {
    margin-top: 10px;
}

/* Toast */
.toast {
    position: fixed;
    bottom: 30px;
    right: 30px;
    background: #1e293b;
    border-left: 4px solid var(--accent-color);
    color: var(--text-primary);
    padding: 16px 24px;
    border-radius: 8px;
    box-shadow: 0 10px 25px rgba(0, 0, 0, 0.3);
    z-index: 1000;
    display: flex;
    align-items: center;
    gap: 12px;
    transform: translateY(0);
    transition: var(--transition-smooth);
}

.toast.success {
    border-left-color: var(--success-color);
}

.toast.error {
    border-left-color: var(--danger-color);
}

.toast.hidden {
    transform: translateY(100px);
    opacity: 0;
    pointer-events: none;
}

/* --- PERFIL / AJUSTES --- */
.profile-card {
    max-width: 600px;
}

.profile-logo-uploader {
    display: flex;
    align-items: center;
    gap: 25px;
    margin-bottom: 25px;
}

.profile-logo-uploader .logo-preview-wrapper {
    width: 120px;
    height: 120px;
    border-radius: 50%; /* Logo redondo premium */
}

/* --- KEYFRAMES --- */
@keyframes fadeIn {
    from { opacity: 0; transform: translateY(10px); }
    to { opacity: 1; transform: translateY(0); }
}

@keyframes modalScaleUp {
    from { transform: scale(0.9); opacity: 0; }
    to { transform: scale(1); opacity: 1; }
}

/* --- MEDIA QUERIES --- */
@media (max-width: 900px) {
    .dashboard-wrapper {
        flex-direction: column;
    }
    
    .sidebar {
        width: 100%;
        border-right: none;
        border-bottom: 1px solid var(--border-color);
        flex-direction: row;
        padding: 10px 20px;
        align-items: center;
    }
    
    .sidebar-nav {
        flex-direction: row;
        width: 100%;
        justify-content: space-around;
        gap: 0;
    }
    
    .nav-item {
        padding: 8px 12px;
        justify-content: center;
        gap: 6px;
        font-size: 13px;
    }
    
    .nav-item span {
        display: none;
    }
    
    .sidebar-footer {
        display: none;
    }
    
    .main-content {
        padding: 20px;
    }
}

@media (max-width: 600px) {
    .auth-card {
        padding: 25px 20px;
    }
    
    .topbar {
        padding: 0 15px;
    }
    
    .user-menu .comercio-title-display {
        display: none;
    }
    
    .section-header {
        flex-direction: column;
        align-items: stretch;
        gap: 15px;
    }
    
    .section-header button {
        width: 100%;
        justify-content: center;
    }
    
    .product-form-row {
        grid-template-columns: 1fr;
    }
}
