/* Variables */
:root {
    --sidebar-width: 260px;
    --sidebar-collapsed: 70px;
    --topbar-height: 60px;
    --primary-color: #2563eb;
    --secondary-color: #f8fafc;
    --text-primary: #1e293b;
    --text-secondary: #64748b;
    --border-color: #e2e8f0;
    --success-color: #10b981;
    --warning-color: #f59e0b;
    --danger-color: #ef4444;
}

/* Reset & Base */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
    background-color: #f1f5f9;
    color: var(--text-primary);
    overflow-x: hidden;
}

/* Layout */
.wrapper {
    display: flex;
    min-height: 100vh;
}

/* Sidebar */
.sidebar {
    width: var(--sidebar-width);
    background: white;
    border-right: 1px solid var(--border-color);
    position: fixed;
    top: 0;
    left: 0;
    height: 100vh;
    z-index: 1000;
    display: flex;
    flex-direction: column;
    transition: all 0.3s ease;
}

.sidebar-header {
    padding: 1.25rem 1.5rem;
    border-bottom: 1px solid var(--border-color);
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.sidebar-header .logo {
    height: 32px;
}

.sidebar-header .brand-text {
    font-weight: 600;
    font-size: 1.1rem;
    color: var(--text-primary);
}

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

.sidebar-nav .nav-item {
    margin-bottom: 0.25rem;
}

.sidebar-nav .nav-link {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.75rem 1rem;
    color: var(--text-secondary);
    text-decoration: none;
    border-radius: 8px;
    font-size: 0.9rem;
    font-weight: 500;
    transition: all 0.2s ease;
}

.sidebar-nav .nav-link:hover {
    background: var(--secondary-color);
    color: var(--text-primary);
}

.sidebar-nav .nav-link.active {
    background: var(--primary-color);
    color: white;
}

.sidebar-nav .nav-link i {
    font-size: 1.1rem;
    width: 24px;
    text-align: center;
}

.sidebar-nav .badge {
    font-size: 0.7rem;
    padding: 0.25rem 0.5rem;
}

.sidebar-footer {
    padding: 1rem 1.5rem;
    border-top: 1px solid var(--border-color);
}

.user-info {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    color: var(--text-secondary);
    font-size: 0.9rem;
}

.user-info i {
    font-size: 1.5rem;
}

/* Main Content */
.main-content {
    flex: 1;
    margin-left: var(--sidebar-width);
    min-height: 100vh;
    transition: all 0.3s ease;
}

/* Top Navbar */
.top-navbar {
    height: var(--topbar-height);
    background: white;
    border-bottom: 1px solid var(--border-color);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 1.5rem;
    gap: 1rem;
    position: sticky;
    top: 0;
    z-index: 100;
}

.sidebar-toggle {
    display: none;
    font-size: 1.5rem;
    color: var(--text-secondary);
}

/* Navbar Info */
.navbar-info {
    display: flex;
    align-items: center;
    gap: 1.5rem;
}

.datetime-info {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-size: 0.8rem;
    color: var(--text-secondary);
    white-space: nowrap;
}

.datetime-info .separator {
    color: var(--border-color);
    margin: 0 0.25rem;
}

.datetime-info i {
    font-size: 0.75rem;
    opacity: 0.7;
}

.model-info {
    display: flex;
    align-items: center;
    gap: 0.4rem;
    font-size: 0.8rem;
    color: var(--text-secondary);
    padding-left: 1rem;
    border-left: 1px solid var(--border-color);
    white-space: nowrap;
}

.model-info i {
    color: var(--primary-color);
    font-size: 0.85rem;
}

.model-info strong {
    color: var(--primary-color);
}

.search-box {
    flex: 1;
    max-width: 400px;
    min-width: 200px;
    position: relative;
    margin: 0 1rem;
}

.search-box i {
    position: absolute;
    left: 1rem;
    top: 50%;
    transform: translateY(-50%);
    color: var(--text-secondary);
}

.search-box input {
    width: 100%;
    padding: 0.5rem 1rem 0.5rem 2.5rem;
    border: 1px solid var(--border-color);
    border-radius: 8px;
    font-size: 0.9rem;
    background: var(--secondary-color);
    transition: all 0.2s ease;
}

.search-box input:focus {
    outline: none;
    border-color: var(--primary-color);
    background: white;
}

.navbar-actions {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.btn-icon {
    width: 40px;
    height: 40px;
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--text-secondary);
    position: relative;
}

.btn-icon:hover {
    background: var(--secondary-color);
    color: var(--text-primary);
}

.notification-dot {
    position: absolute;
    top: 8px;
    right: 8px;
    width: 8px;
    height: 8px;
    background: var(--danger-color);
    border-radius: 50%;
}

/* User Dropdown */
.user-dropdown {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.5rem 0.75rem;
    border: 1px solid var(--border-color);
    border-radius: 8px;
    background: white;
    color: var(--text-primary);
    font-size: 0.85rem;
    transition: all 0.2s ease;
}

.user-dropdown:hover {
    border-color: var(--primary-color);
    background: var(--secondary-color);
}

.user-avatar {
    width: 28px;
    height: 28px;
    border-radius: 50%;
    background: var(--primary-color);
    color: white;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.85rem;
}

.user-email {
    max-width: 150px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.user-dropdown .bi-chevron-down {
    font-size: 0.7rem;
    color: var(--text-secondary);
}

.dropdown-menu {
    border: 1px solid var(--border-color);
    border-radius: 8px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
    padding: 0.5rem;
}

.dropdown-item {
    border-radius: 6px;
    padding: 0.5rem 1rem;
    font-size: 0.9rem;
}

.dropdown-item:hover {
    background: var(--secondary-color);
}

/* Page Content */
.page-content {
    padding: 1.5rem;
}

.page {
    display: none;
}

.page.active {
    display: block;
    animation: fadeIn 0.3s ease;
}

@keyframes fadeIn {
    from { opacity: 0; transform: translateY(10px); }
    to { opacity: 1; transform: translateY(0); }
}

.page-header {
    margin-bottom: 1.5rem;
}

.page-header h1 {
    font-size: 1.75rem;
    font-weight: 600;
    margin-bottom: 0.25rem;
}

/* Stat Cards */
.stat-card {
    background: white;
    border-radius: 12px;
    padding: 1.25rem;
    display: flex;
    align-items: center;
    gap: 1rem;
    border: 1px solid var(--border-color);
    transition: all 0.2s ease;
}

.stat-card:hover {
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.08);
    transform: translateY(-2px);
}

.stat-icon {
    width: 48px;
    height: 48px;
    border-radius: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.25rem;
}

.stat-info {
    display: flex;
    flex-direction: column;
}

.stat-value {
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--text-primary);
}

