/* Reset and Base Styles */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

html, body {
    height: 100%;
    overflow-x: hidden;
}

/* Forzar layout horizontal en pantallas desktop */
@media (min-width: 992px) {
    .main-app {
        display: flex !important;
        flex-direction: row !important;
    }
}

:root {
    --font-size: 14px;
    --background: #ffffff;
    --foreground: #2d3748;
    --card: #ffffff;
    --card-foreground: #2d3748;
    --primary: #030213;
    --primary-foreground: #ffffff;
    --secondary: #f7fafc;
    --secondary-foreground: #030213;
    --muted: #ececf0;
    --muted-foreground: #718096;
    --accent: #e9ebef;
    --accent-foreground: #030213;
    --destructive: #d4183d;
    --destructive-foreground: #ffffff;
    --border: rgba(0, 0, 0, 0.1);
    --input-background: #f3f3f5;
    --radius: 0.625rem;
    --shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06);
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, sans-serif;
    font-size: var(--font-size);
    background-color: var(--background);
    color: var(--foreground);
    line-height: 1.5;
}

.hidden {
    display: none !important;
}

/* Login Styles */
.login-container {
    min-height: 100vh;
    background: linear-gradient(135deg, #f7fafc 0%, #edf2f7 100%);
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 1rem;
}

.login-wrapper {
    width: 100%;
    max-width: 400px;
}

.login-header {
    text-align: center;
    margin-bottom: 2rem;
}

.login-header h1 {
    font-size: 2rem;
    font-weight: 500;
    color: var(--foreground);
    margin-bottom: 0.5rem;
}

.login-header p {
    color: var(--muted-foreground);
}

.login-card {
    background: var(--card);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    overflow: hidden;
}

.card-header {
    padding: 1.5rem 1.5rem 1rem 1.5rem;
    text-align: center;
}

.card-header h2 {
    font-size: 1.5rem;
    font-weight: 500;
    margin-bottom: 0.5rem;
}

.card-header h3 {
    font-size: 1.25rem;
    font-weight: 500;
    margin-bottom: 0.5rem;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.flex-header {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    text-align: left;
}

.card-header p {
    color: var(--muted-foreground);
    font-size: 0.875rem;
}

.login-form {
    padding: 0 1.5rem 1.5rem 1.5rem;
}

.form-group {
    margin-bottom: 1rem;
}

.form-group label {
    display: block;
    margin-bottom: 0.5rem;
    font-weight: 500;
    color: var(--foreground);
}

.form-group input,
.form-group select,
.form-group textarea {
    width: 100%;
    padding: 0.75rem;
    border: 1px solid var(--border);
    border-radius: calc(var(--radius) - 2px);
    background-color: var(--input-background);
    font-size: var(--font-size);
    transition: border-color 0.2s, box-shadow 0.2s;
}

.form-group input:focus,
.form-group select:focus,
.form-group textarea:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(3, 2, 19, 0.1);
}

.form-group textarea {
    resize: vertical;
    min-height: 100px;
}

.help-text {
    font-size: 0.75rem;
    color: var(--muted-foreground);
    margin-top: 0.25rem;
}

.btn-primary,
.btn-secondary,
.btn-destructive {
    padding: 0.75rem 1.5rem;
    border: none;
    border-radius: calc(var(--radius) - 2px);
    font-size: var(--font-size);
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s;
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    text-decoration: none;
}

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

.btn-primary:hover:not(:disabled) {
    background-color: #1a1a1a;
}

.btn-primary:disabled {
    background-color: #9ca3af;
    cursor: not-allowed;
}

.btn-secondary {
    background-color: transparent;
    color: var(--foreground);
    border: 1px solid var(--border);
}

.btn-secondary:hover {
    background-color: var(--accent);
}

.btn-destructive {
    background-color: var(--destructive);
    color: var(--destructive-foreground);
}

.btn-destructive:hover {
    background-color: #b91c3c;
}

.full-width {
    width: 100%;
}

.login-footer {
    padding: 1rem 1.5rem;
    text-align: center;
    border-top: 1px solid var(--border);
    font-size: 0.875rem;
    color: var(--muted-foreground);
}

.link {
    color: var(--primary);
    text-decoration: none;
}

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

.system-info {
    text-align: center;
    margin-top: 1.5rem;
    font-size: 0.875rem;
    color: var(--muted-foreground);
}

/* Main App Layout */
.main-app {
    display: flex !important;
    flex-direction: row !important;
    height: 100vh;
    background-color: #f9fafb;
    width: 100%;
    min-height: 100vh;
}

/* Force horizontal layout */
body .main-app {
    display: flex !important;
    flex-direction: row !important;
}

#main-app {
    display: flex !important;
    flex-direction: row !important;
}

