/* ============================================
   SISTEMA DE GESTIÓN - ESTILO PRO CLEAN (Codestudio App)
   ============================================ */

/* Google Fonts */
@import url('https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600;700&family=Outfit:wght@300;400;500;600;700;800&display=swap');

/* ============================================
   VARIABLES CSS
   ============================================ */
:root {
    --color-fondo: #f8fafc;
    --color-sidebar: #ffffff;
    --color-tarjeta: #ffffff;
    --color-borde: #f1f5f9;
    --color-texto-p: #1e293b;
    --color-texto-s: #64748b;
    
    --primario: #6366f1;
    --primario-hover: #4f46e5;
    --primario-soft: rgba(99, 102, 241, 0.1);
    
    --exito: #10b981;
    --exito-soft: rgba(16, 185, 129, 0.1);
    
    --peligro: #ef4444;
    --peligro-soft: rgba(239, 68, 68, 0.1);
    
    --advertencia: #f59e0b;
    --advertencia-soft: rgba(245, 158, 11, 0.1);
    
    --info: #0ea5e9;
    --info-soft: rgba(14, 165, 233, 0.1);

    --shadow-sm: 0 1px 2px 0 rgb(0 0 0 / 0.05);
    --shadow-md: 0 4px 6px -1px rgb(0 0 0 / 0.1), 0 2px 4px -2px rgb(0 0 0 / 0.1);
    --radius-md: 12px;
    --radius-lg: 16px;
    --sidebar-width: 260px;
    --transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
}

/* ============================================
   RESET Y BASE
   ============================================ */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: 'Inter', sans-serif;
    background-color: var(--color-fondo);
    color: var(--color-texto-p);
    overflow-x: hidden;
    line-height: 1.5;
}

h1, h2, h3, h4, .font-pro {
    font-family: 'Outfit', sans-serif;
}

/* ============================================
   ESTRUCTURA (LAYOUT)
   ============================================ */
.app-container {
    display: flex;
    min-height: 100vh;
}

/* Sidebar */
.sidebar {
    width: var(--sidebar-width);
    background: var(--color-sidebar);
    border-right: 1px solid var(--color-borde);
    height: 100vh;
    position: fixed;
    left: 0;
    top: 0;
    z-index: 1000;
    padding: 24px 0;
    transition: var(--transition);
}

.logo-container {
    padding: 0 24px 32px;
    display: flex;
    align-items: center;
    gap: 12px;
}

.logo-icon {
    width: 40px;
    height: 40px;
    background: var(--primario);
    border-radius: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    font-size: 1.2rem;
}

.logo-text {
    font-family: 'Outfit', sans-serif;
    font-size: 1.5rem;
    font-weight: 800;
    color: var(--color-texto-p);
}

.sidebar-section {
    padding: 0 16px;
    margin-bottom: 24px;
}

.section-label {
    font-size: 0.75rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--color-texto-s);
    font-weight: 700;
    margin-bottom: 12px;
    padding-left: 12px;
}

.nav-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px 16px;
    color: var(--color-texto-s);
    text-decoration: none !important;
    font-size: 0.95rem;
    font-weight: 500;
    border-radius: 10px;
    transition: var(--transition);
    margin-bottom: 4px;
}

.nav-item i {
    width: 20px;
    font-size: 1.1rem;
    text-align: center;
}

.nav-item:hover {
    background: #f1f5f9;
    color: var(--color-texto-p);
}

.nav-item.activo {
    background: var(--primario-soft);
    color: var(--primario);
    font-weight: 600;
}

/* Main Content Area */
.main-content {
    flex: 1;
    margin-left: var(--sidebar-width);
    padding: 0;
    min-height: 100vh;
    transition: var(--transition);
}

.top-bar {
    background: #fff;
    height: 64px;
    border-bottom: 1px solid var(--color-borde);
    padding: 0 32px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    position: sticky;
    top: 0;
    z-index: 999;
}

