/**
 * Tema visual profesional para la app de casos de uso.
 * Basado en Bootstrap 5 con overrides específicos.
 */

:root {
    --brand: #1a2b4c;
    --brand-light: #2d4374;
    --accent: #0d6efd;
    --bg-body: #f1f4f8;
    --bg-card: #ffffff;
    --border: #e1e5eb;
    --text: #1e293b;
    --muted: #64748b;
    --success: #10b981;
    --warning: #f59e0b;
    --danger: #ef4444;
}

body {
    background: var(--bg-body);
    color: var(--text);
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
}

/* Header */
.app-header {
    background: linear-gradient(135deg, var(--brand) 0%, var(--brand-light) 100%);
    color: #fff;
    padding: 0.85rem 0;
    box-shadow: 0 4px 12px rgba(26, 43, 76, 0.2);
}

.app-header h1 {
    color: #fff;
    font-weight: 700;
    letter-spacing: -0.02em;
}

.app-header .text-muted {
    color: rgba(255, 255, 255, 0.75) !important;
}

/* Filtros */
.filters {
    width: 100%;
    background: #f1f5f9;
    border: 2px solid #cbd5e1;
    border-radius: 0.75rem;
    padding: 1rem 1.25rem;
    margin: 1rem auto;
    max-width: 100%;
    box-shadow: 0 4px 12px rgba(0,0,0,0.06);
}

@media (min-width: 576px) { .filters { max-width: 540px; } }
@media (min-width: 768px) { .filters { max-width: 720px; } }
@media (min-width: 992px) { .filters { max-width: 960px; } }
@media (min-width: 1200px) { .filters { max-width: 1140px; } }
@media (min-width: 1400px) { .filters { max-width: 1320px; } }

.filters .container {
    max-width: none;
    padding: 0;
}

.filter-group {
    min-width: 0;
    background: #ffffff;
    border: 1px solid #e2e8f0;
    border-radius: 0.5rem;
    padding: 0.6rem 0.75rem;
    box-shadow: 0 1px 2px rgba(0,0,0,0.04);
}

.filter-group + .filter-group {
    margin-top: 0.5rem;
}

.filter-label {
    font-size: 0.7rem;
    font-weight: 800;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: var(--brand);
    margin-bottom: 0.45rem;
    display: block;
    border-bottom: 1px solid #e2e8f0;
    padding-bottom: 0.35rem;
}

.toggle-buttons {
    display: flex;
    flex-wrap: wrap;
    gap: 0.4rem;
}

.toggle-btn {
    padding: 0.3rem 0.75rem;
    border: 1px solid var(--border);
    border-radius: 0.375rem;
    background: #fff;
    color: var(--muted);
    font-size: 0.82rem;
    cursor: pointer;
    transition: all 0.15s ease;
    font-weight: 500;
}

.toggle-btn:hover {
    border-color: var(--accent);
    color: var(--accent);
    background: #f8fafc;
}

.toggle-btn.active {
    background: var(--accent);
    color: #fff;
    border-color: var(--accent);
    box-shadow: 0 2px 5px rgba(13, 110, 253, 0.35);
    font-weight: 600;
}

.checkbox-group {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem 1rem;
    padding-top: 0.2rem;
}

.checkbox-group .form-check {
    padding-left: 1.25rem;
    margin-bottom: 0;
}

.checkbox-group .form-check-input {
    margin-left: -1.25rem;
    cursor: pointer;
    width: 0.9rem;
    height: 0.9rem;
    border-color: #cbd5e1;
}

.checkbox-group .form-check-label {
    font-size: 0.82rem;
    color: var(--text);
    cursor: pointer;
    padding-top: 0.05rem;
}

/* Tabla */
.summary-table-section {
    background: var(--bg-card);
    border-radius: 0.75rem;
    box-shadow: 0 2px 8px rgba(0,0,0,0.04);
    border: 1px solid var(--border);
    overflow: hidden;
}

.summary-table {
    font-size: 0.82rem;
    margin-bottom: 0;
}

.summary-table thead th {
    background: #f8fafc;
    color: var(--muted);
    font-weight: 700;
    font-size: 0.7rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    padding: 0.65rem 0.75rem;
    border-bottom: 1px solid var(--border);
    white-space: nowrap;
}

.summary-table tbody td {
    padding: 0.6rem 0.75rem;
    vertical-align: middle;
    border-bottom: 1px solid #f1f5f9;
    color: var(--text);
}

.summary-table tbody tr:hover td {
    background: #f8fafc;
}

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

.summary-table .case-title {
    color: var(--accent);
    cursor: pointer;
    font-weight: 600;
    line-height: 1.35;
}

.summary-table .case-title:hover {
    color: #0b5ed7;
    text-decoration: underline;
}

