:root {
    --bg-color: #0f172a;
    --surface-color: #1e293b;
    --surface-light: #334155;
    --primary-color: #3b82f6;
    --primary-hover: #2563eb;
    --text-main: #f8fafc;
    --text-muted: #94a3b8;
    --border-color: #334155;
    --danger-color: #ef4444;
    --success-color: #10b981;
    --warning-color: #f59e0b;
    --glass-bg: rgba(30, 41, 59, 0.7);
    --glass-border: rgba(255, 255, 255, 0.1);
    --nav-height: 70px;
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    font-family: 'Outfit', sans-serif;
    -ms-overflow-style: none; /* IE y Edge */
    scrollbar-width: none; /* Firefox */
}

::-webkit-scrollbar {
    display: none; /* Chrome, Safari y Opera */
}

/* Prevenir salto de diseño (FOUT) cuando cargan los íconos */
.material-symbols-rounded {
    font-family: 'Material Symbols Rounded', sans-serif;
    font-weight: normal;
    font-style: normal;
    display: inline-block;
    line-height: 1;
    text-transform: none;
    letter-spacing: normal;
    word-wrap: normal;
    white-space: nowrap;
    direction: ltr;
    -webkit-font-smoothing: antialiased;
    text-rendering: optimizeLegibility;
    -moz-osx-font-smoothing: grayscale;
    font-feature-settings: 'liga';
    vertical-align: middle;
    transition: opacity 0.15s ease;
}

html:not(.icons-loaded) .material-symbols-rounded {
    opacity: 0 !important;
    visibility: hidden !important;
}

body {
    background-color: var(--bg-color);
    color: var(--text-main);
    overflow-x: hidden;
    -webkit-tap-highlight-color: transparent;
    
    /* Prevenir selección de texto globalmente en la app (evita el copy/paste popup en moviles) */
    -webkit-touch-callout: none; /* iOS Safari */
    -webkit-user-select: none; /* Safari */
    -khtml-user-select: none; /* Konqueror HTML */
    -moz-user-select: none; /* Firefox */
    -ms-user-select: none; /* Internet Explorer/Edge */
    user-select: none; /* Chrome y standard */
}

/* Permitir selección y focus normal solo en inputs y textareas */
input, textarea, [contenteditable="true"] {
    -webkit-user-select: auto !important;
    -khtml-user-select: auto !important;
    -moz-user-select: auto !important;
    -ms-user-select: auto !important;
    user-select: auto !important;
}

#app-container {
    max-width: 600px;
    margin: 0 auto;
    min-height: 100vh;
    position: relative;
    padding-bottom: calc(var(--nav-height) + 20px);
    background: radial-gradient(circle at top left, #1e293b 0%, #0f172a 100%);
}

/* Header */
.app-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 20px 24px;
    position: sticky;
    top: 0;
    z-index: 10;
    background: var(--glass-bg);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border-bottom: 1px solid var(--glass-border);
}

