/* ============================================
   Zoho CRM Integration Card
   ============================================ */

.zoho-card {
    background: #f8fafc;
    border: 1px solid #e2e8f0;
    border-radius: var(--radius);
    margin-bottom: 12px;
    overflow: hidden;
}

.zoho-card-header {
    background: #e8f5e9;
    border-bottom: 1px solid #a5d6a7;
    color: #2e7d32;
    padding: 10px 14px;
    display: flex;
    align-items: center;
    gap: 10px;
    flex-wrap: wrap;
}

.zoho-icon {
    font-size: 1rem;
}

.zoho-title {
    font-weight: 600;
    font-size: 0.9rem;
    flex: 1;
    color: #1b5e20;
}

/* Título clicable: abre la ficha de la localización */
.zoho-title-link {
    cursor: pointer;
    text-decoration: underline dotted;
    text-underline-offset: 3px;
}

.zoho-title-link:hover {
    color: #2e7d32;
    text-decoration: underline;
}

.zoho-codigo {
    background: #c8e6c9;
    color: #2e7d32;
    padding: 2px 8px;
    border-radius: 3px;
    font-size: 0.7rem;
    font-weight: 600;
}

.zoho-estado {
    padding: 2px 8px;
    border-radius: 3px;
    font-size: 0.65rem;
    font-weight: 600;
    text-transform: uppercase;
}

.zoho-estado.estado-activa {
    background: #10b981;
    color: white;
}

.zoho-estado.estado-inactiva {
    background: #ef4444;
    color: white;
}

.zoho-estado.estado-alta {
    background: #3b82f6;
    color: white;
}

.zoho-badges {
    display: flex;
    flex-wrap: wrap;
    gap: 4px;
    padding: 8px 14px;
    background: #ffffff;
    border-bottom: 1px solid #e2e8f0;
}

.zoho-badge {
    padding: 2px 8px;
    border-radius: 3px;
    font-size: 0.6rem;
    font-weight: 600;
    text-transform: uppercase;
}

.zoho-badge-categoria {
    background: #1e40af;
    color: white;
}

.zoho-badge-subcategoria {
    background: #7c3aed;
    color: white;
}

.zoho-badge-caracteristica {
    background: #0d9488;
    color: white;
}

.zoho-card-body {
    padding: 10px 14px;
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 10px;
}

.zoho-section {
    margin-bottom: 0;
}

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

.zoho-section-title {
    font-size: 0.65rem;
    font-weight: 600;
    color: #1e40af;
    text-transform: uppercase;
    margin-bottom: 6px;
    padding-bottom: 3px;
    border-bottom: 1px solid #e2e8f0;
    letter-spacing: 0.03em;
}

.zoho-fields {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 6px;
}

.zoho-field {
    display: flex;
    flex-direction: column;
    gap: 1px;
}

.zoho-field-full {
    grid-column: 1 / -1;
}

.zoho-label {
    font-size: 0.58rem;
    color: #64748b;
    font-weight: 500;
    text-transform: uppercase;
    letter-spacing: 0.03em;
}

.zoho-value {
    font-size: 0.75rem;
    color: #1e293b;
}

.zoho-tarifas {
    grid-template-columns: repeat(auto-fill, minmax(80px, 1fr));
}

.zoho-precio {
    font-weight: 600;
    color: #1e40af;
    font-size: 0.9rem;
}

.zoho-observaciones {
    font-size: 0.72rem;
    color: #475569;
    line-height: 1.4;
    margin: 0;
    background: #f1f5f9;
    padding: 6px 8px;
    border-radius: 4px;
}

.zoho-link {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    color: #1e40af;
    text-decoration: none;
    font-size: 0.7rem;
    padding: 4px 10px;
    background: #dbeafe;
    border-radius: 4px;
    transition: all 0.15s ease;
    margin-top: 4px;
}

.zoho-link:hover {
    background: #bfdbfe;
    color: #1e3a8a;
}

.zoho-link-inline {
    color: #1e40af;
    text-decoration: none;
}

.zoho-link-inline:hover {
    text-decoration: underline;
}

.zoho-card-body pre {
    background: rgba(255, 255, 255, 0.7);
    padding: 12px;
    border-radius: 4px;
    font-size: 0.75rem;
    overflow-x: auto;
    margin: 0;
}

@media (max-width: 768px) {
    .zoho-fields {
        grid-template-columns: 1fr;
    }

    .zoho-tarifas {
        grid-template-columns: repeat(2, 1fr);
    }
}

