/* Estilos comunes para toda la aplicación */
/* Ahora coordinado con styles.css para un tema coherente */

/* Colores principales - sincronizados con styles.css */
:root {
    --primary-color: #0891B2;
    --secondary-color: #2196F3;
    --warning-color: #FFC107;
    --danger-color: #F44336;
    --success-color: #4CAF50;
    --info-color: #2196F3;
    --light-color: #f8f9fa;
    --dark-color: #343a40;
    --muted-text: #6b7280;
    --card-shadow: 0 6px 18px rgba(11, 15, 30, 0.06);
    --card-border: #e6e9ef;
}

/* Tipografía */
body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
    font-size: 14px;
    line-height: 1.5;
    color: var(--app-text-color);
}

/* Layout */
.main-content {
    padding: 20px;
    background-color: var(--app-bg);
    color: var(--app-text-color);
}

.sidebar {
    background-color: var(--app-sidebar-bg);
    min-height: 100vh;
}

/* Cards */
.card {
    border-radius: 10px;
    box-shadow: var(--card-shadow);
    border: 1px solid var(--app-border-color);
    margin-bottom: 20px;
    background-color: var(--app-card-bg);
    color: var(--app-text-color);
}

.card-header {
    background-color: var(--app-card-bg);
    border-bottom: 1px solid var(--app-border-color);
    padding: 14px 18px;
    color: var(--app-text-color);
}

/* Tablas */
.table {
    margin-bottom: 0;
    color: var(--app-text-color);
}

.table th {
    border-top: none;
    font-weight: 600;
    background-color: color-mix(in srgb, var(--app-card-bg) 85%, var(--app-accent-color) 15%);
    color: var(--app-text-color);
    border-color: var(--app-border-color);
}

.table td {
    border-color: var(--app-border-color);
    color: var(--app-text-color);
}

/* Formularios */
.form-control {
    border-radius: 6px;
    border: 1px solid var(--app-border-color);
    background-color: var(--app-card-bg);
    color: var(--app-text-color);
}

.form-control:focus {
    border-color: var(--app-accent-color);
    background-color: var(--app-card-bg);
    color: var(--app-text-color);
    box-shadow: 0 0 0 0.2rem color-mix(in srgb, var(--app-accent-color) 20%, transparent);
}

/* Botones */
.btn {
    border-radius: 8px;
    font-weight: 600;
    padding: 8px 14px;
    transition: all 0.2s ease;
}

.btn-primary {
    background-color: var(--app-primary-color);
    border-color: var(--app-primary-color);
    box-shadow: 0 4px 14px rgba(8, 145, 178, 0.15);
}

.btn-secondary {
    background-color: var(--secondary-color);
    border-color: var(--secondary-color);
}

/* Alertas y notificaciones */
.alert {
    border-radius: 4px;
    border: none;
    padding: 12px 20px;
    background-color: var(--app-card-bg);
    color: var(--app-text-color);
    border-left: 4px solid var(--app-accent-color);
}

/* Badges */
.badge {
    font-weight: 500;
    padding: 5px 10px;
    border-radius: 4px;
}

/* Iconos */
.feather {
    width: 18px;
    height: 18px;
    vertical-align: text-bottom;
    color: var(--app-text-color);
}

body.dark-mode .feather {
    color: var(--app-text-color);
}

/* Navegación */
.nav-link {
    color: var(--app-text-color);
    padding: 8px 16px;
    transition: color 0.2s ease;
}

.nav-link:hover {
    color: var(--app-primary-color);
}

body.dark-mode .nav-link {
    color: var(--app-text-color);
}

body.dark-mode .nav-link:hover {
    color: var(--app-accent-color);
}

/* Modales */
.modal-content {
    border-radius: 8px;
    border: 1px solid var(--app-border-color);
    background-color: var(--app-card-bg);
    color: var(--app-text-color);
}

.modal-header {
    border-bottom: 1px solid var(--app-border-color);
    padding: 15px 20px;
    background-color: var(--app-card-bg);
    color: var(--app-text-color);
}

.modal-footer {
    border-top: 1px solid var(--app-border-color);
    padding: 15px 20px;
    background-color: var(--app-card-bg);
}

/* Stronger borders for light mode to improve contrast against white background */
body:not(.dark-mode) {
    --app-border: #d0d0d0;
    --app-border-2: #c0c0c0;
}

body:not(.dark-mode) .card {
    border: 1px solid var(--app-border);
}

body:not(.dark-mode) .card-header {
    border-bottom-color: var(--app-border-2);
}

body:not(.dark-mode) .table,
body:not(.dark-mode) .table th,
body:not(.dark-mode) .table td {
    border-color: var(--app-border-2) !important;
}

body:not(.dark-mode) .form-control {
    border-color: var(--app-border) !important;
}

/* Utilidades */
.cursor-pointer {
    cursor: pointer;
}