/* Sidebar */
.sidebar {
    width: 256px !important;
    min-width: 256px !important;
    max-width: 256px !important;
    background-color: var(--card);
    border-right: 1px solid var(--border);
    display: flex;
    flex-direction: column;
    height: 100vh;
    overflow-y: auto;
    flex-shrink: 0 !important;
}

.sidebar-header {
    padding: 1.5rem;
    border-bottom: 1px solid var(--border);
}

.sidebar-header h2 {
    font-size: 1.25rem;
    font-weight: 600;
    color: var(--foreground);
}

.sidebar-header p {
    font-size: 0.875rem;
    color: var(--muted-foreground);
    margin-top: 0.25rem;
}

.sidebar-nav {
    flex: 1;
    padding: 1rem;
}

.nav-item {
    width: 100%;
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.75rem;
    margin-bottom: 0.5rem;
    border: none;
    border-radius: calc(var(--radius) - 2px);
    background: none;
    color: var(--muted-foreground);
    font-size: var(--font-size);
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s;
    text-align: left;
}

.nav-item:hover {
    background-color: var(--accent);
    color: var(--foreground);
}

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

.nav-item.logout {
    color: var(--destructive);
}

.nav-item.logout:hover {
    background-color: #fee2e2;
    color: var(--destructive);
}

.sidebar-footer {
    padding: 1rem;
    border-top: 1px solid var(--border);
}

/* Main Content */
.main-content {
    flex: 1 !important;
    height: 100vh;
    overflow-y: auto;
    background-color: #f9fafb;
    min-width: 0;
}

/* Force main content to be beside sidebar */
body .main-content {
    flex: 1 !important;
}

#main-app .main-content {
    flex: 1 !important;
}

.section {
    display: none;
    padding: 1.5rem;
    max-width: 1200px;
    margin: 0 auto;
    width: 100%;
    box-sizing: border-box;
}

.section.active {
    display: block !important;
}

/* Sections styling */
.section-header {
    margin-bottom: 1.5rem;
}

.section-header h1 {
    font-size: 1.875rem;
    font-weight: 700;
    color: var(--foreground);
    margin: 0 0 0.5rem 0;
}

.section-header p {
    color: var(--muted-foreground);
    margin: 0;
}

/* Dashboard Grid */
.dashboard-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(400px, 1fr));
    gap: 1.5rem;
    margin-bottom: 1.5rem;
}

.chart-card {
    background: var(--card);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    overflow: hidden;
}

.chart-card.full-width {
    grid-column: 1 / -1;
}

.chart-container {
    padding: 1rem;
    height: 300px;
}

.chart-container canvas {
    max-height: 100%;
}

/* Forms */
.form-card {
    background: var(--card);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    overflow: hidden;
    margin-bottom: 1.5rem;
}

.customer-form {
    padding: 1.5rem;
}

.form-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 1.5rem;
    margin-bottom: 1.5rem;
}

.form-actions {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding-top: 1.5rem;
    border-top: 1px solid var(--border);
}

/* Search Input */
.search-input {
    position: relative;
}

.search-icon {
    position: absolute;
    left: 0.75rem;
    top: 50%;
    transform: translateY(-50%);
    color: var(--muted-foreground);
    width: 1rem;
    height: 1rem;
}

