/* VMC Sistema - Custom Styles */
:root {
    --primary-color: #0d6efd;
    --secondary-color: #6c757d;
    --success-color: #198754;
    --danger-color: #dc3545;
    --warning-color: #ffc107;
    --info-color: #0dcaf0;
}

body {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    background-color: #f8f9fa;
}

.bg-gradient {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
}

.navbar-brand {
    font-weight: 600;
}

.content-section {
    min-height: 70vh;
    padding: 2rem 0;
}

.sidebar {
    box-shadow: inset -1px 0 0 rgba(0, 0, 0, .1);
    min-height: calc(100vh - 56px);
}

.sidebar .nav-link {
    color: #495057;
    border-radius: 0.375rem;
    margin: 0.125rem 0.5rem;
}

.sidebar .nav-link:hover {
    background-color: #e9ecef;
    color: #0d6efd;
}

.sidebar .nav-link.active {
    background-color: #0d6efd;
    color: white;
}

.table-responsive {
    border-radius: 0.375rem;
    box-shadow: 0 0.125rem 0.25rem rgba(0, 0, 0, 0.075);
    border: 1px solid #dee2e6;
}

.badge-si {
    background-color: var(--success-color) !important;
}

.badge-no {
    background-color: var(--secondary-color) !important;
}

.card {
    border: none;
    box-shadow: 0 0.125rem 0.25rem rgba(0, 0, 0, 0.075);
    transition: all 0.15s ease-in-out;
    border-radius: 0.5rem;
}

.card:hover {
    box-shadow: 0 0.5rem 1rem rgba(0, 0, 0, 0.15);
    transform: translateY(-2px);
}

.card-header {
    background-color: rgba(0, 0, 0, 0.03);
    border-bottom: 1px solid rgba(0, 0, 0, 0.125);
    font-weight: 600;
}

.loading-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(255, 255, 255, 0.9);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 9999;
    backdrop-filter: blur(2px);
}

.stats-card {
    border-left: 4px solid var(--primary-color);
}

.stats-card.success {
    border-left-color: var(--success-color);
}

.stats-card.warning {
    border-left-color: var(--warning-color);
}

.stats-card.danger {
    border-left-color: var(--danger-color);
}

.stats-card.info {
    border-left-color: var(--info-color);
}

.stats-number {
    font-size: 2.5rem;
    font-weight: 700;
    margin: 0;
}

.btn-action {
    margin: 0 0.125rem;
    padding: 0.25rem 0.5rem;
    border-radius: 0.375rem;
}

/* Estilos globales para nombres de clientes - evitar saltos de línea */
#clientes-table tbody tr td:first-child,
#clientes-table tbody tr td:first-child *,
#clientes-table tbody tr td:first-child div,
#clientes-table tbody tr td:first-child span,
#clientes-table tbody tr td:first-child .fw-semibold {
    white-space: nowrap !important;
    word-wrap: normal !important;
    word-break: keep-all !important;
    overflow: visible !important;
    display: inline !important;
}

#clientes-table tbody tr td:first-child {
    min-width: 0 !important;
    max-width: none !important;
    white-space: nowrap !important;
}

/* Estilos globales para razón social - evitar saltos de línea */
#clientes-table tbody tr td:nth-child(2),
#clientes-table tbody tr td:nth-child(2) *,
#clientes-table tbody tr td:nth-child(2) span {
    white-space: nowrap !important;
    word-wrap: normal !important;
    word-break: keep-all !important;
    overflow: visible !important;
    display: inline !important;
}

#clientes-table tbody tr td:nth-child(2) {
    min-width: 0 !important;
    max-width: none !important;
    white-space: nowrap !important;
}

/* Evitar saltos de línea en los TH de las tablas */
.table thead th {
    white-space: nowrap !important;
    vertical-align: middle !important;
    padding: 0.75rem 0.5rem !important;
}

.table thead th * {
    white-space: nowrap !important;
}

.table thead th span {
    display: inline-block !important;
    white-space: nowrap !important;
}

.table thead th i {
    display: inline !important;
    white-space: nowrap !important;
}

