/* =========================================
   Módulo de Firmas Electrónicas
   Diseño Apple/OpenAI style
   ========================================= */

.firmas-container {

    margin: 0 auto;
    padding: 16px 16px;
}

/* ---- Tabs ---- */
.firmas-tabs {
    display: flex;
    gap: 4px;
    background: #f3f4f6;
    border-radius: 10px;
    padding: 4px;
    width: fit-content;
    margin-bottom: 24px;
}

.firmas-tab {
    padding: 8px 20px;
    border: none;
    background: transparent;
    border-radius: 8px;
    font-size: 14px;
    font-weight: 500;
    color: #6b7280;
    cursor: pointer;
    transition: all 0.2s ease;
}

.firmas-tab:hover {
    color: #1a1a1a;
}

.firmas-tab.active {
    background: #fff;
    color: #1a1a1a;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.08);
}

/* ---- Toolbar ---- */
.firmas-toolbar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 16px;
    margin-bottom: 20px;
}

.firmas-search-wrap {
    flex: 1;
    max-width: 360px;
}

.firmas-search {
    width: 100%;
    padding: 10px 16px;
    border: 1px solid #e5e7eb;
    border-radius: 10px;
    font-size: 14px;
    background: #fff;
    transition: border-color 0.2s;
    outline: none;
}

.firmas-search:focus {
    border-color: #3b82f6;
    box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.1);
}

/* ---- Botones ---- */
.firmas-btn-primary {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 10px 20px;
    background: #3b82f6;
    color: #fff;
    border: none;
    border-radius: 10px;
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    transition: background 0.2s;
    white-space: nowrap;
}

.firmas-btn-primary:hover {
    background: #2563eb;
}

.firmas-btn-primary:disabled {
    opacity: 0.6;
    cursor: not-allowed;
}

.firmas-btn-outline {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 10px 20px;
    background: #fff;
    color: #374151;
    border: 1px solid #e5e7eb;
    border-radius: 10px;
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s;
}

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

.firmas-btn-sm {
    padding: 6px 12px;
    font-size: 13px;
}

.firmas-action-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 32px;
    height: 32px;
    border: none;
    background: transparent;
    border-radius: 8px;
    color: #6b7280;
    cursor: pointer;
    transition: all 0.15s;
}

.firmas-action-btn:hover {
    background: #f3f4f6;
    color: #1a1a1a;
}

/* ---- Tabla ---- */
.firmas-table-wrap {
    overflow-x: auto;
    border: 1px solid #e5e7eb;
    border-radius: 12px;
    background: #fff;
}

.firmas-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 14px;
}

.firmas-table thead th {
    text-align: left;
    padding: 12px 16px;
    font-weight: 500;
    color: #6b7280;
    border-bottom: 1px solid #e5e7eb;
    background: #fafafa;
    white-space: nowrap;
}

.firmas-table thead th:first-child {
    border-radius: 12px 0 0 0;
}

.firmas-table thead th:last-child {
    border-radius: 0 12px 0 0;
}

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

.firmas-table tbody tr:hover {
    background: #f9fafb;
}

.firmas-table tbody td {
    padding: 14px 16px;
    border-bottom: 1px solid #f3f4f6;
    color: #1a1a1a;
}

.firmas-table tbody tr:last-child td {
    border-bottom: none;
}

.firmas-actions-cell {
    display: flex;
    gap: 4px;
}

/* ---- Badges ---- */
.firmas-badge {
    display: inline-block;
    padding: 4px 10px;
    border-radius: 20px;
    font-size: 12px;
    font-weight: 500;
    white-space: nowrap;
}

.badge-draft {
    background: #f3f4f6;
    color: #6b7280;
}

.badge-sent {
    background: #dbeafe;
    color: #1d4ed8;
}

.badge-partial {
    background: #fef3c7;
    color: #92400e;
}

.badge-done {
    background: #d1fae5;
    color: #065f46;
}

.badge-expired {
    background: #fee2e2;
    color: #991b1b;
}

.badge-cancelled {
    background: #f3f4f6;
    color: #9ca3af;
}

/* ---- Paginación ---- */
.firmas-pagination {
    display: flex;
    justify-content: center;
    gap: 4px;
    margin-top: 20px;
    padding: 16px 0;
}

.firmas-page-btn {
    width: 36px;
    height: 36px;
    border: 1px solid #e5e7eb;
    background: #fff;
    border-radius: 8px;
    font-size: 14px;
    cursor: pointer;
    transition: all 0.15s;
    color: #374151;
}

.firmas-page-btn:hover {
    background: #f9fafb;
}

.firmas-page-btn.active {
    background: #3b82f6;
    color: #fff;
    border-color: #3b82f6;
}

