/* =====================================================================
   ERP CreaDepot3D - ESTILOS ADMINISTRATIVOS
   Dashboard responsivo con menú lateral
   Colores: Azul (#1E3A8A, #3B82F6) y Gris claro (#F3F4F6, #E5E7EB)
   ===================================================================== */

/* Variables de color */
:root {
    --primary-blue: #1E3A8A;
    --secondary-blue: #3B82F6;
    --light-blue: #DBEAFE;
    --bg-gray: #F3F4F6;
    --border-gray: #E5E7EB;
    --text-gray: #374151;
    --text-dark: #111827;
    --white: #FFFFFF;
    --sidebar-width: 260px;
    --header-height: 60px;
}

/* =====================================================================
   ALERTAS (éxito / error)
   ===================================================================== */

.alert {
    padding: 0.75rem 1rem;
    margin-bottom: 1rem;
    border-radius: 6px;
    border: 1px solid transparent;
    font-size: 0.95rem;
    line-height: 1.4;
}

.alert-error {
    background-color: #fee2e2;
    color: #b91c1c;
    border-color: #fecaca;
    font-weight: 600;
}

.alert-success {
    background-color: #d1fae5;
    color: #15803d;
    border-color: #a7f3d0;
    font-weight: 700;
}

/* =====================================================================
   DASHBOARD LAYOUT
   ===================================================================== */

.dashboard-container {
    display: flex;
    min-height: 100vh;
    background-color: var(--white);
    padding-top: var(--header-height);
}

.main-content {
    flex: 1;
    padding: 2rem;
    margin-left: var(--sidebar-width);
    transition: margin-left 0.3s ease;
    min-height: calc(100vh - var(--header-height));
    background-color: var(--white);
}

/* =====================================================================
   HEADER
   ===================================================================== */

.dashboard-header {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    height: var(--header-height);
    background: var(--white);
    border-bottom: 2px solid var(--border-gray);
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.05);
    z-index: 1000;
}

.header-content {
    display: flex;
    justify-content: space-between;
    align-items: center;
    height: 100%;
    padding: 0 2rem;
}

.header-left {
    display: flex;
    align-items: center;
    gap: 1rem;
    flex: 1;
    min-width: 0;
}

/* En escritorio: mostrar logo section normal */
.header-logo-section {
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
}

/* En escritorio: ocultar contenedor móvil */
.header-mobile-container {
    display: none;
}

.header-mobile-line-1,
.header-mobile-line-2,
.header-mobile-line-3 {
    display: none;
}

/* Checkbox oculto para controlar el menú */
.menu-toggle-checkbox {
    display: none !important;
    position: absolute !important;
    opacity: 0 !important;
    pointer-events: none !important;
    visibility: hidden !important;
    width: 0 !important;
    height: 0 !important;
    margin: 0 !important;
    padding: 0 !important;
}

.menu-toggle {
    display: none;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    background: var(--white);
    color: var(--primary-blue);
    border: 2px solid var(--primary-blue);
    border-radius: 6px;
    cursor: pointer;
    padding: 0.625rem 1.25rem;
    position: relative;
    z-index: 10000;
    -webkit-tap-highlight-color: transparent;
    touch-action: manipulation;
    font-size: 0.875rem;
    font-weight: 600;
    transition: all 0.2s ease;
    user-select: none;
    text-decoration: none;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
    min-width: 140px;
}

.menu-toggle:hover {
    background: var(--primary-blue);
    color: var(--white);
    box-shadow: 0 4px 6px rgba(0, 0, 0, 0.15);
    transform: translateY(-1px);
}

.menu-toggle:active {
    background: var(--primary-blue);
    color: var(--white);
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.1);
    transform: translateY(0);
}

.menu-toggle-text {
    display: inline-block;
    white-space: nowrap;
}

.logo-text {
    font-size: 1.5rem;
    font-weight: bold;
    color: var(--primary-blue);
    margin: 0;
}

.logo-mobile {
    display: none !important;
}

.logo-desktop {
    display: inline !important;
}

.header-right {
    display: flex;
    align-items: center;
    gap: 1rem;
}