.app-title {
    font-size: 2.2rem;
    font-weight: 700;
    background: linear-gradient(to right, #3b82f6, #8b5cf6);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    cursor: pointer;
}

.user-profile .material-symbols-rounded {
    font-size: 32px;
    color: var(--text-muted);
}

/* Views */
.view {
    display: none;
    padding: 20px 24px;
    animation: fadeIn 0.3s ease;
}

.view.active {
    display: block;
}

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

/* Typography & Layout */
.section-header {
    margin-bottom: 24px;
}

.section-header h2 {
    font-size: 2rem;
    font-weight: 700;
    margin-bottom: 4px;
}

.section-header p {
    color: var(--text-muted);
    font-size: 0.95rem;
}

.section-title-bar {
    margin: 24px 0 16px;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.section-title-bar h3 {
    font-size: 1.25rem;
    font-weight: 600;
}

/* City Selector */
.city-selector {
    display: inline-flex;
    align-items: center;
    background: var(--surface-color);
    padding: 6px 12px;
    border-radius: 20px;
    margin-top: 12px;
    border: 1px solid var(--border-color);
}

.city-selector span {
    font-size: 18px;
    color: var(--primary-color);
    margin-right: 6px;
}

@keyframes bounce-pin {
    0%, 100% { transform: translateY(0); }
    50% { transform: translateY(-8px); color: #fff; }
}

.detecting-location {
    animation: bounce-pin 0.5s infinite ease-in-out;
    pointer-events: none;
}

.city-selector select {
    background: transparent;
    border: none;
    color: var(--text-main);
    font-size: 0.9rem;
    font-weight: 600;
    outline: none;
    appearance: none;
    padding-right: 16px;
    cursor: pointer;
}

/* Categories (Horizontal Scroll) */
.categories {
    display: flex;
    gap: 12px;
    overflow-x: auto;
    padding-bottom: 8px;
    scrollbar-width: none;
    margin: 0 -24px;
    padding: 0 24px 12px;
}

.categories::-webkit-scrollbar {
    display: none;
}

.category-chip {
    background: var(--surface-color);
    border: 1px solid var(--border-color);
    color: var(--text-main);
    padding: 8px 16px;
    border-radius: 20px;
    font-size: 0.9rem;
    font-weight: 500;
    white-space: nowrap;
    cursor: pointer;
    transition: all 0.2s ease;
}

.category-chip.active {
    background: var(--primary-color);
    border-color: var(--primary-color);
}

/* Listings Grid */
.listings-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
    gap: 16px;
}

.listings-list {
    display: flex;
    flex-direction: column;
    gap: 16px;
}

/* Cards */
.card {
    background: var(--surface-color);
    border-radius: 16px;
    overflow: hidden;
    border: 1px solid var(--glass-border);
    transition: transform 0.3s cubic-bezier(0.25, 0.8, 0.25, 1), box-shadow 0.3s cubic-bezier(0.25, 0.8, 0.25, 1), border-color 0.3s;
    position: relative;
}

.card:hover {
    transform: translateY(-8px);
    box-shadow: 0 12px 24px rgba(0,0,0,0.6);
    border-color: var(--primary-color);
}

.card:active {
    transform: scale(0.98);
}

.card-img-wrapper {
    position: relative;
    width: 100%;
    height: 140px;
    background: #000;
}

.card-img-carousel {
    display: flex;
    width: 100%;
    height: 100%;
    overflow-x: auto;
    overflow-y: hidden;
    scroll-snap-type: x mandatory;
    scrollbar-width: none;
}

.card-img-carousel::-webkit-scrollbar {
    display: none;
}

.card-img-carousel img {
    flex: 0 0 100%;
    width: 100%;
    height: 100%;
    object-fit: cover;
    opacity: 0.9;
    scroll-snap-align: start;
    scroll-snap-stop: always;
}

.image-counter {
    position: absolute;
    bottom: 8px;
    right: 8px;
    background: rgba(0,0,0,0.6);
    color: white;
    padding: 2px 8px;
    border-radius: 12px;
    font-size: 0.75rem;
    font-weight: 600;
    backdrop-filter: blur(4px);
    pointer-events: none;
}

.carousel-nav-btn {
    position: absolute;
    top: 50%;
    transform: translateY(-50%);
    background: rgba(0, 0, 0, 0.4);
    color: white;
    border: none;
    border-radius: 50%;
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    backdrop-filter: blur(4px);
    transition: background 0.3s;
    z-index: 5;
}

.carousel-nav-btn:hover {
    background: rgba(0, 0, 0, 0.8);
}

.carousel-nav-btn.prev {
    left: 8px;
}

.carousel-nav-btn.next {
    right: 8px;
}


.card-save-btn {
    position: absolute;
    top: 4px;
    right: 4px;
    background: rgba(0,0,0,0.5);
    border: none;
    color: white;
    width: 32px;
    height: 32px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    backdrop-filter: blur(4px);
    cursor: pointer;
}

.card-save-btn.saved {
    color: var(--danger-color);
}

.card-content {
    padding: 12px;
}

.card-title {
    font-size: 0.95rem;
    font-weight: 600;
    margin-bottom: 4px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.card-price {
    font-size: 1.1rem;
    font-weight: 700;
    color: var(--primary-color);
    margin-bottom: 8px;
}

.card-meta {
    display: flex;
    justify-content: space-between;
    align-items: center;
    color: var(--text-muted);
    font-size: 0.75rem;
    gap: 4px;
}

.card-meta > span:first-child {
    font-size: 0.85rem;
    font-weight: 600;
    color: var(--text-main);
}

.card-meta > span:last-child {
    text-align: right;
    flex-grow: 1;
    display: block;
    word-break: break-word;
}

/* My Listings Specific */
.my-listing-card {
    display: flex;
    background: var(--surface-color);
    border-radius: 12px;
    overflow: hidden;
    border: 1px solid var(--border-color);
    margin-bottom: 12px;
    align-items: center;
}

.my-listing-img {
    width: 100px;
    height: 100px;
    object-fit: cover;
}

.my-listing-info {
    padding: 12px;
    flex-grow: 1;
}

.my-listing-title {
    font-weight: 600;
    font-size: 1rem;
    margin-bottom: 4px;
}

.status-badge {
    display: inline-block;
    padding: 4px 8px;
    border-radius: 12px;
    font-size: 0.7rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.status-pendiente, .status-pendiente-autorizacion { background: rgba(245, 158, 11, 0.2); color: var(--warning-color); border: 1px solid var(--warning-color); }
.status-autorizado { background: rgba(16, 185, 129, 0.2); color: var(--success-color); border: 1px solid var(--success-color); }
.status-vendido { background: rgba(239, 68, 68, 0.2); color: var(--danger-color); border: 1px solid var(--danger-color); }

.my-listing-actions {
    display: flex;
    flex-direction: column;
    padding: 12px;
    gap: 8px;
}

/* Forms & Inputs */
.search-bar-container {
    position: relative;
    margin-bottom: 24px;
}

.search-icon {
    position: absolute;
    left: 16px;
    top: 50%;
    transform: translateY(-50%);
    color: var(--text-muted);
}

input[type="text"], input[type="number"], input[type="url"], input[type="tel"], select {
    width: 100%;
    background: var(--surface-color);
    border: 1px solid var(--border-color);
    color: var(--text-main);
    padding: 14px 16px;
    border-radius: 12px;
    font-size: 1rem;
    outline: none;
    transition: border-color 0.2s;
}

.search-bar-container input {
    padding-left: 48px;
}

select option {
    background-color: var(--surface-color);
    color: var(--text-main);
}

input:focus, select:focus {
    border-color: var(--primary-color);
}

.filter-group {
    margin-bottom: 16px;
}

.filter-group label, .form-group label {
    display: block;
    margin-bottom: 8px;
    font-size: 0.9rem;
    color: var(--text-muted);
}

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

.half {
    flex: 1;
}

/* Buttons */
.primary-btn {
    background: var(--primary-color);
    color: white;
    border: none;
    padding: 14px 24px;
    border-radius: 12px;
    font-size: 1rem;
    font-weight: 600;
    width: 100%;
    cursor: pointer;
    transition: background 0.2s;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
}

.primary-btn:hover {
    background: var(--primary-hover);
}

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

.danger-btn {
    background: transparent;
    color: var(--danger-color);
    border: 1px solid var(--danger-color);
    padding: 6px 12px;
    border-radius: 8px;
    font-size: 0.8rem;
    cursor: pointer;
}

.success-btn {
    background: var(--success-color);
    color: white;
    border: none;
    padding: 6px 12px;
    border-radius: 8px;
    font-size: 0.8rem;
    cursor: pointer;
}

.icon-btn {
    background: transparent;
    border: none;
    color: var(--text-muted);
    cursor: pointer;
}

/* Bottom Navigation */
.bottom-nav {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    height: var(--nav-height);
    background: var(--glass-bg);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border-top: 1px solid var(--glass-border);
    display: flex;
    justify-content: space-around;
    align-items: center;
    z-index: 9999;
    padding-bottom: env(safe-area-inset-bottom);
}

.nav-item {
    background: none;
    border: none;
    color: var(--text-muted);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 4px;
    cursor: pointer;
    width: 60px;
    height: 100%;
    transition: color 0.2s;
}

.nav-item span:first-child {
    font-size: 26px;
}

.nav-item span:last-child {
    font-size: 0.7rem;
    font-weight: 500;
}

.nav-item.active {
    color: var(--primary-color);
}

/* Empty State */
.empty-state {
    text-align: center;
    padding: 60px 20px;
    color: var(--text-muted);
}

.empty-state .material-symbols-rounded {
    font-size: 64px;
    margin-bottom: 16px;
    opacity: 0.5;
}

/* Modal */
.modal {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0,0,0,0.8);
    backdrop-filter: blur(5px);
    z-index: 200;
    align-items: center;
    justify-content: center;
    padding: 20px;
    padding-bottom: calc(var(--nav-height) + 20px);
}

.modal.active {
    display: flex;
}

.modal-content {
    background: var(--surface-color);
    width: 100%;
    max-width: 500px;
    border-radius: 20px;
    padding: 24px;
    max-height: 90vh;
    overflow-y: auto;
    border: 1px solid var(--glass-border);
    -ms-overflow-style: none; /* IE y Edge */
    scrollbar-width: none; /* Firefox */
}

/* Validaciones y Errores */
.input-error {
    border-color: var(--danger-color) !important;
    box-shadow: 0 0 0 2px rgba(239, 68, 68, 0.2) !important;
    animation: shake 0.4s ease-in-out;
}

@keyframes shake {
    0%, 100% { transform: translateX(0); }
    25% { transform: translateX(-5px); }
    75% { transform: translateX(5px); }
}

/* Wizard Animations & Layout */
.form-step {
    animation: slideInRight 0.3s ease forwards;
    min-height: 380px; /* Estabiliza los botones y da espacio a los dropdowns */
    display: flex;
    flex-direction: column;
    padding-bottom: 20px;
}

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

.modal-content::-webkit-scrollbar {
    display: none;
}

.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 24px;
}

.modal-header h3 {
    font-size: 1.25rem;
}

.submit-btn {
    margin-top: 24px;
}

/* Admin Dashboard Specific */
.floating-admin-btn {
    position: fixed;
    top: 20px;
    right: 70px;
    background: var(--surface-color);
    color: var(--warning-color);
    border: 1px solid var(--border-color);
    width: 40px;
    height: 40px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 15;
    cursor: pointer;
    box-shadow: 0 4px 12px rgba(0,0,0,0.3);
}

.dashboard-modal .dashboard-content {
    background: var(--bg-color);
    width: 100%;
    max-width: 100%;
    height: 100%;
    border-radius: 0;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    padding: 0;
}

.dashboard-header {
    padding: 20px 24px;
    background: var(--surface-color);
    border-bottom: 1px solid var(--border-color);
    display: flex;
    justify-content: space-between;
}

.dashboard-layout {
    display: flex;
    flex: 1;
    overflow: hidden;
}

.dashboard-sidebar {
    width: 200px;
    background: var(--surface-color);
    border-right: 1px solid var(--border-color);
    display: flex;
    flex-direction: column;
    padding: 16px 0;
}

.dashboard-tab {
    background: transparent;
    border: none;
    color: var(--text-muted);
    padding: 16px 24px;
    text-align: left;
    font-size: 1rem;
    cursor: pointer;
    transition: background 0.2s;
}

.dashboard-tab:hover {
    background: var(--surface-light);
}

.dashboard-tab.active {
    color: var(--primary-color);
    background: rgba(59, 130, 246, 0.1);
    border-left: 3px solid var(--primary-color);
}

.dashboard-main {
    flex: 1;
    padding: 24px;
    overflow-y: auto;
}

.dashboard-view {
    display: none;
}
.dashboard-view.active {
    display: block;
}

.dashboard-view h3 {
    margin-bottom: 20px;
    font-size: 1.5rem;
}

/* Admin lists */
.admin-list {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.admin-list-item {
    background: var(--surface-color);
    border: 1px solid var(--border-color);
    border-radius: 12px;
    padding: 16px;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.admin-actions {
    display: flex;
    gap: 8px;
}

/* --- CRM & Pending Approvals Compact List --- */
/* Copyable Phone & WhatsApp Badge */
.copyable-phone {
    color: #3b82f6;
    font-weight: 600;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    gap: 4px;
    transition: transform 0.2s cubic-bezier(0.175, 0.885, 0.32, 1.275), color 0.2s, background 0.2s;
    text-decoration: underline;
    text-underline-offset: 3px;
    padding: 2px 6px;
    border-radius: 6px;
    white-space: nowrap;
}

.copyable-phone:hover {
    color: #60a5fa;
    transform: scale(1.08);
    background: rgba(59, 130, 246, 0.15);
}

.pending-approval-card {
    background: var(--surface-light);
    border: 1px solid var(--border-color);
    border-radius: 12px;
    overflow: hidden;
    margin-bottom: 10px;
    transition: border-color 0.2s, box-shadow 0.2s;
}

.pending-approval-card:hover {
    border-color: rgba(59, 130, 246, 0.4);
}

.pending-approval-card.expanded {
    border-color: var(--primary-color);
    box-shadow: 0 4px 16px rgba(0,0,0,0.3);
}

.pending-row-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 12px 16px;
    cursor: pointer;
    gap: 12px;
    user-select: none;
}

.pending-row-left {
    display: flex;
    align-items: center;
    gap: 12px;
    flex: 1;
    min-width: 0;
}

.pending-thumb-wrapper {
    position: relative;
    width: 52px;
    height: 52px;
    flex-shrink: 0;
    border-radius: 8px;
    overflow: hidden;
    border: 1px solid var(--border-color);
    background: #000;
}

.pending-thumb-wrapper img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.pending-img-count {
    position: absolute;
    bottom: 2px;
    right: 2px;
    background: rgba(0,0,0,0.75);
    color: white;
    font-size: 0.65rem;
    font-weight: 700;
    padding: 1px 4px;
    border-radius: 4px;
    backdrop-filter: blur(2px);
}

.pending-main-info {
    display: flex;
    flex-direction: column;
    gap: 3px;
    min-width: 0;
    flex: 1;
}

.pending-title {
    font-size: 0.96rem;
    font-weight: 600;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    color: var(--text-main);
}

.pending-sub-info {
    display: flex;
    align-items: center;
    gap: 12px;
    font-size: 0.82rem;
    color: var(--text-muted);
    flex-wrap: wrap;
}

.pending-price-tag {
    font-weight: 700;
    color: var(--success-color);
}

.pending-notes-badge {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    background: rgba(234, 179, 8, 0.12);
    color: #eab308;
    padding: 2px 8px;
    border-radius: 12px;
    font-size: 0.75rem;
    font-weight: 600;
}

.pending-notes-badge.has-notes {
    background: rgba(59, 130, 246, 0.15);
    color: #60a5fa;
}

.pending-row-right {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-shrink: 0;
}

.pending-detail-panel {
    display: none;
    padding: 16px;
    border-top: 1px solid var(--border-color);
    background: rgba(0, 0, 0, 0.25);
    animation: fadeIn 0.2s ease-in-out;
}

.pending-approval-card.expanded .pending-detail-panel {
    display: block;
}

.crm-notes-container {
    background: var(--surface-color);
    border: 1px solid var(--border-color);
    border-radius: 10px;
    padding: 14px;
    margin-top: 14px;
}

.crm-notes-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 10px;
    font-weight: 600;
    font-size: 0.88rem;
    color: var(--text-main);
}

.crm-notes-list {
    display: flex;
    flex-direction: column;
    gap: 8px;
    max-height: 220px;
    overflow-y: auto;
    margin-bottom: 12px;
    padding-right: 4px;
}

.crm-note-item {
    background: var(--surface-light);
    border: 1px solid var(--border-color);
    border-left: 3px solid var(--primary-color);
    border-radius: 6px;
    padding: 8px 12px;
    font-size: 0.85rem;
}

.crm-note-time {
    font-size: 0.72rem;
    color: var(--text-muted);
    margin-bottom: 4px;
    display: flex;
    align-items: center;
    gap: 4px;
}

.crm-note-text {
    color: var(--text-main);
    line-height: 1.35;
    word-break: break-word;
}

.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 20px;
}

.stat-card {
    background: var(--surface-color);
    border: 1px solid var(--border-color);
    padding: 24px;
    border-radius: 16px;
    text-align: center;
}

.stat-card h4 {
    color: var(--text-muted);
    font-weight: 400;
    margin-bottom: 8px;
}

.stat-card p {
    font-size: 2.5rem;
    font-weight: 700;
    color: var(--primary-color);
}

/* Dashboard Premium */
.stats-premium-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    gap: 20px;
}