/* ---- Empty state ---- */
.firmas-empty {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 80px 20px;
    color: #9ca3af;
    text-align: center;
}

.firmas-empty p {
    margin: 12px 0 0;
    font-size: 15px;
    color: #6b7280;
}

.firmas-empty-sub {
    font-size: 13px !important;
    color: #9ca3af !important;
}

/* ---- Modal ---- */
.firmas-modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.4);
    backdrop-filter: blur(4px);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
    padding: 20px;
}

.firmas-modal {
    background: #fff;
    border-radius: 16px;
    width: 100%;
    max-width: 640px;
    max-height: 90vh;
    display: flex;
    flex-direction: column;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.15);
    animation: firmasModalIn 0.25s ease;
}

.firmas-modal-lg {
    max-width: 800px;
}

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

.firmas-modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 20px 24px;
    border-bottom: 1px solid #f3f4f6;
}

.firmas-modal-header h2 {
    margin: 0;
    font-size: 18px;
    font-weight: 600;
    color: #1a1a1a;
}

.firmas-modal-close {
    width: 32px;
    height: 32px;
    border: none;
    background: #f3f4f6;
    border-radius: 8px;
    font-size: 20px;
    color: #6b7280;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.15s;
}

.firmas-modal-close:hover {
    background: #e5e7eb;
}

.firmas-modal-body {
    padding: 24px;
    overflow-y: auto;
    flex: 1;
}

.firmas-modal-footer {
    display: flex;
    justify-content: flex-end;
    gap: 10px;
    padding: 16px 24px;
    border-top: 1px solid #f3f4f6;
}

/* ---- Formulario ---- */
.firmas-form-group {
    margin-bottom: 16px;
}

.firmas-form-group label {
    display: block;
    font-size: 13px;
    font-weight: 500;
    color: #374151;
    margin-bottom: 6px;
}

.firmas-form-group .required {
    color: #ef4444;
}

.firmas-input,
.firmas-textarea,
.firmas-select {
    width: 100%;
    padding: 10px 14px;
    border: 1px solid #e5e7eb;
    border-radius: 10px;
    font-size: 14px;
    background: #fff;
    color: #1a1a1a;
    outline: none;
    transition: border-color 0.2s;
    box-sizing: border-box;
}

.firmas-input:focus,
.firmas-textarea:focus,
.firmas-select:focus {
    border-color: #3b82f6;
    box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.1);
}

.firmas-textarea {
    resize: vertical;
    min-height: 60px;
}

.firmas-select {
    appearance: none;
    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='%23343a40' stroke-linecap='round' stroke-linejoin='round' stroke-width='2' d='M2 5l6 6 6-6'/%3e%3c/svg%3e");
    background-repeat: no-repeat;
    background-position: right 12px center;
    background-size: 12px;
    padding-right: 36px;
}

.firmas-form-row {
    display: flex;
    gap: 12px;
}

.firmas-form-row .flex-1 {
    flex: 1;
}

.firmas-checkbox-label {
    display: flex !important;
    align-items: center;
    gap: 8px;
    cursor: pointer;
    font-size: 14px !important;
}

.firmas-checkbox-label input[type="checkbox"] {
    width: 18px;
    height: 18px;
    accent-color: #3b82f6;
}

/* ---- Upload zone ---- */
.firmas-upload-zone {
    border: 2px dashed #e5e7eb;
    border-radius: 12px;
    padding: 40px 20px;
    text-align: center;
    cursor: pointer;
    transition: all 0.2s;
}

.firmas-upload-zone:hover,
.firmas-upload-zone.drag-over {
    border-color: #3b82f6;
    background: #eff6ff;
}

.firmas-upload-zone p {
    margin: 12px 0 0;
    color: #6b7280;
    font-size: 14px;
}

.firmas-upload-link {
    color: #3b82f6;
    font-weight: 500;
}

.firmas-file-preview {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 12px 16px;
    background: #eff6ff;
    border-radius: 10px;
    font-size: 14px;
    color: #1a1a1a;
}