.stat-label {
    font-size: 0.85rem;
    color: var(--text-secondary);
}

/* Cards */
.card {
    border: 1px solid var(--border-color);
    border-radius: 12px;
    box-shadow: none;
}

.card-header {
    background: white;
    border-bottom: 1px solid var(--border-color);
    padding: 1rem 1.25rem;
}

.card-title {
    font-weight: 600;
    color: var(--text-primary);
}

/* Tables */
.table {
    margin-bottom: 0;
}

.table th {
    font-weight: 600;
    font-size: 0.7rem;
    text-transform: uppercase;
    color: var(--text-secondary);
    border-bottom: 2px solid var(--border-color);
    padding: 0.75rem 0.5rem;
    white-space: nowrap;
    background: var(--secondary-color);
    position: sticky;
    top: 0;
}

.table td {
    padding: 0.6rem 0.5rem;
    vertical-align: middle;
    border-bottom: 1px solid var(--border-color);
    font-size: 0.85rem;
}

.table-sm th,
.table-sm td {
    padding: 0.5rem 0.4rem;
}

#inventoryTableFull {
    font-size: 0.8rem;
}

#inventoryTableFull th {
    font-size: 0.65rem;
}

#inventoryTableFull td {
    padding: 0.4rem 0.35rem;
}