.search-input input {
    padding-left: 2.5rem;
}

/* Phone Input */
.phone-input {
    position: relative;
}

.phone-icon {
    position: absolute;
    left: 0.75rem;
    top: 50%;
    transform: translateY(-50%);
    color: var(--muted-foreground);
    width: 1rem;
    height: 1rem;
}

.phone-input input {
    padding-left: 2.5rem;
}

/* Filters */
.filters-content {
    padding: 1.5rem;
}

.filters-row {
    display: grid;
    grid-template-columns: 1fr 1fr 1fr;
    gap: 1rem;
}

/* Stats Grid */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 1rem;
    margin-bottom: 1.5rem;
}

.stat-card {
    background: var(--card);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    padding: 1rem;
}

.stat-content {
    display: flex;
    align-items: center;
    justify-content: space-between;
}

/* Utils */
.truncate {
    overflow: hidden;
    text-overflow: ellipsis;
    display: -webkit-box;
    line-clamp: 2;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
}

.stat-info {
    flex: 1;
}

.stat-label {
    font-size: 0.875rem;
    color: var(--muted-foreground);
    margin-bottom: 0.25rem;
}

.stat-value {
    font-size: 1.5rem;
    font-weight: 600;
    color: var(--foreground);
}

.stat-value.green {
    color: #10b981;
}

.stat-value.orange {
    color: #f59e0b;
}

.stat-value.red {
    color: #ef4444;
}

.stat-icon {
    width: 2rem;
    height: 2rem;
    opacity: 0.7;
}

.stat-icon.blue {
    color: #3b82f6;
}

.stat-icon.green {
    color: #10b981;
}

.stat-icon.orange {
    color: #f59e0b;
}

.stat-icon.red {
    color: #ef4444;
}

/* Table Styles */
.table-container {
    overflow-x: auto;
    padding: 1.5rem;
}

.clients-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.875rem;
}

.clients-table th,
.clients-table td {
    padding: 0.75rem;
    text-align: left;
    border-bottom: 1px solid var(--border);
}

.clients-table th {
    font-weight: 600;
    background-color: var(--secondary);
    color: var(--foreground);
}

.clients-table tr:hover {
    background-color: var(--accent);
}

.clients-table tr.inactive {
    background-color: #fef2f2;
}

.clients-table tr.inactive:hover {
    background-color: #fecaca;
}

.actions-column {
    width: 120px;
    text-align: right;
}

.table-actions {
    display: flex;
    gap: 0.5rem;
    justify-content: flex-end;
}

/* Modern action buttons container (used by client-manager) */
.action-buttons {
    display: flex;
    gap: 0.375rem;
    justify-content: flex-end;
    align-items: center;
    flex-wrap: wrap;
}

.action-btn {
    padding: 0.375rem;
    border: none;
    border-radius: calc(var(--radius) - 4px);
    background: transparent;
    cursor: pointer;
    transition: all 0.2s;
    display: inline-flex;
    align-items: center;
    justify-content: center;
}

.action-btn:hover {
    background-color: var(--accent);
}

.action-btn.edit {
    color: #3b82f6;
}

.action-btn.delete {
    color: var(--destructive);
}

.action-btn.delete:hover {
    background-color: #fee2e2;
}

/* New modern icon-only buttons */
.btn-icon {
    width: 2.25rem; /* 36px */
    height: 2.25rem;
    padding: 0;
    border: 1px solid transparent;
    border-radius: calc(var(--radius) - 4px);
    background: transparent;
    color: var(--foreground);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: background-color 0.2s ease, color 0.2s ease, box-shadow 0.2s ease, border-color 0.2s ease, transform 0.06s ease;
}

.btn-icon i {
    width: 1rem;
    height: 1rem;
}

.btn-icon:hover {
    background-color: var(--accent);
}

.btn-icon:active {
    transform: translateY(1px);
}

.btn-icon:focus-visible {
    outline: none;
    box-shadow: 0 0 0 3px rgba(3, 2, 19, 0.12);
    border-color: rgba(3, 2, 19, 0.24);
}