.table thead th .sort-icon {
    display: inline !important;
    margin-left: 0.25rem;
}

@media (max-width: 768px) {
    .table-responsive {
        font-size: 0.875rem;
        overflow-x: auto !important;
        -webkit-overflow-scrolling: touch !important;
    }

    .btn-action {
        padding: 0.2rem 0.4rem;
        font-size: 0.75rem;
    }

    .stats-number {
        font-size: 1.8rem;
    }

    .content-section {
        padding: 1rem 0;
    }


    /* Forzar tabla auto-layout en tablets */
    #clientes-table {
        table-layout: auto !important;
    }
}

/* Animation classes */
.fade-in {
    animation: fadeIn 0.3s ease-in;
}

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

/* Toast positioning */
.toast-container {
    z-index: 1060;
}

/* Chart container responsive */
.chart-container {
    position: relative;
    height: 350px;
    width: 100%;
}

.chart-container canvas {
    max-height: 350px !important;
}

/* Custom scrollbar */
.table-responsive::-webkit-scrollbar {
    height: 8px;
}

.table-responsive::-webkit-scrollbar-track {
    background: #f1f1f1;
    border-radius: 4px;
}

.table-responsive::-webkit-scrollbar-thumb {
    background: #c1c1c1;
    border-radius: 4px;
}

.table-responsive::-webkit-scrollbar-thumb:hover {
    background: #a8a8a8;
}

/* Form enhancements */
.form-control:focus {
    border-color: var(--primary-color);
    box-shadow: 0 0 0 0.2rem rgba(13, 110, 253, 0.25);
}

.form-select:focus {
    border-color: var(--primary-color);
    box-shadow: 0 0 0 0.2rem rgba(13, 110, 253, 0.25);
}

/* Modal enhancements */
.modal-content {
    border: none;
    border-radius: 0.75rem;
    box-shadow: 0 0.5rem 1rem rgba(0, 0, 0, 0.15);
}

.modal-header {
    border-bottom: 1px solid rgba(0, 0, 0, 0.125);
    border-radius: 0.75rem 0.75rem 0 0;
}

.modal-footer {
    border-top: 1px solid rgba(0, 0, 0, 0.125);
    border-radius: 0 0 0.75rem 0.75rem;
}

/* Pagination */
.pagination .page-link {
    color: var(--primary-color);
    border-color: #dee2e6;
}

.pagination .page-link:hover {
    color: var(--primary-color);
    background-color: #e9ecef;
    border-color: #dee2e6;
}

.pagination .page-item.active .page-link {
    background-color: var(--primary-color);
    border-color: var(--primary-color);
}

/* Breadcrumb */
.breadcrumb-item + .breadcrumb-item::before {
    content: "›";
    font-size: 1.2em;
}

/* Loading states */
.btn.loading {
    pointer-events: none;
    opacity: 0.6;
}

.btn.loading::after {
    content: "";
    display: inline-block;
    width: 1rem;
    height: 1rem;
    margin-left: 0.5rem;
    border: 2px solid transparent;
    border-top-color: currentColor;
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

@keyframes spin {
    to {
        transform: rotate(360deg);
    }
}

/* Status badges */
.status-badge {
    font-size: 0.75rem;
    padding: 0.25rem 0.5rem;
    border-radius: 0.375rem;
}

.status-si {
    background-color: #d1edff;
    color: #055160;
    border: 1px solid #b8daff;
}

.status-no {
    background-color: #f8d7da;
    color: #721c24;
    border: 1px solid #f1aeb5;
}

/* Responsive utilities */
@media (max-width: 576px) {
    .table th, .table td {
        padding: 0.5rem 0.25rem;
        font-size: 0.8rem;
    }

    .btn-group-sm .btn {
        padding: 0.125rem 0.25rem;
        font-size: 0.7rem;
    }

    .modal-dialog {
        margin: 0.5rem;
    }


    /* Forzar tabla auto-layout y scroll en móviles */
    #clientes-table {
        table-layout: auto !important;
    }

    .table-responsive {
        overflow-x: auto !important;
        -webkit-overflow-scrolling: touch !important;
    }
}

