﻿/* custom.css - Versión final optimizada */

/* ========== VARIABLES Y ESTILOS BASE ========== */
:root {
    --primary-bg: #203d2b;
    --primary-text: #ffffff;
    --secondary-color: #a6b1aa;
    --alert-color: #8b0000;
    --light-bg: #ffffff;
    --dark-text: #203d2b;
    --input-bg: #f5f7f6;
}

/* ========== ESTRUCTURA GENERAL ========== */
html, body {
    height: 100%;
    margin: 0;
    font-family: 'Roboto', 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    overflow-x: hidden;
}

body {
    display: flex;
    flex-direction: column;
    background-color: var(--primary-bg);
    color: var(--primary-text);
}

/* ========== NAVBAR FIJADO ========== */
.navbar {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    z-index: 1030;
    transition: all 0.3s ease;
    background-color: var(--primary-bg) !important;
    padding: 0.5rem 1rem;
    box-shadow: 0 2px 10px rgba(0,0,0,0.1);
}

.navbar-scrolled {
    background-color: rgba(32, 61, 43, 0.95) !important;
}

.navbar-brand {
    font-size: 1.2rem;
    color: var(--primary-text);
}

.navbar-custom .nav-link {
    color: var(--primary-text);
}
/* ========== BOTÓN TOGGLE DEL SIDEBAR ========== */
.sidebar-toggler {
    display: flex !important; /* Forzar visibilidad */
    align-items: center;
    background: #203d2b;
    border: 1px solid rgba(255, 255, 255, 0.3);
    color: white;
    padding: 0.25rem 0.75rem;
    margin-right: 1rem;
    border-radius: 4px;
    transition: all 0.3s ease;
    cursor: pointer;
    z-index: 1050; /* Asegurar que esté por encima de otros elementos */
}

    .sidebar-toggler:hover {
        background: #203d2b;
    }

.sidebar-toggler-icon {
    display: inline-block;
    width: 1.5em;
    height: 1.5em;
    vertical-align: middle;
    background-image: url("data:image/svg+xml,%3csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 30 30'%3e%3cpath stroke='rgba%28255, 255, 255, 0.8%29' stroke-linecap='round' stroke-miterlimit='10' stroke-width='2' d='M4 7h22M4 15h22M4 23h22'/%3e%3c/svg%3e");
    background-repeat: no-repeat;
    background-position: center;
    background-size: 100%;
}

.sidebar-toggler-text {
    margin-left: 8px;
    font-size: 0.9rem;
}
/* ========== COMPORTAMIENTO DEL SIDEBAR ========== */
.sidebar {
    position: fixed;
    top: 56px;
    bottom: 0;
    left: 0;
    z-index: 1020;
    width: 250px;
    overflow-y: auto;
    transition: transform 0.3s ease;
    background-color: var(--light-bg);
    box-shadow: 1px 0 5px rgba(0,0,0,0.1);
}

    /* Estado inicial del sidebar */
    .sidebar:not(.show) {
        transform: translateX(-100%);
    }

/* Comportamiento en desktop */
@media (min-width: 992px) {
    .sidebar {
        transform: translateX(0); /* Visible por defecto en desktop */
    }

        .sidebar:not(.show) {
            transform: translateX(-100%); /* Oculto si tiene clase .show */
        }

    .main-content {
        margin-left: 250px; /* Ajuste inicial para desktop */
    }

    .sidebar:not(.show) + .main-content {
        margin-left: 0; /* Ajuste cuando sidebar está oculto */
    }
}

/* Comportamiento en móvil */
@media (max-width: 991.98px) {
    .sidebar {
        transform: translateX(-100%);
    }

        .sidebar.show {
            transform: translateX(0);
        }
}
/* ========== AJUSTES DEL CONTENIDO PRINCIPAL ========== */
.main-content {
    transition: margin-left 0.3s ease;
    margin-left: 0;
    padding: 20px;
    min-height: calc(100vh - 56px - 60px);
}

@media (min-width: 992px) {
    .main-content {
        margin-left: 250px;
    }

    /* Cuando el sidebar está oculto en desktop */
    .sidebar:not(.show) + .main-content {
        margin-left: 0;
    }
}

/* Scrollbar personalizado para sidebar */
.sidebar::-webkit-scrollbar {
    width: 6px;
}

.sidebar::-webkit-scrollbar-thumb {
    background-color: rgba(0,0,0,0.2);
    border-radius: 3px;
}

.sidebar::-webkit-scrollbar-track {
    background-color: transparent;
}

/* ========== CONTENIDO PRINCIPAL ========== */
.main-content {
    margin-left: 250px;
    transition: margin 0.3s ease;
    width: calc(100% - 250px);
    padding: 20px;
    min-height: calc(100vh - 56px - 60px); /* Altura total - navbar - footer */
}

/* ========== FOOTER FIJADO ========== */
.footer {
    position: relative;
    bottom: 0;
    width: 100%;
    z-index: 1020;
    background-color: var(--primary-bg);
    color: var(--light-bg);
    padding: 1rem 0;
}