.btn-icon.edit {
    color: #2563eb; /* blue-600 */
}

.btn-icon.edit:hover {
    background-color: #eff6ff; /* blue-50 */
}

.btn-icon.delete {
    color: var(--destructive);
}

.btn-icon.delete:hover {
    background-color: #fff1f2; /* rose-50 */
}

/* Variant for destructive actions in contexts other than delete icon */
.btn-icon.btn-danger {
    color: #dc2626; /* red-600 */
}

.btn-icon.btn-danger:hover {
    background-color: #fee2e2; /* red-100 */
}

/* Phone Cell Style */
.phone-cell {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.phone-cell i {
    color: var(--muted-foreground);
    width: 1rem;
    height: 1rem;
}

/* Badge Styles */
.badge {
    padding: 0.25rem 0.75rem;
    border-radius: calc(var(--radius) - 4px);
    font-size: 0.75rem;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s;
    border: none;
    display: inline-flex;
    align-items: center;
    gap: 0.25rem;
}

.badge.active {
    background-color: #dcfce7;
    color: #166534;
}

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

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

.badge-admin {
    background-color: #ddd6fe;
    color: #5b21b6;
    padding: 0.25rem 0.5rem;
    border-radius: 9999px;
    font-size: 0.75rem;
    font-weight: 500;
}

.badge-operator {
    background-color: #e0f2fe;
    color: #0c4a6e;
    padding: 0.25rem 0.5rem;
    border-radius: 9999px;
    font-size: 0.75rem;
    font-weight: 500;
}

.badge-active {
    background-color: #dcfce7;
    color: #166534;
    padding: 0.25rem 0.5rem;
    border-radius: 9999px;
    font-size: 0.75rem;
    font-weight: 500;
}

.badge-inactive {
    background-color: #fee2e2;
    color: #991b1b;
    padding: 0.25rem 0.5rem;
    border-radius: 9999px;
    font-size: 0.75rem;
    font-weight: 500;
}

.lider-badge {
    padding: 0.25rem 0.5rem;
    border-radius: 9999px;
    font-size: 0.75rem;
    font-weight: 500;
    border: none;
    display: inline-flex;
    align-items: center;
    gap: 0.25rem;
}

.lider-badge.lider-si {
    background-color: #dbeafe;
    color: #1e40af;
}

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

.no-results {
    text-align: center;
    padding: 3rem 1rem;
    color: var(--muted-foreground);
}

.no-results i {
    width: 3rem;
    height: 3rem;
    margin-bottom: 1rem;
    opacity: 0.5;
}

/* Modal Styles */
.modal {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 1000;
    display: none; /* Oculto por defecto */
    align-items: center;
    justify-content: center;
    padding: 1rem;
}

.modal.show {
    display: flex; /* Mostrar cuando tenga la clase 'show' */
}

.modal-overlay {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-color: rgba(0, 0, 0, 0.5);
    animation: fadeIn 0.2s ease-out;
}

.modal-content {
    background: var(--card);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    max-width: 600px;
    width: 100%;
    max-height: 90vh;
    overflow-y: auto;
    position: relative;
    animation: slideIn 0.3s ease-out;
}

.modal-content.small {
    max-width: 400px;
}

.modal-header {
    padding: 1.5rem;
    border-bottom: 1px solid var(--border);
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.modal-header h3 {
    font-size: 1.25rem;
    font-weight: 600;
    color: var(--foreground);
}

.modal-close {
    width: 2.25rem;
    height: 2.25rem;
    padding: 0;
    border: 1px solid transparent;
    background: transparent;
    border-radius: calc(var(--radius) - 4px);
    cursor: pointer;
    color: var(--muted-foreground);
    transition: background-color 0.2s ease, box-shadow 0.2s ease, border-color 0.2s ease;
}

.modal-close:hover {
    background-color: var(--accent);
    color: var(--foreground);
}

.modal-close:focus-visible {
    outline: none;
    box-shadow: 0 0 0 3px rgba(3, 2, 19, 0.12);
    border-color: rgba(3, 2, 19, 0.24);
}

.modal-body {
    padding: 1.5rem;
}

.modal-description {
    color: var(--muted-foreground);
    margin-bottom: 1.5rem;
}

.modal-footer {
    padding: 1.5rem;
    border-top: 1px solid var(--border);
    display: flex;
    gap: 0.75rem;
    justify-content: flex-end;
}

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

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

/* Message Section */
.message-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 1.5rem;
}

.message-form {
    padding: 1.5rem;
}

.message-info {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-size: 0.875rem;
    color: var(--muted-foreground);
}

/* Alert */
.alert {
    padding: 1rem;
    border-radius: calc(var(--radius) - 2px);
    background-color: #dbeafe;
    border: 1px solid #93c5fd;
    color: #1e40af;
    display: flex;
    align-items: center;
    gap: 0.5rem;
    margin-bottom: 1rem;
}

/* Clients Section */
.clients-section {
    padding: 1.5rem;
}

.filters-header {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    margin-bottom: 1rem;
    font-weight: 500;
}

.filters-actions {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1rem;
}

.clients-list {
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 1rem;
    max-height: 240px;
    overflow-y: auto;
}

.client-select-all {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding-bottom: 0.75rem;
    margin-bottom: 0.75rem;
    border-bottom: 1px solid var(--border);
    font-weight: 500;
}

.client-item {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    margin-bottom: 0.75rem;
}

.client-item label {
    flex: 1;
    cursor: pointer;
    font-size: 0.875rem;
}

.client-info {
    display: flex;
    flex-direction: column;
}

.client-details {
    font-size: 0.75rem;
    color: var(--muted-foreground);
}

/* Toast Notifications */
.toast-container {
    position: fixed;
    top: 1rem;
    right: 1rem;
    z-index: 1000;
}

.toast {
    background: var(--card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    padding: 1rem;
    margin-bottom: 0.5rem;
    min-width: 300px;
    animation: slideInToast 0.3s ease-out;
}

.toast.success {
    border-left: 4px solid #10b981;
}

.toast.error {
    border-left: 4px solid var(--destructive);
}

@keyframes slideInToast {
    from {
        transform: translateX(100%);
        opacity: 0;
    }
    to {
        transform: translateX(0);
        opacity: 1;
    }
}

/* Responsive Design */
@media (min-width: 769px) {
    .main-app {
        display: flex !important;
        flex-direction: row !important;
        height: 100vh;
    }
    
    .sidebar {
        width: 256px !important;
        min-width: 256px !important;
        height: 100vh;
        flex-shrink: 0 !important;
    }
    
    .main-content {
        flex: 1 !important;
        height: 100vh;
        overflow-y: auto;
    }
}

/* Force horizontal layout on all desktop screens */
@media (min-width: 992px) {
    .main-app {
        display: flex !important;
        flex-direction: row !important;
    }
    
    body .main-app {
        display: flex !important;
        flex-direction: row !important;
    }
}

@media (max-width: 768px) {
    .main-app {
        flex-direction: column;
    }
    
    .sidebar {
        width: 100%;
        height: auto;
    }
    
    .sidebar-nav {
        display: flex;
        overflow-x: auto;
        padding: 0.5rem;
    }
    
    .nav-item {
        min-width: 120px;
        margin-right: 0.5rem;
        margin-bottom: 0;
    }
    
    .dashboard-grid {
        grid-template-columns: 1fr;
    }
    
    .message-grid {
        grid-template-columns: 1fr;
    }
    
    .form-row {
        grid-template-columns: 1fr;
    }
    
    .filters-row {
        grid-template-columns: 1fr;
    }
    
    .stats-grid {
        grid-template-columns: 1fr;
    }
    
    .table-container {
        padding: 0.5rem;
    }
    
    .clients-table {
        font-size: 0.75rem;
    }
    
    .clients-table th,
    .clients-table td {
        padding: 0.5rem 0.25rem;
    }
    
    .modal-content {
        margin: 0.5rem;
        max-height: 95vh;
    }
}

/* Input checkbox styling */
input[type="checkbox"] {
    width: 1rem;
    height: 1rem;
    margin-right: 0.5rem;
}

/* Select styling */
select {
    appearance: none;
    background-image: url("data:image/svg+xml,%3csvg xmlns='http://www.w3.org/2000/svg' fill='none' viewBox='0 0 20 20'%3e%3cpath stroke='%236b7280' stroke-linecap='round' stroke-linejoin='round' stroke-width='1.5' d='m6 8 4 4 4-4'/%3e%3c/svg%3e");
    background-position: right 0.5rem center;
    background-repeat: no-repeat;
    background-size: 1.5em 1.5em;
    padding-right: 2.5rem;
}

/* Image Upload Styles */
.image-upload-container {
    border: 2px dashed var(--border);
    border-radius: var(--radius);
    padding: 2rem;
    text-align: center;
    background-color: var(--secondary);
    transition: all 0.3s ease;
    cursor: pointer;
    position: relative;
    display: block;
}

.image-upload-container:hover {
    border-color: var(--primary);
    background-color: var(--accent);
}

.image-upload-container.dragover {
    border-color: var(--primary);
    background-color: var(--primary);
    color: var(--primary-foreground);
}

.upload-icon {
    font-size: 3rem;
    color: var(--muted-foreground);
    margin-bottom: 1rem;
    display: block;
}

.image-upload-container.dragover .upload-icon {
    color: var(--primary-foreground);
}

.upload-text {
    color: var(--muted-foreground);
    font-size: 0.875rem;
    line-height: 1.25rem;
}

.image-upload-container.dragover .upload-text {
    color: var(--primary-foreground);
}

.hidden {
    display: none !important;
}

.image-preview-container {
    margin-top: 1rem;
    position: relative;
    display: block;
}

.image-preview {
    margin-top: 0.75rem;
    border-radius: var(--radius);
    background: var(--card);
    border: 1px solid var(--border);
    padding: 0.5rem;
    overflow: hidden;
}

/* Asegurar que la imagen no sobreponga el layout */
.image-preview img,
#preview-img {
    display: block;
    max-width: 100%;
    height: auto;
    max-height: 380px; /* limita la altura en pantallas desktop */
    object-fit: contain;
    border-radius: calc(var(--radius) - 2px);
}

/* Fila de info y botón eliminar debajo de la imagen */
.image-info {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.5rem;
    margin-top: 0.5rem;
    color: var(--muted-foreground);
}

.btn-remove {
    background: transparent;
    border: none;
    cursor: pointer;
    color: var(--muted-foreground);
    padding: 0.25rem;
    border-radius: 6px;
}

.btn-remove:hover {
    color: var(--destructive);
    background: #fee2e2;
}

.remove-image-btn {
    position: absolute;
    top: 0.5rem;
    right: 0.5rem;
    background-color: var(--destructive);
    color: var(--destructive-foreground);
    border: none;
    border-radius: 50%;
    width: 2rem;
    height: 2rem;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    font-size: 1rem;
    transition: all 0.2s ease;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.2);
}

