/* admin.css */

.admin-panel-container {
    padding: 0;
    margin-top: 20px;
}

.table-responsive {
    width: 100%;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    border-radius: 10px;
    box-shadow: 0 5px 15px var(--shadow-light);
    background-color: #ffffff;
    border: 1px solid var(--border-color);
    overscroll-behavior-x: contain;
}

.admin-table {
    width: 100%;
    border-collapse: separate;
    border-spacing: 0;
    font-family: 'Poppins', sans-serif;
    min-width: 800px; 
}

/* Encabezados */
.admin-table thead th {
    background: var(--header-bg);
    color: #ffffff;
    padding: 15px 20px;
    font-weight: 500;
    text-transform: uppercase;
    font-size: 0.9rem;
    letter-spacing: 0.5px;
    text-align: left;
    white-space: nowrap;
    border: none;
}

/* Celdas */
.admin-table td {
    padding: 12px 20px;
    text-align: left;
    color: var(--text-color);
    border-bottom: 1px solid var(--border-color);
    font-size: 0.95rem;
    vertical-align: middle;
    transition: all var(--transition-speed);
}

/* Filas alternas y Hover */
.admin-table tbody tr:nth-child(even) { 
    background-color: var(--even-row-bg); 
}
.admin-table tbody tr:hover {
     background-color: var(--hover-row-bg); 
    }
.admin-table tbody tr:last-child td { 
    border-bottom: none; 
}

/* Interruptor administrador */
.switch-admin {
    position: relative;
    display: inline-block;
    width: 42px;
    height: 22px;
}

.switch-admin input {
    opacity: 0;
    width: 0;
    height: 0;
}

.switch-admin span {
    position: absolute;
    cursor: pointer;
    inset: 0;
    background-color: #ccc;
    border-radius: 20px;
    transition: .2s;
}

.switch-admin span:before {
    content: "";
    position: absolute;
    height: 18px;
    width: 18px;
    left: 2px;
    bottom: 2px;
    background: white;
    border-radius: 50%;
    transition: .2s;
    box-shadow: 0 1px 3px rgba(0,0,0,.3);
}


/* Activado */
.switch-admin input:checked + span {
    background-color: #198754;
}

.switch-admin input:checked + span:before {
    transform: translateX(20px);
}


/* Admin protegido */
.switch-admin input:disabled + span {
    background-color: #0d6efd;
    cursor: not-allowed;
    opacity: .8;
}

.tag {
    padding: 6px 12px;
    border-radius: 20px;
    font-size: 0.75rem;
    font-weight: 600;
    text-transform: uppercase;
    display: inline-block;
    white-space: nowrap;
}
.tag.venta { 
    background-color: #e0f7fa; color: #006064; border: 1px solid #b2ebf2; 
}
.tag.compra { 
    background-color: #e8f5e9; color: #1b5e20; border: 1px solid #c8e6c9; 
}

.acciones-wrapper {
    display: flex;
    gap: 8px;
    align-items: center;
    white-space: nowrap; 
}

.btn-accion {
    padding: 6px 14px;
    border-radius: 5px;
    text-decoration: none;
    font-size: 0.85rem;
    font-weight: 500;
    cursor: pointer;
    border: 1px solid transparent;
    display: inline-flex;
    align-items: center;
    justify-content: center;
}

.btn-ver { 
    background-color: var(--primary-color); color: white; 
}
.btn-ver:hover { 
    background-color: var(--secondary-color); transform: translateY(-2px); 
}

.btn-borrar { 
    background-color: rgb(255, 105, 105); color: white; 
}
.btn-borrar:hover { 
    background-color: var(--danger-color); color: white; transform: translateY(-2px); 
}

.admin-modal-overlay {
    display: none; 
    position: fixed; top: 0; left: 0; width: 100%; height: 100%;
    background-color: rgba(0, 0, 0, 0.65);
    z-index: 99999;
    justify-content: center; align-items: center;
    backdrop-filter: blur(4px);
}

.admin-modal-overlay.activo { 
    display: flex !important; 
}


.anuncio-card-preview {
    background: #fff; width: 90%; max-width: 500px; border-radius: 12px;
    box-shadow: 0 25px 50px rgba(0,0,0,0.5);
    position: relative; overflow: hidden;
    animation: slideUp 0.3s ease;
    display: flex; flex-direction: column;
}

@keyframes slideUp { 
    from { 
        transform: translateY(40px); opacity: 0; } 
        to { transform: translateY(0); opacity: 1; } 
}

.preview-header {
    background: var(--header-bg);
    padding: 20px 70px 20px 25px; 
    color: white;
    display: flex;
    justify-content: space-between;
    align-items: center;
    position: relative;
}