.user-info {
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.user-name {
    color: var(--text-gray);
    font-weight: 500;
}

.user-avatar {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background: var(--primary-blue);
    color: var(--white);
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: bold;
}

/* =====================================================================
   SIDEBAR
   ===================================================================== */

.sidebar {
    position: fixed;
    top: var(--header-height);
    left: 0;
    width: var(--sidebar-width);
    height: calc(100vh - var(--header-height));
    background: var(--white);
    border-right: 1px solid var(--border-gray);
    overflow-y: auto;
    z-index: 999;
    transition: transform 0.3s ease;
    pointer-events: auto;
}

.sidebar-nav {
    padding: 1rem 0;
}

.nav-menu {
    list-style: none;
    margin: 0;
    padding: 0;
}

.nav-item {
    margin: 0.25rem 0;
}

.nav-link {
    display: flex;
    align-items: center;
    padding: 0.75rem 1.5rem;
    color: var(--text-gray);
    text-decoration: none;
    transition: all 0.2s ease;
    gap: 0.75rem;
    cursor: pointer;
    pointer-events: auto;
    user-select: none;
}

/* Los toggles de menú no deben mostrar URL en el hover */
.nav-group-toggle {
    cursor: pointer;
}

.nav-group-toggle:hover {
    text-decoration: none;
}

.nav-link:hover {
    background: var(--light-blue);
    color: var(--primary-blue);
}

.nav-item.active > .nav-link {
    background: var(--light-blue);
    color: var(--primary-blue);
    border-left: 3px solid var(--primary-blue);
}

/* =====================================================================
   SIDEBAR BUTTONS - Botones alternados para el menú lateral
   ===================================================================== */

.sidebar-button {
    display: flex;
    align-items: center;
    padding: 0.875rem 1.25rem;
    margin: 0.375rem 0.75rem;
    border-radius: 8px;
    text-decoration: none;
    font-weight: 500;
    transition: all 0.3s ease;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.08);
    border: 2px solid transparent;
    gap: 0.75rem;
}

.sidebar-btn-color-1 {
    background: var(--primary-blue);
    color: var(--white);
}

.sidebar-btn-color-1:hover {
    background: #1E40AF;
    color: var(--white) !important;
    box-shadow: 0 4px 8px rgba(30, 58, 138, 0.25);
    transform: translateX(4px);
    border-color: rgba(255, 255, 255, 0.2);
}

.sidebar-btn-color-1:active,
.sidebar-btn-color-1:focus {
    background: #1E3A8A !important;
    color: var(--white) !important;
    box-shadow: 0 2px 4px rgba(30, 58, 138, 0.3);
    transform: translateX(2px);
    outline: 2px solid rgba(255, 255, 255, 0.5);
    outline-offset: 2px;
}

.sidebar-btn-color-2 {
    background: var(--secondary-blue);
    color: var(--white);
}

.sidebar-btn-color-2:hover {
    background: #2563EB;
    color: var(--white) !important;
    box-shadow: 0 4px 8px rgba(59, 130, 246, 0.25);
    transform: translateX(4px);
    border-color: rgba(255, 255, 255, 0.2);
}

.sidebar-btn-color-2:active,
.sidebar-btn-color-2:focus {
    background: #1D4ED8 !important;
    color: var(--white) !important;
    box-shadow: 0 2px 4px rgba(59, 130, 246, 0.3);
    transform: translateX(2px);
    outline: 2px solid rgba(255, 255, 255, 0.5);
    outline-offset: 2px;
}

.nav-item.active .sidebar-button {
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
    transform: translateX(4px);
    border-color: rgba(255, 255, 255, 0.3);
    font-weight: 600;
}

.nav-item.active .sidebar-btn-color-1 {
    background: #1E40AF;
}

.nav-item.active .sidebar-btn-color-2 {
    background: #2563EB;
}

/* Asegurar que los iconos y texto se vean bien en los botones */
.sidebar-button .nav-icon {
    color: inherit;
}

.sidebar-button .nav-text {
    color: inherit;
}

/* Asegurar que el texto y los iconos permanezcan blancos en todos los estados */
.sidebar-btn-color-1 .nav-icon,
.sidebar-btn-color-1 .nav-text,
.sidebar-btn-color-1:active .nav-icon,
.sidebar-btn-color-1:active .nav-text,
.sidebar-btn-color-1:focus .nav-icon,
.sidebar-btn-color-1:focus .nav-text,
.sidebar-btn-color-1:hover .nav-icon,
.sidebar-btn-color-1:hover .nav-text {
    color: var(--white) !important;
}

.sidebar-btn-color-2 .nav-icon,
.sidebar-btn-color-2 .nav-text,
.sidebar-btn-color-2:active .nav-icon,
.sidebar-btn-color-2:active .nav-text,
.sidebar-btn-color-2:focus .nav-icon,
.sidebar-btn-color-2:focus .nav-text,
.sidebar-btn-color-2:hover .nav-icon,
.sidebar-btn-color-2:hover .nav-text {
    color: var(--white) !important;
}