/* ============================================
   Tags multi-select (Buscar Localizaciones)
   ============================================ */

.filter-group-tags {
    min-width: 260px;
}

.tags-multiselect {
    position: relative;
    width: 100%;
}

.tags-multiselect-control {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 6px;
    padding: 6px 10px;
    border: 1px solid #d1d5db;
    border-radius: 4px;
    background: #fff;
    cursor: pointer;
    font-size: 0.82rem;
    color: #1e293b;
    min-height: 32px;
    box-sizing: border-box;
    transition: border-color 0.15s;
}

.tags-multiselect-control:hover {
    border-color: #94a3b8;
}

.tags-multiselect-control.has-selection {
    border-color: var(--primary, #22c55e);
    background: #f0fdf4;
}

.tags-multiselect-placeholder {
    flex: 1;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    color: #64748b;
}

.tags-multiselect-control.has-selection .tags-multiselect-placeholder {
    color: #1e293b;
    font-weight: 500;
}

.tags-multiselect-arrow {
    font-size: 0.7rem;
    color: #94a3b8;
    transition: transform 0.15s;
}

.tags-multiselect.open .tags-multiselect-arrow {
    transform: rotate(180deg);
}

.tags-multiselect-dropdown {
    display: none;
    position: absolute;
    top: calc(100% + 4px);
    left: 0;
    min-width: 100%;
    width: max-content;
    max-height: 260px;
    overflow-y: auto;
    background: #fff;
    border: 1px solid #d1d5db;
    border-radius: 4px;
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.15);
    z-index: 2000;
    padding: 4px;
}

.tags-multiselect.open .tags-multiselect-dropdown {
    display: block;
}

.tags-multiselect-option {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 6px 8px;
    font-size: 0.78rem;
    color: #1e293b;
    cursor: pointer;
    border-radius: 3px;
    transition: background 0.1s;
}

.tags-multiselect-option:hover {
    background: #f1f5f9;
}

.tags-multiselect-option input[type="checkbox"] {
    margin: 0;
    cursor: pointer;
}

.tags-multiselect-option-name {
    flex: 1;
}

.tags-multiselect-option-count {
    color: #94a3b8;
    font-size: 0.72rem;
}

/* ============================================
   Location Search
   ============================================ */

.locations-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(min(300px, 100%), 1fr));
    gap: 12px;
}

@media (max-width: 768px) {
    .locations-grid {
        grid-template-columns: 1fr;
    }
}

/* Browse Folders: Account search filter */
#section-browse-folders .section-header {
    justify-content: flex-start;
}
.browse-folders-search-wrapper {
    flex: 0 1 350px;
    min-width: 220px;
}
.browse-folders-search-wrapper .autocomplete-combo {
    position: relative;
}
.browse-folders-search-wrapper .autocomplete-combo input[type="text"],
.browse-folders-search-wrapper .autocomplete-combo input[type="search"] {
    font-size: 1rem;
    padding: 10px 32px 10px 36px;
    height: 44px;
}
.browse-folders-search-wrapper .autocomplete-combo-icon {
    top: 14px;
    width: 16px;
    height: 16px;
}
.browse-folders-search-wrapper .autocomplete-combo-clear {
    top: 8px;
    right: 8px;
    width: 26px;
    height: 26px;
    font-size: 1.1rem;
}
.browse-folders-search-wrapper .autocomplete-dropdown {
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    z-index: 100;
    max-height: 250px;
    overflow-y: auto;
}
@media (max-width: 600px) {
    .browse-folders-search-wrapper {
        flex: 1 1 100%;
        order: 3;
    }
}

/* ============================================
   Folder Thumbnail Cards
   ============================================ */

.folders-thumbnail-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
    gap: 12px;
    align-content: start;
}

.folder-thumbnail-card {
    background: #ffffff;
    border: 1px solid #e5e7eb;
    border-radius: var(--radius);
    overflow: hidden;
    cursor: pointer;
    transition: all 0.12s ease;
}

.folder-thumbnail-card:hover {
    border-color: var(--primary);
    box-shadow: var(--shadow-md);
}

.folder-thumbnail {
    width: 100%;
    aspect-ratio: 16/10;
    background-size: cover;
    background-position: center;
    background-color: #f8fafc;
    display: flex;
    align-items: center;
    justify-content: center;
    position: relative;
}

.folder-thumbnail-placeholder {
    font-size: 1.5rem;
    opacity: 0.3;
}

