/* Reset y Variables */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

:root {
    --primary-color: #3b82f6;
    --primary-dark: #2563eb;
    --primary-light: #dbeafe;
    --secondary-color: #8b5cf6;
    --success-color: #10b981;
    --danger-color: #ef4444;
    --warning-color: #f59e0b;
    --gray-50: #f9fafb;
    --gray-100: #f3f4f6;
    --gray-200: #e5e7eb;
    --gray-300: #d1d5db;
    --gray-400: #9ca3af;
    --gray-500: #6b7280;
    --gray-600: #4b5563;
    --gray-700: #374151;
    --gray-800: #1f2937;
    --gray-900: #111827;
    --border-radius: 8px;
    --box-shadow: 0 1px 3px 0 rgba(0, 0, 0, 0.1);
    --box-shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.1);
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
    background-color: var(--gray-50);
    color: var(--gray-900);
    line-height: 1.5;
}

/* Container Principal */
.container {
    display: flex;
    height: 100vh;
    overflow: hidden;
}

/* Sidebar */
.sidebar {
    width: 260px;
    background: var(--gray-900);
    color: white;
    display: flex;
    flex-direction: column;
    padding: 20px;
    box-shadow: var(--box-shadow-lg);
    overflow-y: auto;
}

.sidebar-header {
    margin-bottom: 40px;
}

.sidebar-header h1 {
    font-size: 24px;
    font-weight: 700;
    display: flex;
    align-items: center;
    gap: 10px;
}

.sidebar-logo {
    max-width: 100%;
    height: auto;
    display: block;
}

.sidebar-header i {
    color: var(--primary-color);
}

.sidebar-nav {
    display: flex;
    flex-direction: column;
    gap: 10px;
    flex: 1;
}

.nav-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 16px;
    border-radius: var(--border-radius);
    color: var(--gray-300);
    text-decoration: none;
    transition: all 0.3s ease;
    cursor: pointer;
    font-size: 14px;
    font-weight: 500;
}

.nav-item:hover {
    background-color: rgba(255, 255, 255, 0.1);
    color: white;
}

.nav-item.active {
    background: var(--primary-color);
    color: white;
}

.nav-item i {
    font-size: 18px;
    min-width: 20px;
}

/* Main Content */
.main-content {
    flex: 1;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

/* Header */
.header {
    background: white;
    padding: 20px 30px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-bottom: 1px solid var(--gray-200);
    box-shadow: var(--box-shadow);
    gap: 15px;
}

.header-left {
    display: flex;
    align-items: center;
    gap: 20px;
    flex: 1;
}

.header-center {
    display: flex;
    justify-content: center;
    flex: 2;
}

.header-right {
    display: flex;
    justify-content: flex-end;
    align-items: center;
    flex: 1;
}

.menu-toggle {
    display: none;
    background: none;
    border: none;
    font-size: 20px;
    cursor: pointer;
    color: var(--gray-600);
}

#page-title {
    font-size: 24px;
    font-weight: 700;
    color: var(--gray-900);
}

.search-bar {
    display: flex;
    align-items: center;
    gap: 12px;
    background: var(--gray-100);
    padding: 10px 16px;
    border-radius: var(--border-radius);
    width: 100%;
    max-width: 500px;
}

.search-bar i {
    color: var(--gray-400);
}

.search-bar input {
    border: none;
    background: none;
    outline: none;
    width: 100%;
    font-size: 14px;
}

/* Content Area */
.content {
    flex: 1;
    overflow-y: auto;
    padding: 30px;
}

.view {
    display: none;
}

.view.active {
    display: block;
    animation: fadeIn 0.3s ease;
}

@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* Stats Grid */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
    gap: 20px;
    margin-bottom: 30px;
}

.stat-card {
    background: white;
    padding: 20px;
    border-radius: var(--border-radius);
    box-shadow: var(--box-shadow);
    display: flex;
    align-items: center;
    gap: 16px;
    transition: all 0.3s ease;
}

.stat-card:hover {
    transform: translateY(-4px);
    box-shadow: var(--box-shadow-lg);
}

.stat-icon {
    width: 60px;
    height: 60px;
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 28px;
    color: white;
}

.stat-icon.total {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
}