.remove-image-btn:hover {
    background-color: #b91c1c;
    transform: scale(1.1);
}

.upload-progress {
    margin-top: 1rem;
    width: 100%;
    height: 0.5rem;
    background-color: var(--muted);
    border-radius: var(--radius);
    overflow: hidden;
    position: relative;
}

.upload-progress-bar {
    height: 100%;
    background: linear-gradient(90deg, var(--primary) 0%, #4f46e5 100%);
    border-radius: var(--radius);
    transition: width 0.3s ease;
    width: 0%;
}

.upload-status {
    margin-top: 0.5rem;
    font-size: 0.875rem;
    color: var(--muted-foreground);
    text-align: center;
}

.upload-status.success {
    color: #059669;
}

.upload-status.error {
    color: var(--destructive);
}

/* Switch Styles */
.switch-container {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    margin-top: 0.5rem;
}

.switch-input {
    display: none;
}

.switch-label {
    position: relative;
    display: inline-block;
    width: 3rem;
    height: 1.5rem;
    cursor: pointer;
}

.switch-slider {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-color: var(--muted);
    border-radius: 1.5rem;
    transition: all 0.3s ease;
}

.switch-slider:before {
    position: absolute;
    content: "";
    height: 1.125rem;
    width: 1.125rem;
    left: 0.1875rem;
    bottom: 0.1875rem;
    background-color: white;
    border-radius: 50%;
    transition: all 0.3s ease;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.2);
}

