/* ===== MOBILE-FIRST RESPONSIVE CSS ===== */

/* Reset básico */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

/* Variáveis CSS para cores consistentes */
:root {
    --whatsapp-green: #25D366;
    --whatsapp-dark-green: #128C7E;
    --sidebar-width: 260px;
    --mobile-sidebar-width: 280px;
    --topbar-height: 60px;
    --mobile-topbar-height: 70px;
}

/* Base mobile-first - SEMPRE MOBILE PRIMEIRO */
body {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    background-color: #f5f7fa;
    overflow-x: hidden;
    font-size: 14px;
    line-height: 1.5;
}

/* ===== MOBILE SIDEBAR (PADRÃO) ===== */
.sidebar {
    position: fixed;
    left: -100%;
    top: 0;
    width: var(--mobile-sidebar-width);
    height: 100vh;
    background: linear-gradient(135deg, var(--whatsapp-green) 0%, var(--whatsapp-dark-green) 100%);
    color: white;
    z-index: 9999;
    transition: left 0.3s ease;
    overflow-y: auto;
    box-shadow: 2px 0 10px rgba(0, 0, 0, 0.1);
}

.sidebar.open {
    left: 0;
}

.sidebar-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.5);
    z-index: 9998;
    display: none;
    transition: opacity 0.3s ease;
}

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

.sidebar-header {
    padding: 20px 15px;
    text-align: center;
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
}

.sidebar-header i {
    font-size: 2rem;
    margin-bottom: 8px;
}

.sidebar-header h3 {
    font-size: 1.1rem;
    margin-bottom: 5px;
    font-weight: 600;
}

.sidebar-header p {
    font-size: 0.8rem;
    opacity: 0.8;
}

.sidebar-menu {
    padding: 15px 0;
}

.menu-item {
    display: block;
    padding: 15px 20px;
    color: white;
    text-decoration: none;
    transition: background 0.3s ease;
    font-size: 0.9rem;
    border: none;
    width: 100%;
    text-align: left;
    cursor: pointer;
}

.menu-item:hover, .menu-item.active {
    background: rgba(255, 255, 255, 0.15);
}

.menu-item i {
    width: 20px;
    margin-right: 12px;
    font-size: 1rem;
}

/* ===== MOBILE TOPBAR (PADRÃO) ===== */
.mobile-topbar {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    height: var(--mobile-topbar-height);
    background: white;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 15px;
    z-index: 1000;
}

.menu-toggle {
    background: none;
    border: none;
    font-size: 1.5rem;
    color: var(--whatsapp-green);
    cursor: pointer;
    padding: 8px;
    border-radius: 5px;
    transition: background 0.3s ease;
}

.menu-toggle:hover {
    background: rgba(37, 211, 102, 0.1);
}

.mobile-title {
    font-size: 1.1rem;
    font-weight: 600;
    color: #333;
    text-align: center;
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
}

.mobile-user {
    position: relative;
}

.user-avatar {
    width: 35px;
    height: 35px;
    background: linear-gradient(135deg, var(--whatsapp-green) 0%, var(--whatsapp-dark-green) 100%);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    font-weight: bold;
    font-size: 0.9rem;
    border: none;
    cursor: pointer;
}

/* ===== DESKTOP TOPBAR (ESCONDIDO NO MOBILE) ===== */
.desktop-topbar {
    display: none;
}

/* ===== MAIN CONTENT MOBILE (PADRÃO) ===== */
.main-content {
    margin-left: 0;
    margin-top: var(--mobile-topbar-height);
    min-height: calc(100vh - var(--mobile-topbar-height));
    width: 100%;
}

.content-area {
    padding: 15px;
}

/* ===== CARDS E SECTIONS MOBILE ===== */
.section {
    background: white;
    border-radius: 10px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
    margin-bottom: 15px;
    overflow: hidden;
}

.section-card {
    background: white;
    border-radius: 10px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
    margin-bottom: 15px;
    overflow: hidden;
}

