/* ============================================
   EMEDOS COMPONENTS CSS
   Componentes reutilizables con Tailwind
   ============================================ */

/* ========================================
   CARDS
   ======================================== */
.card {
    background-color: #ffffff;
    border-radius: 0.75rem;
    box-shadow: 0 1px 3px 0 rgba(0, 0, 0, 0.1), 0 1px 2px -1px rgba(0, 0, 0, 0.1);
    border: 1px solid rgba(229, 231, 235, 0.5);
    overflow: hidden;
}

.card-body {
    padding: 1.5rem;
}

.card-header {
    padding: 1rem 1.5rem;
    background-color: #ffffff;
    border-bottom: 1px solid #e5e7eb;
}

.card.h-full {
    height: 100%;
}

/* ========================================
   BUTTONS
   ======================================== */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    padding: 0.625rem 1rem;
    font-size: 0.875rem;
    font-weight: 500;
    line-height: 1.25rem;
    border-radius: 0.5rem;
    transition: all 0.2s;
    cursor: pointer;
    border: 1px solid transparent;
    text-decoration: none;
}

.btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.btn-sm {
    padding: 0.375rem 0.75rem;
    font-size: 0.8125rem;
}

.btn-lg {
    padding: 0.75rem 1.5rem;
    font-size: 1rem;
}

/* Button Colors */
.btn-primary {
    background-color: #7356f1;
    color: #ffffff;
    box-shadow: 0 1px 2px 0 rgba(115, 86, 241, 0.3);
}

.btn-primary:hover {
    background-color: #5d3fd3;
    box-shadow: 0 2px 4px 0 rgba(115, 86, 241, 0.4);
    transform: translateY(-1px);
}

.btn-primary:active {
    transform: scale(0.98);
}

.btn-success {
    background-color: #10b981;
    color: #ffffff;
    box-shadow: 0 1px 2px 0 rgba(16, 185, 129, 0.3);
}

.btn-success:hover {
    background-color: #059669;
    box-shadow: 0 2px 4px 0 rgba(16, 185, 129, 0.4);
    transform: translateY(-1px);
}

.btn-warning {
    background-color: #f59e0b;
    color: #ffffff;
    box-shadow: 0 1px 2px 0 rgba(245, 158, 11, 0.3);
}

.btn-warning:hover {
    background-color: #d97706;
}

.btn-danger {
    background-color: #ef4444;
    color: #ffffff;
    box-shadow: 0 1px 2px 0 rgba(239, 68, 68, 0.3);
}

.btn-danger:hover {
    background-color: #dc2626;
}

.btn-white {
    background-color: #ffffff;
    color: #374151;
    border: 1px solid #e5e7eb;
    box-shadow: 0 1px 2px 0 rgba(0, 0, 0, 0.05);
}

.btn-white:hover {
    background-color: #f9fafb;
    border-color: #d1d5db;
}

.btn-outline-white {
    background-color: transparent;
    color: #ffffff;
    border: 2px solid rgba(255, 255, 255, 0.5);
}

.btn-outline-white:hover {
    background-color: rgba(255, 255, 255, 0.1);
    border-color: #ffffff;
}

.btn-light {
    background-color: #f3f4f6;
    color: #374151;
}

.btn-light:hover {
    background-color: #e5e7eb;
}

/* ========================================
   BADGES
   ======================================== */
.badge {
    display: inline-flex;
    align-items: center;
    gap: 0.25rem;
    padding: 0.375rem 0.625rem;
    font-size: 0.75rem;
    font-weight: 600;
    line-height: 1;
    border-radius: 0.375rem;
}

.badge-success {
    background-color: #10b981;
    color: #ffffff;
}

.badge-success-soft {
    background-color: rgba(16, 185, 129, 0.1);
    color: #10b981;
}

.badge-warning {
    background-color: #f59e0b;
    color: #ffffff;
}

.badge-warning-soft {
    background-color: rgba(245, 158, 11, 0.1);
    color: #f59e0b;
}

.badge-danger {
    background-color: #ef4444;
    color: #ffffff;
}

.badge-danger-soft {
    background-color: rgba(239, 68, 68, 0.1);
    color: #ef4444;
}