.stat-premium-card {
    background: var(--surface-color);
    border: 1px solid var(--border-color);
    padding: 24px;
    border-radius: 16px;
    display: flex;
    align-items: center;
    gap: 16px;
    transition: transform 0.2s, box-shadow 0.2s;
}

.stat-premium-card:hover {
    transform: translateY(-4px);
    box-shadow: 0 10px 25px rgba(0,0,0,0.3);
}

.stat-icon {
    width: 60px;
    height: 60px;
    border-radius: 16px;
    display: flex;
    align-items: center;
    justify-content: center;
}
.stat-icon span {
    font-size: 32px;
}

.stat-details h4 {
    color: var(--text-muted);
    font-size: 0.9rem;
    font-weight: 500;
    margin-bottom: 4px;
}

.stat-value {
    font-size: 1.8rem;
    font-weight: 700;
    margin-bottom: 4px;
}

/* Admin Tables */
.admin-table-container {
    background: var(--surface-color);
    border: 1px solid var(--border-color);
    border-radius: 16px;
    overflow-x: auto;
}

.admin-table {
    width: 100%;
    border-collapse: collapse;
    text-align: left;
}

.admin-table th, .admin-table td {
    padding: 16px;
    border-bottom: 1px solid var(--border-color);
}

.admin-table th {
    background: var(--surface-light);
    color: var(--text-muted);
    font-weight: 500;
    font-size: 0.9rem;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.admin-table tbody tr:hover {
    background: rgba(255, 255, 255, 0.02);
}

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

/* Bar Chart */
.bar-chart-bar {
    width: 100%;
    background: var(--primary-color);
    border-radius: 6px 6px 0 0;
    position: relative;
    transition: height 1s ease-out;
}
.bar-chart-bar:hover {
    background: var(--primary-hover);
}
.bar-chart-bar::after {
    content: attr(data-value);
    position: absolute;
    top: -24px;
    left: 50%;
    transform: translateX(-50%);
    font-size: 0.8rem;
    color: var(--text-muted);
    opacity: 0;
    transition: opacity 0.2s;
}
.bar-chart-bar:hover::after {
    opacity: 1;
}
.bar-chart-col {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: flex-end;
    height: 100%;
    gap: 8px;
}
.bar-chart-label {
    font-size: 0.75rem;
    color: var(--text-muted);
}

/* Responsive adjustments */
@media (max-width: 768px) {
    .dashboard-layout {
        flex-direction: column;
    }
    .dashboard-sidebar {
        width: 100%;
        flex-direction: row;
        overflow-x: auto;
        border-right: none;
        border-bottom: 1px solid var(--border-color);
    }
    .dashboard-tab {
        white-space: nowrap;
        border-left: none;
        border-bottom: 3px solid transparent;
    }
    .dashboard-tab.active {
        border-left: none;
        border-bottom: 3px solid var(--primary-color);
    }
}

/* Vista Detalle */
.carousel-nav-btn {
    position: absolute;
    top: 50%;
    transform: translateY(-50%);
    background: rgba(0,0,0,0.4);
    backdrop-filter: blur(4px);
    -webkit-backdrop-filter: blur(4px);
    color: white;
    border: none;
    width: 36px;
    height: 36px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    z-index: 10;
}
.carousel-nav-btn.prev {
    left: 8px;
    animation: bounceLeft 1.5s infinite ease-in-out;
}
.carousel-nav-btn.next {
    right: 8px;
    animation: bounceRight 1.5s infinite ease-in-out;
}

@keyframes bounceLeft {
    0%, 100% { transform: translate(0, -50%); }
    50% { transform: translate(-4px, -50%); }
}

@keyframes bounceRight {
    0%, 100% { transform: translate(0, -50%); }
    50% { transform: translate(4px, -50%); }
}

.detalle-img-carousel {
    display: flex;
    overflow-x: auto;
    scroll-snap-type: x mandatory;
    background: #000;
    position: relative;
    scrollbar-width: none;
}
.detalle-img-carousel::-webkit-scrollbar { display: none; }

.detalle-img-carousel img {
    flex: 0 0 100%;
    width: 100%;
    aspect-ratio: 4/3;
    height: auto;
    max-height: 450px;
    object-fit: contain;
    scroll-snap-align: start;
    scroll-snap-stop: always;
}

.detalle-floating-btn {
    position: absolute;
    top: 16px;
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background: rgba(0, 0, 0, 0.4);
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
    color: white;
    border: none;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    z-index: 15;
}

.detalle-info {
    padding: 24px;
}

.detalle-title {
    font-size: 1.8rem;
    font-weight: 700;
    margin-bottom: 8px;
}

.detalle-price {
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--primary-color);
    margin-bottom: 20px;
}