/* Sortable table headers */
.sortable-header {
    transition: background-color 0.2s ease, color 0.2s ease;
    position: relative;
}

.sortable-header:hover {
    background-color: #e9ecef !important;
    color: #0d6efd;
}

.sort-icon {
    font-size: 0.8rem;
    margin-left: 0.25rem;
    opacity: 0.5;
    transition: opacity 0.2s ease, transform 0.2s ease;
}

.sortable-header:hover .sort-icon {
    opacity: 0.8;
}

.sortable-header.active .sort-icon {
    opacity: 1;
    color: #0d6efd;
}

.sort-icon.asc {
    transform: rotate(180deg);
}

.sort-icon.desc {
    transform: rotate(0deg);
}

/* Clickable table rows */
#clientes-table tr[style*="cursor: pointer"] {
    transition: background-color 0.2s ease, transform 0.05s ease;
}

#clientes-table tr[style*="cursor: pointer"]:hover {
    background-color: #f0f7ff !important;
    transform: scale(1.01);
}

#clientes-table tr[style*="cursor: pointer"]:active {
    background-color: #e3f2fd !important;
    transform: scale(0.99);
}

/* Info message for clickable rows */
.card-body .text-muted i.bi-info-circle {
    color: #0d6efd;
}

/* Cliente dropdown with search */
#clientes-dropdown {
    position: absolute;
    z-index: 1000;
    border: 1px solid #dee2e6;
    box-shadow: 0 0.5rem 1rem rgba(0, 0, 0, 0.15);
    background: white;
    border-radius: 0.375rem;
    margin-top: 0.125rem;
}

#clientes-dropdown.show {
    display: block;
}

#clientes-dropdown .dropdown-item {
    padding: 0.75rem 1rem;
    cursor: pointer;
    border: none;
    background: white;
    text-align: left;
    width: 100%;
    transition: background-color 0.2s ease;
}

#clientes-dropdown .dropdown-item:hover:not(.disabled) {
    background-color: #f8f9fa;
}

#clientes-dropdown .dropdown-item:active:not(.disabled) {
    background-color: #e9ecef;
}

#clientes-dropdown .dropdown-item.disabled {
    cursor: default;
    opacity: 0.6;
}

#clientes-dropdown .dropdown-item .fw-semibold {
    color: #212529;
    display: block;
}

#clientes-dropdown .dropdown-item small {
    font-size: 0.875rem;
    color: #6c757d;
}

#incidencia-clientes-input.is-invalid {
    border-color: #dc3545;
}

#incidencia-clientes-input.is-invalid:focus {
    border-color: #dc3545;
    box-shadow: 0 0 0 0.25rem rgba(220, 53, 69, 0.25);
}

/* Button toolbar gap */
.btn-toolbar.gap-2 {
    gap: 0.5rem;
}

/* DNI/CIF validation feedback */
#cliente-dni-cif.is-invalid {
    border-color: #dc3545;
    background-image: url("data:image/svg+xml,%3csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 12 12' width='12' height='12' fill='none' stroke='%23dc3545'%3e%3ccircle cx='6' cy='6' r='4.5'/%3e%3cpath stroke-linejoin='round' d='M5.8 3.6h.4L6 6.5z'/%3e%3ccircle cx='6' cy='8.2' r='.6' fill='%23dc3545' stroke='none'/%3e%3c/svg%3e");
    background-repeat: no-repeat;
    background-position: right calc(0.375em + 0.1875rem) center;
    background-size: calc(0.75em + 0.375rem) calc(0.75em + 0.375rem);
    animation: shake 0.3s;
}

#cliente-dni-cif.is-invalid:focus {
    border-color: #dc3545;
    box-shadow: 0 0 0 0.25rem rgba(220, 53, 69, 0.25);
}

@keyframes shake {
    0%, 100% { transform: translateX(0); }
    25% { transform: translateX(-5px); }
    75% { transform: translateX(5px); }
}

