/* Responsive overrides and utility rules for Tess app */

/* Ensure media elements scale */
img, picture, video, canvas {
    max-width: 100%;
    height: auto;
}

/* Make charts responsive */
.chart-container canvas {
    width: 100% !important;
    height: auto !important;
}

/* Fluid containers */
.app-container {
    max-width: 100%;
    box-sizing: border-box;
}

/* Utility hide on small */
.responsive-hidden-sm { display: none; }

/* Mobile menu toggle button */
.mobile-menu-toggle {
    display: none;
    background: none;
    border: none;
    color: var(--text-color);
    font-size: 24px;
    cursor: pointer;
    padding: 8px;
    border-radius: 8px;
    transition: var(--transition);
    z-index: 2001;
    position: fixed;
    top: 20px;
    left: 20px;
}

.mobile-menu-toggle:hover {
    background-color: var(--primary);
    color: white;
}

/* Mobile overlay for sidebar */
.sidebar-overlay {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.5);
    z-index: 1999;
    backdrop-filter: blur(4px);
}

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

/* Horizontal scroll containers */
.horizontal-scroll {
    display: flex;
    overflow-x: auto;
    gap: 16px;
    padding: 16px 0;
    scroll-behavior: smooth;
    scrollbar-width: thin;
    scrollbar-color: var(--primary) transparent;
}

.horizontal-scroll::-webkit-scrollbar {
    height: 6px;
}

.horizontal-scroll::-webkit-scrollbar-track {
    background: transparent;
}

.horizontal-scroll::-webkit-scrollbar-thumb {
    background-color: var(--primary);
    border-radius: 3px;
}

.horizontal-scroll::-webkit-scrollbar-thumb:hover {
    background-color: var(--secondary);
}

/* Breakpoints */
@media (max-width: 1200px) {
    .metrics-grid {
        grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    }
    .charts-grid {
        grid-template-columns: 1fr;
        gap: 18px;
    }
}

@media (max-width: 992px) {
    /* Compact sidebar */
    .sidebar {
        width: 72px;
    }
    .sidebar .nav-links span { 
        display: none; 
    }
    .main-content { 
        margin-left: 72px; 
    }
    .topbar .user-info span { 
        display: none; 
    }
}

@media (max-width: 768px) {
    /* Mobile menu toggle */
    .mobile-menu-toggle {
        display: block;
    }
    
    /* Mobile sidebar */
    .sidebar {
        position: fixed;
        left: -280px;
        top: 0;
        height: 100vh;
        width: 280px;
        z-index: 2000;
        transition: left 0.3s cubic-bezier(0.25, 0.8, 0.25, 1);
        background: var(--sidebar-bg);
        box-shadow: 0 8px 30px rgba(0,0,0,0.15);
        backdrop-filter: blur(10px);
    }
    
    .sidebar.open {
        left: 0;
    }
    
    /* Main content adjustments */
    .main-content {
        margin-left: 0 !important;
        padding: 16px;
        padding-top: 70px; /* Space for mobile menu toggle */
    }
    
    /* Topbar mobile adjustments */
    .topbar {
        flex-direction: column;
        gap: 16px;
        align-items: stretch;
        padding: 20px;
        margin-bottom: 20px;
    }
    
    .topbar h2 {
        font-size: 22px;
        margin: 0;
    }
    
    /* Horizontal scroll for metrics */
    .metrics-grid {
        display: flex;
        overflow-x: auto;
        gap: 16px;
        padding: 16px 0;
        scroll-behavior: smooth;
        scroll-snap-type: x mandatory;
    }
    
    .metric-card {
        flex: 0 0 280px;
        scroll-snap-align: start;
        min-height: 140px;
    }
    
    /* Charts stack vertically */
    .charts-grid {
        grid-template-columns: 1fr;
        gap: 20px;
    }
    
    /* Kanban board horizontal scroll */
    .kanban-board {
        display: flex;
        overflow-x: auto;
        gap: 16px;
        padding: 16px 0;
        scroll-behavior: smooth;
        scroll-snap-type: x mandatory;
    }
    
    .kanban-column {
        flex: 0 0 280px;
        scroll-snap-align: start;
        min-height: 400px;
    }
    
    /* Tables horizontal scroll */
    .table-container {
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
    }
    
    /* Modal adjustments */
    .modal .modal-content {
        width: calc(100% - 32px);
        margin: 20px auto;
        max-height: 90vh;
        overflow-y: auto;
    }
    
    /* Form grids stack */
    .form-grid, .settings-grid, .form-grid-columns {
        grid-template-columns: 1fr !important;
    }
}