.firmas-file-preview span {
    flex: 1;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.firmas-file-remove {
    width: 24px;
    height: 24px;
    border: none;
    background: transparent;
    color: #6b7280;
    font-size: 18px;
    cursor: pointer;
    border-radius: 4px;
}

.firmas-file-remove:hover {
    background: #dbeafe;
    color: #1d4ed8;
}

/* ---- Firmantes ---- */
.firmas-section-divider {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 16px;
    padding-top: 8px;
}

.firmas-section-divider h3 {
    margin: 0;
    font-size: 15px;
    font-weight: 600;
    color: #1a1a1a;
}

.firmas-no-firmantes {
    text-align: center;
    padding: 20px;
    color: #9ca3af;
    font-size: 13px;
}

.firmas-firmante-card {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 12px 16px;
    background: #f9fafb;
    border-radius: 10px;
    margin-bottom: 8px;
}

.firmas-firmante-info {
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.firmas-firmante-info strong {
    font-size: 14px;
    color: #1a1a1a;
}

.firmas-firmante-info span {
    font-size: 13px;
    color: #6b7280;
}

.firmas-firmante-metodo {
    font-size: 12px !important;
    color: #9ca3af !important;
}

.firmas-firmante-btns {
    display: flex;
    gap: 4px;
}

.firmas-firmante-form {
    background: #f9fafb;
    border-radius: 12px;
    padding: 20px;
    margin-bottom: 16px;
    border: 1px solid #e5e7eb;
}

.firmas-firmante-actions {
    display: flex;
    justify-content: flex-end;
    gap: 8px;
    margin-top: 16px;
}

/* ---- Autocomplete ---- */
.firmas-autocomplete {
    position: absolute;
    width: calc(100% - 2px);
    background: #fff;
    border: 1px solid #e5e7eb;
    border-radius: 10px;
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.1);
    z-index: 10;
    margin-top: 4px;
    max-height: 200px;
    overflow-y: auto;
}

.firmas-autocomplete-item {
    padding: 10px 14px;
    cursor: pointer;
    transition: background 0.1s;
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.firmas-autocomplete-item:hover {
    background: #f3f4f6;
}

.firmas-autocomplete-item strong {
    font-size: 14px;
    color: #1a1a1a;
}

.firmas-autocomplete-item span {
    font-size: 12px;
    color: #9ca3af;
}

.firmas-form-group {
    position: relative;
}

/* ---- Detalle ---- */
.firmas-detalle-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    margin-bottom: 20px;
}

.firmas-detalle-header h3 {
    margin: 0 0 6px;
    font-size: 18px;
    color: #1a1a1a;
}

.firmas-detalle-desc {
    color: #6b7280;
    font-size: 14px;
    margin: 0;
}

.firmas-detalle-meta {
    display: flex;
    gap: 20px;
    margin-bottom: 24px;
    flex-wrap: wrap;
}

.firmas-detalle-meta span {
    font-size: 13px;
    color: #9ca3af;
}

.firmas-section-title {
    font-size: 15px;
    font-weight: 600;
    color: #1a1a1a;
    margin: 24px 0 12px;
}

.firmas-firmantes-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
    gap: 12px;
}

.firmas-firmante-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-top: 12px;
    align-items: center;
}

.firmas-firmante-detail-card {
    background: #f9fafb;
    border-radius: 12px;
    padding: 16px;
}

.firmas-firmante-detail-top {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 8px;
}

.firmas-firmante-detail-card p {
    margin: 4px 0;
    font-size: 13px;
    color: #4b5563;
}

.firmas-firmante-detail-card .text-muted {
    color: #9ca3af;
    font-size: 12px;
}

.firmas-detalle-downloads {
    display: flex;
    gap: 12px;
    margin-top: 24px;
    padding-top: 20px;
    border-top: 1px solid #f3f4f6;
}

/* ---- Timeline ---- */
.firmas-timeline {
    border-left: 2px solid #e5e7eb;
    padding-left: 20px;
    margin-left: 10px;
}

.firmas-timeline-item {
    display: flex;
    gap: 12px;
    margin-bottom: 16px;
    position: relative;
}

.firmas-timeline-item::before {
    content: '';
    position: absolute;
    left: -27px;
    top: 4px;
    width: 12px;
    height: 12px;
    background: #fff;
    border: 2px solid #e5e7eb;
    border-radius: 50%;
}

.firmas-timeline-icon {
    font-size: 16px;
    flex-shrink: 0;
}

.firmas-timeline-item p {
    margin: 0 0 2px;
    font-size: 13px;
    color: #374151;
}

.firmas-timeline-item .text-muted {
    color: #9ca3af;
    font-size: 12px;
}

.firmas-timeline-date {
    font-size: 12px;
    color: #9ca3af;
}

/* ---- Responsive ---- */
@media (max-width: 768px) {
    .firmas-toolbar {
        flex-direction: column;
        align-items: stretch;
    }

    .firmas-search-wrap {
        max-width: 100%;
    }

    .firmas-form-row {
        flex-direction: column;
        gap: 0;
    }

    .firmas-modal {
        max-height: 95vh;
        border-radius: 12px;
    }

    .firmas-firmantes-grid {
        grid-template-columns: 1fr;
    }

    .firmas-detalle-downloads {
        flex-direction: column;
    }

    .firmas-table-wrap {
        font-size: 13px;
    }
}
