:root {
    --primary-color: #2c5530;
    --secondary-color: #4a7c59;
    --accent-color: #8fb996;
    --light-color: #f8fbf8;
    --dark-color: #1a331d;
    --text-color: #333;
    --border-radius: 8px;
    --box-shadow: 0 4px 12px rgba(0, 0, 0, 0.08);
    --transition: all 0.3s ease;
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
}

body {
    background-color: var(--light-color);
    color: var(--text-color);
    line-height: 1.6;
    overflow-x: hidden;
}

.container {
    display: none;
    width: 100%;
    min-height: 100vh;
}

.container.active {
    display: block;
}

/* Login Styles */
#login-container {
    display: flex;
    justify-content: center;
    align-items: center;
    min-height: 100vh;
    padding: 1rem;
    background: linear-gradient(rgba(255,255,255,0.9), rgba(255,255,255,0.9)), 
                url('data:image/svg+xml;utf8,<svg xmlns="http://www.w3.org/2000/svg" width="100" height="100" viewBox="0 0 100 100"><rect width="100" height="100" fill="%232c5530" opacity="0.05"/><path d="M0 0L100 100M100 0L0 100" stroke="%234a7c59" stroke-width="1" opacity="0.1"/></svg>');
    background-size: cover;
}

.login-box {
    background-color: white;
    padding: 2rem;
    border-radius: var(--border-radius);
    box-shadow: var(--box-shadow);
    width: 100%;
    max-width: 420px;
    text-align: center;
    transition: var(--transition);
}

.login-box:hover {
    box-shadow: 0 6px 20px rgba(0, 0, 0, 0.12);
}

.logo {
    margin-bottom: 1.5rem;
    padding-bottom: 1rem;
    border-bottom: 1px solid #eee;
}

.logo h1 {
    color: var(--primary-color);
    font-size: clamp(1.5rem, 4vw, 2rem);
    margin-bottom: 0.5rem;
    font-weight: 700;
}

.logo p {
    color: var(--secondary-color);
    font-size: clamp(0.9rem, 2.5vw, 1.1rem);
    letter-spacing: 1px;
}

.input-group {
    margin-bottom: 1.25rem;
    text-align: left;
}

.input-group label {
    display: block;
    margin-bottom: 0.5rem;
    color: var(--dark-color);
    font-weight: 500;
    font-size: 0.9rem;
}

.input-group input {
    width: 100%;
    padding: 0.85rem;
    border: 1px solid #ddd;
    border-radius: var(--border-radius);
    font-size: 1rem;
    transition: var(--transition);
}

.input-group input:focus {
    border-color: var(--accent-color);
    outline: none;
    box-shadow: 0 0 0 3px rgba(143, 185, 150, 0.2);
}

.btn {
    display: inline-block;
    background-color: var(--primary-color);
    color: white;
    border: none;
    padding: 0.85rem 1.5rem;
    border-radius: var(--border-radius);
    cursor: pointer;
    font-size: 1rem;
    font-weight: 600;
    transition: var(--transition);
    text-align: center;
    min-height: 50px;
}

.btn:hover {
    background-color: var(--dark-color);
    transform: translateY(-2px);
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.1);
}

.btn-block {
    width: 100%;
}

/* Dashboard Styles */
header {
    background-color: white;
    color: var(--primary-color);
    padding: 1rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
    box-shadow: var(--box-shadow);
    position: sticky;
    top: 0;
    z-index: 100;
    flex-wrap: wrap;
    gap: 1rem;
}

.header-title h1 {
    font-size: clamp(1.2rem, 3vw, 1.5rem);
    font-weight: 700;
}

.header-title p {
    color: var(--secondary-color);
    font-size: 0.8rem;
}

.user-info {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    flex-wrap: wrap;
}

.user-info span {
    font-size: 0.9rem;
}

.logout-btn {
    background-color: transparent;
    border: 1px solid var(--primary-color);
    color: var(--primary-color);
    padding: 0.5rem 1rem;
    border-radius: var(--border-radius);
    cursor: pointer;
    font-weight: 500;
    transition: var(--transition);
    font-size: 0.9rem;
    white-space: nowrap;
}