.section-header {
    padding: 15px;
    border-bottom: 1px solid #eee;
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.section-title {
    font-size: 1.1rem;
    font-weight: 600;
    color: #333;
    display: flex;
    align-items: center;
    gap: 8px;
}

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

.section-content {
    padding: 15px;
}

/* ===== STATS GRID MOBILE ===== */
.stats-grid {
    display: grid;
    grid-template-columns: 1fr;
    gap: 15px;
    margin-bottom: 20px;
}

.stats-container {
    padding: 0 15px;
}

.stat-card {
    background: white;
    border-radius: 12px;
    padding: 20px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
    transition: transform 0.3s ease;
    position: relative;
    overflow: hidden;
}

.stat-card::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 4px;
    background: linear-gradient(90deg, #25D366, #128C7E);
}

.stat-card:hover {
    transform: translateY(-3px);
}

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

.stat-icon {
    width: 50px;
    height: 50px;
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.5rem;
    color: white;
}

.stat-number {
    font-size: 2rem;
    font-weight: 700;
    color: #2c3e50;
    margin-bottom: 5px;
}

.stat-label {
    font-size: 0.9rem;
    color: #6c757d;
    margin-bottom: 8px;
}

.stat-sublabel {
    font-size: 0.8rem;
    color: #28a745;
    font-weight: 600;
}

/* ===== INSTANCE GRID MOBILE ===== */
.instances-grid {
    display: grid;
    grid-template-columns: 1fr;
    gap: 15px;
}

.instance-card {
    background: linear-gradient(135deg, #fff, #f8f9fa);
    border: 1px solid #e9ecef;
    border-radius: 12px;
    padding: 15px;
    position: relative;
    transition: all 0.3s ease;
}

.instance-card:hover {
    transform: translateY(-3px);
    box-shadow: 0 8px 20px rgba(0, 0, 0, 0.1);
}

.instance-status {
    position: absolute;
    top: 10px;
    right: 10px;
    padding: 4px 8px;
    border-radius: 15px;
    font-size: 0.7rem;
    font-weight: 600;
    text-transform: uppercase;
}

.status-connected { background: #d4edda; color: #155724; }
.status-connecting { background: #fff3cd; color: #856404; }
.status-disconnected { background: #f8d7da; color: #721c24; }

.instance-header {
    margin-bottom: 10px;
}

.instance-name {
    font-size: 1rem;
    font-weight: 600;
    color: #2c3e50;
    margin-bottom: 5px;
}

.instance-details {
    display: flex;
    flex-direction: column;
    gap: 5px;
    margin-bottom: 15px;
}

.instance-detail {
    display: flex;
    align-items: center;
    gap: 8px;
    color: #6c757d;
    font-size: 0.8rem;
}

.instance-detail i {
    color: #25D366;
    width: 14px;
}

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

/* ===== BOTÕES MOBILE ===== */
.btn, .btn-modern {
    padding: 8px 12px;
    border: none;
    border-radius: 8px;
    font-weight: 600;
    text-decoration: none;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    transition: all 0.3s ease;
    font-size: 0.8rem;
    cursor: pointer;
    min-height: 44px; /* Touch target */
}

.btn-primary { background: linear-gradient(135deg, #007bff, #0056b3); color: white; }
.btn-success { background: linear-gradient(135deg, #28a745, #1e7e34); color: white; }
.btn-warning { background: linear-gradient(135deg, #ffc107, #e0a800); color: #212529; }
.btn-danger { background: linear-gradient(135deg, #dc3545, #c82333); color: white; }

.btn:hover, .btn-modern:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
}

/* ===== TABELAS MOBILE ===== */
.leads-table-container {
    overflow-x: auto;
}

.modern-table {
    width: 100%;
    border-collapse: collapse;
    border-radius: 8px;
    overflow: hidden;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.05);
    display: none; /* Escondido no mobile */
}

.mobile-leads {
    display: block;
}

.mobile-lead-card {
    background: #f8f9fa;
    border-radius: 8px;
    padding: 15px;
    margin-bottom: 10px;
    border-left: 4px solid #25D366;
}

.mobile-lead-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 8px;
}

.mobile-lead-name {
    font-weight: 600;
    color: #2c3e50;
    font-size: 0.9rem;
}

.mobile-lead-details {
    display: flex;
    flex-direction: column;
    gap: 4px;
    font-size: 0.8rem;
    color: #6c757d;
}

.lead-status-badge {
    padding: 4px 8px;
    border-radius: 15px;
    font-size: 0.7rem;
    font-weight: 600;
    text-transform: uppercase;
}

.status-new { background: #d1ecf1; color: #0c5460; }
.status-contacted { background: #fff3cd; color: #856404; }
.status-qualified { background: #d4edda; color: #155724; }
.status-converted { background: #d4edda; color: #155724; }
.status-lost { background: #f8d7da; color: #721c24; }

/* ===== EMPTY STATE ===== */
.empty-state {
    text-align: center;
    padding: 40px 20px;
    color: #6c757d;
}

.empty-state i {
    font-size: 3rem;
    margin-bottom: 15px;
    color: #dee2e6;
}

.empty-state h3 {
    margin-bottom: 10px;
    color: #495057;
    font-size: 1.1rem;
}

.empty-state p {
    margin-bottom: 20px;
    font-size: 0.9rem;
}

/* ===== FAB BUTTON MOBILE ===== */
.fab-container {
    position: fixed;
    bottom: 20px;
    right: 20px;
    z-index: 1000;
}

.fab {
    width: 56px;
    height: 56px;
    border-radius: 50%;
    background: linear-gradient(135deg, var(--whatsapp-green), var(--whatsapp-dark-green));
    color: white;
    border: none;
    font-size: 1.5rem;
    cursor: pointer;
    box-shadow: 0 4px 12px rgba(37, 211, 102, 0.3);
    transition: all 0.3s ease;
    display: flex;
    align-items: center;
    justify-content: center;
}

.fab:hover {
    transform: scale(1.1);
    box-shadow: 0 6px 20px rgba(37, 211, 102, 0.4);
}

.fab-menu {
    position: absolute;
    bottom: 70px;
    right: 0;
    background: white;
    border-radius: 12px;
    box-shadow: 0 8px 25px rgba(0, 0, 0, 0.15);
    padding: 8px;
    min-width: 200px;
    transform: scale(0);
    opacity: 0;
    transition: all 0.3s ease;
    transform-origin: bottom right;
}

.fab-menu.active {
    transform: scale(1);
    opacity: 1;
}

.fab-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px;
    border: none;
    background: none;
    width: 100%;
    text-align: left;
    border-radius: 8px;
    cursor: pointer;
    transition: background 0.3s ease;
    font-size: 0.9rem;
}

.fab-item:hover {
    background: #f8f9fa;
}

.fab-item i {
    color: var(--whatsapp-green);
    width: 20px;
}

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

.form-group label {
    display: block;
    margin-bottom: 5px;
    color: #333;
    font-weight: 500;
    font-size: 0.9rem;
}

.form-control {
    width: 100%;
    padding: 12px;
    border: 2px solid #e1e1e1;
    border-radius: 8px;
    font-size: 1rem;
    transition: border-color 0.3s ease;
    outline: none;
    min-height: 44px; /* Touch target */
}

.form-control:focus {
    border-color: var(--whatsapp-green);
}

/* ===== ALERTS MOBILE ===== */
.alert {
    padding: 12px 15px;
    border-radius: 8px;
    margin-bottom: 15px;
    font-size: 0.9rem;
    display: flex;
    align-items: center;
    gap: 8px;
}

.alert-success {
    background-color: #d4edda;
    border: 1px solid #c3e6cb;
    color: #155724;
}

.alert-danger {
    background-color: #f8d7da;
    border: 1px solid #f5c6cb;
    color: #721c24;
}

.alert-warning {
    background-color: #fff3cd;
    border: 1px solid #ffeaa7;
    color: #856404;
}

.alert-info {
    background-color: #d1ecf1;
    border: 1px solid #bee5eb;
    color: #0c5460;
}

/* ===== UTILITY CLASSES ===== */
.d-none { display: none !important; }
.d-block { display: block !important; }
.d-flex { display: flex !important; }
.d-grid { display: grid !important; }

.text-center { text-align: center !important; }
.text-left { text-align: left !important; }
.text-right { text-align: right !important; }

.w-100 { width: 100% !important; }
.h-100 { height: 100% !important; }

/* ===== MEDIA QUERIES - TABLET PEQUENO (576px+) ===== */
@media screen and (min-width: 576px) {
    .stats-grid {
        grid-template-columns: repeat(2, 1fr);
        gap: 20px;
    }
    
    .section-header {
        flex-direction: row;
        justify-content: space-between;
        align-items: center;
    }
    
    .btn, .btn-modern {
        font-size: 0.9rem;
        padding: 10px 16px;
    }
    
    .mobile-topbar {
        padding: 0 20px;
    }
    
    .content-area {
        padding: 20px;
    }
}

/* ===== MEDIA QUERIES - TABLET (768px+) ===== */
@media screen and (min-width: 768px) {
    .stats-grid {
        grid-template-columns: repeat(3, 1fr);
    }
    
    .instances-grid {
        grid-template-columns: repeat(2, 1fr);
        gap: 20px;
    }
    
    .modern-table {
        display: table;
    }
    
    .mobile-leads {
        display: none;
    }
    
    .modern-table th {
        background: linear-gradient(135deg, #25D366, #128C7E);
        color: white;
        padding: 15px;
        text-align: left;
        font-weight: 600;
    }
    
    .modern-table td {
        padding: 15px;
        border-bottom: 1px solid #e9ecef;
    }
    
    .modern-table tr:hover {
        background: #f8f9fa;
    }
    
    .stat-icon {
        width: 60px;
        height: 60px;
        font-size: 1.8rem;
    }
    
    .stat-number {
        font-size: 2.5rem;
    }
}

/* ===== MEDIA QUERIES - DESKTOP (992px+) ===== */
@media screen and (min-width: 992px) {
    /* DESKTOP MODE */
    .mobile-topbar {
        display: none !important;
    }
    
    .desktop-topbar {
        display: flex !important;
        background: white;
        padding: 20px 30px;
        box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
        justify-content: space-between;
        align-items: center;
    }
    
    .sidebar {
        left: 0 !important;
        width: var(--sidebar-width);
        position: fixed;
        z-index: 1000;
    }
    
    .sidebar-overlay {
        display: none !important;
    }
    
    .main-content {
        margin-left: var(--sidebar-width);
        margin-top: 0;
        min-height: 100vh;
    }
    
    .stats-grid {
        grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
        gap: 25px;
        margin-bottom: 30px;
    }
    
    .instances-grid {
        grid-template-columns: repeat(auto-fill, minmax(350px, 1fr));
        gap: 25px;
    }
    
    .content-area {
        padding: 30px;
    }
    
    .fab {
        display: none;
    }
    
    .section-content {
        padding: 25px;
    }
    
    .user-info {
        display: flex;
        align-items: center;
        gap: 15px;
    }
    
    .welcome-text h2 {
        color: #333;
        font-size: 1.8rem;
        margin-bottom: 5px;
    }
    
    .welcome-text p {
        color: #666;
        font-size: 1rem;
    }
}

/* ===== MEDIA QUERIES - DESKTOP GRANDE (1200px+) ===== */
@media screen and (min-width: 1200px) {
    .stats-container {
        max-width: 1200px;
        margin: 0 auto;
        padding: 0 30px;
    }
    
    .stats-grid {
        grid-template-columns: repeat(6, 1fr);
    }
    
    .instances-grid {
        grid-template-columns: repeat(auto-fill, minmax(400px, 1fr));
    }
    
    .content-area {
        padding: 40px;
    }
}

/* ===== MEDIA QUERIES - MOBILE EXTREMO (max-width: 480px) ===== */
@media screen and (max-width: 480px) {
    .content-area {
        padding: 10px;
    }
    
    .section-header {
        padding: 12px;
    }
    
    .section-content {
        padding: 12px;
    }
    
    .stat-card {
        padding: 15px;
    }
    
    .stat-number {
        font-size: 1.8rem;
    }
    
    .btn, .btn-modern {
        font-size: 0.8rem;
        padding: 8px 12px;
    }
    
    .mobile-title {
        font-size: 1rem;
    }
    
    .fab {
        width: 50px;
        height: 50px;
        font-size: 1.3rem;
        bottom: 15px;
        right: 15px;
    }
}

/* ===== MEDIA QUERIES - LANDSCAPE MOBILE ===== */
@media screen and (max-height: 500px) and (orientation: landscape) {
    .mobile-topbar {
        height: 50px;
    }
    
    .main-content {
        margin-top: 50px;
    }
    
    .sidebar-header {
        padding: 15px;
    }
    
    .sidebar-header i {
        font-size: 1.5rem;
        margin-bottom: 5px;
    }
}

/* ===== MEDIA QUERIES - PRINT ===== */
@media print {
    .sidebar,
    .mobile-topbar,
    .desktop-topbar,
    .fab,
    .fab-container {
        display: none !important;
    }
    
    .main-content {
        margin-left: 0 !important;
        margin-top: 0 !important;
    }
    
    .content-area {
        padding: 0 !important;
    }
    
    .section {
        box-shadow: none !important;
        border: 1px solid #ddd !important;
    }
}