.nav-icon {
    font-size: 1.25rem;
    width: 24px;
    text-align: center;
}

.nav-text {
    flex: 1;
}

.nav-arrow {
    font-size: 0.75rem;
    transition: transform 0.3s ease;
}

.nav-group.expanded .nav-arrow {
    transform: rotate(180deg);
}

.nav-submenu {
    list-style: none;
    margin: 0;
    padding: 0;
    max-height: 0;
    overflow: hidden;
    transition: max-height 0.3s ease, opacity 0.3s ease;
    opacity: 0;
}

.nav-group.expanded .nav-submenu {
    max-height: 1000px !important;
    opacity: 1 !important;
    display: block !important;
}

.nav-submenu li a {
    display: block;
    padding: 0.5rem 1.5rem 0.5rem 3.5rem;
    color: var(--text-gray);
    text-decoration: none;
    transition: all 0.2s ease;
}

.nav-submenu li a:hover,
.nav-submenu li a.active {
    background: var(--light-blue);
    color: var(--primary-blue);
}

.nav-separator {
    height: 1px;
    background: var(--border-gray);
    margin: 1rem 0;
}

/* Overlay para móvil - Oculto por defecto en escritorio */
.sidebar-overlay {
    display: none !important;
    position: fixed;
    top: var(--header-height);
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.5);
    z-index: 998;
    opacity: 0;
    transition: opacity 0.3s ease;
    pointer-events: none;
    visibility: hidden;
}

/* Solo mostrar overlay en móvil cuando esté activo */
@media (max-width: 768px) {
    .sidebar-overlay {
        visibility: visible;
    }
    
    .sidebar-overlay.active {
        display: block !important;
        opacity: 1;
        pointer-events: auto;
    }
}

/* Asegurar que el sidebar y sus elementos sean clickeables cuando está activo */
.sidebar.active {
    pointer-events: auto !important;
    z-index: 999 !important;
}

.sidebar.active .nav-link,
.sidebar.active .nav-group-toggle {
    pointer-events: auto !important;
}

/* =====================================================================
   CONTENT CARDS
   ===================================================================== */

.content-card {
    background: var(--white) !important;
    border-radius: 8px;
    padding: 1.5rem;
    margin-bottom: 1.5rem;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
}

.card-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1.5rem;
    padding-bottom: 1rem;
    border-bottom: 1px solid var(--border-gray);
}

.card-title {
    font-size: 1.25rem;
    font-weight: bold;
    color: var(--text-dark);
    margin: 0;
}

/* =====================================================================
   BUTTONS
   ===================================================================== */

.btn {
    display: inline-block;
    padding: 0.5rem 1rem;
    border-radius: 6px;
    text-decoration: none;
    font-weight: 500;
    cursor: pointer;
    border: none;
    transition: all 0.2s ease;
}

.btn-primary {
    background: var(--primary-blue);
    color: var(--white);
}

.btn-primary:hover {
    background: var(--secondary-blue);
}

.btn-secondary {
    background: var(--border-gray);
    color: var(--text-gray);
}

.btn-secondary:hover {
    background: #D1D5DB;
}

.btn-success {
    background: #10B981;
    color: var(--white);
}

.btn-danger {
    background: #EF4444;
    color: var(--white);
}

.btn-danger:hover {
    background: #DC2626;
}

.btn-success:hover {
    background: #059669;
}

.btn-small {
    padding: 0.375rem 0.75rem;
    font-size: 0.875rem;
}

.btn-large {
    padding: 0.75rem 1.5rem;
    font-size: 1.125rem;
}

/* =====================================================================
   INDEX PAGE BUTTONS - Botones alternados para páginas índice
   ===================================================================== */

.btn-index {
    display: inline-block;
    padding: 0.75rem 2rem;
    border-radius: 8px;
    text-decoration: none;
    font-weight: 600;
    font-size: 1rem;
    cursor: pointer;
    border: none;
    transition: all 0.3s ease;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
    min-width: 140px;
}

.btn-color-1 {
    background: var(--primary-blue);
    color: var(--white);
}

.btn-color-1:hover {
    background: #1E40AF;
    color: var(--white);
    box-shadow: 0 4px 8px rgba(30, 58, 138, 0.3);
    transform: translateY(-2px);
}

.btn-color-2 {
    background: var(--secondary-blue);
    color: var(--white);
}

.btn-color-2:hover {
    background: #2563EB;
    color: var(--white);
    box-shadow: 0 4px 8px rgba(59, 130, 246, 0.3);
    transform: translateY(-2px);
}

