/* BS Access CRM/ERP - Styles */
:root {
    /* Couleurs BS Access - Rouge / Gris / Blanc */
    --primary: #e53935;
    --primary-dark: #c62828;
    --primary-light: #ff6f60;
    --secondary: #5a5a5a;
    --success: #22c55e;
    --warning: #f59e0b;
    --danger: #d32f2f;
    --info: #1976d2;
    --light: #fafafa;
    --dark: #4a4a4a;
    --white: #ffffff;
    --gray-100: #f5f5f5;
    --gray-200: #eeeeee;
    --gray-300: #e0e0e0;
    --gray-400: #bdbdbd;
    --gray-500: #9e9e9e;
    --gray-600: #757575;
    --gray-700: #616161;
    --gray-800: #424242;
    --sidebar-width: 260px;
    --header-height: 70px;
    --shadow: 0 1px 3px rgba(0,0,0,0.1);
    --shadow-lg: 0 10px 25px rgba(0,0,0,0.1);
    --radius: 8px;
    --transition: all 0.3s ease;
}

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

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, sans-serif;
    background: var(--gray-100);
    color: var(--gray-800);
    line-height: 1.6;
}

.hidden { display: none !important; }

/* Login Page */
.login-page {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    background: linear-gradient(135deg, #5a5a5a 0%, #3a3a3a 100%);
    padding: 20px;
}

.login-container {
    background: var(--white);
    padding: 40px;
    border-radius: 16px;
    box-shadow: var(--shadow-lg);
    width: 100%;
    max-width: 400px;
}

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

.login-logo .logo-img {
    max-width: 200px;
    height: auto;
    margin-bottom: 10px;
}

.login-logo p {
    color: var(--gray-500);
    font-size: 14px;
    font-weight: 500;
}

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

.login-form label {
    display: block;
    margin-bottom: 8px;
    font-weight: 500;
    color: var(--gray-700);
}

.login-form label i {
    margin-right: 8px;
    color: var(--gray-400);
}

.login-form input {
    width: 100%;
    padding: 12px 16px;
    border: 2px solid var(--gray-200);
    border-radius: var(--radius);
    font-size: 16px;
    transition: var(--transition);
}

.login-form input:focus {
    outline: none;
    border-color: var(--primary);
}

.error-message {
    color: var(--danger);
    font-size: 14px;
    margin-top: 10px;
    text-align: center;
}

.login-footer {
    text-align: center;
    margin-top: 20px;
    color: var(--gray-500);
    font-size: 14px;
}

/* Buttons */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 10px 20px;
    border: none;
    border-radius: var(--radius);
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    transition: var(--transition);
}

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

.btn-primary:hover {
    background: var(--primary-dark);
}

.btn-secondary {
    background: var(--gray-200);
    color: var(--gray-700);
}

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

.btn-success {
    background: var(--success);
    color: var(--white);
}

.btn-danger {
    background: var(--danger);
    color: var(--white);
}

.btn-block {
    width: 100%;
}

.btn-sm {
    padding: 6px 12px;
    font-size: 13px;
}

.btn-icon {
    width: 36px;
    height: 36px;
    padding: 0;
    border-radius: 50%;
}

/* Main App Layout */
.main-app {
    display: flex;
    min-height: 100vh;
}

/* Sidebar */
.sidebar {
    width: var(--sidebar-width);
    background: var(--white);
    color: var(--dark);
    position: fixed;
    height: 100vh;
    display: flex;
    flex-direction: column;
    transition: var(--transition);
    z-index: 100;
    border-right: 1px solid var(--gray-200);
}

.sidebar-header {
    padding: 15px 20px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-bottom: 1px solid var(--gray-200);
    background: var(--white);
}

.sidebar-logo {
    max-width: 160px;
    height: auto;
}

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

.nav-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 20px;
    color: var(--gray-600);
    text-decoration: none;
    transition: var(--transition);
}

.nav-item:hover {
    background: var(--gray-100);
    color: var(--primary);
}

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

.nav-item i {
    width: 24px;
    text-align: center;
}

.sidebar-footer {
    padding: 15px 20px;
    border-top: 1px solid var(--gray-200);
}

.btn-logout {
    width: 100%;
    background: transparent;
    color: var(--gray-600);
    border: 1px solid var(--gray-300);
}

.btn-logout:hover {
    background: var(--primary);
    border-color: var(--primary);
    color: var(--white);
}