.logout-btn:hover {
    background-color: var(--primary-color);
    color: white;
}

.dashboard-content {
    display: flex;
    min-height: calc(100vh - 80px);
    flex-direction: column;
}

.sidebar {
    width: 100%;
    background-color: white;
    color: var(--text-color);
    padding: 0;
    box-shadow: var(--box-shadow);
    z-index: 10;
    order: 1;
}

.nav-items {
    display: flex;
    overflow-x: auto;
    padding: 0.5rem;
    gap: 0.5rem;
}

.nav-item {
    padding: 0.75rem 1rem;
    cursor: pointer;
    transition: var(--transition);
    display: flex;
    align-items: center;
    gap: 0.5rem;
    border-left: none;
    border-bottom: 3px solid transparent;
    white-space: nowrap;
    flex-shrink: 0;
    border-radius: var(--border-radius);
    font-size: 0.9rem;
}

.nav-item.active, .nav-item:hover {
    background-color: rgba(143, 185, 150, 0.1);
    border-bottom-color: var(--primary-color);
    color: var(--primary-color);
}

.main-content {
    flex: 1;
    padding: 1rem;
    background-color: #f9fbf9;
    overflow-y: auto;
    order: 2;
}

.tab-content {
    display: none;
}

.tab-content.active {
    display: block;
    animation: fadeIn 0.4s ease;
}

@keyframes fadeIn {
    from { opacity: 0; transform: translateY(10px); }
    to { opacity: 1; transform: translateY(0); }
}

.card {
    background-color: white;
    border-radius: var(--border-radius);
    box-shadow: var(--box-shadow);
    padding: 1.5rem;
    margin-bottom: 1.5rem;
    transition: var(--transition);
    width: 100%;
}

.card:hover {
    box-shadow: 0 6px 16px rgba(0, 0, 0, 0.1);
}

.card-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    margin-bottom: 1.25rem;
    padding-bottom: 1rem;
    border-bottom: 1px solid #eee;
    flex-direction: column;
    gap: 1rem;
}

.card-title {
    font-size: 1.25rem;
    color: var(--primary-color);
    font-weight: 600;
    line-height: 1.3;
}

.card-header .btn {
    width: 100%;
    max-width: 200px;
}

table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.9rem;
}

th, td {
    padding: 0.75rem;
    text-align: left;
    border-bottom: 1px solid #eee;
    word-wrap: break-word;
}

th {
    background-color: var(--accent-color);
    color: var(--dark-color);
    font-weight: 600;
    font-size: 0.85rem;
}

tr:hover {
    background-color: rgba(143, 185, 150, 0.05);
}

.action-btn {
    background-color: var(--secondary-color);
    color: white;
    border: none;
    padding: 0.4rem 0.7rem;
    border-radius: 4px;
    cursor: pointer;
    margin-right: 0.25rem;
    margin-bottom: 0.25rem;
    font-size: 0.8rem;
    transition: var(--transition);
    white-space: nowrap;
}

.action-btn:hover {
    opacity: 0.9;
    transform: translateY(-1px);
}

.action-btn.edit {
    background-color: #4a7b9d;
}

.action-btn.delete {
    background-color: #c94c4c;
}

.form-group {
    margin-bottom: 1rem;
}

.form-row {
    display: flex;
    flex-direction: column;
    gap: 1rem;
    margin-bottom: 1rem;
}

.form-row .form-group {
    flex: 1;
    min-width: 0;
}

.form-group label {
    display: block;
    margin-bottom: 0.5rem;
    font-weight: 500;
    color: var(--dark-color);
    font-size: 0.9rem;
}

.form-group input, .form-group select, .form-group textarea {
    width: 100%;
    padding: 0.75rem;
    border: 1px solid #ddd;
    border-radius: var(--border-radius);
    font-size: 1rem;
    transition: var(--transition);
    min-height: 48px;
}