.search-container {
    position: relative;
    max-width: 400px;
    width: 100%;
}

.search-container i {
    position: absolute;
    left: 14px;
    top: 50%;
    transform: translateY(-50%);
    color: var(--color-texto-s);
}

.search-input {
    width: 100%;
    padding: 8px 16px 8px 40px;
    border-radius: 8px;
    border: none;
    background: #f1f5f9;
    font-size: 0.9rem;
    transition: var(--transition);
}

.search-input:focus {
    background: #fff;
    box-shadow: 0 0 0 2px var(--primario-soft);
    outline: none;
}

.user-actions {
    display: flex;
    align-items: center;
    gap: 20px;
}

.notification-bell {
    position: relative;
    color: var(--color-texto-s);
    font-size: 1.2rem;
    cursor: pointer;
}

.notification-dot {
    position: absolute;
    top: 0;
    right: 0;
    width: 8px;
    height: 8px;
    background: var(--peligro);
    border: 2px solid #fff;
    border-radius: 50%;
}

.user-profile {
    display: flex;
    align-items: center;
    gap: 12px;
}

.avatar {
    width: 36px;
    height: 36px;
    background: #e2e8f0;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    color: var(--primario);
}

.user-info .name {
    font-weight: 700;
    font-size: 0.9rem;
    margin: 0;
    line-height: 1.2;
}

.user-info .role {
    font-size: 0.75rem;
    color: var(--color-texto-s);
    margin: 0;
}

/* ============================================
   COMPONENTES UI
   ============================================ */

/* Metric Cards (Dashboard) */
.stat-card {
    background: #fff;
    border-radius: var(--radius-md);
    border: 1px solid var(--color-borde);
    padding: 24px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    transition: var(--transition);
    height: 100%;
}

.stat-card:hover {
    box-shadow: var(--shadow-md);
    transform: translateY(-2px);
}

.stat-card.accent-green { border-left: 4px solid var(--exito); }
.stat-card.accent-blue { border-left: 4px solid var(--info); }
.stat-card.accent-purple { border-left: 4px solid var(--primario); }
.stat-card.accent-yellow { border-left: 4px solid var(--advertencia); }

.stat-content .label {
    font-size: 0.85rem;
    color: var(--color-texto-s);
    font-weight: 600;
    margin-bottom: 8px;
}

.stat-content .value {
    font-family: 'Outfit', sans-serif;
    font-size: 1.75rem;
    font-weight: 700;
    margin: 0;
}

.stat-icon {
    width: 48px;
    height: 48px;
    background: var(--color-fondo);
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.25rem;
}

/* Generic Cards */
.pro-card {
    background: #fff;
    border-radius: var(--radius-md);
    border: 1px solid var(--color-borde);
    padding: 24px;
    margin-bottom: 24px;
}

.card-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 20px;
    padding: 0;
    background: transparent;
    border: none;
}

.card-title {
    font-weight: 700;
    font-size: 1.1rem;
    margin: 0;
}

/* Tables & Lists */
.pro-table {
    width: 100%;
    border-collapse: separate;
    border-spacing: 0;
}

.pro-table th {
    padding: 12px 16px;
    font-size: 0.75rem;
    text-transform: uppercase;
    color: var(--color-texto-s);
    font-weight: 700;
    border-bottom: 1px solid var(--color-borde);
}

.pro-table td {
    padding: 16px;
    vertical-align: middle;
    border-bottom: 1px solid var(--color-borde);
    font-size: 0.9rem;
}

.pro-table tr:last-child td {
    border-bottom: none;
}

/* Row Cards (Product List) */
.product-row {
    background: #fff;
    border-radius: var(--radius-md);
    border: 1px solid var(--color-borde);
    padding: 12px 20px;
    margin-bottom: 12px;
    display: flex;
    align-items: center;
    transition: var(--transition);
}

.product-row:hover {
    box-shadow: var(--shadow-sm);
    border-color: var(--primario);
}