.detalle-city-pulsing {
    font-size: 1.15rem;
    font-weight: 700;
    color: var(--text-color, #ffffff);
    margin-top: 2px;
    animation: cityPulse 1.8s infinite ease-in-out;
    transform-origin: left center;
    display: inline-block;
}

@keyframes cityPulse {
    0%, 100% {
        opacity: 1;
        transform: scale(1);
    }
    50% {
        opacity: 0.45;
        transform: scale(1.03);
    }
}


.detalle-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 12px;
    background: var(--surface-color);
    padding: 16px;
    border-radius: 16px;
    border: 1px solid var(--glass-border);
    margin-bottom: 24px;
}

.detalle-item {
    display: flex;
    flex-direction: column;
}

.detalle-label {
    font-size: 0.8rem;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-bottom: 4px;
}

.detalle-value {
    font-size: 1.1rem;
    font-weight: 600;
    word-break: break-word;
    overflow-wrap: break-word;
}

.btn-contactar {
    background: linear-gradient(to right, #10b981, #059669);
    color: white;
    border: none;
    padding: 18px;
    border-radius: 16px;
    font-size: 1.1rem;
    font-weight: 700;
    width: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 12px;
    cursor: pointer;
    box-shadow: 0 8px 16px rgba(16, 185, 129, 0.3);
    transition: transform 0.2s;
}
.btn-contactar:active {
    transform: scale(0.98);
}

/* Image Preview & Reordering */
.image-preview-container {
    display: flex;
    flex-wrap: wrap;
    gap: 12px;
    margin-top: 16px;
    padding-bottom: 8px;
}
.image-preview-item {
    position: relative;
    width: 100px;
    height: 100px;
    flex-shrink: 0;
    border-radius: 12px;
    border: 2px solid var(--border-color);
    cursor: grab;
}
.image-preview-item img {
    display: block;
    width: 100%;
    height: 100%;
    object-fit: cover;
    border-radius: 10px;
}
.image-preview-actions {
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    background: rgba(0,0,0,0.6);
    display: flex;
    justify-content: center;
    padding: 4px;
}
.preview-btn {
    background: transparent;
    border: none;
    color: white;
    font-size: 18px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 24px;
    height: 24px;
    border-radius: 4px;
}
.preview-btn:hover {
    background: rgba(255,255,255,0.2);
}
.preview-badge {
    position: absolute;
    top: 4px;
    left: 4px;
    background: var(--primary-color);
    color: white;
    font-size: 0.7rem;
    padding: 2px 6px;
    border-radius: 10px;
    font-weight: 600;
}

.image-preview-item.sortable-ghost {
    opacity: 0.4;
    border-color: var(--primary-color);
}
.image-preview-item.sortable-drag {
    opacity: 1 !important;
    cursor: grabbing;
}

/* Ocultar flechas (spinners) en inputs de tipo número */
input[type=number]::-webkit-inner-spin-button, 
input[type=number]::-webkit-outer-spin-button { 
  -webkit-appearance: none; 
  margin: 0; 
}
input[type=number] {
  -moz-appearance: textfield; /* Firefox */
}

/* Custom Select Styles (Anti-Zoom & Responsive) */
.custom-select-wrapper {
    position: relative;
    width: 100%;
}

.custom-select-trigger {
    width: 100%;
    padding: 12px 16px;
    background: var(--surface-color);
    border: 1px solid var(--border-color);
    border-radius: 12px;
    color: var(--text-main);
    font-size: 16px; /* Crucial para evitar zoom en iOS */
    cursor: pointer;
    text-align: left;
    display: flex;
    justify-content: space-between;
    align-items: center;
    transition: all 0.3s;
    user-select: none;
    -webkit-tap-highlight-color: transparent;
}

.custom-select-trigger:focus,
.custom-select-trigger.open {
    border-color: var(--primary-color);
    box-shadow: 0 0 0 2px rgba(56, 189, 248, 0.2);
    outline: none;
}

.custom-select-trigger .material-symbols-rounded {
    font-size: 20px;
    color: var(--text-muted);
    transition: transform 0.3s ease;
}

.custom-select-trigger.open .material-symbols-rounded {
    transform: rotate(180deg);
}

.custom-select-dropdown {
    position: absolute;
    top: calc(100% + 4px);
    left: 0;
    right: 0;
    background: var(--surface-color);
    border: 1px solid var(--border-color);
    border-radius: 12px;
    box-shadow: 0 10px 25px rgba(0,0,0,0.5);
    max-height: 250px;
    overflow-y: auto;
    z-index: 10010;
    opacity: 0;
    visibility: hidden;
    transform: translateY(-10px);
    transition: all 0.2s cubic-bezier(0.25, 0.8, 0.25, 1);
}

.custom-select-dropdown.open {
    opacity: 1;
    visibility: visible;
    transform: translateY(0);
}

.custom-select-dropdown::-webkit-scrollbar {
    width: 6px;
}

.custom-select-dropdown::-webkit-scrollbar-track {
    background: transparent;
}

.custom-select-dropdown::-webkit-scrollbar-thumb {
    background: var(--glass-border);
    border-radius: 10px;
}

.custom-select-option {
    padding: 12px 16px;
    color: var(--text-main);
    font-size: 16px;
    cursor: pointer;
    transition: background 0.2s;
    user-select: none;
    -webkit-tap-highlight-color: transparent;
}

.custom-select-option:hover,
.custom-select-option.selected {
    background: rgba(56, 189, 248, 0.1);
}

.custom-select-option.disabled {
    color: var(--text-muted);
    cursor: default;
}
.custom-select-option.disabled:hover {
    background: transparent;
}

/* --- Netflix Style Feed --- */
.netflix-row {
    margin-bottom: 16px;
    position: relative;
}

.row-nav-btn {
    position: absolute;
    top: 50%;
    transform: translateY(-50%);
    background: rgba(0, 0, 0, 0.6);
    color: white;
    border: none;
    border-radius: 50%;
    width: 40px;
    height: 40px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    backdrop-filter: blur(4px);
    transition: all 0.3s ease;
    z-index: 10;
    box-shadow: 0 4px 12px rgba(0,0,0,0.3);
}

.row-nav-btn.hidden {
    opacity: 0;
    pointer-events: none;
}

@media (hover: hover) {
    .row-nav-btn:hover {
        background: rgba(0, 0, 0, 0.9);
        animation: none;
        transform: translateY(-50%) scale(1.1);
    }
}

@keyframes bounce-left {
    0%, 100% { transform: translateY(-50%) translateX(0); }
    50% { transform: translateY(-50%) translateX(-5px); }
}

@keyframes bounce-right {
    0%, 100% { transform: translateY(-50%) translateX(0); }
    50% { transform: translateY(-50%) translateX(5px); }
}

.row-nav-btn.prev {
    left: -10px;
    animation: bounce-left 2s infinite ease-in-out;
}

.row-nav-btn.next {
    right: -10px;
    animation: bounce-right 2s infinite ease-in-out;
}

@media (max-width: 600px) {
    .row-nav-btn {
        width: 32px;
        height: 32px;
    }
    .row-nav-btn.prev { left: 4px; }
    .row-nav-btn.next { right: 4px; }

    .my-listing-card {
        flex-wrap: wrap;
    }
    .my-listing-info {
        width: calc(100% - 100px);
        padding-right: 0;
    }
    .my-listing-actions {
        width: 100%;
        border-top: 1px solid var(--glass-border);
        padding-top: 16px;
    }
}

.netflix-row-title {
    font-size: 1.25rem;
    font-weight: 700;
    margin-bottom: 8px;
    color: var(--text-main);
    padding-left: 4px;
    display: flex;
    align-items: center;
    gap: 8px;
}

.netflix-row-scroll {
    display: flex;
    gap: 12px;
    overflow-x: auto;
    padding-bottom: 8px;
    scroll-snap-type: x mandatory;
    scroll-behavior: smooth;
    -webkit-overflow-scrolling: touch;
    -ms-overflow-style: none;
    scrollbar-width: none;
}

.netflix-row-scroll::-webkit-scrollbar {
    display: none;
}

.netflix-row-scroll .card {
    min-width: 150px;
    max-width: 150px;
    scroll-snap-align: start;
    flex-shrink: 0;
}

.netflix-row-scroll .card-img-wrapper {
    height: 110px;
}

@keyframes heartPulse {
    0% { transform: scale(1); }
    50% { transform: scale(1.4); }
    100% { transform: scale(1); }
}

/* Switch Styles */
.switch {
    position: relative;
    display: inline-block;
    width: 50px;
    height: 28px;
}

.switch input { 
    opacity: 0;
    width: 0;
    height: 0;
}

.slider {
    position: absolute;
    cursor: pointer;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-color: #ccc;
    transition: .4s;
}

.slider:before {
    position: absolute;
    content: "";
    height: 20px;
    width: 20px;
    left: 4px;
    bottom: 4px;
    background-color: white;
    transition: .4s;
}

input:checked + .slider {
    background-color: var(--success-color);
}

input:focus + .slider {
    box-shadow: 0 0 1px var(--success-color);
}

input:checked + .slider:before {
    transform: translateX(22px);
}

.slider.round {
    border-radius: 34px;
}

.slider.round:before {
    border-radius: 50%;
}

@keyframes spin {
    from { transform: rotate(0deg); }
    to { transform: rotate(360deg); }
}

/* Card Transition Animations */
@keyframes slideOutLeft {
    0% { transform: translateX(0); opacity: 1; }
    100% { transform: translateX(-100%); opacity: 0; }
}

@keyframes slideOutRight {
    0% { transform: translateX(0); opacity: 1; }
    100% { transform: translateX(100%); opacity: 0; }
}

@keyframes slideInRight {
    0% { transform: translateX(100%); opacity: 0; }
    100% { transform: translateX(0); opacity: 1; }
}

@keyframes slideInLeft {
    0% { transform: translateX(-100%); opacity: 0; }
    100% { transform: translateX(0); opacity: 1; }
}

.slide-out-left {
    animation: slideOutLeft 0.25s forwards ease-in-out;
}

.slide-out-right {
    animation: slideOutRight 0.25s forwards ease-in-out;
}

.slide-in-right {
    animation: slideInRight 0.25s forwards ease-in-out;
}

.slide-in-left {
    animation: slideInLeft 0.25s forwards ease-in-out;
}

/* ==========================================================================
   DESKTOP RESPONSIVE LAYOUT (PC)
   ========================================================================== */
@media (min-width: 768px) {
    /* 1. App Container Expansion */
    #app-container {
        max-width: 100% !important; 
        padding-bottom: 0 !important; 
        display: flex;
        flex-direction: column;
    }

    /* 2. Navigation Changes */
    .bottom-nav {
        display: none !important; 
    }

    .desktop-nav {
        display: flex;
        gap: 12px;
        align-items: center;
    }

    .desktop-nav .nav-item {
        background: transparent;
        border: none;
        color: var(--text-muted);
        display: flex;
        align-items: center;
        gap: 6px;
        font-size: 0.95rem;
        cursor: pointer;
        padding: 8px 12px;
        border-radius: 8px;
        transition: all 0.2s ease;
        outline: none;
        font-family: inherit;
    }

    .desktop-nav .nav-item:hover {
        background: rgba(255, 255, 255, 0.05);
        color: white;
    }

    .desktop-nav .nav-item.active {
        color: var(--primary-color);
        background: rgba(59, 130, 246, 0.1);
        font-weight: 600;
    }

    /* 3. Listings Grid Multi-column */
    .listings-grid {
        display: grid !important;
        grid-template-columns: repeat(auto-fill, minmax(250px, 1fr));
        gap: 20px;
    }
    
    .my-listings-list {
        display: block !important;
    }

    /* 4. Search View Split Layout */
    #view-busqueda.active {
        display: grid !important;
        grid-template-columns: 320px 1fr;
        gap: 30px;
        align-items: start;
    }
    
    .search-left-panel {
        border-right: 1px solid var(--glass-border);
        padding-right: 30px;
        position: sticky;
        top: 100px;
        height: max-content;
    }

    #view-busqueda .section-header { margin-bottom: 16px; }
    #view-busqueda .search-bar-container { width: 100%; margin-bottom: 20px; }
    #view-busqueda #search-filters-container { position: static; }
    #view-busqueda #search-results { margin-top: 0 !important; }

    /* 5. Ad Detail Modal Side-by-Side */
    #view-detalle.active, #ad-fullscreen-modal.active {
        display: flex !important;
        align-items: center;
        justify-content: center;
        background: rgba(15, 23, 42, 0.9) !important;
        backdrop-filter: blur(8px);
        padding: 40px !important;
        position: fixed !important;
        top: 0;
        left: 0;
        width: 100%;
        height: 100%;
        z-index: 1000;
    }

    #detalle-content, #ad-detalle-content {
        display: flex !important;
        flex-direction: row;
        width: 100%;
        max-width: 1250px;
        background: var(--surface-color);
        border-radius: 16px;
        overflow: visible !important;
        box-shadow: 0 20px 50px rgba(0,0,0,0.5);
        max-height: 90vh;
        margin: auto;
        position: relative;
    }
    
    /* Child element containing the carousel */
    #detalle-content > div:first-child, #ad-detalle-content > div:first-child {
        width: 55% !important;
        padding-bottom: 0 !important; 
        border-right: 1px solid var(--border-color);
        border-radius: 16px 0 0 16px !important;
        overflow: hidden;
    }

    /* Info container */
    #detalle-content > div:last-child, #ad-detalle-content > div:last-child {
        width: 45% !important;
        height: 100%;
        overflow-y: auto;
        padding: 24px !important;
        border-radius: 0 16px 16px 0 !important;
    }

    #ad-image-carousel {
        height: 100% !important;
        min-height: 500px;
    }

    /* Remove black bars and make image fill the container on desktop */
    .detalle-img-carousel {
        height: 100% !important;
        background: var(--surface-color) !important;
    }

    .detalle-img-carousel img {
        max-height: none !important;
        height: 100% !important;
        object-fit: cover !important;
    }

    #ad-image-carousel img {
        object-fit: contain !important;
    }
}