.text-truncate {
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* Responsive */
@media (max-width: 768px) {
    .card-header {
        padding: 10px 15px;
    }
    
    .btn {
        padding: 6px 12px;
    }
    
    .table {
        font-size: 13px;
    }
}

/* Dashboard específico */
.stats-card {
    background: white;
    border-radius: 8px;
    padding: 20px;
    margin-bottom: 20px;
    box-shadow: 0 2px 4px rgba(0,0,0,0.1);
}

.stats-card h3 {
    margin: 0;
    font-size: 16px;
    color: #666;
}

.stats-card .value {
    font-size: 24px;
    font-weight: bold;
    color: var(--primary-color);
    margin: 10px 0;
}

/* Gráficos */
.chart-container {
    background: white;
    border-radius: 8px;
    padding: 20px;
    margin-bottom: 20px;
    box-shadow: 0 2px 4px rgba(0,0,0,0.1);
}

/* Análisis predictivo */
.predictive-card {
    background: white;
    border-radius: 8px;
    padding: 20px;
    margin-bottom: 20px;
    box-shadow: 0 2px 4px rgba(0,0,0,0.1);
}

.predictive-card .trend-indicator {
    font-size: 20px;
    margin-right: 10px;
}

.predictive-card .trend-up {
    color: var(--success-color);
}

.predictive-card .trend-down {
    color: var(--danger-color);
}

/* Loading spinners */
.loading-spinner {
    width: 40px;
    height: 40px;
    margin: 20px auto;
    border: 4px solid #f3f3f3;
    border-top: 4px solid var(--primary-color);
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

/* Product image thumbnails and previews */
.product-image img,
.product-card .card-img-top,
.img-product-thumb,
.product-list-thumb {
    width: 80px;
    height: 80px;
    object-fit: cover;
    border-radius: 8px;
    border: 1px solid rgba(15,23,42,0.06);
    background-color: #ffffff;
    display: inline-block;
    transition: transform 140ms ease, box-shadow 140ms ease;
}

.product-preview {
    width: 80px;
    height: 80px;
    object-fit: cover;
    border-radius: 12px;
    border: 1px solid rgba(15,23,42,0.06);
    box-shadow: 0 6px 18px rgba(11, 15, 30, 0.06);
    background-color: #fff;
}

.product-image .no-image {
    width: 80px;
    height: 80px;
    display: flex;
    align-items: center;
    justify-content: center;
    border: 1px dashed rgba(15,23,42,0.04);
    border-radius: 8px;
    color: var(--muted-text);
    background: linear-gradient(180deg, #ffffff, #fbfbfd);
}

/* Slightly larger thumbnail on product cards when hovered */
.product-card .card:hover .product-image img {
    transform: scale(1.02);
    transition: transform 120ms ease-in-out;
}

/* subtle hover lifted effect */
.product-card .card:hover {
    transform: translateY(-4px);
    transition: transform 180ms ease, box-shadow 180ms ease;
    box-shadow: 0 12px 30px rgba(11, 15, 30, 0.08);
}

/* Stabilize product cards to avoid layout shifts */
.product-card .card {
    height: 100%;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    overflow: hidden;
    min-height: 300px; /* ensure enough room for image, info and button */
}

/* Ensure grid columns stretch so all cards align */
#productsGrid .product-card {
    display: flex;
    align-items: stretch;
}
#productsGrid .product-card .card {
    min-height: 300px;
    justify-content: space-between;
    overflow: hidden;
}
.per-page-form {
    position: relative;
    z-index: 1050;
}
.per-page-form .form-select {
    min-width: 56px;
}
.pagination {
    position: relative;
    z-index: 1;
}

#productsGrid .product-card .card {
    flex: 1 1 auto;
}

.product-card .card .card-body {
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    gap: 8px;
}

/* Ensure add buttons stay at the bottom of the card body */
.product-card .card .card-body > .btn {
    margin-top: auto;
}

/* Reduce input-group vertical padding so layout fits */
.product-card .card .card-body .input-group {
    margin-bottom: 6px;
}

.product-card .card .p-2 {
    display: flex;
    align-items: center;
    justify-content: center;
    height: 100px; /* reserve space for image and avoid reflow */
}

.product-card .card .card-body .card-title {
    min-height: 36px; /* reserve two lines for title to keep cards aligned */
}

/* Floating alert area so notifications do not push page content */
#alert-area {
    position: fixed;
    top: 16px;
    right: 16px;
    z-index: 1080;
    width: 340px;
    display: flex;
    flex-direction: column;
    gap: 8px;
    pointer-events: none; /* allow clicks through when empty */
}

/* compact professional alerts */
#alert-area .alert {
    pointer-events: auto; /* re-enable pointer events for the alerts themselves */
    box-shadow: 0 10px 30px rgba(11, 15, 30, 0.08);
    padding: 10px 12px;
    border-radius: 8px;
    font-size: 13px;
    margin: 0;
}

#alert-area .alert .btn-close {
    opacity: 0.6;
}

@media (max-width: 768px) {
    #alert-area { width: calc(100% - 32px); left: 16px; right: 16px; }
}