/* =====================================================
   DM Fit Store — Sistema Contable y Operativo TikTok Live
   Identidad Visual: Carbón Mate + Rose Gold Metálico
   ===================================================== */

:root {
    --primary: #a86464;
    --primary-light: #c98a8a;
    --primary-dark: #7d4646;
    --accent: #d89c9c;
    --accent-soft: rgba(201, 138, 138, 0.14);
    --dark-bg: #1f1d1c;
    --sidebar-bg: linear-gradient(180deg, #181615 0%, #262322 55%, #322e2d 100%);
    --sidebar-width: 265px;
    --header-height: 62px;
    --body-bg: #f6f4f3;
    --card-bg: #ffffff;
    --text-primary: #22201f;
    --text-secondary: #6b6563;
    --text-light: #9e9693;
    --border-color: #e6e0de;
    --success: #267a4d;
    --warning: #cf7a1f;
    --danger: #c03939;
    --info: #346eb8;
    --shadow-sm: 0 2px 6px rgba(34, 32, 31, 0.05);
    --shadow-md: 0 6px 18px rgba(34, 32, 31, 0.08);
    --shadow-lg: 0 12px 32px rgba(34, 32, 31, 0.14);
    --radius-sm: 8px;
    --radius-md: 14px;
    --radius-lg: 18px;
    --transition: all 0.25s cubic-bezier(0.4, 0, 0.2, 1);
}

* { box-sizing: border-box; }

body {
    font-family: 'Plus Jakarta Sans', 'Segoe UI', system-ui, -apple-system, sans-serif;
    background: var(--body-bg);
    color: var(--text-primary);
    min-height: 100vh;
    overflow-x: hidden;
    font-size: 0.92rem;
}

.font-brand {
    font-family: 'Playfair Display', Georgia, serif;
    letter-spacing: 0.5px;
}

/* === Bootstrap Primary Overrides === */
.btn-primary {
    background: linear-gradient(135deg, var(--primary-light), var(--primary));
    border-color: var(--primary);
    color: #fff;
    font-weight: 600;
}
.btn-primary:hover, .btn-primary:focus {
    background: linear-gradient(135deg, var(--primary), var(--primary-dark));
    border-color: var(--primary-dark);
    color: #fff;
}
.btn-outline-primary {
    color: var(--primary-dark);
    border-color: var(--primary-light);
}
.btn-outline-primary:hover {
    background: var(--primary);
    border-color: var(--primary);
    color: #fff;
}
.text-primary { color: var(--primary-dark) !important; }
.bg-primary { background-color: var(--primary) !important; }
.border-primary { border-color: var(--primary-light) !important; }
.form-control:focus, .form-select:focus {
    border-color: var(--primary-light);
    box-shadow: 0 0 0 0.2rem rgba(201, 138, 138, 0.25);
}

/* === Login Page === */
.login-page {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    background: radial-gradient(circle at top right, #423333 0%, #262322 48%, #161413 100%);
    padding: 1.25rem;
    position: relative;
    overflow: hidden;
}

.login-card {
    background: rgba(255, 255, 255, 0.97);
    border-radius: var(--radius-lg);
    padding: 2.25rem 2rem;
    width: 100%;
    max-width: 420px;
    box-shadow: 0 18px 50px rgba(0, 0, 0, 0.45);
    border: 1px solid rgba(201, 138, 138, 0.35);
    position: relative;
    z-index: 1;
}

.login-logo {
    text-align: center;
    margin-bottom: 1.75rem;
}
.login-logo img {
    width: 96px;
    height: 96px;
    border-radius: 18px;
    object-fit: cover;
    border: 2px solid var(--primary-light);
    box-shadow: 0 8px 24px rgba(168, 100, 100, 0.3);
    margin-bottom: 1rem;
}
.login-logo h1 {
    font-size: 1.45rem;
    font-weight: 700;
    color: var(--dark-bg);
    margin-bottom: 0.2rem;
}
.login-logo p {
    color: var(--text-secondary);
    font-size: 0.85rem;
    margin: 0;
}

.btn-login {
    width: 100%;
    padding: 0.72rem;
    border-radius: 10px;
    background: linear-gradient(135deg, var(--primary-light), var(--primary));
    border: none;
    color: #fff;
    font-weight: 600;
    font-size: 0.96rem;
    transition: var(--transition);
}
.btn-login:hover {
    background: linear-gradient(135deg, var(--primary), var(--primary-dark));
    color: #fff;
    transform: translateY(-1px);
    box-shadow: 0 6px 18px rgba(168, 100, 100, 0.35);
}

/* === Sidebar Layout === */
.sidebar {
    position: fixed;
    top: 0;
    left: 0;
    width: var(--sidebar-width);
    height: 100vh;
    background: var(--sidebar-bg);
    color: #fff;
    display: flex;
    flex-direction: column;
    z-index: 1040;
    transition: var(--transition);
    border-right: 1px solid rgba(201, 138, 138, 0.16);
}

.sidebar-header {
    padding: 1.1rem 1.15rem;
    display: flex;
    align-items: center;
    gap: 0.85rem;
    border-bottom: 1px solid rgba(255, 255, 255, 0.08);
}

.sidebar-logo-img {
    width: 44px;
    height: 44px;
    border-radius: 10px;
    object-fit: cover;
    border: 1.5px solid var(--primary-light);
    flex-shrink: 0;
}

.logo-text {
    font-weight: 700;
    font-size: 1rem;
    line-height: 1.2;
    color: #fff;
}
.logo-text small {
    display: block;
    font-size: 0.7rem;
    font-weight: 400;
    color: var(--accent);
    letter-spacing: 0.4px;
}

.sidebar-nav {
    flex: 1;
    overflow-y: auto;
    padding: 0.75rem 0.75rem 1rem;
}

.nav-section {
    font-size: 0.68rem;
    text-transform: uppercase;
    letter-spacing: 1px;
    color: rgba(255, 255, 255, 0.42);
    padding: 0.85rem 0.75rem 0.35rem;
    font-weight: 700;
}

.nav-item { margin-bottom: 2px; }

.sidebar-nav .nav-link {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.62rem 0.85rem;
    border-radius: 10px;
    color: rgba(255, 255, 255, 0.78);
    text-decoration: none;
    font-size: 0.88rem;
    font-weight: 500;
    transition: var(--transition);
}
.sidebar-nav .nav-link i {
    font-size: 1.05rem;
    color: var(--accent);
    width: 20px;
    text-align: center;
}
.sidebar-nav .nav-link:hover {
    background: rgba(201, 138, 138, 0.14);
    color: #fff;
}
.sidebar-nav .nav-link.active {
    background: linear-gradient(135deg, rgba(201, 138, 138, 0.35), rgba(168, 100, 100, 0.5));
    color: #fff;
    font-weight: 600;
    box-shadow: inset 3px 0 0 var(--accent);
}
.sidebar-nav .nav-link .badge {
    margin-left: auto;
    font-size: 0.7rem;
}

.sidebar-user {
    padding: 0.9rem 1rem;
    border-top: 1px solid rgba(255, 255, 255, 0.08);
    background: rgba(0, 0, 0, 0.18);
}

.user-info {
    display: flex;
    align-items: center;
    gap: 0.7rem;
    margin-bottom: 0.7rem;
}

.user-avatar {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    background: linear-gradient(135deg, var(--primary-light), var(--primary-dark));
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    font-size: 0.8rem;
    color: #fff;
    flex-shrink: 0;
}

.user-name { font-size: 0.84rem; font-weight: 600; color: #fff; line-height: 1.2; }
.user-role { font-size: 0.72rem; color: var(--accent); }

.btn-logout {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.45rem;
    width: 100%;
    padding: 0.45rem;
    border-radius: 8px;
    background: rgba(255, 255, 255, 0.08);
    color: rgba(255, 255, 255, 0.85);
    text-decoration: none;
    font-size: 0.8rem;
    transition: var(--transition);
}
.btn-logout:hover { background: rgba(192, 57, 57, 0.35); color: #fff; }

/* === Main Content & Top Header === */
.main-content {
    margin-left: var(--sidebar-width);
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    transition: var(--transition);
}

.top-header {
    height: var(--header-height);
    background: var(--card-bg);
    border-bottom: 1px solid var(--border-color);
    padding: 0 1.5rem;
    display: flex;
    align-items: center;
    justify-content: space-between;
    position: sticky;
    top: 0;
    z-index: 1020;
    box-shadow: var(--shadow-sm);
}

.btn-sidebar-toggle {
    display: none;
    background: none;
    border: 1px solid var(--border-color);
    border-radius: 8px;
    padding: 0.35rem 0.6rem;
    font-size: 1.25rem;
    color: var(--text-primary);
    cursor: pointer;
}

.page-title {
    font-weight: 700;
    font-size: 1.05rem;
    display: flex;
    align-items: center;
    gap: 0.55rem;
    color: var(--text-primary);
}
.page-title i { color: var(--primary); }

.page-content {
    padding: 1.35rem 1.5rem 2.5rem;
    flex: 1;
}

/* === Cards & Tables === */
.card {
    background: var(--card-bg);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-sm);
    overflow: hidden;
}

.card-header {
    background: #fcfbfa;
    border-bottom: 1px solid var(--border-color);
    padding: 0.85rem 1.15rem;
    font-weight: 600;
    font-size: 0.92rem;
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.table { margin-bottom: 0; vertical-align: middle; }
.table thead th {
    background: #f9f6f5;
    color: var(--text-secondary);
    font-size: 0.74rem;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    font-weight: 700;
    border-bottom: 1px solid var(--border-color);
    padding: 0.72rem 0.85rem;
}
.table tbody td {
    padding: 0.72rem 0.85rem;
    border-color: #f0ecea;
}

/* === Stat Cards === */
.stat-card {
    border-radius: var(--radius-md);
    padding: 1.15rem 1.25rem;
    color: #fff;
    position: relative;
    overflow: hidden;
    box-shadow: var(--shadow-md);
    height: 100%;
}
.stat-card .stat-icon {
    position: absolute;
    right: 0.9rem;
    top: 0.8rem;
    font-size: 2rem;
    opacity: 0.24;
}
.stat-card .stat-value {
    font-size: 1.38rem;
    font-weight: 800;
    line-height: 1.2;
    margin-bottom: 0.2rem;
}
.stat-card .stat-label {
    font-size: 0.78rem;
    opacity: 0.9;
    font-weight: 500;
}

.bg-gradient-brand { background: linear-gradient(135deg, #c98a8a 0%, #9b5a5a 100%); }
.bg-gradient-dark-brand { background: linear-gradient(135deg, #353130 0%, #1d1b1a 100%); }
.bg-gradient-success { background: linear-gradient(135deg, #2e8b57 0%, #1f6840 100%); }
.bg-gradient-danger { background: linear-gradient(135deg, #d34a4a 0%, #a52d2d 100%); }
.bg-gradient-warning { background: linear-gradient(135deg, #e08e2b 0%, #bc6c14 100%); }
.bg-gradient-info { background: linear-gradient(135deg, #3e7ec9 0%, #275a99 100%); }

/* === Live Banner === */
.live-banner {
    background: linear-gradient(135deg, #262322 0%, #442b2b 65%, #a86464 100%);
    color: #fff;
    border-radius: var(--radius-md);
    padding: 1rem 1.35rem;
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: 1rem;
    box-shadow: var(--shadow-md);
}
.live-dot {
    width: 10px;
    height: 10px;
    border-radius: 50%;
    background: #ff4d4f;
    display: inline-block;
    box-shadow: 0 0 0 4px rgba(255, 77, 79, 0.35);
    animation: pulseLive 1.4s infinite;
}
@keyframes pulseLive {
    0%, 100% { transform: scale(1); opacity: 1; }
    50% { transform: scale(1.3); opacity: 0.7; }
}

/* === Alert Cards === */
.alert-card {
    display: flex;
    align-items: center;
    gap: 0.85rem;
    padding: 0.78rem 0.95rem;
    border-radius: 10px;
    border: 1px solid var(--border-color);
    text-decoration: none;
    color: var(--text-primary);
    margin-bottom: 0.65rem;
    transition: var(--transition);
    background: #fff;
}
.alert-card:last-child { margin-bottom: 0; }
.alert-card:hover {
    border-color: var(--primary-light);
    background: #fdf9f9;
    transform: translateX(3px);
}
.alert-card .alert-icon {
    width: 40px;
    height: 40px;
    border-radius: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.15rem;
    flex-shrink: 0;
}
.alert-card .alert-count {
    margin-left: auto;
    font-size: 1.25rem;
    font-weight: 800;
}

/* === Filter Bar & Empty States === */
.filter-bar {
    background: var(--card-bg);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    padding: 0.85rem 1rem;
    margin-bottom: 1rem;
    box-shadow: var(--shadow-sm);
}

.empty-state {
    text-align: center;
    padding: 3rem 1.5rem;
    color: var(--text-secondary);
}
.empty-state i { font-size: 3rem; color: var(--primary-light); margin-bottom: 0.75rem; display: block; }

/* === Badges & Action Buttons === */
.badge-estado {
    font-size: 0.7rem;
    padding: 0.35em 0.65em;
    border-radius: 999px;
    font-weight: 600;
}
.badge-activo, .badge-pagado, .badge-aprobado, .badge-entregado { background: rgba(38, 122, 77, 0.14); color: #1f6840; }
.badge-pendiente, .badge-pendiente_pago, .badge-revision, .badge-preparacion, .badge-por_empacar { background: rgba(207, 122, 31, 0.16); color: #9c580e; }
.badge-eliminacion, .badge-anulado, .badge-cancelado, .badge-baja { background: rgba(192, 57, 57, 0.15); color: #a52d2d; }
.badge-enviado, .badge-empacado, .badge-inactivo { background: rgba(52, 110, 184, 0.14); color: #24538d; }
.badge-en_vivo { background: #dc2626; color: #fff; }
.badge-finalizado { background: #262322; color: #e8c2c2; }
.badge-verificacion_pago { background: #ede9fe; color: #5b21b6; border: 1px solid #c4b5fd; }
.btn-esperando-confirmacion,
.btn-esperando-confirmacion:disabled,
.btn-esperando-confirmacion.disabled {
    background: #fef3c7 !important;
    color: #92400e !important;
    border: 1px solid #f59e0b !important;
    font-weight: 600;
    opacity: 0.95 !important;
}
.btn-esperando-confirmacion:hover { background: #fde68a !important; color: #78350f !important; }

.btn-action {
    width: 30px;
    height: 30px;
    padding: 0;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border-radius: 7px;
    font-size: 0.82rem;
}

/* === Account Tree === */
.account-tree { list-style: none; padding: 0; margin: 0; }
.tree-item {
    background: var(--card-bg);
    border: 1px solid var(--border-color);
    border-radius: 10px;
    margin-bottom: 0.55rem;
    overflow: hidden;
}
.tree-parent {
    padding: 0.78rem 1rem;
    display: flex;
    align-items: center;
    justify-content: space-between;
    cursor: pointer;
    gap: 0.5rem;
}
.tree-parent:hover { background: #faf7f6; }
.tree-children { list-style: none; padding: 0; margin: 0; border-top: 1px solid var(--border-color); background: #fcfbfa; }
.tree-child {
    padding: 0.62rem 1rem 0.62rem 2.2rem;
    display: flex;
    align-items: center;
    justify-content: space-between;
    border-bottom: 1px solid #f0ecea;
}
.tree-child:last-child { border-bottom: none; }

/* === Product Thumbnail & Live Rack Card === */
.product-thumb {
    width: 48px;
    height: 48px;
    border-radius: 8px;
    object-fit: cover;
    border: 1px solid var(--border-color);
    background: #f5f1ef;
}
.product-thumb-placeholder {
    width: 48px;
    height: 48px;
    border-radius: 8px;
    background: var(--accent-soft);
    color: var(--primary-dark);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: 1.2rem;
}

.rack-card {
    border: 1px solid var(--border-color);
    border-radius: 10px;
    padding: 0.65rem 0.85rem;
    background: #fff;
    transition: var(--transition);
    cursor: pointer;
}
.rack-card:hover { border-color: var(--primary-light); background: #fdf9f9; }
.rack-card.selected { border: 2px solid var(--primary); background: var(--accent-soft); }
.rack-card.agotado { opacity: 0.52; background: #f8f6f5; cursor: not-allowed; }
.rack-code {
    display: inline-block;
    background: var(--dark-bg);
    color: var(--accent);
    font-weight: 800;
    font-size: 0.85rem;
    padding: 0.2rem 0.55rem;
    border-radius: 6px;
}

/* === Overlays & FAB === */
.sidebar-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.5);
    z-index: 1035;
}
.sidebar-overlay.show { display: block; }

.loading-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(24, 22, 21, 0.45);
    z-index: 2000;
    align-items: center;
    justify-content: center;
}
.loading-overlay.show { display: flex; }
.spinner-custom {
    width: 44px;
    height: 44px;
    border: 4px solid rgba(255, 255, 255, 0.25);
    border-top-color: var(--accent);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

.fab {
    position: fixed;
    bottom: 1.35rem;
    right: 1.35rem;
    width: 54px;
    height: 54px;
    border-radius: 50%;
    background: linear-gradient(135deg, var(--primary-light), var(--primary));
    color: #fff;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.4rem;
    box-shadow: 0 6px 20px rgba(168, 100, 100, 0.45);
    z-index: 1030;
    text-decoration: none;
}
.fab:hover { color: #fff; transform: scale(1.05); }

/* === Print === */
.print-header { display: none; }
@media print {
    .sidebar, .top-header, .no-print, .fab, .sidebar-overlay { display: none !important; }
    .main-content { margin-left: 0 !important; }
    .page-content { padding: 0 !important; }
    .print-header {
        display: flex !important;
        align-items: center;
        gap: 1rem;
        border-bottom: 2px solid #262322;
        padding-bottom: 0.75rem;
        margin-bottom: 1rem;
    }
    .print-header img { width: 52px; height: 52px; border-radius: 8px; }
    .card { box-shadow: none !important; border: 1px solid #ccc !important; }
}

/* === Responsive === */
@media (max-width: 991.98px) {
    .sidebar { transform: translateX(-100%); }
    .sidebar.show { transform: translateX(0); }
    .main-content { margin-left: 0; }
    .btn-sidebar-toggle { display: inline-flex; }
    .page-content { padding: 1rem 0.9rem 4.5rem; }
    .top-header { padding: 0 1rem; }
    .stat-card .stat-value { font-size: 1.15rem; }
}
