/* ===========================================
   CRMLAH! - MASTER STYLESHEET
   Version: 5.1 - APPLE INSPIRED + RESPONSIVE MODAL WIDTH
   Centralized CSS for CRM, Analytics, Manager, Login, Reset
   =========================================== */

/* ===== GLOBAL STYLES ===== */
* {
    font-family: 'Inter', sans-serif;
    box-sizing: border-box;
}

body {
    background: #f8fafc;
    min-height: 100vh;
    margin: 0;
    padding: 0;
}

/* ===== TYPOGRAPHY ===== */
h1, h2, h3, h4, h5, h6 {
    font-weight: 700;
}

.text-muted-crm {
    color: #64748b;
}

.bg-light-crm {
    background: #f8fafc;
}

.border-crm {
    border: 1px solid #e2e8f0;
}

/* ===== SPINNER ANIMATION ===== */
.spin {
    animation: spin 1s linear infinite;
    display: inline-block;
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

/* ===== BUTTON STYLES - APPLE INSPIRED ===== */
.btn, .btn-primary, .btn-success, .btn-outline-primary,
.btn-outline-danger, .btn-outline-warning, .btn-outline-secondary {
    border-radius: 12px !important;
    padding: 0.6rem 1.2rem;
    transition: all 0.2s;
    font-weight: 600;
}

.btn-sm {
    padding: 0.4rem 0.8rem !important;
    font-size: 0.875rem;
}

.btn-primary-crm {
    background: #4361ee;
    border: none;
    border-radius: 12px;
    padding: 0.6rem 1.5rem;
    font-weight: 600;
    color: white;
    transition: all 0.2s;
}

.btn-primary-crm:hover {
    background: #3651d4;
    transform: translateY(-2px);
    box-shadow: 0 10px 20px rgba(67, 97, 238, 0.3);
}

.btn-outline-crm {
    border: 2px solid #4361ee;
    border-radius: 12px;
    padding: 0.6rem 1.5rem;
    font-weight: 600;
    color: #4361ee;
    background: transparent;
    transition: all 0.2s;
}

.btn-outline-crm:hover {
    background: #4361ee;
    color: white;
}

.btn-success-crm {
    background: #22c55e;
    border: none;
    border-radius: 12px;
    padding: 0.6rem 1.5rem;
    font-weight: 600;
    color: white;
    transition: all 0.2s;
}

.btn-success-crm:hover {
    background: #16a34a;
    transform: translateY(-2px);
    box-shadow: 0 10px 20px rgba(34, 197, 94, 0.3);
}

.btn-warning-crm {
    background: linear-gradient(135deg, #fbbf24, #f59e0b);
    border: none;
    border-radius: 12px;
    padding: 0.6rem 1.5rem;
    font-weight: 600;
    color: white;
    transition: all 0.2s;
}

.btn-warning-crm:hover {
    transform: translateY(-2px);
    box-shadow: 0 10px 20px rgba(245, 158, 11, 0.3);
}

.btn-danger-crm {
    background: #ef4444;
    border: none;
    border-radius: 12px;
    padding: 0.6rem 1.5rem;
    font-weight: 600;
    color: white;
    transition: all 0.2s;
}

.btn-danger-crm:hover {
    background: #dc2626;
    transform: translateY(-2px);
    box-shadow: 0 10px 20px rgba(239, 68, 68, 0.3);
}

/* ===== FORM CONTROLS - APPLE INSPIRED ===== */
.form-control, .form-select,
.form-control-crm, .form-select-crm {
    border-radius: 10px !important;
    padding: 0.6rem 1.2rem;
    border: 1px solid #e9ecef;
    width: 100%;
    transition: all 0.2s;
}

.form-control:focus, .form-select:focus,
.form-control-crm:focus, .form-select-crm:focus {
    border-color: #4361ee;
    box-shadow: 0 0 0 3px rgba(67, 97, 238, 0.1);
    outline: none;
}

/* ===== CARD STYLES - APPLE INSPIRED ===== */
.modal-content {
    border-radius: 20px !important;
    box-shadow: 0 20px 40px rgba(0, 0, 0, 0.08);
    border: 3px solid white !important;
    overflow: hidden;
}

.kanban-card {
    border-radius: 18px !important;
    border: none;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.04);
}

.contacts-sidebar {
    border-radius: 24px !important;
}

.card-crm {
    background: white;
    border-radius: 24px;
    padding: 2rem;
    box-shadow: 0 20px 60px rgba(67, 97, 238, 0.15);
}

/* ===== BADGES - APPLE INSPIRED ===== */
.badge, .badge-crm {
    border-radius: 8px !important;
    padding: 0.3rem 0.8rem;
    font-weight: 600;
    font-size: 0.75rem;
    display: inline-block;
}

.badge-primary-crm {
    background: #4361ee;
    color: white;
}

.badge-success-crm {
    background: #22c55e;
    color: white;
}

.badge-warning-crm {
    background: #f59e0b;
    color: white;
}

.badge-danger-crm {
    background: #ef4444;
    color: white;
}

.badge-info-crm {
    background: #3b82f6;
    color: white;
}

.badge-light-crm {
    background: #f1f5f9;
    color: #1e293b;
}

/* ===== PRO BADGE ===== */
.pro-badge {
    background: linear-gradient(135deg, #fbbf24, #f59e0b);
    color: white;
    padding: 0.2rem 0.5rem;
    border-radius: 8px;
    font-size: 0.7rem;
    font-weight: 600;
}

/* ===== TELEGRAM BADGE ===== */
.telegram-badge {
    background: #0088cc;
    color: white;
    padding: 0.2rem 0.5rem;
    border-radius: 8px;
    font-size: 0.7rem;
    display: inline-block;
}

/* ===== ALERTS ===== */
.alert-crm {
    border-radius: 12px;
    border: none;
    padding: 0.75rem 1.5rem;
    font-weight: 500;
}

.alert-success-crm {
    background: #f0fdf4;
    color: #166534;
    border: 1px solid #22c55e;
}

.alert-danger-crm {
    background: #fef2f2;
    color: #991b1b;
    border: 1px solid #ef4444;
}

.alert-info-crm {
    background: #e0f2fe;
    color: #075985;
    border: 1px solid #38bdf8;
}

.alert-warning-crm {
    background: #fef3c7;
    color: #92400e;
    border: 1px solid #f59e0b;
}

/* ===== CUSTOM SCROLLBAR - APPLE STYLE ===== */
::-webkit-scrollbar-button {
    display: none !important;
    height: 0;
    width: 0;
}

::-webkit-scrollbar {
    width: 3px;
    height: 3px;
}

::-webkit-scrollbar-thumb {
    background: rgba(0, 0, 0, 0.15);
    border-radius: 4px;
    border: none;
}

::-webkit-scrollbar-thumb:hover {
    background: rgba(0, 0, 0, 0.25);
}

::-webkit-scrollbar-track {
    background: transparent;
}

/* Firefox scrollbar */
* {
    scrollbar-width: thin;
    scrollbar-color: rgba(0, 0, 0, 0.15) transparent;
}

/* ===== MODAL FIXES & ENHANCEMENTS ===== */
.modal {
    background-color: rgba(0, 0, 0, 0.5);
    z-index: 1050 !important;
}

.modal.show {
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
}

.modal-backdrop {
    z-index: 1040 !important;
}

.modal.modal-static {
    z-index: 1060 !important;
}

.modal .modal {
    z-index: 1070 !important;
}

/* ===== RESPONSIVE MODAL WIDTH - CORE UPDATE v5.1 ===== */
.modal-dialog {
    margin: 1.75rem auto !important;
    max-height: calc(100vh - 3.5rem) !important;
    overflow-y: auto !important;
    width: auto;
}

/* Default modal width untuk desktop */
.modal-dialog:not(.modal-fullscreen) {
    max-width: 60vw;  /* Desktop: 60% dari viewport */
}

/* Modal kecil (reminder, add field, etc) */
#reminderModal .modal-dialog,
#addFieldModal .modal-dialog,
#editFieldModal .modal-dialog,
#addTemplateModal .modal-dialog,
#csvModal .modal-dialog {
    max-width: 400px;  /* Fixed width untuk desktop */
}

/* Modal sederhana (add contact, groups, etc) */
#addContactModal .modal-dialog,
#saveGroupModal .modal-dialog,
#manageGroupModal .modal-dialog,
#createGroupModal .modal-dialog,
#settingsModal .modal-dialog {
    max-width: 450px;  /* Fixed width untuk desktop */
}