.form-group input:focus, .form-group select:focus, .form-group textarea:focus {
    border-color: var(--accent-color);
    outline: none;
    box-shadow: 0 0 0 3px rgba(143, 185, 150, 0.2);
}

.search-box {
    display: flex;
    margin-bottom: 1rem;
    flex-direction: column;
    gap: 0.5rem;
}

.search-box input {
    flex: 1;
    padding: 0.75rem;
    border: 1px solid #ddd;
    border-radius: var(--border-radius);
    font-size: 1rem;
    min-height: 48px;
}

.search-box button {
    background-color: var(--primary-color);
    color: white;
    border: none;
    padding: 0.75rem 1.5rem;
    border-radius: var(--border-radius);
    cursor: pointer;
    transition: var(--transition);
    min-height: 48px;
}

.search-box button:hover {
    background-color: var(--dark-color);
}

.product-list {
    max-height: 300px;
    overflow-y: auto;
    border: 1px solid #eee;
    border-radius: var(--border-radius);
}

.product-item {
    display: flex;
    flex-direction: column;
    padding: 1rem;
    border-bottom: 1px solid #eee;
    cursor: pointer;
    transition: var(--transition);
    gap: 0.5rem;
}

.product-item:hover {
    background-color: rgba(143, 185, 150, 0.1);
}

.product-item:last-child {
    border-bottom: none;
}

.product-item > div:first-child {
    flex: 1;
}

.product-item > div:last-child {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 0.5rem;
}

.cart-item {
    display: flex;
    flex-direction: column;
    padding: 1rem;
    border-bottom: 1px solid #eee;
    gap: 0.75rem;
}

.cart-item > div:first-child {
    flex: 1;
}

.cart-item > div:last-child {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.cart-total {
    text-align: center;
    font-size: 1.25rem;
    font-weight: 700;
    margin-top: 1.5rem;
    padding-top: 1.5rem;
    border-top: 2px solid #eee;
    color: var(--primary-color);
}

.report-summary {
    display: flex;
    flex-direction: column;
    gap: 1rem;
    margin-bottom: 1.5rem;
}

.summary-card {
    flex: 1;
    background-color: white;
    border-radius: var(--border-radius);
    box-shadow: var(--box-shadow);
    padding: 1.5rem;
    text-align: center;
    transition: var(--transition);
    min-width: 0;
}

.summary-card:hover {
    transform: translateY(-3px);
    box-shadow: 0 8px 20px rgba(0, 0, 0, 0.12);
}

.summary-value {
    font-size: 1.75rem;
    font-weight: 700;
    color: var(--primary-color);
    margin: 0.5rem 0;
    line-height: 1.2;
}

.summary-label {
    color: #666;
    font-size: 0.9rem;
}

.modal {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.5);
    justify-content: center;
    align-items: center;
    z-index: 1000;
    padding: 1rem;
}

.modal.active {
    display: flex;
    animation: fadeIn 0.3s ease;
}

.modal-content {
    background-color: white;
    border-radius: var(--border-radius);
    box-shadow: var(--box-shadow);
    width: 100%;
    max-width: 500px;
    padding: 1.5rem;
    max-height: 90vh;
    overflow-y: auto;
}

.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1.25rem;
    padding-bottom: 1rem;
    border-bottom: 1px solid #eee;
}

.modal-title {
    font-size: 1.25rem;
    color: var(--primary-color);
    font-weight: 600;
}

.close-btn {
    background: none;
    border: none;
    font-size: 1.5rem;
    cursor: pointer;
    color: #666;
    transition: var(--transition);
    padding: 0.25rem;
}

.close-btn:hover {
    color: var(--primary-color);
}

.modal-footer {
    display: flex;
    justify-content: flex-end;
    gap: 0.75rem;
    margin-top: 1.25rem;
    padding-top: 1rem;
    border-top: 1px solid #eee;
    flex-wrap: wrap;
}

.modal-footer .btn {
    flex: 1;
    min-width: 120px;
}

.btn-secondary {
    background-color: #6c757d;
}

.btn-secondary:hover {
    background-color: #5a6268;
}

.empty-state {
    text-align: center;
    padding: 2rem 1rem;
    color: #666;
}