@media (max-width: 767px) {
    .desktop-nav {
        display: none !important;
    }

    /* ==========================================================================
       AD FULLSCREEN VIEW (MOBILE SPECIFIC FIXES)
       ========================================================================== */
    /* Remove margins and paddings so it goes edge-to-edge on mobile */
    #ad-fullscreen-modal .detalle-container {
        padding: 0 !important;
        padding-bottom: calc(var(--nav-height) + 20px) !important;
    }
    
    #ad-fullscreen-modal #ad-detalle-content {
        margin-top: 0 !important;
        border-radius: 0 !important;
        background: transparent !important;
        box-shadow: none !important;
    }

    #ad-fullscreen-modal #ad-image-carousel {
        border-radius: 0 !important;
    }

    #ad-fullscreen-modal .detalle-info {
        background: transparent !important;
        border-radius: 0 !important;
        padding-top: 16px !important;
    }

    /* Float the back button over the image */
    #ad-fullscreen-modal .modal-header.desktop-hidden {
        position: absolute !important;
        top: 0 !important;
        left: 0 !important;
        right: 0 !important;
        background: transparent !important;
        backdrop-filter: none !important;
        padding: 16px !important;
        z-index: 20 !important;
    }

    #ad-fullscreen-modal #btn-close-ad-modal {
        background: rgba(0, 0, 0, 0.4) !important;
        border-radius: 50% !important;
        width: 40px !important;
        height: 40px !important;
        display: flex !important;
        align-items: center !important;
        justify-content: center !important;
        color: white !important;
        border: none !important;
    }
}