.product-icon {
    width: 44px;
    height: 44px;
    background: var(--primario-soft);
    border-radius: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--primario);
    font-size: 1.2rem;
    margin-right: 16px;
}

.product-info { flex: 1; }
.product-name { font-weight: 700; font-size: 1rem; margin-bottom: 2px; }
.product-meta { font-size: 0.8rem; color: var(--color-texto-s); }

/* Order Grid Cards */
.order-card {
    background: #fff;
    border-radius: var(--radius-md);
    border: 1px solid var(--color-borde);
    padding: 20px;
    position: relative;
    transition: var(--transition);
    border-left: 4px solid var(--primario);
}

.order-card:hover { border-color: var(--primario); }

.order-header {
    display: flex;
    justify-content: space-between;
    margin-bottom: 16px;
}

.order-number { font-weight: 800; color: var(--primario); font-size: 0.9rem; }
.order-date { font-size: 0.8rem; color: var(--color-texto-s); display: flex; align-items: center; gap: 6px; }

.order-client { font-weight: 700; font-size: 1.1rem; margin-bottom: 4px; }
.order-phone { font-size: 0.85rem; color: var(--color-texto-s); display: flex; align-items: center; gap: 6px; }

.order-footer {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-top: 16px;
    padding-top: 16px;
    border-top: 1px dashed var(--color-borde);
}

.order-total { font-size: 1.25rem; font-weight: 800; color: var(--color-texto-p); }

/* Buttons */
.btn-pro {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 10px 24px;
    border-radius: 50px; /* Pill style */
    font-weight: 600;
    font-size: 0.875rem;
    transition: var(--transition);
    border: none;
    cursor: pointer;
    text-decoration: none !important;
    white-space: nowrap;
}

/* Override Bootstrap py-2/py-3 on buttons */
.btn-pro.py-2 { padding-top: 10px !important; padding-bottom: 10px !important; }
.btn-pro.py-3 { padding-top: 10px !important; padding-bottom: 10px !important; }

/* Global Button Centering & Width Cap for Mobile */
@media (max-width: 767.98px) {
    .flex-column > .btn-pro,
    .flex-column > a.btn-pro,
    .d-grid > .btn-pro {
        max-width: 280px;
        width: 100%;
        margin-left: auto;
        margin-right: auto;
    }
}