.preview-ref { 
    background: rgba(255, 255, 255, 0.25); padding: 4px 12px; border-radius: 20px; font-weight: 600; font-size: 0.9rem; 
}
#prev-fecha { font-size: 0.9rem; opacity: 0.9; 
}

.preview-body {
    padding: 30px; color: #444; font-size: 1.05rem;
    line-height: 1.8; 
    word-wrap: break-word; overflow-wrap: break-word;
    max-height: 55vh; overflow-y: auto; background: white;
}
.preview-body p { 
    margin-bottom: 15px; 
}
.preview-body p:last-child { 
    margin-bottom: 0; 
}

.preview-footer { 
    background: #f8f9fa; padding: 15px 25px; border-top: 1px solid #eee; text-align: right; 
}
.preview-badge { 
    display: inline-block; background: var(--primary-color); color: white; padding: 6px 15px; border-radius: 6px; font-size: 0.9rem; font-weight: 500;
 }

.cerrar-preview {
    position: absolute;
    top: 22px; 
    right: 25px; 
    color: white;
    font-size: 2rem;
    cursor: pointer;
    line-height: 0.8;
    opacity: 0.8;
    z-index: 10;
    transition: opacity 0.2s;
}
.cerrar-preview:hover {
    opacity: 1;
}


.confirmation-card {
    background: #fff;
    padding: 30px;
    border-radius: 12px;
    max-width: 400px;
    width: 90%;
    text-align: center;
    box-shadow: 0 25px 50px rgba(0,0,0,0.4);
    animation: slideUp 0.3s ease;
}

.confirmation-card h3 {
    margin-top: 0;
    color: var(--danger-color);
    margin-bottom: 15px;
}

.confirmation-actions {
    display: flex;
    justify-content: center;
    gap: 15px;
    margin-top: 25px;
}

.confirmation-actions button {
    padding: 10px 20px;
    border: none;
    border-radius: 6px;
    cursor: pointer;
    font-weight: 600;
    transition: transform 0.2s;
}

.confirmation-actions button:hover {
    transform: translateY(-2px);
}

.btn-cancelar {
    background-color: #e0e0e0;
    color: #333;
}

.btn-confirmar {
    background-color: var(--danger-color);
    color: white;
    box-shadow: 0 4px 10px rgba(211, 47, 47, 0.3);
}

/* Select de privilegios */
.select-privilegio {
    appearance: none;
    -webkit-appearance: none;
    -moz-appearance: none;

    background-color: #ffffff;
    color: var(--text-color);

    border: 1px solid var(--border-color);
    border-radius: 6px;

    padding: 8px 35px 8px 12px;
    font-family: 'Poppins', sans-serif;
    font-size: 0.9rem;
    font-weight: 500;

    cursor: pointer;
    transition: all var(--transition-speed);

    background-image: linear-gradient(45deg, transparent 50%, var(--primary-color) 50%),
                      linear-gradient(135deg, var(--primary-color) 50%, transparent 50%);
    background-position:
        calc(100% - 15px) 50%,
        calc(100% - 10px) 50%;
    background-size:
        5px 5px,
        5px 5px;
    background-repeat: no-repeat;
}

.select-privilegio:hover {
    border-color: var(--primary-color);
    background-color: #fafafa;
}

.select-privilegio:focus {
    outline: none;
    border-color: var(--primary-color);
    box-shadow: 0 0 0 3px rgba(0, 123, 255, 0.15);
}

.select-privilegio option {
    font-family: 'Poppins', sans-serif;
    font-size: 0.9rem;
    color: var(--text-color);
}

/* --- MEDIA QUERIES --- */
@media screen and (max-width: 940px) {
    .table-responsive {
        display: block;
        overflow-x: auto;
        white-space: nowrap;
    }

    .admin-table td, .admin-table th {
        padding: 12px 15px;
    }
    
    .acciones-wrapper {
        justify-content: flex-start;
    }
}

/* Lista de adjuntos: con scroll propio y sin recortar las carpetas */
#lista-adjuntos-persona {
    max-height: 340px;
    overflow-y: auto;
    padding-right: 4px;
}

.adjuntos-carpeta {
    flex-shrink: 0;          /* evita que la carpeta se encoja y recorte los archivos */
    height: auto !important;
    margin-bottom: 10px;
    border: 1px solid #d7dce2;
    border-radius: 8px;
    overflow: visible;
    background: #fff;
}
.adjuntos-carpeta > summary {
    cursor: pointer;
    padding: 8px 12px;
    background: #f4f6f8;
    border-radius: 8px 8px 0 0;
    font-weight: 600;
    text-align: left;
    list-style: none;
}
.adjuntos-carpeta > summary::-webkit-details-marker { display: none; }
.adjuntos-carpeta:not([open]) > summary { border-radius: 8px; }