.badge-primary {
    background-color: #7356f1;
    color: #ffffff;
}

.badge-primary-soft {
    background-color: rgba(115, 86, 241, 0.1);
    color: #7356f1;
}

/* ========================================
   TABLE
   ======================================== */
.table {
    width: 100%;
    font-size: 0.875rem;
    color: #1f2937;
}

.table thead th {
    font-weight: 600;
    text-align: left;
    padding: 1rem 1.5rem;
}

.table tbody td {
    padding: 1rem 1.5rem;
    vertical-align: middle;
}

.table-hover tbody tr {
    transition: background-color 0.15s;
}

.table-hover tbody tr:hover {
    background-color: rgba(249, 250, 251, 0.5);
}

/* ========================================
   TEXT UTILITIES
   ======================================== */
.text-heading {
    color: #1e293b;
}

.text-muted {
    color: #64748b;
}

.text-success {
    color: #10b981;
}

.text-warning {
    color: #f59e0b;
}

.text-danger {
    color: #ef4444;
}

.text-primary {
    color: #7356f1;
}

/* ========================================
   BACKGROUND UTILITIES
   ======================================== */
.bg-success {
    background-color: #10b981;
}

.bg-warning {
    background-color: #f59e0b;
}

.bg-danger {
    background-color: #ef4444;
}

.bg-primary {
    background-color: #7356f1;
}

/* Background con opacity */
.bg-success\/10 {
    background-color: rgba(16, 185, 129, 0.1);
}

.bg-warning\/10 {
    background-color: rgba(245, 158, 11, 0.1);
}

.bg-danger\/10 {
    background-color: rgba(239, 68, 68, 0.1);
}

.bg-primary\/10 {
    background-color: rgba(115, 86, 241, 0.1);
}

/* ========================================
   MODAL STYLES (Bootstrap compatible)
   ======================================== */
.modal-content {
    border-radius: 1rem;
    border: none;
    box-shadow: 0 20px 25px -5px rgba(0, 0, 0, 0.1), 0 10px 10px -5px rgba(0, 0, 0, 0.04);
}

.modal-header {
    padding: 1.5rem;
    border-bottom: 1px solid #e5e7eb;
}

.modal-body {
    padding: 1.5rem;
}

.modal-footer {
    padding: 1.5rem;
    border-top: 1px solid #e5e7eb;
}

/* ========================================
   UTILITIES
   ======================================== */
.border-border {
    border-color: #e2e8f0;
}

.divide-border > * + * {
    border-top: 1px solid #e2e8f0;
}

.ml-13 {
    margin-left: 3.25rem;
}

/* Opacity */
.opacity-30 {
    opacity: 0.3;
}

.opacity-90 {
    opacity: 0.9;
}

/* Text opacity */
.text-white\/70 {
    color: rgba(255, 255, 255, 0.7);
}

.text-white\/50 {
    color: rgba(255, 255, 255, 0.5);
}

.text-muted\/70 {
    color: rgba(100, 116, 139, 0.7);
}

/* ========================================
   DATATABLES - ESTILOS GLOBALES REUTILIZABLES
   Compatible con DataTables v1.13.7 + Bootstrap5 integration
   DOM personalizado: '<"dt-top"lf>rt<"dt-bottom"ip>'
   ======================================== */

/* --- Wrapper base --- */
.dataTables_wrapper {
    position: relative;
}

/* --- Fila superior: Length (izq) + Search (der) --- */
.dt-top {
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: 0.75rem;
    padding: 0.875rem 0 0.875rem 0;
    border-bottom: 1px solid #f1f5f9;
    margin-bottom: 0;
}

/* --- Fila inferior: Info (izq) + Paginación (der) --- */
.dt-bottom {
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: 0.75rem;
    padding: 0.875rem 0 0 0;
    border-top: 1px solid #f1f5f9;
    margin-top: 0;
}

/* --- Label de controles --- */
.dataTables_length label,
.dataTables_filter label {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-size: 0.8125rem;
    color: #64748b;
    margin: 0;
    font-weight: 400;
    white-space: nowrap;
}

