/* ========================================
   EvoAdmin - Estilos
   ======================================== */

:root {
    --color-primary: #2563eb;
    --color-primary-dark: #1d4ed8;
    --color-primary-light: #dbeafe;
    --color-success: #16a34a;
    --color-success-light: #dcfce7;
    --color-warning: #f59e0b;
    --color-warning-light: #fef3c7;
    --color-danger: #dc2626;
    --color-danger-light: #fee2e2;
    --color-info: #0891b2;
    --color-info-light: #cffafe;
    --color-secondary: #6b7280;
    --color-bg: #f3f4f6;
    --color-surface: #ffffff;
    --color-text: #1f2937;
    --color-text-muted: #6b7280;
    --color-border: #e5e7eb;
    --sidebar-width: 250px;
    --radius: 8px;
    --shadow: 0 1px 3px rgba(0,0,0,0.1);
    --shadow-lg: 0 4px 12px rgba(0,0,0,0.15);
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', sans-serif;
    background: var(--color-bg);
    color: var(--color-text);
    font-size: 14px;
    line-height: 1.6;
}

/* ========================================
   LOGIN PAGE
   ======================================== */

.login-page {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 100vh;
    background: linear-gradient(135deg, #1e3a5f 0%, #2563eb 50%, #1d4ed8 100%);
}

.login-container {
    width: 100%;
    max-width: 400px;
    padding: 20px;
}

.login-card {
    background: var(--color-surface);
    border-radius: 16px;
    padding: 40px 30px;
    box-shadow: 0 20px 60px rgba(0,0,0,0.3);
}

.login-header {
    text-align: center;
    margin-bottom: 30px;
}

.login-logo {
    font-size: 48px;
    margin-bottom: 10px;
}

.login-header h1 {
    font-size: 28px;
    color: var(--color-text);
    margin-bottom: 5px;
}

.login-subtitle {
    color: var(--color-text-muted);
    font-size: 14px;
}

.login-form .form-group {
    margin-bottom: 20px;
}

.login-footer {
    text-align: center;
    margin-top: 25px;
    color: var(--color-text-muted);
}

/* ========================================
   APP LAYOUT
   ======================================== */

.app-layout {
    display: flex;
    min-height: 100vh;
}

/* SIDEBAR */
.sidebar {
    width: var(--sidebar-width);
    background: #1e293b;
    color: #cbd5e1;
    display: flex;
    flex-direction: column;
    position: fixed;
    top: 0;
    bottom: 0;
    left: 0;
    z-index: 100;
}

.sidebar-header {
    padding: 20px;
    display: flex;
    align-items: center;
    gap: 10px;
    border-bottom: 1px solid #334155;
}

.sidebar-logo {
    font-size: 28px;
}

.sidebar-title {
    font-size: 20px;
    font-weight: 700;
    color: #fff;
}

.sidebar-nav {
    flex: 1;
    padding: 15px 0;
    overflow-y: auto;
}

.nav-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 20px;
    color: #cbd5e1;
    text-decoration: none;
    transition: all 0.15s;
    border-left: 3px solid transparent;
}

.nav-item:hover {
    background: #334155;
    color: #fff;
}

.nav-item.active {
    background: #334155;
    color: #60a5fa;
    border-left-color: #60a5fa;
}

.nav-icon {
    font-size: 18px;
    width: 24px;
    text-align: center;
}

.nav-label {
    font-size: 14px;
}

.sidebar-footer {
    border-top: 1px solid #334155;
    padding: 10px 0;
}

.nav-logout:hover {
    background: var(--color-danger) !important;
    color: #fff !important;
}

.version-tag {
    display: block;
    text-align: center;
    padding: 5px;
    font-size: 11px;
    color: #64748b;
}

/* MAIN CONTENT */
.main-content {
    flex: 1;
    margin-left: var(--sidebar-width);
    padding: 0;
}

.content-header {
    background: var(--color-surface);
    padding: 20px 30px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    border-bottom: 1px solid var(--color-border);
    box-shadow: var(--shadow);
}

.page-title {
    font-size: 22px;
    font-weight: 600;
}