/* ========== COMPONENTES COMUNES ========== */
.card {
    border-radius: 12px;
    border: none;
    background-color: var(--light-bg);
    color: var(--dark-text);
    box-shadow: 0 8px 30px rgba(0, 0, 0, 0.12);
}

.btn-primary {
    background-color: var(--primary-bg);
    border: none;
    color: var(--primary-text);
    transition: all 0.3s ease;
    padding: 12px 24px;
    font-weight: 600;
    letter-spacing: 0.5px;
    border-radius: 10px;
}

    .btn-primary:hover {
        background-color: #1a3324;
        transform: translateY(-2px);
        box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
    }

.form-control {
    background-color: var(--input-bg);
    border: 1px solid var(--secondary-color);
    border-radius: 8px;
    padding: 12px 15px;
    transition: all 0.3s ease;
}

    .form-control:focus {
        border-color: var(--primary-bg);
        box-shadow: 0 0 0 0.25rem rgba(32, 61, 43, 0.25);
    }

/* ========== PÁGINA DE LOGIN ========== */
.login-page {
    width: 100%;
    max-width: 1200px;
    margin: 0 auto;
    padding: 0 15px;
}

    .login-page .card {
        width: 100%;
        max-width: 500px;
        margin: 0 auto;
    }

    .login-page .input-group-text {
        background-color: var(--secondary-color);
        color: var(--dark-text);
        border: none;
    }

    .login-page .form-check-input:checked {
        background-color: var(--primary-bg);
        border-color: var(--primary-bg);
    }

    .login-page .login-link {
        color: var(--primary-bg);
        transition: all 0.3s ease;
        text-decoration: none;
        font-weight: 500;
    }

        .login-page .login-link:hover {
            color: #1a3324 !important;
            text-decoration: underline;
        }

    .login-page .alert-danger {
        background-color: var(--alert-color);
        color: var(--primary-text);
        border: none;
        border-radius: 8px;
    }

    .login-page .text-muted {
        color: var(--secondary-color) !important;
    }

    .login-page .logo-hover {
        transition: transform 0.3s ease;
    }

        .login-page .logo-hover:hover {
            transform: scale(1.05);
        }

/* ========== TABLAS ========== */
.table {
    color: var(--dark-text);
}

.table-hover tbody tr:hover {
    background-color: rgba(166, 177, 170, 0.1);
}

/* ========== MODALES ========== */
.modal-content {
    border-radius: 12px;
    border: none;
    background-color: var(--light-bg);
    color: var(--dark-text);
}

.modal-header {
    border-bottom: 1px solid var(--secondary-color);
}

.nav-tabs {
    border-bottom: 1px solid var(--secondary-color);
}

.nav-link {
    color: var(--dark-text);
}

    .nav-link.active {
        color: var(--primary-bg);
        border-bottom: 2px solid var(--primary-bg);
    }

.btn-close {
    filter: invert(0.5);
}

/* ========== FORMULARIOS ========== */
.form-input {
    position: relative;
    margin-bottom: 1.5rem;
}

    .form-input input {
        width: 100%;
        padding: 10px 15px;
        border: 1px solid var(--secondary-color);
        border-radius: 8px;
        background-color: var(--input-bg);
        transition: all 0.3s ease;
    }

        .form-input input:focus {
            border-color: var(--primary-bg);
            box-shadow: 0 0 0 0.2rem rgba(32, 61, 43, 0.25);
        }

    .form-input label {
        position: absolute;
        top: 10px;
        left: 15px;
        color: var(--secondary-color);
        transition: all 0.3s ease;
        pointer-events: none;
        background-color: var(--light-bg);
        padding: 0 5px;
    }

    .form-input input:focus + label,
    .form-input input:not(:placeholder-shown) + label {
        top: -10px;
        left: 10px;
        font-size: 0.8rem;
        color: var(--primary-bg);
    }

/* ========== VALIDACIÓN ========== */
.was-validated .form-control:invalid,
.form-control.is-invalid {
    border-color: #dc3545;
}

.was-validated .form-control:valid,
.form-control.is-valid {
    border-color: #28a745;
}

.invalid-feedback {
    display: none;
    width: 100%;
    margin-top: 0.25rem;
    font-size: 0.875em;
    color: #dc3545;
}

.was-validated .form-control:invalid ~ .invalid-feedback,
.form-control.is-invalid ~ .invalid-feedback {
    display: block;
}

/* ========== ANIMACIONES ========== */
.fade-in {
    animation: fadeIn 0.8s ease-in-out;
}

.slide-up {
    animation: slideUp 0.6s ease-out;
}

@keyframes fadeIn {
    from {
        opacity: 0;
    }

    to {
        opacity: 1;
    }
}

@keyframes slideUp {
    from {
        opacity: 0;
        transform: translateY(20px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* ========== RESPONSIVE ========== */
@media (max-width: 991.98px) {
    .sidebar {
        transform: translateX(-100%);
    }

        .sidebar.show {
            transform: translateX(0);
        }

    .sidebar-toggle {
        display: block;
    }

    .main-content {
        margin-left: 0;
        width: 100%;
    }
}

@media (max-width: 767.98px) {
    .main-content {
        padding: 15px;
    }
}
body.sidebar-hidden .main-content {
    margin-left: 0 !important;
    width: 100% !important;
}