/* Upload Zone */
.upload-zone {
    border: 2px dashed var(--border-color);
    border-radius: 12px;
    padding: 3rem 2rem;
    text-align: center;
    background: var(--secondary-color);
    cursor: pointer;
    transition: all 0.2s ease;
}

.upload-zone:hover,
.upload-zone.dragover {
    border-color: var(--primary-color);
    background: rgba(37, 99, 235, 0.05);
}

.upload-zone i {
    font-size: 3rem;
    color: var(--primary-color);
    margin-bottom: 1rem;
    display: block;
}

.upload-zone h5 {
    margin-bottom: 0.5rem;
}

/* Preview Zone */
.preview-zone {
    position: relative;
    border-radius: 12px;
    overflow: hidden;
}

.preview-zone img {
    width: 100%;
    height: auto;
    display: block;
}

.remove-preview {
    position: absolute;
    top: 0.5rem;
    right: 0.5rem;
}

/* Parts List */
.parts-list {
    max-height: 400px;
    overflow-y: auto;
}

.part-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0.75rem 1rem;
    background: var(--secondary-color);
    border-radius: 8px;
    margin-bottom: 0.5rem;
}

.part-item:last-child {
    margin-bottom: 0;
}

.part-info {
    flex: 1;
}

.part-name {
    font-weight: 500;
    margin-bottom: 0.25rem;
}

.part-meta {
    font-size: 0.8rem;
    color: var(--text-secondary);
}

.part-price {
    font-weight: 600;
    color: var(--success-color);
    font-size: 1rem;
}

/* Status Badges */
.badge-condition {
    font-size: 0.7rem;
    padding: 0.25rem 0.5rem;
    border-radius: 4px;
    text-transform: uppercase;
    font-weight: 600;
}