/* ==========================================================================
   PUBLICATIONS SPLIT LAYOUT (Mis Vehículos / Anuncios)
   ========================================================================== */
.publications-split-layout {
    display: flex;
    flex-direction: column;
    gap: 30px;
    margin-top: 16px;
    width: 100%;
}

.pub-col {
    display: flex;
    flex-direction: column;
}

.desktop-only-btn {
    display: none !important;
}

/* My Listing Cards Fix for Button Wrapping */
.my-listing-actions > div {
    flex-wrap: wrap;
}

@media (min-width: 768px) {
    .publications-split-layout {
        flex-direction: row;
        align-items: flex-start;
    }
    
    .pub-col {
        flex: 1;
        min-width: 0; /* Prevents overflow in flexbox */
    }

    .desktop-only-btn {
        display: flex !important;
    }

    .desktop-hidden {
        display: none !important;
    }
}

/* ==========================================================================
   GLOBAL NAVIGATION BUTTONS (Next / Prev on Fullscreen Modals)
   ========================================================================== */
.global-nav-btn {
    position: fixed;
    top: 50vh;
    transform: translateY(-50%);
    background: rgba(255, 255, 255, 0.1);
    color: white;
    border: 1px solid rgba(255, 255, 255, 0.2);
    border-radius: 50%;
    width: 60px;
    height: 60px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    backdrop-filter: blur(8px);
    transition: all 0.3s ease;
    z-index: 1100;
}

