/* =========================================================
   Sistema de Gestión y Venta de Productos - Estilos
   ========================================================= */

* {
    box-sizing: border-box;
}

body {
    font-family: 'Arial', sans-serif;
    margin: 0;
    padding: 0;
    background-color: #f5f5f5;
}

.hidden {
    display: none !important;
}

h1, h2, h3 {
    color: #333;
}

code {
    background: #eee;
    padding: 2px 6px;
    border-radius: 4px;
}

/* ================= LOGIN ================= */
.login-container {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    background: linear-gradient(135deg, #2196F3, #4CAF50);
    padding: 20px;
}

.login-box {
    background: white;
    padding: 40px;
    border-radius: 10px;
    box-shadow: 0 4px 20px rgba(0,0,0,0.25);
    width: 100%;
    max-width: 380px;
    text-align: center;
}

.login-box h1 {
    font-size: 1.4em;
    margin-bottom: 10px;
}

.login-box .form-group {
    text-align: left;
}

.btn-login {
    width: 100%;
    background-color: #2196F3;
    color: white;
    padding: 12px;
    border: none;
    border-radius: 4px;
    font-size: 1em;
    cursor: pointer;
    margin-top: 10px;
}

.btn-login:hover {
    background-color: #0b7dda;
}

.error-message {
    color: #f44336;
    font-weight: bold;
    min-height: 20px;
}

.login-hint {
    margin-top: 20px;
    padding-top: 15px;
    border-top: 1px solid #ddd;
    font-size: 0.85em;
    color: #666;
}

.login-hint p {
    margin: 4px 0;
}

/* ================= BIENVENIDA ================= */
.welcome-container {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    background: linear-gradient(135deg, #4CAF50, #2196F3);
}

.welcome-box {
    text-align: center;
    color: white;
    animation: fadeIn 0.6s ease-in;
}

.welcome-box h1 {
    color: white;
    font-size: 2.2em;
}

.welcome-box p {
    font-size: 1.2em;
}

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

/* ================= LAYOUT PRINCIPAL ================= */
.container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 20px;
}

.app-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 10px;
    background: white;
    padding: 15px 20px;
    border-radius: 8px;
    box-shadow: 0 0 10px rgba(0,0,0,0.1);
    margin-bottom: 15px;
}

.app-header h1 {
    font-size: 1.3em;
    margin: 0;
}

.user-info {
    display: flex;
    align-items: center;
    gap: 15px;
    font-weight: bold;
}

/* ================= NAVEGACIÓN PRINCIPAL (pestañas) ================= */
.main-nav {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    background: white;
    padding: 10px;
    border-radius: 8px;
    box-shadow: 0 0 10px rgba(0,0,0,0.1);
    margin-bottom: 20px;
}

.nav-btn {
    background-color: #eee;
    color: #333;
    padding: 10px 16px;
    border: none;
    border-radius: 4px;
    cursor: pointer;
    font-size: 0.95em;
}

.nav-btn:hover {
    background-color: #ddd;
}

.nav-btn.active {
    background-color: #2196F3;
    color: white;
}

.badge {
    background: #f44336;
    color: white;
    border-radius: 50%;
    padding: 2px 7px;
    font-size: 0.8em;
    margin-left: 4px;
}

/* ================= SECCIONES DE CONTENIDO ================= */
.content-section {
    background-color: white;
    padding: 20px;
    border-radius: 8px;
    box-shadow: 0 0 10px rgba(0,0,0,0.1);
    margin-bottom: 30px;
}

/* ================= PESTAÑAS DE CATEGORÍA ================= */
.category-tabs {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-bottom: 15px;
    border-bottom: 2px solid #eee;
    padding-bottom: 15px;
}

.cat-tab {
    background: none;
    border: 1px solid #ccc;
    padding: 8px 14px;
    border-radius: 20px;
    cursor: pointer;
    color: #444;
}

.cat-tab:hover {
    background-color: #f0f0f0;
}

.cat-tab.active {
    background-color: #4CAF50;
    color: white;
    border-color: #4CAF50;
}

/* ================= CATÁLOGO EN TARJETAS ================= */
.catalog-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
    gap: 15px;
}

.product-card {
    border: 1px solid #ddd;
    border-radius: 8px;
    padding: 15px;
    display: flex;
    flex-direction: column;
    gap: 6px;
    transition: box-shadow 0.2s;
}

.product-card:hover {
    box-shadow: 0 2px 10px rgba(0,0,0,0.15);
}

.product-card img.product-img {
    width: 100%;
    height: 160px;
    object-fit: cover;
    border-radius: 6px;
    background: #f0f0f0;
}

.product-card h4 {
    margin: 0;
    color: #222;
}