.stat-icon.active {
    background: linear-gradient(135deg, #f093fb 0%, #f5576c 100%);
}

.stat-icon.inactive {
    background: linear-gradient(135deg, #4facfe 0%, #00f2fe 100%);
}

.stat-icon.maintenance {
    background: linear-gradient(135deg, #fa709a 0%, #fee140 100%);
}

.stat-icon.value {
    background: linear-gradient(135deg, #a8edea 0%, #fed6e3 100%);
}

.stat-info h3 {
    font-size: 13px;
    font-weight: 600;
    color: var(--gray-500);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-bottom: 8px;
}

.stat-value {
    font-size: 28px;
    font-weight: 700;
    color: var(--gray-900);
}

/* Dashboard Bottom */
.dashboard-bottom {
    background: white;
    padding: 25px;
    border-radius: var(--border-radius);
    box-shadow: var(--box-shadow);
}

.dashboard-bottom h3 {
    font-size: 18px;
    font-weight: 700;
    margin-bottom: 20px;
    color: var(--gray-900);
}

.equipos-list {
    display: grid;
    gap: 12px;
}

.equipo-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 12px;
    background: var(--gray-50);
    border-radius: 6px;
    border-left: 4px solid var(--primary-color);
}

.equipo-item-info h4 {
    font-size: 14px;
    font-weight: 600;
    color: var(--gray-900);
    margin-bottom: 4px;
}

.equipo-item-info p {
    font-size: 12px;
    color: var(--gray-500);
}

.equipo-item-badge {
    padding: 4px 12px;
    border-radius: 20px;
    font-size: 12px;
    font-weight: 600;
}

.badge-activo {
    background: #dcfce7;
    color: #166534;
}

.badge-inactivo {
    background: #fecaca;
    color: #991b1b;
}

.badge-mantenimiento {
    background: #fef3c7;
    color: #92400e;
}

/* Inventario View */
.inventario-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
    flex-wrap: wrap;
    gap: 15px;
}

.inventario-header h3 {
    font-size: 20px;
    font-weight: 700;
}

.inventario-actions {
    display: flex;
    gap: 15px;
    align-items: center;
    flex-wrap: wrap;
}

.export-buttons {
    display: flex;
    gap: 8px;
}

.filters {
    display: flex;
    gap: 12px;
}

.filter-select {
    padding: 10px 12px;
    border: 1px solid var(--gray-200);
    border-radius: var(--border-radius);
    background: white;
    font-size: 14px;
    cursor: pointer;
    transition: all 0.3s ease;
}

.filter-select:hover {
    border-color: var(--primary-color);
}

.filter-select:focus {
    outline: none;
    border-color: var(--primary-color);
    box-shadow: 0 0 0 3px var(--primary-light);
}

/* Table Responsive */
.table-responsive {
    background: white;
    border-radius: var(--border-radius);
    box-shadow: var(--box-shadow);
    overflow: auto;
}

.equipos-table {
    width: 100%;
    border-collapse: collapse;
}

.equipos-table thead {
    background: var(--gray-50);
    border-bottom: 2px solid var(--gray-200);
}

.equipos-table th {
    padding: 16px;
    text-align: left;
    font-weight: 600;
    font-size: 13px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: var(--gray-600);
}

.equipos-table tbody tr {
    border-bottom: 1px solid var(--gray-100);
    transition: background 0.2s ease;
}

.equipos-table tbody tr:hover {
    background: var(--gray-50);
}

.equipos-table td {
    padding: 16px;
    font-size: 14px;
    color: var(--gray-700);
}

.equipos-table .estado-badge {
    padding: 4px 12px;
    border-radius: 20px;
    font-size: 12px;
    font-weight: 600;
}

.estado-activo {
    background: #dcfce7;
    color: #166534;
}

.estado-inactivo {
    background: #fecaca;
    color: #991b1b;
}

.estado-mantenimiento {
    background: #fef3c7;
    color: #92400e;
}

.action-buttons {
    display: flex;
    gap: 8px;
}

.btn-icon {
    width: 36px;
    height: 36px;
    border-radius: 6px;
    border: none;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s ease;
    font-size: 14px;
}

.btn-edit {
    background: var(--primary-light);
    color: var(--primary-dark);
}

.btn-edit:hover {
    background: var(--primary-color);
    color: white;
}

.btn-delete {
    background: #fee2e2;
    color: #dc2626;
}

.btn-delete:hover {
    background: var(--danger-color);
    color: white;
}

/* Form Container */
.form-container {
    background: white;
    padding: 30px;
    border-radius: var(--border-radius);
    box-shadow: var(--box-shadow);
    max-width: 900px;
}

.form-container h3 {
    font-size: 20px;
    font-weight: 700;
    margin-bottom: 25px;
}

.form-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
    gap: 20px;
}

.form-group {
    display: flex;
    flex-direction: column;
}

.form-group.full-width {
    grid-column: 1 / -1;
}

.form-group label {
    font-weight: 600;
    margin-bottom: 8px;
    font-size: 14px;
    color: var(--gray-700);
}

.form-group input,
.form-group select,
.form-group textarea {
    padding: 12px;
    border: 1px solid var(--gray-200);
    border-radius: var(--border-radius);
    font-size: 14px;
    font-family: inherit;
    transition: all 0.3s ease;
}

.form-group input:focus,
.form-group select:focus,
.form-group textarea:focus {
    outline: none;
    border-color: var(--primary-color);
    box-shadow: 0 0 0 3px var(--primary-light);
}

.form-group textarea {
    resize: vertical;
    min-height: 120px;
}

.form-actions {
    display: flex;
    gap: 12px;
    justify-content: flex-start;
}

.btn {
    padding: 12px 24px;
    border: none;
    border-radius: var(--border-radius);
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
    display: inline-flex;
    align-items: center;
    gap: 8px;
}

.btn-primary {
    background: var(--primary-color);
    color: white;
}

.btn-primary:hover {
    background: var(--primary-dark);
    transform: translateY(-2px);
    box-shadow: var(--box-shadow-lg);
}

.btn-secondary {
    background: var(--gray-200);
    color: var(--gray-700);
}

.btn-secondary:hover {
    background: var(--gray-300);
}

.btn-danger {
    background: var(--danger-color);
    color: white;
}

.btn-danger:hover {
    background: #dc2626;
}

/* Modal */
.modal {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.5);
    z-index: 1000;
    justify-content: center;
    align-items: center;
    animation: fadeIn 0.3s ease;
}