.global-nav-btn:hover {
    background: rgba(255, 255, 255, 0.2);
    transform: translateY(-50%) scale(1.1);
}

.global-nav-btn.prev {
    left: max(20px, calc(50vw - 625px - 75px));
}

.global-nav-btn.next {
    right: max(20px, calc(50vw - 625px - 75px));
}

.global-nav-btn .material-symbols-rounded {
    font-size: 32px;
}

/* Ajustes de selector de ubicación y menú para PC */
@media (min-width: 768px) {
    /* Selector de ubicación */
    .city-selector {
        width: auto !important;
        display: inline-flex !important;
        min-width: 360px;
        max-width: 400px;
    }
    #user-state {
        flex: 0 0 180px !important;
    }
    #btn-user-cities {
        flex: 1 !important;
        justify-content: space-between !important;
    }

    /* Menú de Navegación */
    .desktop-nav {
        display: flex;
        gap: 40px !important; /* Más separación entre los botones */
    }
    .desktop-nav .nav-item {
        flex-direction: column !important;
        font-size: 1.25rem !important; /* Letra más grande */
        padding: 12px 20px !important;
        gap: 6px !important;
        border-radius: 12px !important;
        min-width: 90px; /* Asegura que el texto no se apriete */
        text-align: center;
    }
    .desktop-nav .nav-item .material-symbols-rounded {
        font-size: 34px !important; /* Íconos más grandes */
    }

    /* Botón Anúnciate */
    #btn-advertise {
        padding: 10px 18px !important;
        font-size: 1.05rem !important;
        border-radius: 20px !important;
        background: rgba(255, 255, 255, 0.15) !important;
        border: 1px solid rgba(255, 255, 255, 0.25) !important;
    }
    #btn-advertise .material-symbols-rounded {
        font-size: 22px !important;
    }
}