.product-card .cat-label {
    display: inline-block;
    background: #e3f2fd;
    color: #1565c0;
    font-size: 0.75em;
    padding: 2px 8px;
    border-radius: 10px;
    width: fit-content;
}

.product-card .price {
    font-size: 1.2em;
    font-weight: bold;
    color: #2e7d32;
}

.product-card .stock {
    font-size: 0.85em;
    color: #666;
}

.product-card .stock.low {
    color: #f44336;
    font-weight: bold;
}

.product-card .add-cart-row {
    display: flex;
    gap: 6px;
    margin-top: 6px;
}

.product-card .add-cart-row input {
    width: 60px;
}

/* ================= FORMULARIOS ================= */
.form-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 12px 20px;
    margin-bottom: 10px;
}

.form-group {
    margin-bottom: 15px;
}

label {
    display: block;
    margin-bottom: 5px;
    font-weight: bold;
}

input, select {
    width: 100%;
    padding: 8px;
    border: 1px solid #ddd;
    border-radius: 4px;
}

button {
    background-color: #4CAF50;
    color: white;
    padding: 10px 15px;
    border: none;
    border-radius: 4px;
    cursor: pointer;
    margin-right: 10px;
    margin-top: 5px;
}

button:hover {
    background-color: #45a049;
}

.btn-danger {
    background-color: #f44336;
}

.btn-danger:hover {
    background-color: #d32f2f;
}

.btn-primary {
    background-color: #2196F3;
}

.btn-primary:hover {
    background-color: #0b7dda;
}

/* ================= TABLAS ================= */
table {
    width: 100%;
    border-collapse: collapse;
    margin-top: 20px;
}

th, td {
    border: 1px solid #ddd;
    padding: 8px;
    text-align: left;
}

th {
    background-color: #f2f2f2;
}

tr:nth-child(even) {
    background-color: #f9f9f9;
}

.search-box {
    margin: 15px 0;
}

/* ================= PUNTO DE VENTA ================= */
.pos-layout {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 25px;
}

@media (max-width: 800px) {
    .pos-layout {
        grid-template-columns: 1fr;
    }
}

.pos-cart-preview {
    background: #fafafa;
    border: 1px solid #eee;
    border-radius: 6px;
    padding: 15px;
}

/* ================= CARRITO ================= */
.cart-empty-msg {
    text-align: center;
    color: #888;
    padding: 20px;
    font-style: italic;
}

.cart-options {
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 15px;
    margin-top: 15px;
}

.discount-group {
    display: flex;
    align-items: center;
    gap: 10px;
    margin: 0;
}

.discount-group label {
    margin: 0;
}

.discount-group input {
    width: 80px;
}

.cart-buttons {
    display: flex;
    gap: 10px;
}

.qty-controls {
    display: flex;
    align-items: center;
    gap: 6px;
}

.qty-controls button {
    padding: 2px 10px;
    margin: 0;
}

.qty-controls span {
    min-width: 25px;
    text-align: center;
    display: inline-block;
}

.total-section {
    font-size: 1.1em;
    margin-top: 20px;
    text-align: right;
}

.total-section .grand-total {
    font-size: 1.4em;
    font-weight: bold;
    color: #2e7d32;
}

/* ================= SERVICIO A DOMICILIO / CHECKOUT ================= */
.delivery-box {
    margin-top: 25px;
    padding: 20px;
    background: #f7faff;
    border: 1px solid #d5e4f7;
    border-radius: 8px;
}

.delivery-box h3 {
    margin-top: 0;
}

.delivery-hint {
    color: #555;
    font-size: 0.9em;
    margin-top: -5px;
}

.payment-info {
    background: #fff8e1;
    border: 1px solid #ffe082;
    border-radius: 6px;
    padding: 10px 14px;
    margin: 12px 0;
}

.btn-confirmar {
    width: 100%;
    font-size: 1.05em;
    padding: 14px;
}

.compra-resultado {
    background: #e8f5e9;
    border: 1px solid #a5d6a7;
    border-radius: 8px;
    padding: 15px 20px;
    margin-bottom: 20px;
}

.compra-resultado.error {
    background: #ffebee;
    border-color: #ef9a9a;
}

.compra-resultado a {
    display: inline-block;
    margin-top: 8px;
    background-color: #2196F3;
    color: white;
    padding: 8px 14px;
    border-radius: 4px;
    text-decoration: none;
}

.compra-resultado a:hover {
    background-color: #0b7dda;
}

/* ================= IMAGEN EN GESTIÓN DE PRODUCTOS ================= */
.image-hint {
    display: block;
    color: #666;
    margin-top: 4px;
}

#productsTable img.product-thumb {
    width: 50px;
    height: 50px;
    object-fit: cover;
    border-radius: 4px;
}