.folder-thumbnail-info {
    padding: 4px 6px;
    background: #fafbfc;
    text-align: center;
}

.folder-thumbnail-name {
    font-size: 0.68rem;
    font-weight: 600;
    color: #2d5a3d;
    margin: 0;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    line-height: 1.2;
    background: #e8f5e9;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 2px 10px;
    border-radius: 12px;
    letter-spacing: 0.3px;
}

.folder-thumbnail-count,
.folder-thumbnail-meta {
    font-size: 0.8rem;
    color: var(--text-secondary);
}

.folder-thumbnail-local-name {
    display: block;
    font-size: 0.7rem;
    color: var(--text-secondary);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    margin: 1px 0;
}

.folder-thumbnail-meta--secondary {
    display: block;
    font-size: 0.7rem;
    color: var(--text-muted);
}

/* No-photo location cards */
.folder-thumbnail-card.no-photos {
    opacity: 0.85;
}

.folder-thumbnail--empty {
    background-color: #f1f5f9;
    border-bottom: 1px dashed #cbd5e1;
}

.folder-thumbnail--empty .folder-thumbnail-placeholder {
    font-size: 2rem;
    opacity: 0.25;
    filter: grayscale(1);
}

.no-photos-badge {
    position: absolute;
    bottom: 6px;
    right: 6px;
    background: rgba(100, 116, 139, 0.85);
    color: #fff;
    font-size: 0.6rem;
    font-weight: 600;
    padding: 2px 6px;
    border-radius: 4px;
    text-transform: uppercase;
    letter-spacing: 0.03em;
}

.search-tag {
    padding: 1px 4px;
    border-radius: 2px;
    font-size: 0.55rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.03em;
}

.search-tag-match {
    background: var(--success-light);
    color: #047857;
}

.search-tag-dim {
    background: #f1f5f9;
    color: #94a3b8;
}

.search-highlight {
    background: var(--success-light);
    color: #047857;
    padding: 0 2px;
    border-radius: 2px;
    font-weight: 600;
}

/* Mobile folder thumbnail overrides moved to main 768px media query block */

/* ============================================
   Debug JSON Display
   ============================================ */

.debug-json {
    background: #1e1e1e;
    border-radius: var(--radius);
    padding: 16px;
    margin-bottom: 20px;
    overflow: hidden;
}

.debug-section {
    margin-bottom: 16px;
}

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

.debug-section h4 {
    color: #4fc3f7;
    margin: 0 0 8px 0;
    font-size: 0.85rem;
}

.debug-json pre {
    background: #2d2d2d;
    color: #a5d6a7;
    padding: 12px;
    border-radius: 4px;
    font-size: 0.75rem;
    overflow-x: auto;
    margin: 0;
    white-space: pre-wrap;
    word-break: break-word;
    max-height: 300px;
    overflow-y: auto;
}

.sync-modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.5);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
    animation: fadeIn 0.2s ease;
}

@keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

.sync-modal {
    background: white;
    border-radius: var(--radius);
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
    max-width: 400px;
    width: 90%;
    overflow: hidden;
    animation: slideUp 0.3s ease;
}

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

.sync-modal-header {
    padding: 20px 24px;
    display: flex;
    align-items: center;
    gap: 12px;
}