.adjuntos-carpeta .adjunto-item {
    flex-shrink: 0;
    height: auto !important;
    padding: 8px 12px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    border-top: 1px solid #eef0f3;
}
.adjuntos-carpeta .adjunto-info { flex: 1; min-width: 0; text-align: left; }
.adjuntos-carpeta .adjunto-nombre { word-break: break-all; }
.adjuntos-carpeta .adjunto-acciones { display: flex; align-items: center; gap: 6px; flex-shrink: 0; }

/* Selector de carpeta de cada archivo, más compacto */
/* Selector de carpeta de cada archivo, más compacto (con el texto siempre visible) */
.adjunto-mover {
    width: 160px;
    max-width: 100%;
    height: auto !important;
    min-height: 32px;
    box-sizing: border-box;
    padding: 5px 26px 5px 8px !important;
    font-size: 13px !important;
    line-height: 1.3 !important;
    text-overflow: ellipsis;
}
.adjuntos-carpeta .adjunto-item { flex-wrap: wrap; }
.adjuntos-carpeta .adjunto-info { flex: 1 1 200px; }
.adjuntos-carpeta .adjunto-acciones { flex-wrap: wrap; justify-content: flex-end; }

/* ===== Archivos de la Comunidad: barra de botones ===== */
.comunidad-barra { display:flex; gap:10px; flex-wrap:wrap; align-items:center; margin-bottom:14px; }
.btn-comunidad-sec {
    display:inline-flex; align-items:center; gap:8px;
    padding:10px 16px; border:2px solid #d32f2f; border-radius:8px;
    background:#fff; color:#d32f2f; font-weight:600; font-size:.95rem; cursor:pointer;
    transition:background .15s, color .15s;
}
.btn-comunidad-sec:hover { background:#d32f2f; color:#fff; }
.btn-comunidad-sec .contador {
    min-width:22px; padding:1px 7px; border-radius:11px; text-align:center;
    background:#d32f2f; color:#fff; font-size:.8rem;
}
.btn-comunidad-sec:hover .contador { background:#fff; color:#d32f2f; }

/* ===== Ventana de categorías ===== */
#modal-categorias-comunidad .cat-card {
    width:94%; max-width:560px; max-height:88vh; display:flex; flex-direction:column;
    background:#fff; border-radius:12px; padding:0; overflow:hidden; text-align:left;
}
.cat-cabecera {
    display:flex; align-items:center; justify-content:space-between;
    padding:16px 20px; border-bottom:1px solid #e5e5e5;
}
.cat-cabecera h3 { margin:0; font-size:1.15rem; color:#d32f2f; }
.cat-cerrar { background:none; border:none; font-size:1.2rem; color:#777; cursor:pointer; padding:4px 8px; }
.cat-cerrar:hover { color:#d32f2f; }
.cat-nueva { display:flex; gap:8px; padding:14px 20px; background:#fafafa; border-bottom:1px solid #e5e5e5; }
.cat-nueva input {
    flex:1; padding:9px 12px; border:1px solid #ccc; border-radius:6px; font-size:.95rem;
}
.cat-nueva input:focus, .cat-fila input:focus { outline:none; border-color:#d32f2f; box-shadow:0 0 0 2px rgba(211,47,47,.15); }
.cat-nueva button {
    padding:9px 16px; border:none; border-radius:6px; background:#d32f2f; color:#fff; font-weight:600; cursor:pointer;
}
.cat-lista { flex:1; overflow-y:auto; padding:12px 20px; min-height:80px; }
.cat-fila {
    display:flex; align-items:center; gap:8px; padding:6px 0; border-bottom:1px solid #f0f0f0;
}
.cat-fila input {
    flex:1; min-width:0; padding:7px 10px; border:1px solid transparent; border-radius:6px;
    background:#f6f6f6; font-size:.95rem;
}
.cat-fila input:hover { border-color:#ccc; }
.cat-fila input.modificada { border-color:#d32f2f; background:#fff; }
.cat-total { font-size:.8rem; color:#888; white-space:nowrap; min-width:70px; text-align:right; }
.cat-fila button {
    width:32px; height:32px; border:none; border-radius:6px; background:transparent; cursor:pointer; font-size:.95rem;
}
.cat-fila .cat-guardar { color:#2e7d32; }
.cat-fila .cat-guardar:disabled { color:#ccc; cursor:default; }
.cat-fila .cat-guardar:not(:disabled):hover { background:#e8f5e9; }
.cat-fila .cat-borrar { color:#d32f2f; }
.cat-fila .cat-borrar:hover { background:#ffebee; }
.cat-vacia { text-align:center; color:#888; padding:24px 0; margin:0; }
.cat-pie { display:flex; justify-content:flex-end; padding:12px 20px; border-top:1px solid #e5e5e5; }