@font-face {
    font-family: 'Route159';
    src: url('./fonts/route159-regular.ttf') format('truetype');
    font-weight: normal;
    font-style: normal;
}

:root {
    /* Light mode colors */
    --bg-primary: #f5f5f5;
    --bg-secondary: white;
    --bg-tertiary: #fbfbfb;
    --bg-header: linear-gradient(135deg, #ffffff 0%, #f8f9fa 100%);
    --bg-filters: white;
    --bg-table: white;
    --bg-stats: white;
    --text-primary: #333;
    --text-secondary: #555;
    --text-muted: #6c757d;
    --text-header: #2c3e50;
    --border-color: #ddd;
    --border-light: #e8e8e8;
    --shadow: rgba(0,0,0,0.1);
    --shadow-light: rgba(0,0,0,0.05);
    --table-header-bg: linear-gradient(135deg, #2c3e50 0%, #34495e 100%);
    --table-header-hover: linear-gradient(135deg, #1a252f 0%, #2c3e50 100%);
    --table-hover-bg: #f0f8ff;
    --table-even-bg: #fbfbfb;
    --percentage-bg: #f0f0f0;
}

[data-theme="dark"] {
    /* Dark mode colors */
    --bg-primary: #1a1a1a;
    --bg-secondary: #2d2d2d;
    --bg-tertiary: #3a3a3a;
    --bg-header: linear-gradient(135deg, #2d2d2d 0%, #3a3a3a 100%);
    --bg-filters: #2d2d2d;
    --bg-table: #2d2d2d;
    --bg-stats: #2d2d2d;
    --text-primary: #e0e0e0;
    --text-secondary: #b0b0b0;
    --text-muted: #888;
    --text-header: #e0e0e0;
    --border-color: #404040;
    --border-light: #555;
    --shadow: rgba(0,0,0,0.3);
    --shadow-light: rgba(0,0,0,0.2);
    --table-header-bg: linear-gradient(135deg, #1a1a1a 0%, #2d2d2d 100%);
    --table-header-hover: linear-gradient(135deg, #0d1117 0%, #1a1a1a 100%);
    --table-hover-bg: #404040;
    --table-even-bg: #2a2a2a;
    --percentage-bg: #404040;
}

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

body {
    font-family: 'Route159', 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    background-color: var(--bg-primary);
    color: var(--text-primary);
    transition: background-color 0.3s, color 0.3s;
}

.container {
    max-width: 1400px;
    margin: 0 auto;
    padding: 20px;
}

header {
    display: flex;
    flex-direction: column;
    align-items: center;
    margin-bottom: 30px;
    padding: 20px 0;
    background: var(--bg-header);
    border-radius: 12px;
    box-shadow: 0 4px 15px var(--shadow);
}

.logo-container {
    display: flex;
    justify-content: center;
    margin-bottom: 20px;
    padding-bottom: 20px;
    border-bottom: 2px solid var(--border-light);
    position: relative;
}

.logo-container::after {
    content: '';
    position: absolute;
    bottom: -1px;
    left: 50%;
    transform: translateX(-50%);
    width: 60px;
    height: 2px;
    background: linear-gradient(90deg, #3498db 0%, #2c3e50 50%, #3498db 100%);
    border-radius: 1px;
}

.company-logo {
    height: 80px;
    width: auto;
    filter: drop-shadow(0 2px 4px rgba(0,0,0,0.1));
}

.title-container {
    text-align: center;
    padding-top: 10px;
}

h1 {
    color: var(--text-header);
    font-size: 1.8rem;
    font-weight: 400;
    font-family: 'Route159', serif;
    letter-spacing: -0.5px;
    text-shadow: 0 1px 2px rgba(0,0,0,0.1);
    margin: 0;
}

.filters {
    background: var(--bg-filters);
    padding: 20px;
    border-radius: 8px;
    box-shadow: 0 2px 10px var(--shadow);
    margin-bottom: 30px;
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
    gap: 20px;
}

.filter-group {
    display: flex;
    flex-direction: column;
    gap: 5px;
}

.filter-group label {
    font-weight: 600;
    color: var(--text-secondary);
}

.filter-group select,
.filter-group input {
    padding: 10px;
    border: 2px solid var(--border-color);
    border-radius: 4px;
    font-size: 14px;
    transition: border-color 0.3s;
    background-color: var(--bg-secondary);
    color: var(--text-primary);
}

.filter-group select:focus,
.filter-group input:focus {
    outline: none;
    border-color: #3498db;
}

.admin-group {
    display: flex;
    flex-direction: row;
    justify-content: center;
    align-items: center;
    gap: 10px;
}

.admin-link {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 40px;
    height: 40px;
    background: linear-gradient(135deg, #e74c3c 0%, #c0392b 100%);
    color: white;
    text-decoration: none;
    border-radius: 50%;
    font-size: 18px;
    transition: all 0.3s;
    box-shadow: 0 2px 4px rgba(0,0,0,0.1);
}

.admin-link:hover {
    transform: translateY(-1px) scale(1.1);
    box-shadow: 0 4px 8px rgba(231, 76, 60, 0.3);
    text-decoration: none;
    color: white;
}

.logout-link {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 40px;
    height: 40px;
    background: linear-gradient(135deg, #6c757d 0%, #5a6268 100%);
    color: white;
    border: none;
    border-radius: 50%;
    font-size: 18px;
    cursor: pointer;
    transition: all 0.3s;
    box-shadow: 0 2px 4px rgba(0,0,0,0.1);
}

.logout-link:hover {
    transform: translateY(-1px) scale(1.1);
    box-shadow: 0 4px 8px rgba(108, 117, 125, 0.3);
}

.table-container {
    background: var(--bg-table);
    border-radius: 8px;
    box-shadow: 0 2px 10px var(--shadow);
    overflow-x: auto;
    margin-bottom: 30px;
}

table {
    width: 100%;
    border-collapse: collapse;
    table-layout: fixed;
}

/* Definir anchos específicos para las columnas */
th:nth-child(1), td:nth-child(1) { width: 25%; } /* Planta */
th:nth-child(2), td:nth-child(2) { width: 8%; }  /* Silo */
th:nth-child(3), td:nth-child(3) { width: 25%; } /* Material */
th:nth-child(4), td:nth-child(4) { width: 12%; } /* Stock Real */
th:nth-child(5), td:nth-child(5) { width: 10%; } /* Última Entrada */
th:nth-child(6), td:nth-child(6) { width: 20%; } /* % Llenado */

th {
    background: var(--table-header-bg);
    color: white;
    padding: 15px;
    text-align: left;
    font-weight: 600;
    cursor: pointer;
    user-select: none;
    position: relative;
    border-bottom: 2px solid #1a252f;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    font-size: 13px;
}

th:hover {
    background: var(--table-header-hover);
    transform: translateY(-1px);
    box-shadow: 0 2px 4px rgba(0,0,0,0.2);
}

.sort-indicator {
    position: absolute;
    right: 8px;
    opacity: 0.6;
}

td {
    padding: 14px 15px;
    border-bottom: 1px solid var(--border-light);
    font-size: 14px;
    color: var(--text-primary);
    font-weight: 500;
}

tbody tr:hover {
    background-color: var(--table-hover-bg) !important;
    box-shadow: 0 2px 8px rgba(52, 152, 219, 0.15);
    transform: translateY(-1px);
    transition: all 0.2s ease;
}

tbody tr:nth-child(even) {
    background-color: var(--table-even-bg);
}

tbody tr.plant-separator {
    border-top: 3px solid #2c3e50 !important;
}

tbody tr.plant-separator td:first-child {
    position: relative;
}

tbody tr.plant-separator td:first-child::before {
    content: '';
    position: absolute;
    top: -3px;
    left: 0;
    right: 0;
    height: 3px;
    background: linear-gradient(90deg, #2c3e50 0%, #3498db 50%, #2c3e50 100%);
    box-shadow: 0 2px 4px rgba(44, 62, 80, 0.3);
}

.plant-cell {
    font-weight: 600;
    color: var(--text-primary);
    vertical-align: top;
}

.plant-cell:empty {
    background: none;
}


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

.stat-item {
    background: var(--bg-stats);
    padding: 20px;
    border-radius: 8px;
    box-shadow: 0 2px 10px var(--shadow);
    text-align: center;
}

.stat-label {
    display: block;
    font-weight: 600;
    color: var(--text-secondary);
    margin-bottom: 10px;
}

.stat-item span:last-child {
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--text-primary);
}

.percentage-container {
    position: relative;
    width: 100%;
    height: 25px;
    background-color: var(--percentage-bg);
    border-radius: 12px;
    overflow: hidden;
    border: 1px solid var(--border-color);
}

.percentage-bar {
    height: 100%;
    transition: width 0.3s ease;
    border-radius: 12px;
}

.percentage-text {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    font-weight: 600;
    font-size: 12px;
    color: #333;
    text-shadow: 1px 1px 1px rgba(255,255,255,0.8);
}

@media (max-width: 768px) {
    .container {
        padding: 10px;
    }
    
    .company-logo {
        height: 60px;
    }
    
    h1 {
        font-size: 1.4rem;
    }
    
    .filters {
        grid-template-columns: 1fr;
        padding: 15px;
        gap: 15px;
    }
    
    .admin-group {
        justify-content: space-around;
        padding: 10px 0;
    }
    
    /* Table responsive design */
    .table-container {
        overflow-x: auto;
    }
    
    table {
        min-width: 800px;
        font-size: 12px;
    }
    
    th, td {
        padding: 6px 4px;
        font-size: 11px;
    }
    
    th {
        font-size: 10px;
    }
    
    /* Adjust column widths for mobile */
    th:nth-child(1), td:nth-child(1) { width: 20%; }
    th:nth-child(2), td:nth-child(2) { width: 8%; }
    th:nth-child(3), td:nth-child(3) { width: 22%; }
    th:nth-child(4), td:nth-child(4) { width: 12%; }
    th:nth-child(5), td:nth-child(5) { width: 12%; }
    th:nth-child(6), td:nth-child(6) { width: 26%; }
    
    .percentage-container {
        height: 20px;
    }
    
    .percentage-text {
        font-size: 10px;
    }
    
    /* Stats responsive */
    .stats {
        grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
        gap: 15px;
    }
    
    .stat-item {
        padding: 15px;
    }
    
    .stat-label {
        font-size: 12px;
    }
    
    .stat-item span:last-child {
        font-size: 1.2rem;
    }
}

@media (max-width: 480px) {
    .container {
        padding: 5px;
    }
    
    h1 {
        font-size: 1.2rem;
    }
    
    .filters {
        padding: 10px;
        gap: 10px;
    }
    
    .admin-link, .logout-link {
        width: 35px;
        height: 35px;
        font-size: 16px;
    }
    
    table {
        min-width: 700px;
        font-size: 11px;
    }
    
    th, td {
        padding: 4px 2px;
        font-size: 10px;
    }
    
    th {
        font-size: 9px;
        letter-spacing: 0px;
    }
    
    .percentage-container {
        height: 18px;
    }
    
    .percentage-text {
        font-size: 9px;
    }
    
    .stats {
        grid-template-columns: 1fr 1fr;
        gap: 10px;
    }
    
    .stat-item {
        padding: 10px;
    }
    
    .stat-label {
        font-size: 11px;
        margin-bottom: 5px;
    }
    
    .stat-item span:last-child {
        font-size: 1.1rem;
    }
}