.sync-modal-header.sync-success {
    background: linear-gradient(135deg, #16a34a 0%, #15803d 100%);
    color: white;
}

.sync-modal-header.sync-error {
    background: linear-gradient(135deg, #dc2626 0%, #b91c1c 100%);
    color: white;
}

.sync-icon {
    font-size: 1.5rem;
}

.sync-title {
    font-size: 1.1rem;
    font-weight: 600;
}

.sync-modal-body {
    padding: 24px;
    text-align: left;
}

.sync-step-result {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 0;
    border-bottom: 1px solid var(--border-color, #e5e7eb);
}

.sync-step-result:last-child {
    border-bottom: none;
}

.sync-step-icon {
    flex-shrink: 0;
    font-size: 1.1rem;
}

.sync-step-label {
    font-weight: 600;
    font-size: 0.9rem;
    color: var(--text-primary);
    min-width: 0;
}

.sync-step-detail {
    margin-left: auto;
    font-size: 0.85rem;
    color: var(--text-secondary);
    text-align: right;
    flex-shrink: 0;
}

.sync-modal-footer {
    padding: 16px 24px;
    background: #f8f9fa;
    display: flex;
    justify-content: center;
}

.sync-modal-footer .btn-primary {
    min-width: 120px;
}

/* ============================================
   Toggle Form Button
   ============================================ */

.btn-toggle-form {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 6px 14px;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    cursor: pointer;
    font-size: 0.8rem;
    font-weight: 500;
    color: var(--text-secondary);
    transition: all 0.2s;
}

.btn-toggle-form:hover {
    background: var(--bg-hover);
    color: var(--text-primary);
    border-color: var(--primary);
}

/* Mostrar u ocultar la búsqueda: resaltado en verde para que se vea */
#zohoFormToggleBtn {
    background: var(--success);
    border-color: var(--success);
    color: var(--primary-text);
}

#zohoFormToggleBtn:hover {
    background: var(--success);
    color: var(--primary-text);
    filter: brightness(0.92);
}

/* Criterios de la búsqueda activa, visibles con el formulario plegado */
.zoho-criterios {
    margin: 0 0 12px;
    padding: 8px 12px;
    background: var(--success-light);
    border: 1px solid var(--success);
    border-radius: var(--radius);
    font-size: 0.85rem;
    color: var(--text-primary);
}

.zoho-criterios b {
    font-weight: 600;
}

/* Buscar por código: sugerencias bajo el campo y resto de filtros apagados */
.filter-group-codigo {
    position: relative;
}

.codigo-sugerencias {
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    z-index: 30;
    max-height: 260px;
    overflow-y: auto;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: var(--shadow-md);
}

.codigo-sugerencia {
    display: block;
    width: 100%;
    padding: 6px 10px;
    border: none;
    background: none;
    text-align: left;
    font-size: 0.85rem;
    color: var(--text-primary);
    cursor: pointer;
}

.codigo-sugerencia:hover,
.codigo-sugerencia.activa {
    background: var(--bg-hover);
}

.codigo-sugerencia small {
    color: var(--text-muted);
}

.codigo-sugerencias .codigo-vacio {
    padding: 6px 10px;
    font-size: 0.85rem;
    color: var(--text-muted);
}

.zoho-por-codigo .zoho-form-main .filter-group:not(.filter-group-codigo),
.zoho-por-codigo .search-mode-toggle,
.zoho-por-codigo .zoho-image-search,
.zoho-por-codigo .sunlocs-controls {
    opacity: 0.45;
    pointer-events: none;
}

.toggle-form-icon {
    font-size: 0.65rem;
    transition: transform 0.3s ease;
    display: inline-block;
}

.btn-toggle-form.collapsed .toggle-form-icon {
    transform: rotate(180deg);
}

.zoho-search-form.collapsed > .zoho-form-main {
    display: none;
}


/* localización borrada entre las sugerencias de código: gris y con su fecha */
.codigo-sugerencia.codigo-borrada { color: var(--text-muted); }
.codigo-sugerencia.codigo-borrada b { text-decoration: line-through; }
.codigo-borrada-fecha { display: inline-block; margin-left: 4px; padding: 0 6px; border: 1px dashed var(--border); border-radius: 999px; font-size: 0.75rem; }

/* ficha de solo lectura de una localización borrada */
.loc-borrada h2 code { font-size: 1rem; margin-right: 6px; }
.loc-borrada-aviso { margin: 10px 0 16px; padding: 10px 14px; border-radius: var(--radius-lg); background: rgba(239, 68, 68, 0.08); color: var(--error); font-size: 0.9rem; }
.loc-borrada-titulo { margin: 18px 0 8px; font-size: 0.95rem; }
.loc-borrada-datos { display: grid; grid-template-columns: repeat(auto-fill, minmax(180px, 1fr)); gap: 8px 16px; }
.loc-borrada-dato span { display: block; font-size: 0.75rem; color: var(--text-muted); }
.loc-borrada-dato strong { font-weight: 500; }
.loc-borrada-desc, .loc-borrada-nota { color: var(--text-secondary); font-size: 0.9rem; }
.loc-borrada-fotos { display: grid; grid-template-columns: repeat(auto-fill, minmax(110px, 1fr)); gap: 8px; }
.loc-borrada-fotos img { width: 100%; aspect-ratio: 4 / 3; object-fit: cover; border-radius: var(--radius); display: block; }
.loc-borrada-usos { margin: 0; padding-left: 18px; }
.loc-borrada-usos li { margin: 4px 0; }
.loc-borrada-usos small { color: var(--text-muted); margin-left: 6px; }