/* Modal besar (form builder, template manager) */
#formBuilderModal .modal-dialog,
#templateModal .modal-dialog {
    max-width: 800px;  /* Fixed width untuk desktop */
}

/* Table view modal - fullscreen */
#tableViewModal .modal-dialog.modal-fullscreen {
    max-width: 100%;
    margin: 0 !important;
    height: 100vh;
}

/* Dalam <style> - tambah */
#editableTable th {
    position: relative;
    white-space: nowrap;
    min-width: 100px;
}

#editableTable td input,
#editableTable td select,
#editableTable td textarea {
    width: 100%;
    min-width: 80px;
}

/* Fix horizontal scroll untuk table */
.table-responsive {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
}

.modal-content {
    max-height: calc(100vh - 4rem) !important;
    overflow: hidden !important;
    display: flex;
    flex-direction: column;
}

.modal-header, .modal-footer {
    flex-shrink: 0;
}

.modal-body {
    max-height: calc(100vh - 12rem) !important;
    overflow-y: auto !important;
    -webkit-overflow-scrolling: touch;
}

/* ===========================================
   NAVBAR STYLES
   =========================================== */
.navbar-crm {
    background: white;
    box-shadow: 0 2px 10px rgba(0,0,0,0.05);
    padding: 0.8rem 1.5rem;
}