.empty-state i {
    font-size: 2.5rem;
    margin-bottom: 1rem;
    color: #ccc;
}

.quantity-controls {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.75rem;
    margin: 0.5rem 0;
}

.quantity-btn {
    background-color: #f0f0f0;
    border: none;
    width: 32px;
    height: 32px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: var(--transition);
    font-weight: bold;
}

.quantity-btn:hover {
    background-color: #e0e0e0;
}

.budget-actions {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
    margin-top: 1.5rem;
}

.budget-actions .btn {
    width: 100%;
}

.status-badge {
    display: inline-block;
    padding: 0.3rem 0.6rem;
    border-radius: 20px;
    font-size: 0.75rem;
    font-weight: 600;
    white-space: nowrap;
}

.status-pending {
    background-color: #fff3cd;
    color: #856404;
}

.status-completed {
    background-color: #d1ecf1;
    color: #0c5460;
}

.status-approved {
    background-color: #d4edda;
    color: #155724;
}

.status-rejected {
    background-color: #f8d7da;
    color: #721c24;
}

.alert {
    padding: 0.75rem 1rem;
    border-radius: var(--border-radius);
    margin-bottom: 1rem;
    font-weight: 500;
    font-size: 0.9rem;
}

.alert-error {
    background-color: #f8d7da;
    color: #721c24;
    border: 1px solid #f5c6cb;
}

.alert-success {
    background-color: #d4edda;
    color: #155724;
    border: 1px solid #c3e6cb;
}

