@import url('https://fonts.googleapis.com/css2?family=Montserrat:wght@400;700&display=swap');

:root {
    --bg-color: #0B0D17;
    --card-bg: #161B22;
    --primary-red: #E30613;
    --accent-gold: #C5A059;
    --text-white: #FFFFFF;
    --text-muted: #8B949E;
    --border-color: #30363D;
    --transition: all 0.3s ease;
}

* {
    box-sizing: border-box;
}

body {
    background-color: var(--bg-color);
    color: var(--text-white);
    font-family: 'Montserrat', sans-serif;
    margin: 0;
    padding: 0;
    line-height: 1.6;
    overflow-x: hidden; /* Evitar scroll lateral global */
}

header {
    background-color: rgba(11, 13, 23, 0.98);
    padding: 15px 20px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-bottom: 2px solid var(--primary-red);
    position: sticky;
    top: 0;
    z-index: 1001;
    box-shadow: 0 4px 10px rgba(0,0,0,0.5);
}

header h1 {
    margin: 0;
    font-size: 1.5rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 2px;
}

header span {
    color: var(--primary-red);
}

.container {
    max-width: 96%;
    margin: 30px auto;
    padding: 0 20px;
}

/* Form Styles */
.card {
    background-color: var(--card-bg);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    padding: 25px;
    margin-bottom: 30px;
}

.form-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 15px;
}

input, select, textarea {
    background-color: var(--bg-color);
    border: 1px solid var(--border-color);
    color: white;
    padding: 12px;
    border-radius: 5px;
    width: 100%;
    box-sizing: border-box;
    font-family: 'Montserrat', sans-serif;
}

input:focus {
    outline: none;
    border-color: var(--primary-red);
}

button {
    background-color: var(--primary-red);
    color: white;
    padding: 12px 25px;
    border: none;
    border-radius: 5px;
    cursor: pointer;
    font-weight: 700;
    transition: var(--transition);
    text-transform: uppercase;
}

button:hover {
    background-color: #b3050f;
    transform: translateY(-2px);
}

button.secondary {
    background-color: transparent;
    border: 1px solid var(--accent-gold);
    color: var(--accent-gold);
}

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

th {
    text-align: left;
    border-bottom: 2px solid var(--primary-red);
    padding: 15px;
    color: var(--text-muted);
    font-size: 0.75rem;
    text-transform: uppercase;
    letter-spacing: 1px;
}

th:last-child, td:last-child {
    text-align: right;
}

tr {
    transition: var(--transition);
}

tr:hover {
    background-color: rgba(255, 255, 255, 0.03);
}

td {
    padding: 20px 15px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.05); /* Línea más sutil */
    vertical-align: middle;
}

.stock-img {
    width: 60px;
    height: 60px;
    object-fit: cover;
    border-radius: 4px;
    border: 1px solid var(--border-color);
}

.actions {
    display: flex;
    gap: 8px;
    justify-content: flex-end; /* Alineado a la derecha */
}

.actions button {
    padding: 6px 12px;
    font-size: 0.75rem;
    letter-spacing: 0.5px;
}

.delete-btn {
    background-color: transparent;
    color: #ff4d4d;
    border: 1px solid rgba(255, 77, 77, 0.3);
    padding: 5px 10px;
}

/* Filter Bar */
.filter-bar {
    display: flex;
    gap: 15px;
    margin-bottom: 20px;
    align-items: center;
    background: rgba(255, 255, 255, 0.02);
    padding: 15px;
    border-radius: 8px;
    border: 1px solid var(--border-color);
}

.filter-bar input, .filter-bar select {
    width: auto;
    min-width: 200px;
    padding: 10px;
}

/* Nav Button */
.nav-btn {
    background-color: transparent;
    border: 1px solid var(--primary-red);
    color: white;
    padding: 8px 15px;
    border-radius: 5px;
    text-decoration: none;
    font-size: 0.8rem;
    font-weight: bold;
    text-transform: uppercase;
    transition: var(--transition);
}

.nav-btn:hover {
    background-color: var(--primary-red);
    color: white;
}

.new-cat-input {
    margin-top: 10px;
    display: none;
    border-color: var(--accent-gold);
}

.new-cat-input.show {
    display: block;
}

/* Table Order Adjustments */
th:nth-child(1) { width: 15%; } /* Producto */
th:nth-child(2) { width: 25%; } /* Nota */
th:nth-child(3) { width: 15%; } /* Categoria */
th:nth-child(4) { width: 15%; } /* Proveedor */
th:nth-child(5) { width: 10%; } /* Cantidad */
th:nth-child(6) { width: 80px; } /* Foto */
th:nth-child(7) { width: 150px; } /* Acciones */

.delete-btn:hover {
    background-color: #ff4d4d;
    color: white;
}

/* Back to Top */
#backToTop {
    position: fixed;
    bottom: 30px;
    right: 30px;
    background-color: var(--primary-red);
    color: white;
    width: 45px;
    height: 45px;
    border-radius: 50%;
    display: flex;
    justify-content: center;
    align-items: center;
    cursor: pointer;
    z-index: 1002;
    opacity: 0;
    visibility: hidden;
    transition: var(--transition);
    box-shadow: 0 4px 15px rgba(0,0,0,0.4);
    border: none;
    font-size: 20px;
}

#backToTop.show {
    opacity: 1;
    visibility: visible;
}

#backToTop:hover {
    transform: scale(1.1);
    background-color: #b3050f;
}

/* Responsive Improvements */
@media (max-width: 768px) {
    header {
        flex-direction: column;
        gap: 15px;
        text-align: center;
        padding: 20px 10px;
    }

    header h1 {
        font-size: 1.2rem;
    }

    .nav-btn {
        width: 100%;
        text-align: center;
    }

    .container {
        padding: 10px;
        margin-top: 15px;
    }

    .card {
        padding: 15px;
    }

    .filter-bar {
        flex-direction: column;
        align-items: stretch;
    }

    .filter-bar input, .filter-bar select {
        width: 100% !important;
        min-width: 0 !important;
        max-width: 100%;
    }

    /* Table to Cards */
    th { display: none; }
    
    table, tbody, tr, td {
        display: block;
        width: 100%;
    }

    tr {
        margin-bottom: 20px;
        background: rgba(255, 255, 255, 0.02);
        border: 1px solid var(--border-color);
        border-radius: 8px;
        padding: 10px;
    }

    td {
        text-align: right;
        padding: 10px 5px;
        border-bottom: 1px solid rgba(255, 255, 255, 0.03);
        position: relative;
        padding-left: 45%;
        min-height: 40px;
        display: flex;
        justify-content: flex-end;
        align-items: center;
    }

    td:last-child {
        border-bottom: none;
        justify-content: center;
        padding-top: 15px;
    }

    td::before {
        content: attr(data-label);
        position: absolute;
        left: 10px;
        width: 40%;
        text-align: left;
        font-weight: bold;
        color: var(--text-muted);
        font-size: 0.75rem;
        text-transform: uppercase;
    }

    .stock-img {
        width: 100px;
        height: 100px;
    }

    .actions {
        width: 100%;
        justify-content: center;
        gap: 15px;
    }

    .actions button {
        flex: 1;
        padding: 10px;
    }

    #backToTop {
        bottom: 20px;
        right: 20px;
        width: 40px;
        height: 40px;
    }
}