.navbar-crm-brand {
    font-weight: 800;
    color: #4361ee !important;
    font-size: 1.25rem;
    text-decoration: none;
}

.navbar-crm .badge {
    font-size: 0.9rem;
    padding: 0.5rem 1rem;
}

/* Desktop actions */
.desktop-actions {
    display: flex;
    gap: 0.5rem;
}

/* Mobile elements - hidden by default */
.mobile-username-row,
.mobile-actions-row {
    display: none;
}

/* ===========================================
   STATS CARDS
   =========================================== */
.stat-card {
    background: white;
    border-radius: 24px;
    padding: 1.5rem;
    box-shadow: 0 8px 20px rgba(67, 97, 238, 0.08);
    height: 100%;
    transition: transform 0.2s;
}

.stat-card:hover {
    transform: translateY(-5px);
}

.stat-value {
    font-size: 2.5rem;
    font-weight: 800;
    color: #4361ee;
    line-height: 1.2;
    margin-bottom: 0.25rem;
}

.stat-label {
    color: #64748b;
    font-weight: 600;
    font-size: 0.8rem;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.stat-trend {
    font-size: 0.9rem;
    display: flex;
    align-items: center;
    gap: 0.3rem;
}

.trend-up {
    color: #22c55e;
}

.trend-down {
    color: #ef4444;
}

/* ===========================================
   CONTACTS SIDEBAR
   =========================================== */
.contacts-sidebar {
    background: white;
    border-radius: 24px;
    padding: 1.2rem;
    height: calc(100vh - 100px);
    overflow-y: auto;
    box-shadow: 0 4px 12px rgba(0,0,0,0.05);
}

.contact-item {
    background: white;
    border: 1px solid #e2e8f0;
    border-radius: 16px;
    padding: 0.8rem;
    margin-bottom: 0.5rem;
    cursor: pointer;
    transition: all 0.2s;
    position: relative;
}

.contact-item:hover {
    border-color: #4361ee;
    transform: translateX(5px);
    box-shadow: 0 4px 12px rgba(67, 97, 238, 0.1);
}

.contact-item .actions {
    position: absolute;
    right: 10px;
    top: 50%;
    transform: translateY(-50%);
    display: none;
    gap: 5px;
}

.contact-item:hover .actions {
    display: flex;
}

/* ===========================================
   KANBAN BOARD
   =========================================== */
.kanban-col {
    background: #f1f5f9;
    border-radius: 24px;
    padding: 1rem;
    min-height: calc(50vh - 80px);
    max-height: calc(100vh - 120px);
    overflow-y: auto;
    transition: all 0.2s;
}

.kanban-col.drag-over {
    background: #e2e8f0;
    border: 2px dashed #4361ee;
}

/* Quality icons */
.quality-icon {
    transition: all 0.2s ease;
}

.quality-icon:hover {
    transform: scale(1.2);
    opacity: 1 !important;
}

.selected-quality {
    filter: drop-shadow(0 2px 4px rgba(0,0,0,0.2));
    transform: scale(1.1);
}

.opacity-50 {
    opacity: 0.5 !important;
}

/* ===========================================
   SEARCH BOX
   =========================================== */
.search-box {
    position: relative;
}

.search-box i {
    position: absolute;
    left: 15px;
    top: 50%;
    transform: translateY(-50%);
    color: #94a3b8;
    z-index: 1;
}

.search-box input {
    padding-left: 40px !important;
    border-radius: 10px;
    border: 1px solid #e2e8f0;
    background: white;
    width: 100%;
}

/* ===========================================
   TOAST NOTIFICATION
   =========================================== */
.toast-container {
    position: fixed;
    bottom: 20px;
    right: 20px;
    z-index: 9999;
}

.toast-message {
    background: #10b981;
    color: white;
    padding: 0.8rem 1.5rem;
    border-radius: 12px;
    box-shadow: 0 10px 20px rgba(16, 185, 129, 0.3);
    font-weight: 600;
    display: none;
    animation: slideIn 0.3s ease;
}

@keyframes slideIn {
    from {
        transform: translateX(100%);
        opacity: 0;
    }
    to {
        transform: translateX(0);
        opacity: 1;
    }
}

/* ===========================================
   FLOATING ACTION BUTTON
   =========================================== */
.fab-btn {
    position: fixed;
    bottom: 30px;
    right: 30px;
    width: 60px;
    height: 60px;
    border-radius: 30px;
    background: #4361ee;
    color: white;
    border: none;
    box-shadow: 0 4px 15px rgba(67, 97, 238, 0.4);
    font-size: 24px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.3s;
    z-index: 999;
}

.fab-btn:hover {
    transform: scale(1.1);
    background: #3651d4;
    box-shadow: 0 6px 20px rgba(67, 97, 238, 0.6);
}

/* ===========================================
   TABLE VIEW
   =========================================== */
.table-crm {
    font-size: 0.9rem;
    width: 100%;
    margin-bottom: 0;
}

.table-crm th {
    background: #f8fafc;
    position: sticky;
    top: 0;
    z-index: 10;
    white-space: nowrap;
    padding: 0.8rem 0.5rem;
    font-weight: 600;
    color: #475569;
    border-bottom: 2px solid #e2e8f0;
}

.table-crm td {
    padding: 0.5rem;
    vertical-align: middle;
    border-bottom: 1px solid #e2e8f0;
}

.table-crm input,
.table-crm select,
.table-crm textarea {
    border: 1px solid transparent;
    background: transparent;
    width: 100%;
    padding: 0.25rem 0.5rem;
    border-radius: 8px;
    transition: all 0.2s;
}

.table-crm input:focus,
.table-crm select:focus,
.table-crm textarea:focus {
    border-color: #4361ee;
    background: white;
    outline: none;
    box-shadow: 0 0 0 3px rgba(67, 97, 238, 0.1);
}

.table-crm .date-cell {
    color: #64748b;
    font-size: 0.85rem;
    white-space: nowrap;
}

/* ===========================================
   FORM BUILDER
   =========================================== */
.field-item {
    background: #f8fafc;
    border: 1px solid #e2e8f0;
    border-radius: 16px;
    padding: 1rem;
    margin-bottom: 0.75rem;
    transition: all 0.2s;
}

.field-item:hover {
    border-color: #4361ee;
    box-shadow: 0 4px 12px rgba(67, 97, 238, 0.1);
}

.field-item .drag-handle {
    cursor: move;
    color: #94a3b8;
    font-size: 1.2rem;
}

/* ===========================================
   CUSTOM FIELDS STYLES
   =========================================== */
.custom-field-row {
    background: #f8fafc;
    border-radius: 12px;
    padding: 0.8rem;
    transition: all 0.2s;
    margin-bottom: 0.5rem;
    border: 1px solid #e2e8f0;
}

.custom-field-row:hover {
    background: #f1f5f9;
    border-color: #4361ee;
}

.global-badge {
    background: #4361ee;
    color: white;
    font-size: 0.65rem;
    padding: 0.2rem 0.5rem;
    border-radius: 6px;
    display: inline-block;
}

.local-badge {
    background: #64748b;
    color: white;
    font-size: 0.65rem;
    padding: 0.2rem 0.5rem;
    border-radius: 6px;
    display: inline-block;
}

/* ===========================================
   GROUPS STYLES
   =========================================== */
.groups-container {
    overflow-x: auto;
    white-space: nowrap;
    padding: 0.5rem;
    border: 1px solid #e2e8f0;
    border-radius: 16px;
    background: white;
}

.group-tab {
    transition: all 0.2s;
    font-size: 0.9rem;
    border: 1px solid transparent;
    border-radius: 12px;
    padding: 0.5rem 1rem;
    display: inline-block;
    cursor: pointer;
}

.group-tab:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 8px rgba(67, 97, 238, 0.2);
}