.index-card-button {
    transition: all 0.3s ease;
    border: 2px solid transparent;
}

.index-card-button:hover {
    border-color: var(--border-gray);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
    transform: translateY(-2px);
}

/* =====================================================================
   TABLES
   ===================================================================== */

.table-container {
    overflow-x: auto;
}

table {
    width: 100%;
    border-collapse: collapse;
    background: var(--white);
}

table th,
table td {
    padding: 0.75rem;
    text-align: left;
    border-bottom: 1px solid var(--border-gray);
}

table th {
    background: var(--bg-gray);
    font-weight: 600;
    color: var(--text-dark);
}

table tr:hover {
    background: var(--bg-gray);
}

table td a {
    color: var(--primary-blue);
    text-decoration: none;
    margin-right: 0.5rem;
}

table td a:hover {
    text-decoration: underline;
}

/* Estados de orden */
.estado-pendiente {
    background: #FEF3C7;
    color: #92400E;
    padding: 0.25rem 0.5rem;
    border-radius: 4px;
    font-size: 0.875rem;
    font-weight: 500;
}

.estado-pagada {
    background: #D1FAE5;
    color: #065F46;
    padding: 0.25rem 0.5rem;
    border-radius: 4px;
    font-size: 0.875rem;
    font-weight: 500;
}

.estado-lista-envio {
    background: #DBEAFE;
    color: #1E40AF;
    padding: 0.25rem 0.5rem;
    border-radius: 4px;
    font-size: 0.875rem;
    font-weight: 500;
}

.estado-transito {
    background: #E0E7FF;
    color: #3730A3;
    padding: 0.25rem 0.5rem;
    border-radius: 4px;
    font-size: 0.875rem;
    font-weight: 500;
}

.estado-cerrada {
    background: #D1D5DB;
    color: #374151;
    padding: 0.25rem 0.5rem;
    border-radius: 4px;
    font-size: 0.875rem;
    font-weight: 500;
}

.estado-cancelada {
    background: #FEE2E2;
    color: #991B1B;
    padding: 0.25rem 0.5rem;
    border-radius: 4px;
    font-size: 0.875rem;
    font-weight: 500;
}

/* =====================================================================
   FORMS
   ===================================================================== */

.form-group {
    margin-bottom: 1.5rem;
}

.form-label {
    display: block;
    margin-bottom: 0.5rem;
    font-weight: 500;
    color: var(--text-dark);
}

.form-control {
    width: 100%;
    padding: 0.5rem;
    border: 1px solid var(--border-gray);
    border-radius: 6px;
    font-size: 1rem;
    transition: all 0.2s ease;
}

.form-control:focus {
    outline: none;
    border-color: var(--primary-blue);
    box-shadow: 0 0 0 3px var(--light-blue);
}

.form-control:disabled {
    background: var(--bg-gray);
    cursor: not-allowed;
}

select.form-control {
    cursor: pointer;
}

textarea.form-control {
    resize: vertical;
    min-height: 100px;
}

.form-row {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
    gap: 1rem;
    margin-bottom: 1rem;
}

.form-actions {
    display: flex;
    gap: 1rem;
    margin-top: 1.5rem;
    padding-top: 1.5rem;
    border-top: 1px solid var(--border-gray);
}

.form-section {
    margin-bottom: 2rem;
    padding-bottom: 2rem;
    border-bottom: 1px solid var(--border-gray);
}

.form-section:last-child {
    border-bottom: none;
}

.text-muted {
    color: #6B7280;
    font-size: 0.9rem;
}

/* =====================================================================
   UTILITIES - PERMISOS
   ===================================================================== */

.hidden {
    display: none !important;
}

/* =====================================================================
   FOOTER
   ===================================================================== */

.dashboard-footer {
    background: var(--white);
    border-top: 1px solid var(--border-gray);
    padding: 1rem 2rem;
    text-align: center;
    color: var(--text-gray);
    margin-top: auto;
}

/* =====================================================================
   RESPONSIVE - TABLET Y MÓVIL
   ===================================================================== */
/* Los estilos móviles están en admin-mobile.css */
/* Este archivo (admin.css) contiene solo estilos para escritorio (min-width: 769px) */

@media print {
    .sidebar,
    .header,
    .top-header,
    nav,
    .no-print,
    .btn {
        display: none !important;
    }
    .main-content {
        margin-left: 0 !important;
        padding: 0 !important;
    }
    .content-card {
        box-shadow: none !important;
        border: none !important;
    }
    body {
        background: #fff !important;
    }
}