.badge-excellent { background: #d1fae5; color: #065f46; }
.badge-good { background: #dbeafe; color: #1e40af; }
.badge-fair { background: #fef3c7; color: #92400e; }
.badge-poor { background: #fee2e2; color: #991b1b; }
.badge-damaged { background: #7f1d1d; color: #fef2f2; }

/* Category Sections */
.category-section {
    border: 1px solid var(--border-color);
    border-radius: 8px;
    overflow: hidden;
    background: white;
}

.category-header {
    cursor: pointer;
    transition: background-color 0.2s ease;
}

.category-parts {
    max-height: 500px;
    overflow-y: auto;
}

.category-parts .part-item {
    padding: 10px 12px;
    border-bottom: 1px solid #f0f0f0;
    margin: 0;
    border-radius: 0;
    transition: background-color 0.15s ease;
}

.category-parts .part-item:last-child {
    border-bottom: none;
}

.category-parts .part-item:hover {
    background-color: #f8f9fa;
}

/* Usability Summary */
.usability-summary {
    animation: fadeInUp 0.5s ease;
}

@keyframes fadeInUp {
    from {
        opacity: 0;
        transform: translateY(10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* Order Card */
.order-card {
    background: white;
    border: 1px solid var(--border-color);
    border-radius: 12px;
    overflow: hidden;
    transition: all 0.2s ease;
}

.order-card:hover {
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.08);
}

.order-card-header {
    padding: 1rem 1.25rem;
    border-bottom: 1px solid var(--border-color);
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.order-card-body {
    padding: 1rem 1.25rem;
}

.order-card-footer {
    padding: 1rem 1.25rem;
    border-top: 1px solid var(--border-color);
    background: var(--secondary-color);
}

.order-vehicle {
    display: flex;
    align-items: center;
    gap: 1rem;
    margin-bottom: 1rem;
}

.order-vehicle img {
    width: 80px;
    height: 60px;
    object-fit: cover;
    border-radius: 8px;
}

/* Parts Verification */
.parts-verification-list {
    max-height: 500px;
    overflow-y: auto;
}

.verification-item {
    display: flex;
    align-items: center;
    gap: 1rem;
    padding: 1rem;
    background: var(--secondary-color);
    border-radius: 8px;
    margin-bottom: 0.5rem;
    transition: all 0.2s ease;
}

.verification-item:hover {
    background: #e9ecef;
}

.verification-item.manual-part {
    background: rgba(13, 202, 240, 0.1);
    border-left: 3px solid #0dcaf0;
}

.verification-item .form-check {
    flex-shrink: 0;
}

.verification-item .part-details {
    flex: 1;
}

.verification-item .price-input {
    width: 100px;
}

/* Formulario añadir pieza manual */
.add-part-manual {
    background: linear-gradient(135deg, #f8f9fa 0%, #e9ecef 100%);
    padding: 15px;
    border-radius: 12px;
    border: 2px dashed var(--border-color);
}

.add-part-manual:hover {
    border-color: var(--primary-color);
}

.verification-summary {
    border: 1px solid var(--border-color);
}

/* Asegurar visibilidad del alert de vehículo */
#vehicleInfoAlert {
    display: block !important;
}

h5#modalVehicleName {
    display: none;
}

/* Chat Styles */
.chat-list-card {
    height: 600px;
    display: flex;
    flex-direction: column;
}

.chat-list {
    flex: 1;
    overflow-y: auto;
}

.chat-item {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 1rem;
    border-bottom: 1px solid var(--border-color);
    cursor: pointer;
    transition: background 0.2s ease;
}

.chat-item:hover,
.chat-item.active {
    background: var(--secondary-color);
}

.chat-avatar {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background: var(--primary-color);
    color: white;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 600;
    font-size: 0.85rem;
    flex-shrink: 0;
}

.chat-info {
    flex: 1;
    min-width: 0;
}

.chat-name {
    font-weight: 500;
    display: block;
}

.chat-preview {
    font-size: 0.85rem;
    color: var(--text-secondary);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    display: block;
}

.chat-time {
    font-size: 0.75rem;
    color: var(--text-secondary);
}

.chat-window-card {
    height: 600px;
    display: flex;
    flex-direction: column;
}

.chat-messages-area {
    flex: 1;
    overflow-y: auto;
    padding: 1rem;
    background: var(--secondary-color);
}

.chat-message {
    max-width: 70%;
    padding: 0.75rem 1rem;
    border-radius: 12px;
    margin-bottom: 0.75rem;
}

.chat-message.received {
    background: white;
    margin-right: auto;
}

.chat-message.sent {
    background: var(--primary-color);
    color: white;
    margin-left: auto;
}

.chat-message p {
    margin-bottom: 0.25rem;
}

.chat-message .chat-time {
    font-size: 0.7rem;
    opacity: 0.7;
}

/* Chart Placeholder */
.chart-placeholder {
    height: 300px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    background: var(--secondary-color);
    border-radius: 8px;
    color: var(--text-secondary);
}

.chart-placeholder i {
    font-size: 3rem;
    margin-bottom: 1rem;
    opacity: 0.5;
}

/* Demand List */
.demand-list,
.top-list {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
}

.demand-item,
.top-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0.75rem 1rem;
    background: var(--secondary-color);
    border-radius: 8px;
}

/* Responsive */
@media (max-width: 991px) {
    .sidebar {
        transform: translateX(-100%);
    }

    .sidebar.show {
        transform: translateX(0);
    }

    .main-content {
        margin-left: 0;
    }

    .sidebar-toggle {
        display: block;
    }
}

@media (max-width: 768px) {
    .page-content {
        padding: 1rem;
    }

    .stat-card {
        padding: 1rem;
    }

    .stat-value {
        font-size: 1.25rem;
    }
}

/* Client Avatar */
.client-avatar {
    width: 36px;
    height: 36px;
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1rem;
    flex-shrink: 0;
}

/* Utilities */
.text-success { color: var(--success-color) !important; }
.text-warning { color: var(--warning-color) !important; }
.text-danger { color: var(--danger-color) !important; }

/* Loading Overlay */
.loading-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(255, 255, 255, 0.9);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 9999;
}

/* ==================== PREDICCIÓN DE DEMANDA ==================== */

.prediction-kpi {
    transition: all 0.3s ease;
    border: none;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.05);
}

.prediction-kpi:hover {
    transform: translateY(-3px);
    box-shadow: 0 8px 20px rgba(0, 0, 0, 0.1);
}

.prediction-kpi .kpi-icon {
    width: 50px;
    height: 50px;
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.4rem;
    margin: 0 auto 10px;
}

.prediction-kpi h3 {
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--text-primary);
}

.prediction-kpi .kpi-trend {
    font-size: 0.75rem;
    font-weight: 600;
    margin-top: 5px;
}

/* Gráfico de barras CSS */
.chart-container {
    padding: 20px 0;
}

.chart-bars {
    display: flex;
    justify-content: space-around;
    align-items: stretch;
    height: 220px;
    padding: 20px 10px 0 10px;
    background: linear-gradient(180deg, transparent 0%, rgba(0, 0, 0, 0.02) 100%);
    border-radius: 8px;
    position: relative;
    border: 1px solid #e9ecef;
}

.chart-bars::before {
    content: '';
    position: absolute;
    left: 10px;
    right: 10px;
    top: 25%;
    border-top: 1px dashed #dee2e6;
    z-index: 0;
}

.chart-bars::after {
    content: '';
    position: absolute;
    left: 10px;
    right: 10px;
    top: 55%;
    border-top: 1px dashed #dee2e6;
    z-index: 0;
}

.chart-bar-group {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: flex-end;
    gap: 0;
    flex: 1;
    height: 100%;
    position: relative;
}

.chart-bar-group .bars-container {
    display: flex;
    flex-direction: row;
    align-items: flex-end;
    justify-content: center;
    gap: 3px;
    flex: 1;
    width: 100%;
}

.chart-bar-group .chart-bar {
    width: 16px;
    border-radius: 3px 3px 0 0;
    transition: all 0.3s ease;
    position: relative;
    cursor: pointer;
    z-index: 1;
}

.chart-bar-group .chart-bar.actual {
    background: linear-gradient(180deg, #2563eb, #1d4ed8);
    box-shadow: 0 2px 4px rgba(37, 99, 235, 0.3);
}

.chart-bar-group .chart-bar.predicted {
    background: linear-gradient(180deg, #10b981, #059669);
    box-shadow: 0 2px 4px rgba(16, 185, 129, 0.3);
}

.chart-bar-group.future .chart-bar.predicted {
    background: linear-gradient(180deg, #10b981, #34d399);
    opacity: 0.7;
}

.chart-bar-group .chart-label {
    padding: 5px 0;
    font-size: 0.75rem;
    color: var(--text-secondary);
    font-weight: 500;
}

.chart-bar:hover {
    transform: scaleY(1.05);
    filter: brightness(1.1);
}

.chart-bar:hover::after {
    content: attr(data-value);
    position: absolute;
    top: -25px;
    left: 50%;
    transform: translateX(-50%);
    background: #333;
    color: white;
    padding: 2px 6px;
    border-radius: 4px;
    font-size: 0.7rem;
    white-space: nowrap;
}

.chart-label {
    font-size: 0.75rem;
    color: var(--text-secondary);
    font-weight: 500;
}

.chart-legend {
    display: flex;
    justify-content: center;
    gap: 20px;
    margin-top: 15px;
    font-size: 0.85rem;
}

.legend-dot {
    display: inline-block;
    width: 12px;
    height: 12px;
    border-radius: 3px;
    margin-right: 5px;
    vertical-align: middle;
}

.legend-dot.actual {
    background: #2563eb;
}

.legend-dot.predicted {
    background: #10b981;
}

/* Ranking de demanda */
.demand-ranking {
    padding: 10px;
}

.demand-rank-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px;
    border-bottom: 1px solid #f0f0f0;
    transition: background 0.2s;
}

.demand-rank-item:hover {
    background: #f9f9f9;
}

.demand-rank-item:last-child {
    border-bottom: none;
}

.rank-position {
    width: 28px;
    height: 28px;
    border-radius: 50%;
    background: #e9ecef;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    font-size: 0.8rem;
    color: #666;
}

.rank-position.gold {
    background: linear-gradient(135deg, #ffd700, #ffb700);
    color: white;
}

.rank-position.silver {
    background: linear-gradient(135deg, #c0c0c0, #a8a8a8);
    color: white;
}

.rank-position.bronze {
    background: linear-gradient(135deg, #cd7f32, #b87333);
    color: white;
}

.rank-info {
    flex: 1;
}

.rank-info strong {
    display: block;
    font-size: 0.85rem;
    margin-bottom: 4px;
}

.rank-bar {
    height: 6px;
    background: #e9ecef;
    border-radius: 3px;
    overflow: hidden;
}

.rank-fill {
    height: 100%;
    background: linear-gradient(90deg, #2563eb, #10b981);
    border-radius: 3px;
    transition: width 0.5s ease;
}

.rank-demand {
    font-weight: 700;
    font-size: 0.85rem;
    color: #10b981;
}

/* Predicción por categoría */
.category-prediction {
    display: flex;
    flex-direction: column;
    gap: 15px;
}

.category-pred-item {
    padding: 10px 0;
    border-bottom: 1px solid #f0f0f0;
}

.category-pred-item:last-child {
    border-bottom: none;
}

.cat-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 6px;
}

.cat-name {
    font-weight: 600;
    font-size: 0.9rem;
}

.cat-trend {
    font-weight: 700;
    font-size: 0.8rem;
}

.cat-bar {
    height: 8px;
    background: #e9ecef;
    border-radius: 4px;
    overflow: hidden;
    margin-bottom: 4px;
}

.cat-fill {
    height: 100%;
    border-radius: 4px;
    transition: width 0.5s ease;
}

/* Recomendaciones IA */
.ai-recommendations {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.ai-rec-item {
    display: flex;
    gap: 12px;
    padding: 12px;
    border-radius: 8px;
    font-size: 0.85rem;
}

.ai-rec-item i {
    font-size: 1.2rem;
    margin-top: 2px;
}

.ai-rec-item strong {
    display: block;
    margin-bottom: 4px;
}

.ai-rec-item p {
    margin: 0;
    color: #666;
    font-size: 0.8rem;
    line-height: 1.4;
}

.ai-rec-item.success {
    background: rgba(16, 185, 129, 0.1);
    border-left: 3px solid #10b981;
}

.ai-rec-item.success i {
    color: #10b981;
}

.ai-rec-item.warning {
    background: rgba(245, 158, 11, 0.1);
    border-left: 3px solid #f59e0b;
}

.ai-rec-item.warning i {
    color: #f59e0b;
}

.ai-rec-item.info {
    background: rgba(37, 99, 235, 0.1);
    border-left: 3px solid #2563eb;
}

.ai-rec-item.info i {
    color: #2563eb;
}

.ai-rec-item.danger {
    background: rgba(239, 68, 68, 0.1);
    border-left: 3px solid #ef4444;
}

.ai-rec-item.danger i {
    color: #ef4444;
}

/* Demanda por marca */
.brand-demand-grid {
    display: flex;
    gap: 15px;
    flex-wrap: wrap;
    justify-content: center;
}

.brand-demand-card {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 8px;
    padding: 15px 20px;
    background: #f8f9fa;
    border-radius: 12px;
    transition: all 0.3s ease;
    min-width: 100px;
    border: 2px solid transparent;
}

.brand-demand-card:hover {
    background: white;
    border-color: var(--primary-color);
    transform: translateY(-3px);
    box-shadow: 0 5px 15px rgba(0, 0, 0, 0.1);
}

.brand-logo {
    width: 50px;
    height: 50px;
    border-radius: 50%;
    background: linear-gradient(135deg, #333, #666);
    color: white;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 800;
    font-size: 0.7rem;
}

.brand-info {
    text-align: center;
}

.brand-info strong {
    display: block;
    font-size: 0.85rem;
}

.brand-share {
    font-size: 0.75rem;
    color: var(--text-secondary);
}

.brand-trend {
    font-weight: 700;
    font-size: 0.85rem;
}

/* ==================== ANALÍTICA AVANZADA ==================== */

.analytics-kpi {
    border: none;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.04);
    transition: all 0.3s ease;
}

.analytics-kpi:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.08);
}

.kpi-badge {
    font-size: 0.7rem;
    font-weight: 600;
    padding: 0.25rem 0.5rem;
    border-radius: 6px;
}

.kpi-sparkline {
    height: 30px;
    background: linear-gradient(90deg, transparent 0%, rgba(16, 185, 129, 0.1) 50%, rgba(16, 185, 129, 0.2) 100%);
    border-radius: 4px;
    position: relative;
    overflow: hidden;
}

.kpi-sparkline::after {
    content: '';
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    height: 2px;
    background: linear-gradient(90deg, #10b981 0%, #10b981 100%);
}

.kpi-sparkline.green { background: linear-gradient(90deg, transparent, rgba(16, 185, 129, 0.15)); }
.kpi-sparkline.green::after { background: #10b981; }
.kpi-sparkline.red { background: linear-gradient(90deg, transparent, rgba(239, 68, 68, 0.15)); }
.kpi-sparkline.red::after { background: #ef4444; }
.kpi-sparkline.yellow { background: linear-gradient(90deg, transparent, rgba(245, 158, 11, 0.15)); }
.kpi-sparkline.yellow::after { background: #f59e0b; }

/* Gráfico de Ventas */
.sales-chart {
    display: flex;
    gap: 10px;
    height: 220px;
}

.chart-y-axis {
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    font-size: 0.7rem;
    color: var(--text-secondary);
    padding: 5px 0;
    min-width: 35px;
    text-align: right;
}

.chart-area {
    flex: 1;
    display: flex;
    flex-direction: column;
}

.line-chart {
    flex: 1;
    width: 100%;
}

.chart-x-labels {
    display: flex;
    justify-content: space-between;
    font-size: 0.7rem;
    color: var(--text-secondary);
    padding-top: 8px;
}

.chart-summary {
    display: flex;
    gap: 20px;
    padding-top: 10px;
    border-top: 1px solid var(--border-color);
}

.summary-item {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 0.85rem;
}

.summary-dot {
    width: 10px;
    height: 10px;
    border-radius: 50%;
}

/* Gráfico Donut */
.donut-chart-container {
    display: flex;
    justify-content: center;
    margin-bottom: 20px;
}

.donut-chart {
    position: relative;
    width: 160px;
    height: 160px;
}

.donut-svg {
    transform: rotate(-90deg);
}

.donut-center {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    text-align: center;
}

.donut-center strong {
    display: block;
    font-size: 1.25rem;
}

.donut-center small {
    color: var(--text-secondary);
}

.category-legend {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.legend-item {
    display: flex;
    align-items: center;
    gap: 10px;
    font-size: 0.85rem;
}

.legend-color {
    width: 12px;
    height: 12px;
    border-radius: 3px;
    flex-shrink: 0;
}

.legend-item span:nth-child(2) {
    flex: 1;
}

.legend-item strong {
    min-width: 40px;
    text-align: right;
}

.legend-item .text-muted {
    min-width: 70px;
    text-align: right;
}

/* Segmentos de Clientes */
.client-segments {
    display: flex;
    flex-direction: column;
    gap: 15px;
}

.segment-item {
    padding: 10px 0;
}

.segment-header {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 8px;
}

.segment-icon {
    width: 36px;
    height: 36px;
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1rem;
}

.segment-info {
    flex: 1;
}

.segment-info strong {
    display: block;
    font-size: 0.9rem;
}

.segment-info small {
    font-size: 0.75rem;
}

.segment-stats {
    text-align: right;
}

.segment-count {
    display: block;
    font-weight: 700;
    font-size: 1.1rem;
}

.segment-revenue {
    font-size: 0.8rem;
    color: var(--text-secondary);
}

.segment-bar {
    height: 6px;
    background: #e9ecef;
    border-radius: 3px;
    overflow: hidden;
}

.segment-fill {
    height: 100%;
    border-radius: 3px;
    transition: width 0.5s ease;
}

/* Métricas de Cliente */
.client-metrics {
    display: flex;
    justify-content: space-around;
    text-align: center;
}

.metric-item {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.metric-label {
    font-size: 0.75rem;
    color: var(--text-secondary);
}

.metric-value {
    font-size: 1.25rem;
    font-weight: 700;
}

/* Top Productos */
.top-products-list,
.top-clients-list {
    display: flex;
    flex-direction: column;
}

.top-product-item,
.top-client-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 15px;
    border-bottom: 1px solid var(--border-color);
    transition: background 0.2s;
}

.top-product-item:hover,
.top-client-item:hover {
    background: var(--secondary-color);
}

.top-product-item:last-child,
.top-client-item:last-child {
    border-bottom: none;
}

.product-rank {
    width: 28px;
    height: 28px;
    border-radius: 50%;
    background: #e9ecef;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    font-size: 0.8rem;
    color: #666;
}

.product-rank.gold { background: linear-gradient(135deg, #ffd700, #ffb700); color: white; }
.product-rank.silver { background: linear-gradient(135deg, #c0c0c0, #a8a8a8); color: white; }
.product-rank.bronze { background: linear-gradient(135deg, #cd7f32, #b87333); color: white; }

.product-info,
.client-info {
    flex: 1;
    min-width: 0;
}

.product-info strong,
.client-info strong {
    display: block;
    font-size: 0.85rem;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.product-info small,
.client-info small {
    font-size: 0.75rem;
}

.product-revenue,
.client-revenue {
    font-weight: 700;
    color: var(--success-color);
    font-size: 0.9rem;
    white-space: nowrap;
}

.client-avatar-sm {
    width: 36px;
    height: 36px;
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1rem;
    flex-shrink: 0;
}

/* Métricas de Rendimiento */
.performance-metrics {
    display: flex;
    flex-direction: column;
    gap: 18px;
}

.perf-metric {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.perf-header {
    display: flex;
    justify-content: space-between;
    font-size: 0.85rem;
}

.perf-bar {
    height: 8px;
    background: #e9ecef;
    border-radius: 4px;
    overflow: hidden;
}

.perf-fill {
    height: 100%;
    border-radius: 4px;
    transition: width 0.5s ease;
}

/* Comparativa Año vs Año */
.comparison-grid {
    display: grid;
    grid-template-columns: repeat(6, 1fr);
    gap: 20px;
}

.comparison-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    text-align: center;
    padding: 15px;
    background: var(--secondary-color);
    border-radius: 12px;
    transition: all 0.3s ease;
}

.comparison-item:hover {
    transform: translateY(-3px);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.08);
}

.comp-icon {
    width: 48px;
    height: 48px;
    border-radius: 50%;
    background: white;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.25rem;
    color: var(--primary-color);
    margin-bottom: 10px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.08);
}

.comp-data {
    margin-bottom: 8px;
}

.comp-label {
    font-size: 0.75rem;
    color: var(--text-secondary);
    display: block;
    margin-bottom: 4px;
}

.comp-values {
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.comp-current {
    font-size: 1.1rem;
    font-weight: 700;
    color: var(--text-primary);
}

.comp-previous {
    font-size: 0.8rem;
    color: var(--text-secondary);
    text-decoration: line-through;
}

.comp-change {
    font-weight: 700;
    font-size: 0.85rem;
    padding: 4px 10px;
    border-radius: 20px;
}

.comp-change.positive {
    background: rgba(16, 185, 129, 0.15);
    color: #10b981;
}

.comp-change.negative {
    background: rgba(239, 68, 68, 0.15);
    color: #ef4444;
}

@media (max-width: 1200px) {
    .comparison-grid {
        grid-template-columns: repeat(3, 1fr);
    }
}

@media (max-width: 768px) {
    .comparison-grid {
        grid-template-columns: repeat(2, 1fr);
    }
}