.group-tab.active {
    background: #4361ee;
    color: white;
    border-color: #4361ee;
}

.group-tab-add {
    transition: all 0.2s;
    font-size: 0.9rem;
    border: 1px dashed #cbd5e1;
    border-radius: 12px;
    padding: 0.5rem 1rem;
    background: #f1f5f9;
    cursor: pointer;
}

.group-tab-add:hover {
    background: #e2e8f0;
    transform: translateY(-2px);
    border-color: #4361ee;
}

/* ===========================================
   MANAGER TABLE STYLES
   =========================================== */
.table-container {
    background: white;
    border-radius: 24px;
    overflow: hidden;
    box-shadow: 0 8px 20px rgba(67, 97, 238, 0.08);
    margin-bottom: 2rem;
}

.table-header {
    background: #4361ee;
    color: white;
    padding: 1rem 1.5rem;
    font-weight: 700;
    font-size: 1.1rem;
}

.table-manager {
    width: 100%;
    border-collapse: collapse;
}

.table-manager th {
    background: #f1f5f9;
    color: #1e293b;
    font-weight: 600;
    font-size: 0.8rem;
    text-transform: uppercase;
    padding: 0.8rem 1rem;
    border-bottom: 2px solid #e2e8f0;
    text-align: left;
}

.table-manager td {
    padding: 1rem;
    vertical-align: middle;
    border-bottom: 1px solid #e2e8f0;
    font-size: 0.9rem;
}