/* Main Content */
.main-content {
    flex: 1;
    margin-left: var(--sidebar-width);
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

.main-header {
    height: var(--header-height);
    background: var(--white);
    padding: 0 30px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    box-shadow: var(--shadow);
    position: sticky;
    top: 0;
    z-index: 50;
}

.menu-toggle {
    display: none;
    background: none;
    border: none;
    font-size: 24px;
    color: var(--gray-600);
    cursor: pointer;
}

.header-title h1 {
    font-size: 24px;
    color: var(--dark);
}

.header-title span {
    font-size: 14px;
    color: var(--gray-500);
}

.header-user {
    display: flex;
    align-items: center;
    gap: 10px;
    color: var(--gray-600);
}

.header-user i {
    font-size: 32px;
    color: var(--primary);
}

/* Page Content */
.page-content {
    flex: 1;
    padding: 30px;
}

.page {
    display: none;
}

.page.active {
    display: block;
}

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

.stat-card {
    background: var(--white);
    padding: 24px;
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    display: flex;
    align-items: center;
    gap: 20px;
}

.stat-icon {
    width: 60px;
    height: 60px;
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 24px;
    color: var(--white);
}

.stat-icon.clients { background: linear-gradient(135deg, #e53935, #c62828); }
.stat-icon.products { background: linear-gradient(135deg, #5a5a5a, #424242); }
.stat-icon.orders { background: linear-gradient(135deg, #22c55e, #15803d); }
.stat-icon.revenue { background: linear-gradient(135deg, #e53935, #c62828); }

.stat-info h3 {
    font-size: 28px;
    color: var(--dark);
    margin-bottom: 4px;
}

.stat-info p {
    color: var(--gray-500);
    font-size: 14px;
}

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

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

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

.card-header h3 {
    font-size: 16px;
    color: var(--dark);
    display: flex;
    align-items: center;
    gap: 10px;
}

.card-header h3 i {
    color: var(--primary);
}

.card-body {
    padding: 20px;
}

.alerts-card .alert-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px;
    background: var(--gray-100);
    border-radius: var(--radius);
    margin-bottom: 10px;
}

.alerts-card .alert-item:last-child {
    margin-bottom: 0;
}

.alerts-card .alert-item i {
    color: var(--warning);
}

/* Page Header */
.page-header {
    display: flex;
    align-items: center;
    gap: 20px;
    margin-bottom: 20px;
    flex-wrap: wrap;
}

.page-header h2 {
    font-size: 20px;
    color: var(--dark);
}

.search-bar {
    display: flex;
    align-items: center;
    background: var(--white);
    border: 1px solid var(--gray-200);
    border-radius: var(--radius);
    padding: 0 12px;
    flex: 1;
    max-width: 400px;
}

.search-bar i {
    color: var(--gray-400);
}

.search-bar input {
    border: none;
    padding: 10px 12px;
    font-size: 14px;
    width: 100%;
}

.search-bar input:focus {
    outline: none;
}

.filters {
    display: flex;
    align-items: center;
    gap: 12px;
}

.filters select,
.filters input[type="date"] {
    padding: 10px 12px;
    border: 1px solid var(--gray-200);
    border-radius: var(--radius);
    font-size: 14px;
    background: var(--white);
}

.checkbox-label {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 14px;
    color: var(--gray-600);
    cursor: pointer;
}

/* Tables */
.table-container {
    background: var(--white);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    overflow: hidden;
}

.table {
    width: 100%;
    border-collapse: collapse;
}

.table th,
.table td {
    padding: 12px 16px;
    text-align: left;
    border-bottom: 1px solid var(--gray-200);
}

.table th {
    background: var(--gray-100);
    font-weight: 600;
    color: var(--gray-700);
    font-size: 13px;
    text-transform: uppercase;
}

.table td {
    font-size: 14px;
    color: var(--gray-700);
}

.table tbody tr:hover {
    background: var(--gray-50);
}

.table .actions {
    display: flex;
    gap: 8px;
}

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

.badge-success { background: #dcfce7; color: #15803d; }
.badge-warning { background: #fef3c7; color: #b45309; }
.badge-danger { background: #fee2e2; color: #b91c1c; }
.badge-info { background: #dbeafe; color: #1d4ed8; }
.badge-secondary { background: var(--gray-200); color: var(--gray-700); }

/* Product Image */
.product-thumb {
    width: 50px;
    height: 50px;
    object-fit: cover;
    border-radius: var(--radius);
    background: var(--gray-200);
}

/* Stock Status */
.stock-ok { color: var(--success); }
.stock-low { color: var(--warning); }
.stock-out { color: var(--danger); }

/* Modal */
.modal {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0,0,0,0.5);
    z-index: 1000;
    align-items: center;
    justify-content: center;
    padding: 20px;
}

.modal.active {
    display: flex;
}

.modal-content {
    background: var(--white);
    border-radius: var(--radius);
    width: 100%;
    max-width: 700px;
    max-height: 90vh;
    overflow: hidden;
    display: flex;
    flex-direction: column;
}

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

.modal-header h3 {
    font-size: 18px;
    color: var(--dark);
}

.modal-close {
    background: none;
    border: none;
    font-size: 28px;
    color: var(--gray-400);
    cursor: pointer;
}

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

.modal-body {
    padding: 20px;
    overflow-y: auto;
    flex: 1;
}

.modal-footer {
    padding: 16px 20px;
    border-top: 1px solid var(--gray-200);
    display: flex;
    justify-content: flex-end;
    gap: 12px;
}

/* Form Styles in Modal */
.form-row {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 16px;
    margin-bottom: 16px;
}

.form-group {
    margin-bottom: 16px;
}

.form-group label {
    display: block;
    margin-bottom: 6px;
    font-weight: 500;
    color: var(--gray-700);
    font-size: 14px;
}

.form-group input,
.form-group select,
.form-group textarea {
    width: 100%;
    padding: 10px 12px;
    border: 1px solid var(--gray-300);
    border-radius: var(--radius);
    font-size: 14px;
}

.form-group input:focus,
.form-group select:focus,
.form-group textarea:focus {
    outline: none;
    border-color: var(--primary);
}

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

.form-section {
    margin-bottom: 24px;
}

.form-section h4 {
    font-size: 16px;
    color: var(--dark);
    margin-bottom: 16px;
    padding-bottom: 8px;
    border-bottom: 1px solid var(--gray-200);
}

/* Toast */
.toast {
    position: fixed;
    bottom: 30px;
    right: 30px;
    padding: 16px 24px;
    border-radius: var(--radius);
    color: var(--white);
    font-weight: 500;
    z-index: 2000;
    transform: translateX(150%);
    transition: var(--transition);
}

.toast.active {
    transform: translateX(0);
}

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

/* Reports */
.reports-tabs {
    display: flex;
    gap: 8px;
    margin-bottom: 20px;
}

.tab-btn {
    padding: 10px 20px;
    background: var(--white);
    border: 1px solid var(--gray-200);
    border-radius: var(--radius);
    cursor: pointer;
    font-size: 14px;
    transition: var(--transition);
}

.tab-btn:hover {
    background: var(--gray-100);
}

.tab-btn.active {
    background: var(--primary);
    color: var(--white);
    border-color: var(--primary);
}

.report-content {
    display: none;
}

.report-content.active {
    display: block;
}

.report-summary {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 20px;
    margin-bottom: 30px;
}

.summary-item {
    background: var(--white);
    padding: 20px;
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    text-align: center;
}

.summary-item h4 {
    color: var(--gray-500);
    font-size: 14px;
    margin-bottom: 8px;
}

.summary-item span {
    font-size: 28px;
    font-weight: 700;
    color: var(--primary);
}

.chart-container {
    background: var(--white);
    padding: 20px;
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    margin-bottom: 20px;
    height: 400px;
}

/* Signature Canvas */
.signature-container {
    border: 2px dashed var(--gray-300);
    border-radius: var(--radius);
    padding: 10px;
    margin-bottom: 16px;
}

.signature-canvas {
    width: 100%;
    height: 200px;
    border: 1px solid var(--gray-200);
    border-radius: var(--radius);
    cursor: crosshair;
}

/* Order Items */
.order-items-list {
    margin-top: 16px;
}

.order-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px;
    background: var(--gray-100);
    border-radius: var(--radius);
    margin-bottom: 8px;
}

.order-item-info {
    flex: 1;
}

.order-item-name {
    font-weight: 500;
}

.order-item-price {
    color: var(--gray-500);
    font-size: 14px;
}

.order-item-qty {
    display: flex;
    align-items: center;
    gap: 8px;
}

.order-item-qty input {
    width: 60px;
    text-align: center;
}

.order-item-remove {
    color: var(--danger);
    cursor: pointer;
}

/* Client Detail */
.client-detail-header {
    display: flex;
    align-items: flex-start;
    gap: 20px;
    margin-bottom: 24px;
}

.client-detail-info h2 {
    font-size: 24px;
    color: var(--dark);
    margin-bottom: 4px;
}

.client-detail-info p {
    color: var(--gray-500);
}

.client-stats {
    display: flex;
    gap: 20px;
    margin-top: 16px;
}

.client-stat {
    text-align: center;
    padding: 12px 20px;
    background: var(--gray-100);
    border-radius: var(--radius);
}

.client-stat strong {
    display: block;
    font-size: 20px;
    color: var(--primary);
}

.client-stat span {
    font-size: 12px;
    color: var(--gray-500);
}

/* Responsive */
@media (max-width: 1024px) {
    .sidebar {
        transform: translateX(-100%);
        box-shadow: 4px 0 20px rgba(0,0,0,0.3);
    }

    .sidebar.active {
        transform: translateX(0);
    }

    .main-content {
        margin-left: 0;
    }

    .menu-toggle {
        display: block;
    }

    .dashboard-grid {
        grid-template-columns: 1fr;
    }

    /* Overlay when sidebar is open */
    .sidebar-overlay {
        display: none;
        position: fixed;
        top: 0;
        left: 0;
        right: 0;
        bottom: 0;
        background: rgba(0,0,0,0.5);
        z-index: 99;
    }

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

@media (max-width: 768px) {
    .page-header {
        flex-direction: column;
        align-items: stretch;
    }

    .search-bar {
        max-width: none;
    }

    .filters {
        flex-wrap: wrap;
    }

    .stats-grid {
        grid-template-columns: 1fr 1fr;
    }

    .table-container {
        overflow-x: auto;
    }

    .modal-content {
        max-width: 100%;
        margin: 10px;
    }
}

@media (max-width: 480px) {
    .stats-grid {
        grid-template-columns: 1fr;
    }

    .main-header {
        padding: 0 16px;
    }

    .page-content {
        padding: 16px;
    }

    .header-title h1 {
        font-size: 18px;
    }
}

/* Price columns styling */
.price-telephonie {
    color: var(--info);
    font-weight: 500;
}

.price-alimentaire {
    color: var(--warning);
    font-weight: 500;
}

.price-minimum {
    color: var(--danger);
    font-weight: 500;
    font-size: 12px;
}

/* Products table - smaller font for more columns */
.table-products th,
.table-products td {
    font-size: 13px;
    padding: 8px 6px;
}

.table-products th {
    white-space: nowrap;
}

/* Alert warnings */
.alert {
    padding: 12px 16px;
    border-radius: var(--radius);
    font-size: 14px;
}

.alert-warning {
    background: #fef3c7;
    border: 1px solid #f59e0b;
    color: #92400e;
}

.alert-warning i {
    margin-right: 8px;
    color: #f59e0b;
}

.alert-danger {
    background: #fee2e2;
    border: 1px solid #ef4444;
    color: #991b1b;
}

.alert-info {
    background: #e0f2fe;
    border: 1px solid #06b6d4;
    color: #0e7490;
}

/* Segment badges */
.badge-telephonie {
    background: var(--info);
}

.badge-alimentaire {
    background: var(--warning);
}

/* =====================================================
   MOBILE RESPONSIVE IMPROVEMENTS
   ===================================================== */

/* Mobile tables - card view for small screens */
@media (max-width: 768px) {
    /* Hide table headers on mobile */
    .table-mobile-cards thead {
        display: none;
    }

    .table-mobile-cards tbody tr {
        display: block;
        margin-bottom: 16px;
        background: var(--white);
        border-radius: var(--radius);
        box-shadow: var(--shadow);
        padding: 12px;
    }

    .table-mobile-cards tbody td {
        display: flex;
        justify-content: space-between;
        align-items: center;
        padding: 8px 0;
        border: none;
        border-bottom: 1px solid var(--gray-100);
    }

    .table-mobile-cards tbody td:last-child {
        border-bottom: none;
    }

    .table-mobile-cards tbody td::before {
        content: attr(data-label);
        font-weight: 600;
        color: var(--gray-600);
        font-size: 12px;
        text-transform: uppercase;
    }

    /* Products table mobile */
    .table-products {
        font-size: 12px;
    }

    .table-products th,
    .table-products td {
        padding: 6px 4px;
        font-size: 11px;
    }

    .table-products .product-thumb {
        width: 30px;
        height: 30px;
    }

    /* Hide less important columns on mobile */
    .table-products th:nth-child(4),
    .table-products td:nth-child(4),
    .table-products th:nth-child(5),
    .table-products td:nth-child(5) {
        display: none;
    }

    /* Clients table mobile - hide some columns */
    #clientsPage .table th:nth-child(6),
    #clientsPage .table td:nth-child(6),
    #clientsPage .table th:nth-child(7),
    #clientsPage .table td:nth-child(7) {
        display: none;
    }

    /* Orders table mobile */
    #ordersPage .table th:nth-child(4),
    #ordersPage .table td:nth-child(4) {
        display: none;
    }

    /* Action buttons on mobile */
    .actions {
        display: flex;
        gap: 4px;
        flex-wrap: wrap;
        justify-content: flex-end;
    }

    .actions .btn-sm {
        padding: 6px 8px;
        font-size: 12px;
    }

    /* Page header mobile */
    .page-header {
        gap: 12px;
    }

    .page-header .btn {
        width: 100%;
        justify-content: center;
    }

    /* Filters on mobile */
    .filters {
        width: 100%;
        gap: 8px;
    }

    .filters select,
    .filters input {
        flex: 1;
        min-width: 120px;
    }

    /* Modal improvements for mobile */
    .modal-content {
        width: 95%;
        max-height: 90vh;
        margin: 5vh auto;
    }

    .modal-body {
        padding: 16px;
    }

    .modal-footer {
        flex-direction: column;
        gap: 8px;
    }

    .modal-footer .btn {
        width: 100%;
    }

    /* Form improvements for mobile */
    .form-row {
        grid-template-columns: 1fr;
        gap: 12px;
    }

    .form-group input,
    .form-group select,
    .form-group textarea {
        font-size: 16px; /* Prevents zoom on iOS */
        padding: 12px;
    }

    .form-section h4 {
        font-size: 14px;
    }

    /* Dashboard cards on mobile */
    .stat-card {
        padding: 16px;
    }

    .stat-card .stat-icon {
        width: 40px;
        height: 40px;
        font-size: 18px;
    }

    .stat-info h3 {
        font-size: 20px;
    }

    .stat-info p {
        font-size: 12px;
    }

    /* Dashboard grid mobile */
    .dashboard-card {
        padding: 12px;
    }

    .card-header h3 {
        font-size: 14px;
    }

    /* Order items on mobile */
    .order-item {
        flex-direction: column;
        align-items: flex-start;
        gap: 8px;
    }

    .order-item-qty {
        width: 100%;
        justify-content: space-between;
    }

    /* Reports on mobile */
    .reports-tabs {
        flex-wrap: wrap;
    }

    .tab-btn {
        flex: 1;
        min-width: 80px;
        text-align: center;
        padding: 8px 12px;
        font-size: 12px;
    }

    .report-summary {
        grid-template-columns: 1fr;
    }

    .chart-container {
        height: 250px;
    }

    /* Client stats on mobile */
    .client-stats {
        flex-wrap: wrap;
    }

    .client-stat {
        flex: 1;
        min-width: 80px;
        padding: 8px 12px;
    }

    /* Header on mobile */
    .main-header {
        height: auto;
        min-height: 60px;
        padding: 10px 16px;
    }

    .header-title h1 {
        font-size: 16px;
    }

    #headerDate {
        display: none;
    }

    .header-user span {
        display: none;
    }
}

/* Extra small screens (phones in portrait) */
@media (max-width: 400px) {
    .stats-grid {
        gap: 8px;
    }

    .stat-card {
        padding: 12px;
    }

    .page-content {
        padding: 12px;
    }

    .table th,
    .table td {
        padding: 6px 4px;
        font-size: 11px;
    }

    .badge {
        padding: 2px 6px;
        font-size: 10px;
    }

    .btn-sm {
        padding: 4px 6px;
        font-size: 11px;
    }

    /* Hide more columns on very small screens */
    .table-products th:nth-child(3),
    .table-products td:nth-child(3) {
        max-width: 80px;
        overflow: hidden;
        text-overflow: ellipsis;
        white-space: nowrap;
    }
}

/* Touch-friendly improvements */
@media (hover: none) and (pointer: coarse) {
    .btn {
        min-height: 44px;
        min-width: 44px;
    }

    .nav-item {
        padding: 14px 20px;
    }

    .table td,
    .table th {
        padding: 12px 8px;
    }

    select,
    input[type="text"],
    input[type="email"],
    input[type="password"],
    input[type="number"],
    input[type="date"],
    input[type="tel"],
    textarea {
        min-height: 44px;
    }
}

/* Landscape phone orientation */
@media (max-height: 500px) and (orientation: landscape) {
    .modal-content {
        max-height: 95vh;
    }

    .modal-body {
        max-height: 60vh;
    }

    .login-container {
        padding: 20px;
    }

    .login-logo {
        margin-bottom: 15px;
    }

    .login-logo i {
        font-size: 32px;
    }
}

/* Login page mobile improvements */
@media (max-width: 480px) {
    .login-container {
        padding: 24px;
        margin: 10px;
    }

    .login-logo i {
        font-size: 40px;
    }

    .login-logo h1 {
        font-size: 24px;
    }

    .login-form input {
        padding: 14px;
        font-size: 16px;
    }

    .login-form .btn {
        padding: 14px;
        font-size: 16px;
    }
}

/* Safe area insets for notched phones */
@supports (padding: max(0px)) {
    .main-app {
        padding-left: env(safe-area-inset-left);
        padding-right: env(safe-area-inset-right);
    }

    .sidebar {
        padding-bottom: env(safe-area-inset-bottom);
    }

    .modal-content {
        padding-bottom: env(safe-area-inset-bottom);
    }
}

/* Prevent text selection on buttons for better mobile UX */
.btn, .nav-item, .tab-btn {
    -webkit-user-select: none;
    user-select: none;
    -webkit-tap-highlight-color: transparent;
}

/* Smooth scrolling for iOS */
.table-container,
.modal-body,
.sidebar-nav {
    -webkit-overflow-scrolling: touch;
}

/* =====================================================
   MOBILE CARDS VIEW
   ===================================================== */

.cards-container {
    display: flex;
    flex-direction: column;
    gap: 12px;
    padding: 0;
}

/* Product Cards */
.product-card {
    background: var(--white);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    padding: 12px;
}

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

.product-sku {
    font-size: 12px;
    font-weight: 600;
    color: var(--primary);
    background: var(--gray-100);
    padding: 2px 8px;
    border-radius: 4px;
}

.product-stock {
    font-size: 11px;
    font-weight: 500;
    padding: 2px 8px;
    border-radius: 4px;
}

.product-stock.stock-ok {
    background: #dcfce7;
    color: #166534;
}

.product-stock.stock-low {
    background: #fef3c7;
    color: #92400e;
}

.product-stock.stock-out {
    background: #fee2e2;
    color: #991b1b;
}

.product-card-name {
    font-size: 14px;
    font-weight: 600;
    color: var(--dark);
    margin-bottom: 10px;
    line-height: 1.3;
}

.product-card-prices {
    display: flex;
    gap: 12px;
    margin-bottom: 12px;
    flex-wrap: wrap;
}

.price-item {
    display: flex;
    align-items: center;
    gap: 4px;
    font-size: 13px;
}

.price-label {
    color: var(--gray-500);
    font-size: 11px;
}

.product-card-actions {
    display: flex;
    gap: 8px;
    justify-content: flex-end;
    padding-top: 10px;
    border-top: 1px solid var(--gray-100);
}

/* Client Cards */
.client-card {
    background: var(--white);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    padding: 12px;
}

.client-card-header {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 6px;
}

.client-code {
    font-size: 12px;
    font-weight: 600;
    color: var(--primary);
    background: var(--gray-100);
    padding: 2px 8px;
    border-radius: 4px;
}

.client-card-name {
    font-size: 15px;
    font-weight: 600;
    color: var(--dark);
    margin-bottom: 8px;
}

.client-card-info {
    display: flex;
    gap: 16px;
    font-size: 12px;
    color: var(--gray-500);
    margin-bottom: 12px;
}

.client-card-info i {
    margin-right: 4px;
    color: var(--gray-400);
}

.client-card-actions {
    display: flex;
    gap: 8px;
    justify-content: flex-end;
    padding-top: 10px;
    border-top: 1px solid var(--gray-100);
}

/* No data message */
.no-data {
    text-align: center;
    padding: 40px 20px;
    color: var(--gray-500);
    font-size: 14px;
}