/* --- Select de cantidad (form-select Bootstrap5) --- */
.dataTables_wrapper .form-select,
.dataTables_wrapper select.form-select-sm {
    display: inline-block;
    padding: 0.3125rem 1.75rem 0.3125rem 0.625rem;
    font-size: 0.8125rem;
    font-weight: 400;
    line-height: 1.5;
    color: #374151;
    background-color: #ffffff;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16'%3E%3Cpath fill='none' stroke='%2364748b' stroke-linecap='round' stroke-linejoin='round' stroke-width='2' d='m2 5 6 6 6-6'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 0.5rem center;
    background-size: 0.75rem 0.75rem;
    border: 1px solid #d1d5db;
    border-radius: 0.5rem;
    -webkit-appearance: none;
    appearance: none;
    cursor: pointer;
    transition: border-color 0.2s ease, box-shadow 0.2s ease;
}

.dataTables_wrapper .form-select:focus,
.dataTables_wrapper select.form-select-sm:focus {
    outline: none;
    border-color: #7356f1;
    box-shadow: 0 0 0 3px rgba(115, 86, 241, 0.1);
}

/* --- Input de búsqueda (form-control Bootstrap5) --- */
.dataTables_wrapper .form-control,
.dataTables_wrapper input.form-control-sm {
    display: inline-block;
    padding: 0.3125rem 0.625rem 0.3125rem 2rem;
    font-size: 0.8125rem;
    font-weight: 400;
    line-height: 1.5;
    color: #374151;
    background-color: #ffffff;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='14' height='14' viewBox='0 0 24 24' fill='none' stroke='%2364748b' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Ccircle cx='11' cy='11' r='8'/%3E%3Cpath d='m21 21-4.35-4.35'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: 0.5rem center;
    background-size: 0.875rem 0.875rem;
    border: 1px solid #d1d5db;
    border-radius: 0.5rem;
    min-width: 200px;
    transition: border-color 0.2s ease, box-shadow 0.2s ease;
}

.dataTables_wrapper .form-control:focus,
.dataTables_wrapper input.form-control-sm:focus {
    outline: none;
    border-color: #7356f1;
    box-shadow: 0 0 0 3px rgba(115, 86, 241, 0.1);
}

/* --- Info text --- */
.dataTables_info {
    font-size: 0.8125rem;
    color: #94a3b8;
    padding: 0;
}

/* --- Processing indicator --- */
.dataTables_processing {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    background: rgba(255, 255, 255, 0.95);
    padding: 0.75rem 1.5rem;
    border-radius: 0.75rem;
    box-shadow: 0 4px 6px -1px rgba(0,0,0,0.1), 0 2px 4px -2px rgba(0,0,0,0.1);
    font-size: 0.875rem;
    color: #7356f1;
    z-index: 20;
    border: 1px solid rgba(115, 86, 241, 0.15);
}

/* --- Paginación (Bootstrap5: ul.pagination > li.page-item > a.page-link) --- */
.dataTables_paginate .pagination {
    display: flex;
    list-style: none;
    gap: 0.25rem;
    margin: 0;
    padding: 0;
    align-items: center;
}

.dataTables_paginate .page-item .page-link {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 2rem;
    height: 2rem;
    padding: 0 0.5rem;
    font-size: 0.8125rem;
    font-weight: 500;
    color: #374151;
    background-color: #ffffff;
    border: 1px solid #e5e7eb;
    border-radius: 0.5rem;
    text-decoration: none;
    cursor: pointer;
    transition: all 0.15s ease;
    line-height: 1;
}

.dataTables_paginate .page-item .page-link:hover {
    background-color: #7356f1;
    color: #ffffff;
    border-color: #7356f1;
    transform: translateY(-1px);
    box-shadow: 0 2px 4px rgba(115, 86, 241, 0.3);
}

.dataTables_paginate .page-item.active .page-link {
    background-color: #7356f1;
    color: #ffffff;
    border-color: #7356f1;
    font-weight: 600;
    box-shadow: 0 2px 4px rgba(115, 86, 241, 0.3);
}

.dataTables_paginate .page-item.disabled .page-link {
    opacity: 0.4;
    cursor: not-allowed;
    pointer-events: none;
    color: #cbd5e1;
    background-color: #f8fafc;
}