@media (max-width: 576px) {
    .mobile-menu-toggle {
        top: 15px;
        left: 15px;
        font-size: 20px;
    }
    
    .main-content {
        padding: 12px;
        padding-top: 60px;
    }
    
    .topbar {
        padding: 16px;
        margin-bottom: 16px;
    }
    
    .topbar h2 {
        font-size: 20px;
    }
    
    .user-avatar {
        width: 36px;
        height: 36px;
        font-size: 16px;
    }
    
    .btn {
        padding: 12px 16px;
        font-size: 14px;
    }
    
    .metric-card {
        flex: 0 0 260px;
        padding: 20px;
    }
    
    .card-icon {
        width: 50px;
        height: 50px;
        font-size: 24px;
    }
    
    .metric-value {
        font-size: 24px;
    }
    
    .kanban-column {
        flex: 0 0 260px;
    }
    
    /* Tables become cards on very small screens */
    .table-container table {
        display: block;
    }
    
    .table-container thead {
        display: none;
    }
    
    .table-container tbody tr {
        display: block;
        border: 1px solid var(--border-color);
        border-radius: 12px;
        margin-bottom: 12px;
        padding: 16px;
        background: var(--card-bg);
        box-shadow: var(--shadow);
    }
    
    .table-container tbody td {
        display: block;
        padding: 8px 0;
        border: none;
        text-align: left;
    }
    
    .table-container tbody td:before {
        content: attr(data-label) ": ";
        font-weight: 600;
        color: var(--text-color-light);
        display: inline-block;
        width: 120px;
    }
}

/* Touch-friendly improvements */
@media (hover: none) and (pointer: coarse) {
    .btn {
        min-height: 44px;
        min-width: 44px;
    }
    
    .nav-links a {
        min-height: 44px;
    }
    
    .modal .close-modal {
        min-width: 44px;
        min-height: 44px;
    }
    
    .metric-card {
        min-height: 44px;
    }
    
    .kanban-column {
        min-height: 44px;
    }
}

/* Mobile-specific table improvements */
@media (max-width: 768px) {
    .status-badge {
        display: inline-block;
        padding: 4px 8px;
        border-radius: 12px;
        font-size: 12px;
        font-weight: 600;
        text-transform: uppercase;
        letter-spacing: 0.5px;
    }
    
    .status-badge[data-status="Ativo"] {
        background-color: rgba(46, 204, 113, 0.2);
        color: #27ae60;
    }
    
    .status-badge[data-status="Lead"] {
        background-color: rgba(52, 152, 219, 0.2);
        color: #3498db;
    }
    
    .status-badge[data-status="Inativo"] {
        background-color: rgba(149, 165, 166, 0.2);
        color: #95a5a6;
    }
    
    .client-actions, .product-actions {
        display: flex;
        gap: 8px;
        flex-wrap: wrap;
    }
    
    .btn-sm {
        padding: 8px 12px;
        font-size: 12px;
        min-width: auto;
    }
    
    .product-media-cell {
        max-width: 60px;
        max-height: 60px;
        overflow: hidden;
        border-radius: 8px;
    }
    
    .product-media-cell img {
        width: 100%;
        height: 100%;
        object-fit: cover;
    }
    
    .product-info {
        display: flex;
        align-items: center;
        gap: 12px;
    }
}

/* Small utility tweaks */
.modal {
    padding: 12px;
}

.toast {
    left: 12px;
    right: 12px;
    top: 80px; /* Below mobile menu toggle */
}

/* Accessibility: ensure focus outlines remain visible on small screens */
button:focus, a:focus, input:focus, select:focus, textarea:focus {
    outline: 3px solid rgba(38, 194, 129, 0.3);
    outline-offset: 2px;
}

/* End of responsive overrides */