.content-body {
    padding: 25px 30px;
}

/* ========================================
   SIDEBAR COLLAPSE — TOGGLE BUTTON
   ======================================== */

.content-header-left {
    display: flex;
    align-items: center;
    gap: 12px;
}

.sidebar-toggle-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 36px;
    height: 36px;
    background: transparent;
    border: 1px solid var(--color-border);
    border-radius: var(--radius);
    cursor: pointer;
    color: var(--color-text);
    transition: all 0.15s;
    flex-shrink: 0;
    line-height: 1;
}

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

.sidebar-toggle-btn svg {
    width: 18px;
    height: 18px;
}

/* SIDEBAR COLLAPSE — ICON-ONLY MODE (desktop/tablet) */
.sidebar {
    transition: width 0.25s ease;
}

.sidebar-header,
.nav-item {
    transition: padding 0.25s ease;
}

.sidebar-collapsed .sidebar {
    width: 60px;
}

.sidebar-collapsed .sidebar-header {
    justify-content: center;
    padding: 20px 0;
}

.sidebar-collapsed .sidebar-logo {
    font-size: 24px;
}

.sidebar-collapsed .sidebar-title,
.sidebar-collapsed .nav-label,
.sidebar-collapsed .version-tag {
    display: none;
}

.sidebar-collapsed .nav-item {
    justify-content: center;
    padding: 12px 0;
    gap: 0;
    border-left: none;
    border-right: 3px solid transparent;
}

.sidebar-collapsed .nav-item.active {
    border-right-color: #60a5fa;
}

.sidebar-collapsed .nav-icon {
    width: auto;
    font-size: 20px;
}

.sidebar-collapsed .sidebar-footer .nav-item {
    justify-content: center;
    padding: 12px 0;
}

.sidebar-collapsed .main-content {
    margin-left: 60px;
}

.main-content {
    transition: margin-left 0.25s ease;
}

/* MOBILE SIDEBAR OVERLAY */
.sidebar-overlay {
    display: none;
    position: fixed;
    top: 0; left: 0; right: 0; bottom: 0;
    background: rgba(0,0,0,0.5);
    z-index: 99;
    cursor: pointer;
}

.sidebar-overlay.active {
    display: block;
}

/* ========================================
   COMPONENTS
   ======================================== */

/* CARDS */
.card {
    background: var(--color-surface);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    margin-bottom: 20px;
    overflow: hidden;
}

.card-header {
    padding: 16px 20px;
    border-bottom: 1px solid var(--color-border);
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.card-header h2 {
    font-size: 16px;
    font-weight: 600;
}

.card-body {
    padding: 20px;
}

/* STATS GRID */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 15px;
    margin-bottom: 20px;
}

.stat-card {
    background: var(--color-surface);
    border-radius: var(--radius);
    padding: 20px;
    display: flex;
    align-items: center;
    gap: 15px;
    box-shadow: var(--shadow);
    border-left: 4px solid var(--color-primary);
}