/* Teléfono validation styles */
#cliente-telefono.is-invalid {
    border-color: #dc3545 !important;
    padding-right: calc(1.5em + 0.75rem);
    background-image: url("data:image/svg+xml,%3csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 12 12' width='12' height='12' fill='none' stroke='%23dc3545'%3e%3ccircle cx='6' cy='6' r='4.5'/%3e%3cpath stroke-linejoin='round' d='M5.8 3.6h.4L6 6.5z'/%3e%3ccircle cx='6' cy='8.2' r='.6' fill='%23dc3545' stroke='none'/%3e%3c/svg%3e");
    background-repeat: no-repeat;
    background-position: right calc(0.375em + 0.1875rem) center;
    background-size: calc(0.75em + 0.375rem) calc(0.75em + 0.375rem);
    animation: shake 0.3s;
}

#cliente-telefono.is-invalid:focus {
    border-color: #dc3545 !important;
    box-shadow: 0 0 0 0.25rem rgba(220, 53, 69, 0.25) !important;
}

#cliente-telefono.is-invalid ~ .invalid-feedback {
    display: block !important;
    color: #dc3545;
    font-size: 0.875rem;
    margin-top: 0.25rem;
}

/* Email validation styles */
#cliente-email.is-invalid {
    border-color: #dc3545 !important;
    padding-right: calc(1.5em + 0.75rem);
    background-image: url("data:image/svg+xml,%3csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 12 12' width='12' height='12' fill='none' stroke='%23dc3545'%3e%3ccircle cx='6' cy='6' r='4.5'/%3e%3cpath stroke-linejoin='round' d='M5.8 3.6h.4L6 6.5z'/%3e%3ccircle cx='6' cy='8.2' r='.6' fill='%23dc3545' stroke='none'/%3e%3c/svg%3e");
    background-repeat: no-repeat;
    background-position: right calc(0.375em + 0.1875rem) center;
    background-size: calc(0.75em + 0.375rem) calc(0.75em + 0.375rem);
    animation: shake 0.3s;
}

#cliente-email.is-invalid:focus {
    border-color: #dc3545 !important;
    box-shadow: 0 0 0 0.25rem rgba(220, 53, 69, 0.25) !important;
}

#cliente-email.is-invalid ~ .invalid-feedback {
    display: block !important;
    color: #dc3545;
    font-size: 0.875rem;
    margin-top: 0.25rem;
}

/* Documento upload styles */
#documento-actual-container {
    margin-top: 1rem;
}

#documento-actual-container .alert {
    display: flex;
    align-items: center;
    padding: 0.75rem 1rem;
}

#documento-actual-container .alert i {
    font-size: 1.2rem;
}

#documento-actual-nombre {
    flex: 1;
    margin: 0 0.5rem;
    font-weight: 500;
}

#incidencia-documento {
    cursor: pointer;
}

#incidencia-documento:hover {
    border-color: #0d6efd;
}

/* Document buttons in incidencias list */
.btn-group-vertical.d-grid {
    width: 100%;
}

.btn-group-vertical .btn-group {
    width: 100%;
}

.btn-group-vertical .btn-group .btn {
    flex: 1;
}

/* Document action buttons colors */
.btn-outline-warning:hover {
    color: #fff;
    background-color: #ffc107;
    border-color: #ffc107;
}

.btn-outline-warning {
    color: #ffc107;
    border-color: #ffc107;
}

/* Importar clientes modal */
#importarClientesModal .table-responsive {
    max-height: 400px;
    overflow-y: auto;
}

#importarClientesModal .table td,
#importarClientesModal .table th {
    vertical-align: middle;
}

#importarClientesModal .table-danger {
    background-color: rgba(220, 53, 69, 0.1);
}

#importarClientesModal .badge {
    font-size: 0.75rem;
}

#preview-warnings {
    max-height: 150px;
    overflow-y: auto;
}

/* Efecto hover en columnas clickeables (nombre y razón social) */
#clientes-table tbody tr td:first-child:hover,
#clientes-table tbody tr td:nth-child(2):hover {
    background-color: rgba(13, 110, 253, 0.08) !important;
}

#clientes-table tbody tr td:first-child,
#clientes-table tbody tr td:nth-child(2) {
    transition: background-color 0.15s ease-in-out;
}