.btn-pro-p { background: var(--primario); color: #fff; }
.btn-pro-p:hover { background: var(--primario-hover); box-shadow: 0 4px 12px rgba(99, 102, 241, 0.3); }

.btn-pro-s { background: #f1f5f9; color: var(--color-texto-p); }
.btn-pro-s:hover { background: #e2e8f0; }

.btn-pro-success { background: var(--exito); color: #fff; }
.btn-pro-danger { background: var(--peligro); color: #fff; }

/* Badges */
.badge-pro {
    padding: 4px 12px;
    border-radius: 8px;
    font-size: 0.75rem;
    font-weight: 700;
}

.badge-exito { background: var(--exito-soft); color: var(--exito); }
.badge-peligro { background: var(--peligro-soft); color: var(--peligro); }
.badge-advertencia { background: var(--advertencia-soft); color: var(--advertencia); }

/* Forms */
.form-pro-label {
    display: block;
    font-size: 0.85rem;
    font-weight: 700;
    color: var(--color-texto-p);
    margin-bottom: 8px;
}

.form-pro-input {
    width: 100%;
    padding: 10px 16px;
    border-radius: 10px;
    border: 1px solid var(--color-borde);
    background: #f8fafc;
    font-size: 0.95rem;
    transition: var(--transition);
}

.form-pro-input:focus {
    border-color: var(--primario);
    background: #fff;
    box-shadow: 0 0 0 3px var(--primario-soft);
    outline: none;
}

/* Stepper */
.stepper {
    display: flex;
    justify-content: center;
    gap: 40px;
    margin-bottom: 32px;
}

.step-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 8px;
    position: relative;
}

.step-circle {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    background: #e2e8f0;
    color: var(--color-texto-s);
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    font-size: 0.9rem;
    z-index: 2;
}

.step-item.active .step-circle { background: var(--primario); color: #fff; }
.step-item.complete .step-circle { background: var(--exito); color: #fff; }

.step-label { font-size: 0.8rem; font-weight: 600; color: var(--color-texto-s); }
.step-item.active .step-label { color: var(--primario); }

/* ============================================
   UTILITIES
   ============================================ */
.p-32 { padding: 32px; }
.mb-24 { margin-bottom: 24px; }
.grid-3 { display: grid; grid-template-columns: repeat(auto-fit, minmax(300px, 1fr)); gap: 24px; }
.grid-dashboard { display: grid; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); gap: 24px; }
.x-small { font-size: 0.8rem; }

/* ============================================
   RESPONSIVE - MOBILE FIRST PROFESSIONAL
   ============================================ */

/* === TABLET (992px and below) === */
@media (max-width: 991.98px) {
    .sidebar {
        transform: translateX(-100%);
        box-shadow: 4px 0 25px rgba(0,0,0,0.15);
    }
    .sidebar.show {
        transform: translateX(0);
    }
    .main-content {
        margin-left: 0;
    }
    .top-bar {
        padding: 0 16px;
    }
    .p-32 {
        padding: 16px;
    }
    
    /* Sidebar overlay backdrop */
    .sidebar-backdrop {
        position: fixed;
        top: 0; left: 0; right: 0; bottom: 0;
        background: rgba(0,0,0,0.4);
        z-index: 999;
        display: none;
    }
    .sidebar-backdrop.show {
        display: block;
    }
}

/* === MOBILE (768px and below) === */
@media (max-width: 767.98px) {
    /* Dashboard metrics */
    .stat-card {
        padding: 14px;
    }
    .stat-content .value {
        font-size: 1.3rem;
    }
    .stat-icon {
        width: 40px;
        height: 40px;
        font-size: 1rem;
    }
    .top-bar .name { display: none; }

    /* Cards & content */
    .pro-card {
        padding: 14px;
        border-radius: 10px;
        margin-bottom: 14px;
    }
    .card-header {
        flex-direction: column;
        align-items: flex-start;
        gap: 10px;
    }
    .card-title {
        font-size: 0.95rem;
    }

    /* Product rows */
    .product-row {
        padding: 10px 12px;
        margin-bottom: 8px;
        flex-wrap: wrap;
        gap: 8px;
    }
    .product-icon {
        width: 36px;
        height: 36px;
        margin-right: 10px;
        font-size: 1rem;
    }
    .product-name {
        font-size: 0.9rem;
    }
    .product-meta {
        font-size: 0.75rem;
    }

    /* BUTTONS - Clean app style */
    .btn-pro {
        padding: 10px 16px;
        font-size: 0.85rem;
        border-radius: 10px;
    }

    /* Full-width action buttons on mobile */
    .d-flex.flex-column.flex-md-row .btn-pro,
    .d-flex.flex-column.flex-sm-row .btn-pro {
        width: 100%;
    }

    /* Forms - bigger touch targets */
    .form-pro-input {
        padding: 10px 14px;
        font-size: 0.95rem;
    }
    .form-pro-label {
        font-size: 0.8rem;
    }
    select.form-pro-input {
        -webkit-appearance: menulist;
        appearance: menulist;
    }

    /* Tables - scroll & compact */
    .pro-table th {
        padding: 8px 10px;
        font-size: 0.7rem;
    }
    .pro-table td {
        padding: 10px;
        font-size: 0.8rem;
    }

    /* Page titles */
    h2.font-pro {
        font-size: 1.3rem;
    }

    /* Grid adjustments */
    .grid-dashboard {
        grid-template-columns: repeat(2, 1fr);
        gap: 10px;
    }

    /* Search */
    .search-container {
        max-width: 100%;
    }

    /* Hide on mobile helper */
    .ocultar-movil {
        display: none !important;
    }

    /* Order detail sidebar stacking */
    .col-lg-4 .pro-card {
        padding: 14px;
    }
}

/* === SMALL MOBILE (480px and below) === */
@media (max-width: 480px) {
    .p-32 {
        padding: 12px;
    }
    .top-bar {
        height: 54px;
        padding: 0 12px;
    }
    h2.font-pro {
        font-size: 1.15rem;
    }

    /* Stack everything */
    .stat-card {
        padding: 12px;
    }
    .stat-content .value {
        font-size: 1.1rem;
    }

    /* Buttons even bigger for small phones */
    .btn-pro {
        padding: 10px 14px;
        font-size: 0.82rem;
    }

    /* Product cards in POS */
    .row-cols-2 > .col {
        flex: 0 0 50%;
        max-width: 50%;
    }

    /* Grid single column */
    .grid-dashboard {
        grid-template-columns: 1fr 1fr;
        gap: 8px;
    }

    /* Badge compact */
    .badge-pro {
        padding: 3px 8px;
        font-size: 0.7rem;
    }

    /* Search full width */
    .search-container {
        width: 100% !important;
        max-width: 100% !important;
    }
}

/* ============================================
   UTILIDADES
   ============================================ */
.sin-datos {
    text-align: center;
    padding: 40px 20px;
    color: #999;
}

.sin-datos i {
    font-size: 3rem;
    display: block;
    margin-bottom: 12px;
    opacity: 0.5;
}

.sin-datos p {
    font-size: 0.95rem;
    font-weight: 500;
}

/* Botón toggle sidebar (móvil) */
.btn-toggle-sidebar {
    background: none;
    border: none;
    font-size: 1.3rem;
    color: #667eea;
    cursor: pointer;
    padding: 4px 8px;
    display: none;
}

@media (max-width: 991.98px) {
    .btn-toggle-sidebar {
        display: inline-block;
    }
}

/* Scrollbar personalizada */
::-webkit-scrollbar {
    width: 6px;
}

::-webkit-scrollbar-track {
    background: transparent;
}

::-webkit-scrollbar-thumb {
    background: rgba(102, 126, 234, 0.3);
    border-radius: 3px;
}

::-webkit-scrollbar-thumb:hover {
    background: rgba(102, 126, 234, 0.5);
}

/* Stepper Moderno */
.stepper-wrapper {
    display: flex;
    justify-content: space-between;
    align-items: center;
    position: relative;
    max-width: 600px;
    margin: 0 auto;
}

.stepper-item {
    position: relative;
    display: flex;
    flex-direction: column;
    align-items: center;
    flex: 1;
    z-index: 2;
}

.stepper-item::before {
    content: "";
    position: absolute;
    width: 100%;
    height: 2px;
    background: #e2e8f0;
    top: 20px;
    left: -50%;
    z-index: -1;
}

.stepper-item:first-child::before {
    content: none;
}

.step-counter {
    width: 40px;
    height: 40px;
    display: flex;
    justify-content: center;
    align-items: center;
    border-radius: 50%;
    background: #fff;
    border: 2px solid #e2e8f0;
    font-weight: 700;
    margin-bottom: 8px;
    transition: all 0.3s ease;
    color: var(--texto-secundario);
}

.step-name {
    font-size: 0.8rem;
    font-weight: 600;
    color: var(--texto-secundario);
    font-family: var(--fuente-pro);
}

.stepper-item.activo .step-counter {
    background: var(--primario);
    border-color: var(--primario);
    color: #fff;
    box-shadow: 0 4px 12px rgba(99, 102, 241, 0.3);
}

.stepper-item.activo .step-name {
    color: var(--primario);
    font-weight: 700;
}

.stepper-item.activo::before {
    background: var(--primario);
}