.stat-card.stat-blue { border-left-color: #3b82f6; }
.stat-card.stat-green { border-left-color: #22c55e; }
.stat-card.stat-purple { border-left-color: #a855f7; }
.stat-card.stat-orange { border-left-color: #f97316; }

.stat-icon {
    font-size: 32px;
}

.stat-value {
    font-size: 28px;
    font-weight: 700;
    line-height: 1;
}

.stat-label {
    color: var(--color-text-muted);
    font-size: 13px;
    margin-top: 4px;
}

/* BUTTONS */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    padding: 8px 16px;
    border: none;
    border-radius: var(--radius);
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.15s;
    text-decoration: none;
    white-space: nowrap;
}

.btn:hover { opacity: 0.9; transform: translateY(-1px); }
.btn:active { transform: translateY(0); }

.btn-primary { background: var(--color-primary); color: #fff; }
.btn-success { background: var(--color-success); color: #fff; }
.btn-danger { background: var(--color-danger); color: #fff; }
.btn-warning { background: var(--color-warning); color: #fff; }
.btn-outline { background: transparent; color: var(--color-text); border: 1px solid var(--color-border); }
.btn-outline:hover { background: var(--color-bg); }
.btn-sm { padding: 5px 10px; font-size: 13px; }
.btn-block { width: 100%; }

/* FORM */
.form-group {
    margin-bottom: 15px;
}

.form-group label {
    display: block;
    margin-bottom: 5px;
    font-weight: 500;
    font-size: 14px;
}

.form-group input,
.form-group select,
.form-group textarea {
    width: 100%;
    padding: 9px 12px;
    border: 1px solid var(--color-border);
    border-radius: var(--radius);
    font-size: 14px;
    font-family: inherit;
    transition: border-color 0.15s;
}

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

.form-group small {
    display: block;
    margin-top: 4px;
    color: var(--color-text-muted);
    font-size: 12px;
}

.form-row {
    display: flex;
    gap: 15px;
}

.form-row .form-group {
    flex: 1;
}

.form-grow {
    flex: 2 !important;
}

.form-actions {
    display: flex;
    gap: 10px;
    margin-top: 10px;
}

/* TABLES */
.data-table {
    width: 100%;
    border-collapse: collapse;
}

.data-table th,
.data-table td {
    padding: 10px 12px;
    text-align: left;
    border-bottom: 1px solid var(--color-border);
}

.data-table th {
    font-weight: 600;
    color: var(--color-text-muted);
    font-size: 13px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.data-table tbody tr:hover {
    background: #f9fafb;
}

/* BADGES */
.badge {
    display: inline-block;
    padding: 3px 10px;
    border-radius: 20px;
    font-size: 12px;
    font-weight: 500;
}

.badge-success { background: var(--color-success-light); color: var(--color-success); }
.badge-danger { background: var(--color-danger-light); color: var(--color-danger); }
.badge-warning { background: var(--color-warning-light); color: var(--color-warning); }
.badge-info { background: var(--color-info-light); color: var(--color-info); }
.badge-secondary { background: #f3f4f6; color: var(--color-secondary); }

/* ALERTS */
.alert {
    padding: 12px 16px;
    border-radius: var(--radius);
    margin-bottom: 15px;
    font-size: 14px;
}

.alert-success { background: var(--color-success-light); color: var(--color-success); }
.alert-error { background: var(--color-danger-light); color: var(--color-danger); }
.alert-warning { background: var(--color-warning-light); color: var(--color-warning); }
.alert-info { background: var(--color-info-light); color: var(--color-info); }

/* MODAL */
.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0,0,0,0.5);
    z-index: 1000;
    display: none;
    align-items: center;
    justify-content: center;
}

.modal-overlay.active {
    display: flex;
}

.modal {
    background: var(--color-surface);
    border-radius: var(--radius);
    width: 90%;
    max-width: 500px;
    max-height: 90vh;
    overflow-y: auto;
    box-shadow: var(--shadow-lg);
}

.modal-lg {
    max-width: 600px;
}

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

.modal-header h3 {
    font-size: 18px;
    font-weight: 600;
}

.modal-close {
    background: none;
    border: none;
    font-size: 20px;
    cursor: pointer;
    color: var(--color-text-muted);
    padding: 0;
    width: 30px;
    height: 30px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
}

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

.modal-body {
    padding: 20px;
}

.modal-footer {
    padding: 15px 0 0;
    display: flex;
    justify-content: flex-end;
    gap: 10px;
    margin-top: 15px;
}

/* DASHBOARD GRID */
.dashboard-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
    gap: 20px;
    margin-bottom: 20px;
}

.message-stats {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 10px;
}

.msg-stat {
    text-align: center;
    padding: 15px;
    background: var(--color-bg);
    border-radius: var(--radius);
}

.msg-stat-label {
    display: block;
    color: var(--color-text-muted);
    font-size: 12px;
    margin-bottom: 5px;
}

.msg-stat-value {
    font-size: 24px;
    font-weight: 700;
}

.msg-sent { color: var(--color-success); }
.msg-received { color: var(--color-info); }
.msg-error { color: var(--color-danger); }

/* WEBSITE LIST */
.website-list {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.website-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 10px 12px;
    background: var(--color-bg);
    border-radius: var(--radius);
}

.website-info strong {
    display: block;
}

.website-info small {
    color: var(--color-text-muted);
}

/* INSTANCE CARDS */
.instances-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
    gap: 15px;
}

.instance-card {
    border: 1px solid var(--color-border);
    border-radius: var(--radius);
    padding: 15px;
    background: var(--color-surface);
    transition: box-shadow 0.15s;
}

.instance-card:hover {
    box-shadow: var(--shadow-lg);
}

.instance-card-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 12px;
}

.instance-card-header h3 {
    font-size: 16px;
    font-weight: 600;
}

.instance-card-header small {
    color: var(--color-text-muted);
}

.status-dot {
    width: 12px;
    height: 12px;
    border-radius: 50%;
    flex-shrink: 0;
}

.status-dot.status-open { background: var(--color-success); box-shadow: 0 0 6px var(--color-success); }
.status-dot.status-qr_ready { background: var(--color-warning); animation: pulse 1.5s infinite; }
.status-dot.status-connecting { background: var(--color-info); animation: pulse 1.5s infinite; }
.status-dot.status-disconnected { background: var(--color-danger); }
.status-dot.status-unknown { background: var(--color-secondary); }

@keyframes pulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.5; }
}

.instance-card-body {
    margin-bottom: 12px;
}

.instance-meta {
    display: flex;
    justify-content: space-between;
    padding: 4px 0;
    font-size: 13px;
}

.meta-label {
    color: var(--color-text-muted);
}

.instance-card-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
}

/* QR CODE */
.qr-code-container {
    text-align: center;
    padding: 20px;
    min-height: 250px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.qr-image {
    max-width: 300px;
    width: 100%;
    border: 1px solid var(--color-border);
    border-radius: var(--radius);
}

.qr-instructions {
    text-align: center;
    color: var(--color-text-muted);
    font-size: 13px;
    margin: 15px 0;
}

.qr-body {
    text-align: center;
}

/* MESSAGES PAGE */
.messages-layout {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 20px;
}

.phone-input-group {
    display: flex;
    gap: 8px;
}

.char-counter {
    text-align: right;
    color: var(--color-text-muted);
    font-size: 12px;
    margin-top: 3px;
}

.send-result {
    margin-top: 15px;
}

.history-row {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 8px 0;
    border-bottom: 1px solid var(--color-border);
}

.history-row.sent .hist-dir { color: var(--color-success); }
.history-row.received .hist-dir { color: var(--color-info); }

.hist-content {
    flex: 1;
    overflow: hidden;
}

.hist-content strong {
    font-size: 13px;
}

.hist-text {
    display: block;
    color: var(--color-text-muted);
    font-size: 12px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.hist-status {
    font-size: 11px;
    padding: 2px 8px;
    border-radius: 10px;
}

.status-success { background: var(--color-success-light); color: var(--color-success); }
.status-error { background: var(--color-danger-light); color: var(--color-danger); }
.status-pending { background: var(--color-warning-light); color: var(--color-warning); }
.status-received { background: var(--color-info-light); color: var(--color-info); }

/* REPLY BUTTON IN HISTORY */
.hist-reply-btn {
    margin-top: 4px;
    font-size: 11px !important;
    padding: 2px 8px !important;
    color: var(--color-primary) !important;
    border-color: var(--color-primary-light) !important;
}

.hist-reply-btn:hover {
    background: var(--color-primary-light) !important;
}

/* LOGS STATS */
.logs-stats {
    display: flex;
    gap: 10px;
    margin-bottom: 20px;
    flex-wrap: wrap;
}

.log-stat-card {
    background: var(--color-surface);
    padding: 12px 20px;
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    text-align: center;
    min-width: 120px;
}

.log-stat-label {
    display: block;
    font-size: 12px;
    color: var(--color-text-muted);
    margin-bottom: 3px;
}

.log-stat-value {
    font-size: 22px;
    font-weight: 700;
}

/* PAGE ACTIONS */
.page-actions {
    display: flex;
    gap: 10px;
    margin-bottom: 20px;
    align-items: center;
}

.filter-select {
    padding: 8px 12px;
    border: 1px solid var(--color-border);
    border-radius: var(--radius);
    font-size: 14px;
    background: var(--color-surface);
}

/* ACTION BUTTONS IN TABLES */
.action-buttons {
    display: flex;
    gap: 4px;
}

/* INFO TABLE */
.info-table {
    width: 100%;
}

.info-table td {
    padding: 8px 0;
}

.info-table td:first-child {
    width: 200px;
}

.info-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
    gap: 10px;
}

.info-item {
    display: flex;
    flex-direction: column;
    padding: 10px;
    background: var(--color-bg);
    border-radius: var(--radius);
}

.info-label {
    font-size: 12px;
    color: var(--color-text-muted);
}

.info-value {
    font-weight: 600;
    font-size: 14px;
    word-break: break-all;
}

/* EMPTY STATES */
.empty-state {
    text-align: center;
    padding: 40px 20px;
    color: var(--color-text-muted);
}

.empty-state p {
    margin-bottom: 10px;
}

.loading-text {
    color: var(--color-text-muted);
    text-align: center;
    padding: 20px;
}

.success-text {
    color: var(--color-success);
    font-size: 18px;
    font-weight: 600;
}

.error-text {
    color: var(--color-danger);
    font-size: 16px;
}

/* TEXT COLORS */
.text-success { color: var(--color-success); }
.text-error { color: var(--color-danger); }
.text-info { color: var(--color-info); }
.text-warning { color: var(--color-warning); }
.text-muted { color: var(--color-text-muted); }

/* TOAST */
#toast-container {
    position: fixed;
    top: 20px;
    right: 20px;
    z-index: 2000;
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.toast {
    padding: 12px 20px;
    border-radius: var(--radius);
    color: #fff;
    font-size: 14px;
    box-shadow: var(--shadow-lg);
    animation: slideIn 0.3s ease;
    max-width: 350px;
}

.toast-success { background: var(--color-success); }
.toast-error { background: var(--color-danger); }
.toast-warning { background: var(--color-warning); }
.toast-info { background: var(--color-info); }

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

/* WEBHOOKS */
.webhook-url-box {
    margin-top: 15px;
}

.copy-group {
    display: flex;
    gap: 8px;
    margin-top: 5px;
}

.copy-group input {
    flex: 1;
    padding: 8px 12px;
    border: 1px solid var(--color-border);
    border-radius: var(--radius);
    font-family: monospace;
    font-size: 13px;
}

.checkbox-group {
    display: flex;
    flex-wrap: wrap;
    gap: 12px;
    margin-top: 5px;
}

.checkbox-group label {
    display: flex;
    align-items: center;
    gap: 5px;
    font-weight: 400;
    cursor: pointer;
}

/* DOCS */
.docs-section h3 {
    font-size: 15px;
    margin: 15px 0 8px;
}

.docs-section ol, .docs-section ul {
    margin-left: 20px;
    margin-bottom: 15px;
}

.docs-section li {
    margin-bottom: 5px;
}

.docs-section code {
    background: var(--color-bg);
    padding: 2px 6px;
    border-radius: 4px;
    font-size: 13px;
}

/* SETTINGS LAYOUT */
.settings-layout {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
    gap: 20px;
    margin-bottom: 20px;
}

/* MAINTENANCE */
.maintenance-actions {
    display: flex;
    gap: 10px;
    margin-bottom: 15px;
}

.api-test-result {
    margin-top: 10px;
}

/* RESPONSIVE */
@media (max-width: 768px) {
    .sidebar {
        transform: translateX(-100%);
        transition: transform 0.3s;
    }
    
    .sidebar.open {
        transform: translateX(0);
    }
    
    .main-content {
        margin-left: 0;
    }
    
    .messages-layout {
        grid-template-columns: 1fr;
    }
    
    .form-row {
        flex-direction: column;
    }
    
    .stats-grid {
        grid-template-columns: 1fr;
    }
}

/* ========================================
   CHAT MOBILE LAYOUT (WhatsApp-style slide)
   ======================================== */

/* Back button: hidden on desktop, shown on mobile */
.chat-back-btn {
    display: none;
    align-items: center;
    justify-content: center;
    width: 36px;
    height: 36px;
    min-width: 36px;
    background: transparent;
    border: none;
    border-radius: 50%;
    cursor: pointer;
    font-size: 1.5em;
    color: var(--color-text);
    flex-shrink: 0;
    padding: 0;
    line-height: 1;
}
.chat-back-btn:active { background: var(--color-bg); }

@media (max-width: 768px) {
    /* === CONTENT LAYOUT: maximize space === */
    .content-header {
        padding: 8px 12px !important;
    }
    .content-body {
        padding: 6px !important;
    }
    .page-title {
        font-size: 17px !important;
    }

    /* === CHAT PANEL SLIDE NAVIGATION === */
    .chat-layout {
        height: calc(100vh - 75px) !important;
        min-height: 400px !important;
        position: relative;
        overflow: hidden;
    }

    /* Sidebar: full screen, slides left when chat opens */
    .chat-sidebar {
        width: 100% !important;
        min-width: 0 !important;
        position: absolute !important;
        top: 0 !important;
        left: 0 !important;
        right: 0 !important;
        bottom: 0 !important;
        z-index: 5;
        transition: transform 0.3s ease;
    }
    .chat-layout.mobile-chat-open .chat-sidebar {
        transform: translateX(-100%);
    }

    /* Main chat: full screen, slides in from right */
    .chat-main {
        flex: 1 !important;
        position: absolute !important;
        top: 0 !important;
        left: 0 !important;
        right: 0 !important;
        bottom: 0 !important;
        z-index: 10;
        transform: translateX(100%);
        transition: transform 0.3s ease;
    }
    .chat-layout.mobile-chat-open .chat-main {
        transform: translateX(0);
    }

    /* Show back button on mobile */
    .chat-back-btn {
        display: flex !important;
    }

    /* Hide button text labels in chat header (icon-only) */
    #chat-header .btn-text {
        display: none;
    }

    /* "Responder" button redundant on mobile (reply bar always visible) */
    #chat-reply-wrap {
        display: none !important;
    }

    /* === TYPOGRAPHY: bigger, readable === */
    /* Conversation list: larger touch targets */
    .conv-item {
        padding: 14px 12px !important;
    }

    /* Chat header: compact */
    #chat-header {
        padding: 8px 8px !important;
        gap: 4px !important;
        flex-wrap: nowrap !important;
        overflow: hidden;
    }
    #chat-contact-name {
        font-size: 1.05em !important;
    }

    /* Message bubbles: wider on mobile */
    #chat-messages [data-msg-id] {
        max-width: 88% !important;
        padding: 9px 13px !important;
    }

    /* Message text: slightly bigger */
    #chat-messages [data-msg-id] > div:nth-child(2) {
        font-size: 0.95em !important;
    }

    /* === INPUTS: 16px to prevent iOS auto-zoom === */
    #chat-search,
    #chat-status-filter,
    #chat-instance,
    #chat-reply-text,
    .rename-input {
        font-size: 16px !important;
    }

    #chat-reply-text {
        padding: 10px 14px !important;
    }

    /* Sidebar search: stack on narrow screens */
    .chat-search-row {
        flex-direction: column !important;
        gap: 6px !important;
    }

    /* Buttons in header: icon-only, bigger touch area */
    #ticket-btn,
    #mark-unread-btn {
        padding: 6px 10px !important;
        font-size: 1.15em !important;
    }

    /* Modals: fuller width */
    .modal {
        width: 95% !important;
    }
}

@media (max-width: 420px) {
    .chat-layout {
        height: calc(100vh - 70px) !important;
    }
    .page-title {
        font-size: 15px !important;
    }
    /* Hide header actions (notification gear/bell) to save space */
    .header-actions .btn-sm {
        padding: 4px 6px !important;
    }
}