.switch-input:checked + .switch-label .switch-slider {
    background-color: var(--primary);
}

.switch-input:checked + .switch-label .switch-slider:before {
    transform: translateX(1.5rem);
}

.switch-text {
    font-size: 0.875rem;
    color: var(--muted-foreground);
    font-weight: 500;
    min-width: 2rem;
}

.switch-input:checked ~ .switch-text {
    color: var(--primary);
}

/* Estilos para Mensajes Recibidos */
.stats-container {
    margin-bottom: 2rem;
}

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

.stat-card {
    background: var(--card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 1.5rem;
    text-align: center;
    transition: all 0.3s ease;
}

.stat-card:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow);
}

.stat-card.stat-alert {
    border-color: #fbbf24;
    background: #fef3c7;
}

.stat-card.stat-warning {
    border-color: #f59e0b;
    background: #fde68a;
}

.stat-number {
    font-size: 2rem;
    font-weight: bold;
    color: var(--primary);
    margin-bottom: 0.5rem;
}

.stat-label {
    font-size: 0.875rem;
    color: var(--muted-foreground);
    font-weight: 500;
}

.filters-container {
    background: var(--card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 1.5rem;
    margin-bottom: 2rem;
}

.filters-row {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 1rem;
    align-items: end;
}

.filter-group {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.filter-group label {
    font-size: 0.875rem;
    font-weight: 500;
    color: var(--foreground);
}

.filter-group select,
.filter-group input {
    padding: 0.5rem;
    border: 1px solid var(--border);
    border-radius: 0.375rem;
    font-size: 0.875rem;
    background: var(--input-background);
}

.messages-container {
    background: var(--card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    overflow: hidden;
}

.messages-list {
    max-height: 600px;
    overflow-y: auto;
}

.mensaje-item {
    border-bottom: 1px solid var(--border);
    padding: 1.5rem;
    transition: background-color 0.2s ease;
}

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

.mensaje-item:hover {
    background-color: var(--secondary);
}

.mensaje-item.no-leido {
    background-color: #fef3c7;
    border-left: 4px solid #f59e0b;
}

.mensaje-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    margin-bottom: 1rem;
}

.mensaje-info {
    flex: 1;
}

.mensaje-cliente {
    font-weight: 600;
    font-size: 1rem;
    margin-bottom: 0.25rem;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.mensaje-telefono {
    font-size: 0.875rem;
    color: var(--muted-foreground);
}

.mensaje-meta {
    text-align: right;
}

.mensaje-fecha {
    font-size: 0.875rem;
    color: var(--muted-foreground);
    margin-bottom: 0.25rem;
}

.mensaje-estados {
    display: flex;
    gap: 0.5rem;
    justify-content: flex-end;
}

.estado {
    font-size: 0.75rem;
}

.estado.no-leido {
    color: #f59e0b;
}

.estado.sin-responder {
    color: #ef4444;
}

.estado.respondido {
    color: #10b981;
}

.mensaje-contenido {
    background: var(--secondary);
    padding: 1rem;
    border-radius: 0.375rem;
    font-size: 0.875rem;
    line-height: 1.6;
    margin-bottom: 1rem;
    white-space: pre-wrap;
}

.mensaje-acciones {
    display: flex;
    gap: 0.5rem;
    flex-wrap: wrap;
}

.btn-sm {
    padding: 0.375rem 0.75rem;
    font-size: 0.875rem;
}

.btn-outline {
    background: transparent;
    border: 1px solid var(--border);
    color: var(--foreground);
}

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

.badge {
    display: inline-block;
    padding: 0.125rem 0.5rem;
    font-size: 0.75rem;
    font-weight: 500;
    border-radius: 0.25rem;
}

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

.badge-warning {
    background: #fde68a;
    color: #92400e;
}

.pagination-container {
    border-top: 1px solid var(--border);
    padding: 1rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 1rem;
}

.pagination-info {
    font-size: 0.875rem;
    color: var(--muted-foreground);
}

.pagination-controls {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.page-numbers {
    display: flex;
    gap: 0.25rem;
}

.page-number {
    padding: 0.375rem 0.75rem;
    border: 1px solid var(--border);
    background: var(--background);
    color: var(--foreground);
    border-radius: 0.375rem;
    font-size: 0.875rem;
    cursor: pointer;
    transition: all 0.2s ease;
}

.page-number:hover {
    background: var(--secondary);
}

.page-number.active {
    background: var(--primary);
    color: var(--primary-foreground);
    border-color: var(--primary);
}

.empty-state {
    text-align: center;
    padding: 3rem 2rem;
    color: var(--muted-foreground);
}

.empty-icon {
    font-size: 3rem;
    margin-bottom: 1rem;
}

/* Modal de Respuesta */
.response-modal {
    max-width: 600px;
    width: 90%;
}

.cliente-info-section {
    background: var(--secondary);
    padding: 1rem;
    border-radius: 0.375rem;
    margin-bottom: 1rem;
}

.cliente-info h4 {
    margin-bottom: 0.25rem;
    color: var(--primary);
}

.cliente-info p {
    margin-bottom: 0.25rem;
    color: var(--muted-foreground);
}

.cliente-info .timestamp {
    font-size: 0.875rem;
    color: var(--muted-foreground);
}

.mensaje-original-section {
    margin-bottom: 1rem;
}

.mensaje-original-section label {
    display: block;
    font-weight: 500;
    margin-bottom: 0.5rem;
    color: var(--foreground);
}

.mensaje-original {
    background: var(--muted);
    padding: 1rem;
    border-radius: 0.375rem;
    font-size: 0.875rem;
    line-height: 1.6;
    white-space: pre-wrap;
    border-left: 4px solid var(--primary);
}

.respuesta-section label {
    display: block;
    font-weight: 500;
    margin-bottom: 0.5rem;
    color: var(--foreground);
}

.respuesta-section textarea {
    width: 100%;
    padding: 0.75rem;
    border: 1px solid var(--border);
    border-radius: 0.375rem;
    font-size: 0.875rem;
    line-height: 1.6;
    resize: vertical;
    font-family: inherit;
}

.respuesta-section textarea:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 2px rgba(3, 2, 19, 0.1);
}

.char-counter {
    text-align: right;
    margin-top: 0.5rem;
    font-size: 0.75rem;
    color: var(--muted-foreground);
}

.btn-back {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.5rem 1rem;
    background: var(--secondary);
    border: 1px solid var(--border);
    border-radius: 0.375rem;
    color: var(--foreground);
    text-decoration: none;
    font-size: 0.875rem;
    transition: all 0.2s ease;
    margin-bottom: 1rem;
}

.btn-back:hover {
    background: var(--muted);
    transform: translateX(-2px);
}

/* Responsivo para móviles */
@media (max-width: 768px) {
    .filters-row {
        grid-template-columns: 1fr;
    }
    
    .mensaje-header {
        flex-direction: column;
        gap: 0.5rem;
    }
    
    .mensaje-meta {
        text-align: left;
    }
    
    .mensaje-estados {
        justify-content: flex-start;
    }
    
    .pagination-container {
        flex-direction: column;
        text-align: center;
    }
    
    .stats-grid {
        grid-template-columns: repeat(2, 1fr);
    }
}