/* --- Sorting indicators en headers --- */
table.dataTable thead .sorting,
table.dataTable thead .sorting_asc,
table.dataTable thead .sorting_desc {
    cursor: pointer;
    padding-right: 1.5rem;
    position: relative;
    user-select: none;
}

table.dataTable thead .sorting::after,
table.dataTable thead .sorting_asc::after,
table.dataTable thead .sorting_desc::after {
    position: absolute;
    right: 0.375rem;
    top: 50%;
    transform: translateY(-50%);
    font-size: 0.625rem;
    line-height: 1;
    opacity: 0.4;
    content: '▲▼';
    font-family: inherit;
    letter-spacing: -1px;
}

table.dataTable thead .sorting_asc::after {
    content: '▲';
    opacity: 1;
    color: #7356f1;
}

table.dataTable thead .sorting_desc::after {
    content: '▼';
    opacity: 1;
    color: #7356f1;
}

/* --- Responsive --- */
@media (max-width: 640px) {
    .dt-top,
    .dt-bottom {
        flex-direction: column;
        align-items: stretch;
        gap: 0.5rem;
    }

    .dataTables_wrapper .form-control,
    .dataTables_wrapper input.form-control-sm {
        min-width: unset;
        width: 100%;
    }

    .dataTables_paginate .pagination {
        flex-wrap: wrap;
        justify-content: center;
    }

    .dt-bottom {
        flex-direction: column-reverse;
        align-items: center;
        text-align: center;
    }
}

/* ========================================
   CHOICES.JS TAILWIND INTEGRATION
   ======================================== */
.choices {
    margin-bottom: 0;
}

.choices__inner {
    padding: 0.625rem 1rem;
    border: 1px solid #d1d5db;
    border-radius: 0.5rem;
    background-color: #ffffff;
    font-size: 0.875rem;
    min-height: 42px;
    transition: all 0.2s;
}

.choices__inner:focus,
.choices.is-focused .choices__inner {
    border-color: #7356f1;
    box-shadow: 0 0 0 3px rgba(115, 86, 241, 0.1);
}

.choices__list--dropdown {
    border: 1px solid #e5e7eb;
    border-radius: 0.5rem;
    box-shadow: 0 10px 15px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -2px rgba(0, 0, 0, 0.05);
    margin-top: 0.25rem;
    z-index: 10;
}

.choices__list--dropdown .choices__item--selectable {
    padding: 0.625rem 1rem;
    font-size: 0.875rem;
}

.choices__list--dropdown .choices__item--selectable.is-highlighted {
    background-color: #f3f4f6;
}

.choices__list--dropdown .choices__item {
    display: flex;
    align-items: center;
}

.choices__list--single {
    padding: 0;
}

.choices__list--single .choices__item {
    display: flex;
    align-items: center;
}

.choices[data-type*="select-one"] .choices__inner {
    padding-bottom: 0.625rem;
}

.choices__list--dropdown .choices__item--selectable::after {
    display: none;
}

/* Iconos en Choices.js */
.choices .bx {
    font-size: 1.125rem;
    vertical-align: middle;
}

/* ========================================
   BADGES
   ======================================== */
.badge {
    display: inline-flex;
    align-items: center;
    gap: 0.25rem;
    font-weight: 600;
    border-radius: 9999px;
}

.badge-success-soft {
    background-color: rgba(16, 185, 129, 0.1);
    color: #10b981;
}

.badge-warning-soft {
    background-color: rgba(245, 158, 11, 0.1);
    color: #f59e0b;
}

.badge-danger-soft {
    background-color: rgba(239, 68, 68, 0.1);
    color: #ef4444;
}

.badge-primary-soft {
    background-color: rgba(115, 86, 241, 0.1);
    color: #7356f1;
}

/* ========================================
   POPOVERS
   ======================================== */
.popover-arrow {
    position: absolute;
    left: 50%;
    transform: translateX(-50%);
    top: 100%;
    width: 0;
    height: 0;
    border-left: 8px solid transparent;
    border-right: 8px solid transparent;
    border-top: 8px solid white;
    filter: drop-shadow(0 2px 4px rgba(0, 0, 0, 0.1));
}