.modal.active {
    display: flex;
}

.modal-content {
    background: white;
    padding: 30px;
    border-radius: var(--border-radius);
    max-width: 700px;
    width: 90%;
    max-height: 90vh;
    overflow-y: auto;
    box-shadow: var(--box-shadow-lg);
}

.modal-content.small {
    max-width: 400px;
}

.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
}

.modal-header h2 {
    font-size: 20px;
    font-weight: 700;
}

.close-modal {
    background: none;
    border: none;
    font-size: 28px;
    cursor: pointer;
    color: var(--gray-400);
    transition: color 0.2s ease;
}

.close-modal:hover {
    color: var(--gray-600);
}

/* Toast Notification */
.toast {
    position: fixed;
    bottom: 20px;
    right: 20px;
    padding: 16px 24px;
    background: var(--gray-900);
    color: white;
    border-radius: var(--border-radius);
    box-shadow: var(--box-shadow-lg);
    z-index: 2000;
    min-width: 250px;
    opacity: 0;
    transform: translateY(100px);
    transition: all 0.3s ease;
}

.toast.show {
    opacity: 1;
    transform: translateY(0);
}

.toast.success {
    background: var(--success-color);
}

.toast.error {
    background: var(--danger-color);
}

.toast.warning {
    background: var(--warning-color);
}

/* Responsive */
@media (max-width: 768px) {
    .container {
        flex-direction: column;
    }

    .sidebar {
        width: 100%;
        height: auto;
        padding: 16px;
        flex-direction: row;
        align-items: center;
        justify-content: space-between;
    }

    .sidebar-logo {
        max-width: 140px;
    }

        .sidebar-header {
            margin-bottom: 0;
        }

    .sidebar-header h1 {
        font-size: 18px;
    }

    .sidebar-nav {
        flex-direction: row;
        gap: 5px;
            overflow-x: auto;
            -webkit-overflow-scrolling: touch;
    }

    .nav-item {
        padding: 10px 12px;
    }

    .nav-item span {
        display: none;
    }

    .header {
        flex-direction: row;
        flex-wrap: wrap;
        gap: 12px;
        align-items: center;
    }

    .header-left {
        flex: 1;
    }
    .header-right {
        flex: 1;
        justify-content: flex-end;
    }
    .header-center {
        width: 100%;
        order: 3;
        flex: none;
    }

    .search-bar {
        max-width: 100%;
    }

    .menu-toggle {
            display: none; /* Oculto porque el menú lateral ya se vuelve visible en la parte superior */
    }

    .content {
        padding: 20px;
    }

    .stats-grid {
        grid-template-columns: repeat(2, 1fr);
        gap: 12px;
    }

    .stat-card {
        flex-direction: column;
        text-align: center;
    }

    .stat-icon {
        width: 50px;
        height: 50px;
        font-size: 20px;
    }

    .inventario-header {
        flex-direction: column;
        align-items: flex-start;
    }

    .filters {
        width: 100%;
        flex-direction: column;
    }

    .filter-select {
        width: 100%;
    }

    .equipos-table {
        font-size: 12px;
    }

    .equipos-table th,
    .equipos-table td {
        padding: 12px 8px;
    }

    .action-buttons {
        flex-direction: column;
    }

    .modal-content {
        width: 95%;
    }

    .form-grid {
        grid-template-columns: 1fr;
    }
}