/* ===== PRO TOGGLE (MANAGER) ===== */
.pro-toggle {
    display: inline-block;
    width: 50px;
    height: 24px;
    background-color: #cbd5e1;
    border-radius: 12px;
    position: relative;
    cursor: pointer;
    transition: background-color 0.2s;
}

.pro-toggle.active {
    background: linear-gradient(135deg, #fbbf24, #f59e0b);
}

.pro-toggle .slider {
    position: absolute;
    width: 20px;
    height: 20px;
    background-color: white;
    border-radius: 10px;
    top: 2px;
    left: 2px;
    transition: transform 0.2s;
    box-shadow: 0 1px 3px rgba(0,0,0,0.2);
}

.pro-toggle.active .slider {
    transform: translateX(26px);
}

/* ===== DELETE BUTTON ===== */
.btn-delete {
    color: #ef4444;
    background: #fef2f2;
    border: none;
    width: 32px;
    height: 32px;
    border-radius: 8px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s;
    cursor: pointer;
    font-size: 1rem;
}

.btn-delete:hover {
    background: #ef4444;
    color: white;
    transform: scale(1.1);
}

/* ===========================================
   LOGIN PAGE STYLES
   =========================================== */
.login-card {
    background: white;
    border-radius: 24px;
    padding: 2.5rem 2rem;
    box-shadow: 0 20px 60px rgba(67, 97, 238, 0.25);
    max-width: 450px;
    width: 100%;
    margin: 0 auto;
}

.login-card .logo {
    text-align: center;
    margin-bottom: 2rem;
}

.login-card .logo i {
    font-size: 3.5rem;
    color: #4361ee;
}

.login-card .logo h1 {
    font-size: 2rem;
    font-weight: 800;
    color: #4361ee;
    margin: 0;
}

.login-card .form-control-crm {
    margin-bottom: 1rem;
}

.login-card .btn-primary-crm {
    width: 100%;
    margin-bottom: 1rem;
}

.login-card .honeypot-field {
    display: none !important;
}

/* ===========================================
   RESET PAGE STYLES
   =========================================== */
.reset-card {
    background: white;
    border-radius: 24px;
    padding: 2.5rem 2rem;
    box-shadow: 0 20px 60px rgba(67, 97, 238, 0.25);
    max-width: 450px;
    width: 100%;
    margin: 0 auto;
}

.reset-card .logo {
    text-align: center;
    margin-bottom: 2rem;
}

.reset-card .logo i {
    font-size: 3.5rem;
    color: #4361ee;
}

.reset-card .logo h1 {
    font-size: 1.8rem;
    font-weight: 800;
    color: #4361ee;
}

.reset-card .token-info {
    background: #f8fafc;
    border-radius: 16px;
    padding: 1.5rem;
    text-align: center;
    margin-bottom: 1.5rem;
}

/* ===========================================
   INDEX PAGE (REDIRECT) STYLES
   =========================================== */
.redirect-card {
    background: white;
    border-radius: 24px;
    padding: 2.5rem 2rem;
    box-shadow: 0 20px 60px rgba(67, 97, 238, 0.25);
    max-width: 500px;
    width: 100%;
    margin: 0 auto;
    text-align: center;
    animation: fadeInUp 0.6s ease-out;
}

@keyframes fadeInUp {
    from {
        opacity: 0;
        transform: translateY(30px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* ===========================================
   FORM STYLES (form.php & form-step.php)
   =========================================== */
.product-badge {
    background: rgba(67, 97, 238, 0.1);
    color: #4361ee;
    padding: 0.3rem 1rem;
    border-radius: 8px;
    font-size: 0.8rem;
    font-weight: 600;
    display: inline-block;
    margin-bottom: 1rem;
}

.required:after {
    content: " *";
    color: #ef4444;
}

.powered-by {
    text-align: center;
    margin-top: 1.5rem;
    font-size: 0.75rem;
    color: #94a3b8;
}

.powered-by a {
    color: #4361ee;
    text-decoration: none;
}

.form-container-crm {
    max-width: 500px;
    margin: 0 auto;
    background: white;
    border-radius: 24px;
    padding: 2rem;
    box-shadow: 0 20px 60px rgba(67, 97, 238, 0.15);
}

/* ===========================================
   DEBUG BAR
   =========================================== */
.debug-bar {
    background: #f1f5f9;
    color: #1e293b;
    padding: 0.5rem 1rem;
    font-size: 0.8rem;
    text-align: center;
    border-bottom: 1px solid #e2e8f0;
    border-radius: 8px;
    font-weight: 500;
}

/* ===========================================
   FOOTER
   =========================================== */
.footer-note {
    color: #94a3b8;
    font-size: 0.7rem;
    padding: 1.5rem 0;
    margin-top: 2rem;
    border-top: 1px solid #e2e8f0;
    text-align: center;
    width: 100%;
}

/* ===========================================
   DARK MODE
   =========================================== */
@media (prefers-color-scheme: dark) {
    ::-webkit-scrollbar-thumb {
        background: rgba(255, 255, 255, 0.15);
    }
    
    ::-webkit-scrollbar-thumb:hover {
        background: rgba(255, 255, 255, 0.25);
    }
    
    * {
        scrollbar-color: rgba(255, 255, 255, 0.15) transparent;
    }
}

/* ===========================================
   RESPONSIVE - MOBILE OPTIMIZED
   =========================================== */
@media (max-width: 768px) {
    /* Hide desktop elements */
    .desktop-username {
        display: none !important;
    }
    
    .desktop-actions {
        display: none !important;
    }
    
    /* Show mobile elements */
    .mobile-username-row {
        display: flex;
        align-items: center;
        justify-content: space-between;
        width: 100%;
        margin-top: 0.5rem;
    }
    
    .mobile-username-row .badge {
        margin-left: 0;
        font-size: 0.9rem;
        width: 100%;
    }
    
    .mobile-actions-row {
        display: flex;
        gap: 0.5rem;
        width: 100%;
        margin-top: 0.5rem;
        flex-wrap: wrap;
    }
    
    .mobile-actions-row .btn {
        flex: 1 1 auto;
        padding: 0.4rem 0;
        font-size: 0.8rem;
    }
    
    /* ===== MOBILE MODAL FIXES - UPDATED v5.1 ===== */
    .modal-dialog {
        margin: 0.5rem !important;
        max-height: calc(100vh - 1rem) !important;
    }
    
    /* Semua modal jadi 90vw pada mobile */
    .modal-dialog:not(.modal-fullscreen) {
        max-width: 90vw !important;  /* Mobile: 90% dari viewport */
        width: auto !important;
    }
    
    /* Override untuk modal yang ada fixed width */
    #reminderModal .modal-dialog,
    #addFieldModal .modal-dialog,
    #editFieldModal .modal-dialog,
    #addTemplateModal .modal-dialog,
    #csvModal .modal-dialog,
    #addContactModal .modal-dialog,
    #saveGroupModal .modal-dialog,
    #manageGroupModal .modal-dialog,
    #createGroupModal .modal-dialog,
    #settingsModal .modal-dialog,
    #formBuilderModal .modal-dialog,
    #templateModal .modal-dialog {
        max-width: 90vw !important;  /* Semua modal guna 90vw on mobile */
    }
    
    /* Force remove inline styles on mobile */
    .modal-dialog[style*="min-width"] {
        min-width: auto !important;
        width: 90vw !important;
    }
    
    .modal-dialog[style*="max-width"] {
        max-width: 90vw !important;
        width: auto !important;
    }
    
    .modal-content {
        max-height: calc(100vh - 1rem) !important;
        border-radius: 20px !important;
        overflow: hidden !important;
    }
    
    .modal-body {
        max-height: calc(100vh - 8rem) !important;
        overflow-y: auto !important;
        padding: 1rem !important;
        -webkit-overflow-scrolling: touch;
    }
    
    .modal-header, .modal-footer {
        flex-shrink: 0;
        padding: 0.75rem 1rem !important;
    }
    
    .btn-close {
        padding: 0.75rem !important;
    }
    
    /* Form controls - prevent zoom on iOS */
    .form-control, .form-select, .btn {
        font-size: 16px !important;
        max-width: 100% !important;
    }
    
    /* Custom fields container */
    #customFieldsContainer {
        max-height: 200px;
        overflow-y: auto;
    }
    
    /* Two column layout adjustments */
    .row.g-2 {
        margin-right: 0;
        margin-left: 0;
    }
    
    .col-6 {
        padding-right: 0.25rem;
        padding-left: 0.25rem;
    }
    
    /* Tabs scrolling */
    .nav-tabs {
        flex-wrap: nowrap;
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
        padding-bottom: 5px;
    }
    
    .nav-tabs .nav-item {
        white-space: nowrap;
    }
    
    /* Group stats boxes */
    .bg-light.p-2.rounded-3 {
        padding: 0.5rem !important;
    }
    
    .bg-light.p-2.rounded-3 .fs-5 {
        font-size: 1.1rem !important;
    }
    
    /* Calendar options grid */
    #bulkCalendarOptions .row.g-2 {
        margin-right: -0.25rem;
        margin-left: -0.25rem;
    }
    
    #bulkCalendarOptions .col-6 {
        padding-right: 0.25rem;
        padding-left: 0.25rem;
    }
    
    /* Bulk action buttons */
    .d-flex.gap-2.mb-2 {
        flex-wrap: wrap;
    }
    
    .d-flex.gap-2.mb-2 .btn {
        width: 100% !important;
        margin-bottom: 0.25rem;
    }
    
    /* Quick options buttons */
    .d-flex.gap-1.mb-3.flex-wrap {
        gap: 0.25rem !important;
    }
    
    .btn-sm.rounded-pill.px-2.py-0 {
        font-size: 0.7rem !important;
        padding: 0.2rem 0.4rem !important;
    }
    
    /* Description container */
    #groupDescriptionContainer .p-3 {
        padding: 0.75rem !important;
    }
    
    /* Existing reminders list */
    #remindersList {
        max-height: 100px !important;
    }
    
    /* Table view adjustments */
    .table-responsive {
        font-size: 0.8rem;
    }
    
    .table-crm th, .table-crm td {
        padding: 0.3rem !important;
    }
    
    /* FAB button adjustment */
    .fab-btn {
        bottom: 15px;
        right: 15px;
        width: 50px;
        height: 50px;
        font-size: 20px;
    }
    
    /* Card adjustments */
    .login-card,
    .reset-card {
        padding: 1.5rem;
    }
    
    .redirect-card {
        padding: 1.5rem;
    }
    
    .redirect-card .redirect-countdown {
        font-size: 2.5rem;
    }
    
    /* Contacts sidebar */
    .contacts-sidebar {
        height: auto;
        max-height: 300px;
        margin-bottom: 1rem;
    }
    
    /* Stat cards */
    .stat-value {
        font-size: 2rem;
    }
}