.loading {
    display: inline-block;
    width: 18px;
    height: 18px;
    border: 2px solid rgba(255,255,255,.3);
    border-radius: 50%;
    border-top-color: #fff;
    animation: spin 1s ease-in-out infinite;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

.hidden {
    display: none !important;
}

/* Budget Print Styles */
.budget-print {
    display: none;
}

/* ========== MEDIA QUERIES ========== */

/* Tablets y pantallas medianas (768px - 1024px) */
@media (min-width: 768px) {
    .login-box {
        padding: 2.5rem;
    }
    
    header {
        padding: 1rem 1.5rem;
        flex-wrap: nowrap;
    }
    
    .main-content {
        padding: 1.5rem;
    }
    
    .card {
        padding: 1.75rem;
    }
    
    .card-header {
        flex-direction: row;
        align-items: center;
    }
    
    .card-header .btn {
        width: auto;
    }
    
    .form-row {
        flex-direction: row;
    }
    
    .search-box {
        flex-direction: row;
    }
    
    .search-box input {
        border-radius: var(--border-radius) 0 0 var(--border-radius);
    }
    
    .search-box button {
        border-radius: 0 var(--border-radius) var(--border-radius) 0;
    }
    
    .product-item {
        flex-direction: row;
        align-items: center;
    }
    
    .cart-item {
        flex-direction: row;
        align-items: center;
    }
    
    .cart-total {
        text-align: right;
    }
    
    .report-summary {
        flex-direction: row;
    }
    
    .budget-actions {
        flex-direction: row;
    }
    
    .budget-actions .btn {
        width: auto;
        flex: 1;
    }
    
    .modal-content {
        padding: 2rem;
    }
    
    .modal-footer .btn {
        flex: none;
    }
}

/* Desktop y pantallas grandes (1024px+) */
@media (min-width: 1024px) {
    .dashboard-content {
        flex-direction: row;
    }
    
    .sidebar {
        width: 280px;
        padding: 1.5rem 0;
        order: 1;
    }
    
    .nav-items {
        display: block;
        overflow-x: visible;
        padding: 0;
    }
    
    .nav-item {
        border-left: 4px solid transparent;
        border-bottom: none;
        border-radius: 0;
        white-space: normal;
        flex-shrink: 1;
    }
    
    .nav-item.active, .nav-item:hover {
        border-left-color: var(--primary-color);
        border-bottom-color: transparent;
    }
    
    .main-content {
        order: 2;
        padding: 2rem;
    }
    
    .summary-value {
        font-size: 2.25rem;
    }
    
    .card-header {
        gap: 1rem;
    }
}

/* Pantallas muy pequeñas (480px o menos) */
@media (max-width: 480px) {
    .login-box {
        padding: 1.5rem;
    }
    
    header {
        padding: 0.75rem;
    }
    
    .user-info {
        flex-direction: column;
        align-items: flex-start;
        gap: 0.5rem;
    }
    
    .main-content {
        padding: 0.75rem;
    }
    
    .card {
        padding: 1rem;
        margin-bottom: 1rem;
    }
    
    th, td {
        padding: 0.5rem;
        font-size: 0.8rem;
    }
    
    .action-btn {
        padding: 0.3rem 0.5rem;
        font-size: 0.75rem;
        margin-right: 0.2rem;
    }
    
    .modal-content {
        padding: 1rem;
    }
    
    .modal-footer {
        flex-direction: column;
    }
    
    .modal-footer .btn {
        width: 100%;
    }
}

/* Mejoras para tablas en móviles */
@media (max-width: 768px) {
    table {
        display: block;
        overflow-x: auto;
        white-space: nowrap;
    }
    
    th, td {
        min-width: 120px;
    }
    
    .action-buttons {
        display: flex;
        flex-wrap: wrap;
        gap: 0.25rem;
    }
}

/* Impresión */
@media print {
    .budget-print {
        display: block;
        font-family: Arial, sans-serif;
        padding: 2cm;
        color: #000;
    }
    
    .budget-print * {
        box-sizing: border-box;
    }
    
    .budget-header {
        text-align: center;
        margin-bottom: 2rem;
        border-bottom: 2px solid #2c5530;
        padding-bottom: 1rem;
    }
    
    .budget-title {
        font-size: 24px;
        font-weight: bold;
        color: #2c5530;
        margin-bottom: 0.5rem;
    }
    
    .budget-subtitle {
        font-size: 18px;
        color: #4a7c59;
        margin-bottom: 0.5rem;
    }
    
    .budget-info {
        margin-bottom: 2rem;
    }
    
    .budget-table {
        width: 100%;
        border-collapse: collapse;
        margin-bottom: 2rem;
    }
    
    .budget-table th {
        background-color: #8fb996;
        color: #1a331d;
        padding: 0.75rem;
        text-align: left;
        border: 1px solid #ddd;
        font-weight: bold;
    }
    
    .budget-table td {
        padding: 0.75rem;
        border: 1px solid #ddd;
    }
    
    .budget-total {
        text-align: right;
        font-size: 18px;
        font-weight: bold;
        margin-top: 1rem;
        padding-top: 1rem;
        border-top: 2px solid #2c5530;
    }
    
    .budget-footer {
        margin-top: 3rem;
        text-align: center;
        font-size: 12px;
        color: #666;
    }
    
    body * {
        visibility: hidden;
    }
    
    .budget-print, .budget-print * {
        visibility: visible;
    }
    
    .budget-print {
        position: absolute;
        left: 0;
        top: 0;
        width: 100%;
    }
}

/* Mejoras de accesibilidad */
@media (prefers-reduced-motion: reduce) {
    * {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
    }
}

/* Soporte para modo oscuro del sistema */
@media (prefers-color-scheme: dark) {
    :root {
        --light-color: #1a1a1a;
        --text-color: #e0e0e0;
        --dark-color: #8fb996;
    }
    
    body {
        background-color: var(--light-color);
        color: var(--text-color);
    }
    
    .card, .sidebar, header, .login-box, .modal-content {
        background-color: #2d2d2d;
        color: var(--text-color);
    }
    
    .input-group input, .form-group input, .form-group select, .form-group textarea {
        background-color: #3d3d3d;
        border-color: #555;
        color: var(--text-color);
    }
    
    th {
        background-color: #4a7c59;
        color: white;
    }
}
/* Estilos para tablas de reportes */
.data-table {
    width: 100%;
    border-collapse: collapse;
    margin-top: 1rem;
    font-size: 0.9rem;
}

.data-table th {
    background: var(--primary-color);
    color: white;
    padding: 0.75rem;
    text-align: left;
    font-weight: 600;
}

.data-table td {
    padding: 0.75rem;
    border-bottom: 1px solid #eee;
}

.data-table tr:nth-child(even) {
    background-color: #f8fbf8;
}

.data-table tr:hover {
    background-color: rgba(143, 185, 150, 0.1);
}

.card-content {
    padding: 0;
}

.card-content > *:first-child {
    margin-top: 0;
}

.card-content > *:last-child {
    margin-bottom: 0;
}

/* Mejoras responsive para tablas */
@media (max-width: 768px) {
    .data-table {
        font-size: 0.8rem;
    }
    
    .data-table th,
    .data-table td {
        padding: 0.5rem;
    }
}
.action-buttons {
    display: flex;
    flex-wrap: wrap;
    gap: 0.25rem;
}

.action-buttons .action-btn {
    margin: 0;
    flex: 1;
    min-width: 70px;
    text-align: center;
}

/* Mejoras responsive para la tabla de presupuestos */
@media (max-width: 1200px) {
    #budgets-table th:nth-child(3),
    #budgets-table td:nth-child(3) {
        display: none;
    }
}