.summary-table td.conf-cell,
.summary-table td.disc-cell {
    white-space: nowrap;
    text-align: center;
}

.summary-table td.opportunity-cell {
    max-width: 380px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    color: var(--muted);
    font-size: 0.8rem;
}

.summary-table .btn-view-detail {
    padding: 0.25rem 0.5rem;
    font-size: 0.75rem;
    border-radius: 0.375rem;
    white-space: nowrap;
}

/* Badges */
.badge-domain-armoured {
    background: #eef3e0;
    color: #4d5d2b;
}

.badge-domain-uav {
    background: #e0f2fe;
    color: #0369a1;
}

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

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

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

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

.badge-tech {
    display: inline-block;
    padding: 0.15rem 0.45rem;
    margin: 0.05rem;
    background: #eef2f6;
    color: #475569;
    border-radius: 0.25rem;
    font-size: 0.72rem;
    font-weight: 500;
}

/* Tarjetas */
.cards-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
    gap: 1rem;
}

.custom-card {
    border: 1px solid var(--border);
    border-radius: 0.75rem;
    transition: transform 0.12s, box-shadow 0.15s;
    background: var(--bg-card);
}

.custom-card:hover {
    transform: translateY(-3px);
    box-shadow: 0 10px 25px rgba(0,0,0,0.08);
    border-color: #cbd5e1;
}

.custom-card .case-number {
    font-size: 0.75rem;
    font-weight: 800;
    color: var(--brand);
    background: #e2e8f0;
    padding: 0.15rem 0.5rem;
    border-radius: 0.375rem;
    white-space: nowrap;
}

.custom-card .card-title {
    color: var(--accent);
    cursor: pointer;
    font-weight: 600;
    font-size: 0.95rem;
    line-height: 1.35;
}

.custom-card .card-title:hover {
    color: #0b5ed7;
    text-decoration: underline;
}

.custom-card .problem-summary {
    display: -webkit-box;
    -webkit-line-clamp: 3;
    line-clamp: 3;
    -webkit-box-orient: vertical;
    overflow: hidden;
    color: var(--muted);
    font-size: 0.82rem;
    line-height: 1.45;
}

/* Modal de documentación */
.doc-modal .modal-body-custom {
    padding: 1.5rem;
    background: #f8fafc;
}

.doc-section {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: 0.5rem;
    padding: 1rem 1.25rem;
    margin-bottom: 1rem;
    box-shadow: 0 1px 3px rgba(0,0,0,0.04);
}

.doc-section:last-child {
    margin-bottom: 0;
}

.doc-section h3 {
    font-size: 0.95rem;
    font-weight: 700;
    color: var(--brand);
    margin-bottom: 0.6rem;
    border-bottom: 1px solid var(--border);
    padding-bottom: 0.4rem;
}

.doc-section p,
.doc-section li {
    font-size: 0.85rem;
    line-height: 1.5;
    color: var(--text);
}

.doc-section ul,
.doc-section ol {
    padding-left: 1.1rem;
    margin-bottom: 0.6rem;
}

.doc-section code {
    background: #e2e8f0;
    padding: 0.1rem 0.3rem;
    border-radius: 0.25rem;
    font-size: 0.8rem;
}

/* Modal */
.modal-backdrop {
    position: fixed;
    inset: 0;
    background: rgba(15, 23, 42, 0.55);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1050;
    padding: 1.5rem;
    overflow-y: auto;
}

.modal-custom {
    background: var(--bg-card);
    border-radius: 0.75rem;
    box-shadow: 0 24px 60px rgba(0,0,0,0.35);
    width: 100%;
    max-width: 760px;
    margin: auto;
    display: flex;
    flex-direction: column;
    max-height: calc(100vh - 3rem);
    overflow: hidden;
}

.modal-header-custom {
    background: #f8fafc;
    border-bottom: 1px solid var(--border);
    padding: 0.9rem 1.25rem;
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-shrink: 0;
}

.modal-header-custom h2 {
    font-size: 1.05rem;
    font-weight: 700;
    color: var(--text);
    margin: 0;
    flex: 1;
    padding-right: 1rem;
    line-height: 1.35;
}

.modal-body-custom {
    padding: 1.25rem;
    overflow-y: auto;
    flex: 1;
    scrollbar-width: thin;
    scrollbar-color: #cbd5e1 #f1f5f9;
}

.modal-body-custom::-webkit-scrollbar {
    width: 8px;
}

.modal-body-custom::-webkit-scrollbar-track {
    background: #f1f5f9;
    border-radius: 4px;
}

.modal-body-custom::-webkit-scrollbar-thumb {
    background: #cbd5e1;
    border-radius: 4px;
}