/* Extra small devices */
@media (max-width: 380px) {
    .modal-body {
        padding: 0.75rem !important;
    }
    
    .small.fw-bold.text-muted {
        font-size: 0.7rem !important;
    }
    
    .form-control-sm, .form-select-sm {
        font-size: 0.8rem !important;
        padding: 0.4rem 0.6rem !important;
    }
    
    .d-flex.gap-2 .btn {
        font-size: 0.8rem !important;
        padding: 0.4rem 0.6rem !important;
    }
}

/* Fix for iOS input zoom */
@supports (-webkit-touch-callout: none) {
    .form-control, .form-select, .btn {
        font-size: 16px !important;
    }
}

/* ===========================================
   UTILITY CLASSES
   =========================================== */
.text-primary-crm {
    color: #4361ee !important;
}

.text-success-crm {
    color: #22c55e !important;
}

.text-warning-crm {
    color: #f59e0b !important;
}

.text-danger-crm {
    color: #ef4444 !important;
}

.bg-primary-crm {
    background: #4361ee !important;
}

.bg-success-crm {
    background: #22c55e !important;
}

.bg-warning-crm {
    background: #f59e0b !important;
}

.bg-danger-crm {
    background: #ef4444 !important;
}

.rounded-4-crm {
    border-radius: 16px !important;
}