@media (max-width: 992px) {
    #budgets-table th:nth-child(7),
    #budgets-table td:nth-child(7) {
        display: none;
    }
}

@media (max-width: 768px) {
    #budgets-table {
        display: block;
        overflow-x: auto;
    }
    
    .action-buttons {
        flex-direction: column;
    }
    
    .action-buttons .action-btn {
        min-width: 60px;
        font-size: 0.75rem;
        padding: 0.3rem 0.5rem;
    }
}
/* Estilos para botones de acciones */
.action-btn[style*="background-color: #28a745"] {
    background-color: #28a745 !important;
}

.action-btn[style*="background-color: #28a745"]:hover {
    background-color: #218838 !important;
}

.action-btn[style*="background-color: #6c757d"] {
    background-color: #6c757d !important;
    cursor: not-allowed;
    opacity: 0.6;
}

.text-warning {
    color: #856404;
    background-color: #fff3cd;
    border: 1px solid #ffeaa7;
    padding: 8px 12px;
    border-radius: 4px;
    font-size: 0.9rem;
}

/* Mejoras para los botones de acción en móviles */
@media (max-width: 768px) {
    .action-buttons {
        flex-direction: column;
    }
    
    .action-buttons .action-btn {
        margin-bottom: 0.25rem;
        font-size: 0.75rem;
        padding: 0.4rem 0.6rem;
    }
}


/* Header Styles Mejorados */
/* Alternativa: Logo sin fondo */
.logo-container {
    display: flex;
    justify-content: center;
    align-items: center;
    padding: 0.5rem;
    background: rgba(255, 255, 255, 0.1);
    border-radius: 12px;
    backdrop-filter: blur(10px);
    border: 1px solid rgba(255, 255, 255, 0.2);
    transition: var(--transition);
}

.header-logo {
    height: 50px;
    width: auto;
    max-width: 180px;
    object-fit: contain;
    /* Removemos el filtro blanco */
    filter: none;
    transition: var(--transition);
}
/* Responsive Design para el Header */
@media (max-width: 768px) {
    header {
        padding: 1rem;
        flex-direction: column;
        text-align: center;
        gap: 1rem;
        min-height: auto;
    }
    
    .header-left, .header-center, .header-right {
        justify-content: center;
        width: 100%;
    }
    
    .header-left {
        order: 1;
    }
    
    .header-center {
        order: 3;
    }
    
    .header-right {
        order: 2;
    }
    
    .user-details {
        align-items: center;
        text-align: center;
    }
    
    .header-logo {
        height: 40px;
    }
    
    .logo-container {
        padding: 0.5rem;
    }
}

@media (max-width: 480px) {
    .user-info {
        flex-direction: column;
        gap: 0.75rem;
    }
    
    .logout-btn {
        width: 100%;
        justify-content: center;
    }
    
    .header-logo {
        height: 35px;
    }
}