/* ============================================
   Centro de Depilaciones - Estilos Principales
   Tablet-first, diseño premium
   ============================================ */

/* --- Variables de color (default, overridden by PHP) --- */
:root {
    --primary: #9b59b6;
    --primary-dark: #7d3c98;
    --primary-light: #d2b4de;
    --primary-soft: #f4ecf7;
    --secondary: #e91e8c;
    --secondary-light: #f8bbd0;
    --accent: #f39c12;
    --success: #27ae60;
    --danger: #e74c3c;
    --warning: #f39c12;
    --info: #3498db;
    --dark: #2c2c3e;
    --gray: #6c757d;
    --gray-light: #e9ecef;
    --bg: #faf5ff;
    --white: #ffffff;
    --shadow: 0 2px 12px rgba(155, 89, 182, 0.10);
    --shadow-lg: 0 8px 32px rgba(155, 89, 182, 0.15);
    --radius: 12px;
    --radius-sm: 8px;
    --transition: all 0.2s ease;
}

/* --- Base --- */
body {
    background-color: var(--bg);
    font-family: 'Segoe UI', system-ui, -apple-system, sans-serif;
    font-size: 16px;
    color: var(--dark);
    -webkit-tap-highlight-color: transparent;
}

/* --- Login --- */
.login-body {
    background: linear-gradient(135deg, var(--primary-soft) 0%, #fce4ec 50%, var(--primary-soft) 100%);
    min-height: 100vh;
}

.login-icon {
    width: 70px;
    height: 70px;
    border-radius: 50%;
    background: linear-gradient(135deg, var(--primary), var(--secondary));
    display: inline-flex;
    align-items: center;
    justify-content: center;
    color: white;
    font-size: 28px;
}

.login-logo {
    max-height: 80px;
    max-width: 180px;
    object-fit: contain;
}

.text-primary-custom {
    color: var(--primary) !important;
}

.btn-primary-custom {
    background: linear-gradient(135deg, var(--primary), var(--secondary));
    border: none;
    color: white;
    font-weight: 600;
    padding: 12px;
    border-radius: var(--radius-sm);
    transition: var(--transition);
}

.btn-primary-custom:hover {
    background: linear-gradient(135deg, var(--primary-dark), #c2185b);
    color: white;
    transform: translateY(-1px);
    box-shadow: var(--shadow-lg);
}

/* --- Navbar --- */
.navbar-custom {
    background: linear-gradient(135deg, var(--dark) 0%, #1a1a2e 100%);
    padding: 8px 16px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.15);
}

.navbar-custom .navbar-brand {
    color: white !important;
    font-size: 1.1rem;
}

.navbar-logo {
    max-height: 36px;
    max-width: 120px;
    object-fit: contain;
    border-radius: 4px;
}

.navbar-custom .nav-link {
    color: rgba(255, 255, 255, 0.85) !important;
    padding: 10px 14px !important;
    border-radius: var(--radius-sm);
    transition: var(--transition);
    font-size: 0.95rem;
}

.navbar-custom .nav-link:hover,
.navbar-custom .nav-link.active {
    color: white !important;
    background: rgba(155, 89, 182, 0.3);
}

.navbar-custom .navbar-toggler {
    border-color: rgba(255, 255, 255, 0.3);
    padding: 8px 12px;
}

.navbar-custom .navbar-toggler-icon {
    background-image: url("data:image/svg+xml,%3csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 30 30'%3e%3cpath stroke='rgba%28255,255,255,0.8%29' stroke-linecap='round' stroke-miterlimit='10' stroke-width='2' d='M4 7h22M4 15h22M4 23h22'/%3e%3c/svg%3e");
}

/* --- Cards --- */
.card {
    border: none;
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    transition: var(--transition);
}

.card:hover {
    box-shadow: var(--shadow-lg);
}

.card-stat {
    border-left: 4px solid var(--primary);
    cursor: default;
}

.card-stat .stat-icon {
    width: 48px;
    height: 48px;
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 20px;
    color: white;
}

.card-stat .stat-number {
    font-size: 1.8rem;
    font-weight: 700;
    color: var(--dark);
    line-height: 1;
}

.card-stat .stat-label {
    font-size: 0.85rem;
    color: var(--gray);
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

/* --- Botones generales --- */
.btn {
    border-radius: var(--radius-sm);
    font-weight: 500;
    transition: var(--transition);
    min-height: 44px;
    /* Touch target mínimo */
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
}

.btn-sm {
    min-height: 38px;
    padding: 6px 12px;
}

.btn-primary {
    background-color: var(--primary);
    border-color: var(--primary);
}

.btn-primary:hover {
    background-color: var(--primary-dark);
    border-color: var(--primary-dark);
    transform: translateY(-1px);
}

.btn-whatsapp {
    background-color: #25D366;
    border: none;
    color: white;
    padding: 6px 12px;
}

.btn-whatsapp:hover {
    background-color: #128C7E;
    color: white;
}

/* --- Formularios --- */
.form-control,
.form-select {
    border-radius: var(--radius-sm);
    padding: 10px 14px;
    font-size: 16px;
    /* Prevenir zoom en iOS */
    border: 2px solid var(--gray-light);
    transition: var(--transition);
    min-height: 44px;
}

.form-control:focus,
.form-select:focus {
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(155, 89, 182, 0.15);
}

.form-label {
    font-weight: 600;
    font-size: 0.9rem;
    color: var(--dark);
    margin-bottom: 4px;
}

/* --- Tablas --- */
.table {
    border-radius: var(--radius);
    overflow: hidden;
}

.table thead th {
    background-color: var(--primary-soft);
    color: var(--primary-dark);
    font-weight: 600;
    font-size: 0.85rem;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    border: none;
    padding: 12px;
}

.table tbody td {
    padding: 12px;
    vertical-align: middle;
    border-color: var(--gray-light);
}

.table tbody tr:hover {
    background-color: var(--primary-soft);
}

/* --- Badges --- */
.badge {
    border-radius: 6px;
    font-weight: 500;
    padding: 5px 10px;
    font-size: 0.8rem;
}

/* --- Check realizada --- */
.check-realizada {
    width: 28px;
    height: 28px;
    cursor: pointer;
    accent-color: var(--success);
}

/* --- Calendario mini --- */
.calendar-grid {
    display: grid;
    grid-template-columns: repeat(7, 1fr);
    gap: 2px;
}

.calendar-cell {
    min-height: 80px;
    padding: 4px;
    border: 1px solid var(--gray-light);
    border-radius: 4px;
    font-size: 0.85rem;
    position: relative;
    background: white;
}

.calendar-cell.today {
    border-color: var(--primary);
    background: var(--primary-soft);
}

.calendar-cell .day-number {
    font-weight: 700;
    font-size: 0.9rem;
    color: var(--dark);
}

.calendar-cell .ficha-dot {
    display: inline-block;
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: var(--primary);
    margin: 1px;
}

.calendar-cell .ficha-dot.realizada {
    background: var(--success);
}

.calendar-cell .ficha-dot.pendiente {
    background: var(--warning);
}

.calendar-header {
    font-weight: 600;
    text-align: center;
    padding: 8px;
    background: var(--primary-soft);
    color: var(--primary-dark);
    font-size: 0.8rem;
    text-transform: uppercase;
}

.calendar-cell.other-month {
    opacity: 0.3;
}

/* --- Ficha Items en form --- */
.item-depilacion {
    background: var(--white);
    border: 2px solid var(--gray-light);
    border-radius: var(--radius-sm);
    padding: 12px;
    margin-bottom: 8px;
    transition: var(--transition);
}

.item-depilacion.selected {
    border-color: var(--primary);
    background: var(--primary-soft);
}

.item-depilacion .form-check-input {
    width: 22px;
    height: 22px;
    margin-top: 0;
}

.item-depilacion .item-nombre {
    font-weight: 600;
    font-size: 1rem;
}

.item-depilacion .item-precio {
    font-weight: 700;
    color: var(--primary);
    font-size: 1.1rem;
}

/* Precio clickeable */
.item-depilacion .precio-display {
    cursor: pointer;
    padding: 4px 8px;
    border-radius: var(--radius-sm);
    transition: var(--transition);
}

.item-depilacion.selected .precio-display:hover {
    background: rgba(155, 89, 182, 0.15);
    text-decoration: underline;
}

.precio-edit-wrapper {
    animation: fadeIn 0.2s ease;
}

/* --- Pagos --- */
.pago-item {
    border-left: 3px solid var(--success);
    padding: 10px 14px;
    margin-bottom: 8px;
    background: white;
    border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
    box-shadow: var(--shadow);
}

/* --- Sección detalle ficha --- */
.ficha-detail-section {
    background: white;
    border-radius: var(--radius);
    padding: 20px;
    margin-bottom: 16px;
    box-shadow: var(--shadow);
}

.ficha-detail-section h5 {
    color: var(--primary-dark);
    font-weight: 700;
    margin-bottom: 16px;
    padding-bottom: 8px;
    border-bottom: 2px solid var(--primary-light);
}

/* --- Total box --- */
.total-box {
    background: linear-gradient(135deg, var(--primary), var(--secondary));
    color: white;
    border-radius: var(--radius);
    padding: 16px 20px;
    text-align: center;
}

.total-box .total-label {
    font-size: 0.85rem;
    opacity: 0.9;
    text-transform: uppercase;
    letter-spacing: 1px;
}

.total-box .total-amount {
    font-size: 2rem;
    font-weight: 700;
}

/* --- Configuración: Paletas --- */
.paleta-option {
    display: block;
    cursor: pointer;
}

.paleta-option .paleta-card {
    border: 2px solid var(--gray-light);
    transition: var(--transition);
}

.paleta-option:hover .paleta-card {
    border-color: var(--primary);
    transform: translateY(-2px);
    box-shadow: var(--shadow);
}

.paleta-option.active .paleta-card {
    border-color: var(--primary);
    background: var(--primary-soft);
    box-shadow: var(--shadow);
}

.paleta-swatch {
    width: 20px;
    height: 20px;
    border-radius: 50%;
    border: 2px solid rgba(0, 0, 0, 0.1);
}

/* --- Caja: Tipo insumo selector --- */
.tipo-insumo-option {
    display: block;
    cursor: pointer;
}

.tipo-insumo-option .tipo-insumo-card {
    border: 2px solid var(--gray-light);
    transition: var(--transition);
}

.tipo-insumo-option:hover .tipo-insumo-card {
    transform: translateY(-1px);
    box-shadow: var(--shadow);
}

.tipo-insumo-option.active-egreso .tipo-insumo-card {
    border-color: var(--danger);
    background: rgba(231, 76, 60, 0.08);
}

.tipo-insumo-option.active-ingreso .tipo-insumo-card {
    border-color: var(--success);
    background: rgba(39, 174, 96, 0.08);
}

/* --- Chart bars animation --- */
.chart-bar-ingreso,
.chart-bar-egreso {
    transition: height 0.5s ease;
}

.chart-bar-ingreso:hover,
.chart-bar-egreso:hover {
    opacity: 0.8;
    filter: brightness(1.1);
}

/* --- Sticky form for caja --- */
.sticky-form {
    position: sticky;
    top: 80px;
}

/* --- Animations --- */
@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(-4px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* --- Progress bar --- */
.progress {
    background: var(--gray-light);
}

/* --- Responsive tablet-first --- */
@media (max-width: 1024px) {
    .container-fluid {
        padding-left: 12px;
        padding-right: 12px;
    }

    .calendar-cell {
        min-height: 60px;
        font-size: 0.75rem;
    }

    .sticky-form {
        position: static;
    }
}

@media (max-width: 768px) {
    .card-stat .stat-number {
        font-size: 1.4rem;
    }

    .calendar-cell {
        min-height: 50px;
        padding: 2px;
    }

    .calendar-cell .day-number {
        font-size: 0.8rem;
    }

    .table {
        font-size: 0.9rem;
    }

    .btn {
        padding: 10px 16px;
    }

    .navbar-logo {
        max-height: 28px;
    }
}

/* --- Utilidades --- */
.text-primary-custom {
    color: var(--primary) !important;
}

.bg-primary-soft {
    background-color: var(--primary-soft) !important;
}

.border-primary {
    border-color: var(--primary) !important;
}

.gap-2 {
    gap: 8px;
}

.gap-3 {
    gap: 12px;
}

/* DataTables overrides */
.dataTables_wrapper .dataTables_filter input {
    border-radius: var(--radius-sm);
    padding: 8px 12px;
    border: 2px solid var(--gray-light);
    min-height: 40px;
}

.dataTables_wrapper .dataTables_length select {
    border-radius: var(--radius-sm);
    padding: 6px 10px;
    min-height: 38px;
}

.page-link {
    min-width: 40px;
    min-height: 40px;
    display: flex;
    align-items: center;
    justify-content: center;
}

/* SweetAlert custom */
.swal2-popup {
    border-radius: var(--radius) !important;
}

/* Print */
@media print {

    .navbar,
    .btn,
    .dataTables_wrapper .dataTables_filter,
    .dataTables_wrapper .dataTables_length,
    .dataTables_wrapper .dataTables_paginate {
        display: none !important;
    }
}