.rounded-pill-crm {
    border-radius: 100px !important;
}

.shadow-crm {
    box-shadow: 0 4px 12px rgba(0,0,0,0.05) !important;
}

.shadow-hover-crm:hover {
    box-shadow: 0 8px 20px rgba(67, 97, 238, 0.15) !important;
    transform: translateY(-2px);
}

/* Telegram Toggle Switch - Apple Style */
.telegram-toggle .form-check-input {
    width: 3rem;
    height: 1.5rem;
    margin-left: 0;
    background-color: #22c55e;
    border-color: #22c55e;
    cursor: pointer;
    box-shadow: 0 2px 6px rgba(34, 197, 94, 0.3);
    transition: all 0.2s;
}

.telegram-toggle .form-check-input:checked {
    background-color: #22c55e;
    border-color: #22c55e;
}

.telegram-toggle .form-check-input:focus {
    box-shadow: 0 0 0 3px rgba(34, 197, 94, 0.2);
    border-color: #22c55e;
}

.telegram-toggle .form-check-input:not(:checked) {
    background-color: #ef4444;
    border-color: #ef4444;
}

.telegram-avatar {
    width: 48px;
    height: 48px;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.15);
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
}

/* Dark mode adjustments */
body.dark-mode .telegram-toggle .form-check-input:not(:checked) {
    background-color: #dc2626;
    border-color: #dc2626;
}