.modal-body-custom::-webkit-scrollbar-thumb:hover {
    background: #94a3b8;
}

.modal-footer-custom {
    background: #f8fafc;
    border-top: 1px solid var(--border);
    padding: 0.75rem 1.25rem;
    display: flex;
    justify-content: flex-end;
    gap: 0.5rem;
    flex-shrink: 0;
}

.modal-close {
    background: #fff;
    border: 1px solid var(--border);
    border-radius: 50%;
    width: 2rem;
    height: 2rem;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.25rem;
    color: var(--muted);
    cursor: pointer;
    padding: 0;
    transition: all 0.15s;
}

.modal-close:hover {
    background: #f1f5f9;
    color: var(--text);
    border-color: #cbd5e1;
}

/* Secciones del popup */
.popup-section {
    margin-bottom: 1.25rem;
    padding: 1rem;
    background: #f8fafc;
    border: 1px solid var(--border);
    border-radius: 0.6rem;
}

.popup-section-title {
    font-size: 0.72rem;
    font-weight: 800;
    text-transform: uppercase;
    letter-spacing: 0.07em;
    color: var(--brand);
    margin-bottom: 0.75rem;
    padding-bottom: 0.4rem;
    border-bottom: 1px solid var(--border);
}

.popup-field-row {
    margin-bottom: 0.6rem;
}

.popup-field-row:last-child {
    margin-bottom: 0;
}

.popup-field-label {
    font-size: 0.74rem;
    font-weight: 600;
    color: var(--muted);
    margin-bottom: 0.15rem;
    line-height: 1.3;
}

.popup-field-value {
    font-size: 0.88rem;
    line-height: 1.45;
    color: var(--text);
}

.popup-badges-row {
    display: flex;
    gap: 0.35rem;
    flex-wrap: wrap;
    margin-bottom: 1rem;
}

/* Referencias */
.reference-item {
    padding: 0.5rem 0;
    border-bottom: 1px solid #e2e8f0;
    font-size: 0.85rem;
}

.reference-item:last-child {
    border-bottom: none;
}

.reference-item a {
    color: var(--accent);
    font-weight: 600;
    text-decoration: none;
}

.reference-item a:hover {
    text-decoration: underline;
}

.reference-meta {
    font-size: 0.76rem;
    color: var(--muted);
    margin-top: 0.1rem;
}

/* Referencias en modo edición */
.ref-edit-row {
    display: grid;
    grid-template-columns: 2fr 2fr 1fr 1fr auto;
    gap: 0.4rem;
    margin-bottom: 0.5rem;
    align-items: start;
}

/* Tarjeta descartada */
.card-discarded {
    background: #fef2f2;
    border-color: #fecaca;
}

.card-discarded .card-body {
    opacity: 0.85;
}

/* Campos Sixtema en tarjetas */
.sixtema-card-block {
    margin-top: 0.5rem;
    padding-top: 0.5rem;
    border-top: 1px dashed #c7d2fe;
}

.sixtema-card-field {
    display: flex;
    flex-direction: column;
    margin-bottom: 0.35rem;
}

.sixtema-card-label {
    font-size: 0.68rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--brand);
    margin-bottom: 0.1rem;
}

.sixtema-card-value {
    font-size: 0.78rem;
    color: var(--text);
    display: -webkit-box;
    -webkit-line-clamp: 2;
    line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

/* Sección Sixtema en popup */
.popup-section-sixtema {
    border: 2px solid var(--brand);
    background: #f0f7ff;
}

.popup-section-sixtema .popup-section-title {
    color: var(--brand);
    border-bottom-color: var(--brand);
}

/* Categorías técnicas */
.tech-cats-edit {
    display: flex;
    flex-wrap: wrap;
    gap: 0.4rem 1.25rem;
}

.tech-cats-edit .form-check {
    margin-bottom: 0;
    min-width: 180px;
}

/* Utilidades */
.empty-state {
    text-align: center;
    padding: 3rem 1rem;
    color: var(--muted);
    font-size: 0.95rem;
    background: var(--bg-card);
    border-radius: 0.75rem;
    border: 1px solid var(--border);
}

/* Responsive */
@media (max-width: 768px) {
    .cards-grid {
        grid-template-columns: 1fr;
    }

    .summary-table .case-title {
        max-width: 220px;
    }

    .ref-edit-row {
        grid-template-columns: 1fr;
        gap: 0.3rem;
    }

    .modal-backdrop {
        padding: 1rem;
    }

    .modal-custom {
        max-height: calc(100vh - 2rem);
        border-radius: 0.5rem;
    }

    .modal-header-custom,
    .modal-body-custom,
    .modal-footer-custom {
        padding-left: 1rem;
        padding-right: 1rem;
    }
}