/* Optimizaciones para teléfonos muy pequeños (ej. pantallas menores a 480px) */
@media (max-width: 480px) {
    .stats-grid {
        grid-template-columns: 1fr;
    }
    
    .login-box {
        padding: 25px 20px;
    }

    .export-buttons {
        width: 100%;
    }
    
    .export-buttons .btn {
        flex: 1;
        justify-content: center;
    }
}

/* Scrollbar Styling */
::-webkit-scrollbar {
    width: 8px;
    height: 8px;
}

::-webkit-scrollbar-track {
    background: var(--gray-100);
}

::-webkit-scrollbar-thumb {
    background: var(--gray-300);
    border-radius: 4px;
}

::-webkit-scrollbar-thumb:hover {
    background: var(--gray-400);
}

/* Login Styles */
.login-container {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 100vh;
    background: linear-gradient(135deg, #64748b 0%, #334155 100%);
}

.login-container.hidden {
    display: none;
}

.login-box {
    background: white;
    padding: 40px;
    border-radius: 12px;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
    width: 100%;
    max-width: 400px;
}

.login-header {
    text-align: center;
    margin-bottom: 30px;
}

.login-header i {
    font-size: 48px;
    color: var(--primary-color);
    margin-bottom: 10px;
}

.login-logo {
    max-width: 250px;
    height: auto;
    margin-bottom: 15px;
}

.login-header h1 {
    font-size: 28px;
    font-weight: 700;
    margin-bottom: 5px;
    color: var(--gray-900);
}

.login-header p {
    color: var(--gray-500);
    font-size: 14px;
}

.login-form {
    display: flex;
    flex-direction: column;
    gap: 20px;
}

.login-form .form-group {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.login-form label {
    font-weight: 600;
    color: var(--gray-700);
    font-size: 14px;
}

.login-form input {
    padding: 12px;
    border: 1px solid var(--gray-200);
    border-radius: var(--border-radius);
    font-size: 14px;
    transition: all 0.3s ease;
}

.login-form input:focus {
    outline: none;
    border-color: var(--primary-color);
    box-shadow: 0 0 0 3px var(--primary-light);
}

.login-info {
    background: var(--gray-50);
    padding: 15px;
    border-radius: var(--border-radius);
    font-size: 12px;
    color: var(--gray-700);
    border-left: 4px solid var(--primary-color);
}

.login-info p {
    margin: 5px 0;
}

.login-info code {
    background: white;
    padding: 2px 6px;
    border-radius: 4px;
    font-weight: 600;
    color: var(--primary-color);
}

.app-hidden {
    display: none;
}

/* User Info in Header */
.user-info {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 8px 16px;
    background: var(--gray-100);
    border-radius: var(--border-radius);
}

.user-name {
    font-weight: 600;
    color: var(--gray-900);
    font-size: 14px;
}

.user-rol {
    font-size: 12px;
    color: var(--gray-500);
    background: white;
    padding: 2px 8px;
    border-radius: 12px;
}

.btn-logout {
    background: none;
    border: none;
    color: var(--danger-color);
    cursor: pointer;
    font-size: 16px;
    transition: all 0.2s ease;
    padding: 4px 8px;
}

.btn-logout:hover {
    color: #dc2626;
    transform: scale(1.1);
}

.full-width {
    width: 100% !important;
}

/* Global Search Results */
.search-results {
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    background: white;
    border-radius: var(--border-radius);
    box-shadow: var(--box-shadow-lg);
    margin-top: 8px;
    max-height: 350px;
    overflow-y: auto;
    z-index: 1000;
    border: 1px solid var(--gray-200);
}

.search-results.hidden {
    display: none;
}

.search-result-item {
    padding: 12px 16px;
    border-bottom: 1px solid var(--gray-100);
    cursor: pointer;
    transition: background 0.2s ease;
}

.search-result-item:last-child {
    border-bottom: none;
}

.search-result-item:hover {
    background: var(--gray-50);
}

.sr-title {
    font-weight: 600;
    font-size: 14px;
    color: var(--gray-900);
    margin-bottom: 4px;
}

.sr-subtitle {
    font-size: 12px;
    color: var(--gray-500);
}

.search-result-item.empty {
    text-align: center;
    color: var(--gray-500);
    cursor: default;
}
.search-result-item.empty:hover {
    background: white;
}

/* Estilos para el campo de contraseña con ojito */
.password-wrapper {
    position: relative;
    display: flex;
    align-items: center;
}
.password-wrapper input {
    width: 100%;
    padding-right: 40px !important;
}
.toggle-password {
    position: absolute;
    right: 12px;
    color: var(--gray-400);
    cursor: pointer;
    transition: color 0.2s;
    z-index: 10;
}
.toggle-password:hover {
    color: var(--gray-700);
}