/* --- Efecto Destello / Flash para Botones de Redes Sociales --- */
.social-btn-link {
    position: relative;
    overflow: hidden;
    transition: transform 0.15s ease, box-shadow 0.15s ease, filter 0.15s ease !important;
    -webkit-tap-highlight-color: transparent;
}

.social-btn-link:active,
.social-btn-link.flash-active {
    transform: scale(0.94) !important;
    filter: brightness(1.7) contrast(1.1) !important;
    box-shadow: 0 0 25px rgba(255, 255, 255, 0.9), 0 0 10px rgba(255, 255, 255, 0.6) !important;
    animation: socialPulseFlash 0.35s ease-out forwards;
}

.social-btn-link::after {
    content: '';
    position: absolute;
    top: -50%;
    left: -50%;
    width: 200%;
    height: 200%;
    background: radial-gradient(circle, rgba(255,255,255,0.85) 0%, rgba(255,255,255,0) 70%);
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.3s ease;
}

.social-btn-link:active::after,
.social-btn-link.flash-active::after {
    opacity: 1;
    animation: flashShine 0.35s ease-out forwards;
}

@keyframes socialPulseFlash {
    0% {
        filter: brightness(1);
        box-shadow: 0 3px 10px rgba(0,0,0,0.25);
    }
    40% {
        filter: brightness(2) contrast(1.2);
        box-shadow: 0 0 30px rgba(255, 255, 255, 1), 0 0 15px rgba(255, 255, 255, 0.8);
    }
    100% {
        filter: brightness(1.2);
        box-shadow: 0 0 15px rgba(255, 255, 255, 0.5);
    }
}

@keyframes flashShine {
    0% { opacity: 0; transform: scale(0.3); }
    50% { opacity: 1; transform: scale(1.1); }
    100% { opacity: 0; transform: scale(1.5); }
}

