/* Comprehensive Responsive Design for KICT CRM */

/* ===== GLOBAL RESPONSIVE SETTINGS ===== */
* {
    box-sizing: border-box;
}

/* ===== VIEWPORT & BASE RESPONSIVE ===== */
@media (max-width: 1200px) {
    .grid-4-col { 
        grid-template-columns: repeat(3, minmax(0, 1fr)); 
    }
    .sidebar { 
        width: 260px; 
    }
    .main-content { 
        margin-left: 260px; 
        padding: 1.5rem; 
    }
}

@media (max-width: 992px) {
    .grid-4-col { 
        grid-template-columns: repeat(2, minmax(0, 1fr)); 
    }
    .grid-3-col { 
        grid-template-columns: repeat(2, minmax(0, 1fr)); 
    }
    .sidebar { 
        width: 240px; 
    }
    .main-content { 
        margin-left: 240px; 
        padding: 1.25rem; 
    }
    .top-navbar { 
        flex-wrap: wrap; 
        gap: 0.75rem; 
    }
    .table-responsive { 
        width: 100%; 
        overflow-x: auto; 
    }
    .stat-card {
        padding: 1.25rem;
    }
    .page-header {
        flex-direction: column;
        align-items: flex-start;
        gap: 1rem;
    }
}

/* ===== MOBILE RESPONSIVE (768px and below) ===== */
@media (max-width: 768px) {
    /* Sidebar Mobile Behavior */
    .sidebar {
        position: fixed;
        top: 0; 
        left: 0; 
        bottom: 0;
        width: 280px;
        transform: translateX(-100%);
        transition: transform 0.3s ease;
        z-index: 1000;
        box-shadow: 2px 0 10px rgba(0,0,0,0.3);
    }
    
    .sidebar.is-open { 
        transform: translateX(0); 
    }
    
    .main-content { 
        margin-left: 0 !important; 
        padding: 1rem; 
        width: 100%;
    }
    
    /* Sidebar Navigation Scroll */
    .sidebar .nav {
        height: calc(100vh - 120px);
        max-height: calc(100vh - 120px);
        overflow-y: auto;
        overflow-x: hidden;
        padding-bottom: 2rem;
    }
    
    /* Grid Layouts */
    .grid-4-col, 
    .grid-3-col, 
    .grid-2-col { 
        grid-template-columns: 1fr; 
        gap: 1rem;
    }
    
    /* Hide elements on mobile */
    .hide-sm { 
        display: none !important; 
    }
    
    /* Top Navbar Mobile */
    .top-navbar {
        padding: 0.75rem 1rem;
        flex-direction: column;
        align-items: stretch;
        gap: 0.5rem;
    }
    
    .top-navbar h5 {
        font-size: 1.1rem;
        margin: 0;
    }
    
    .user-info {
        justify-content: space-between;
        width: 100%;
    }
    
    /* Cards and Content */
    .card {
        margin-bottom: 1rem;
        padding: 1rem;
    }
    
    .stat-card {
        padding: 1rem;
        margin-bottom: 1rem;
    }
    
    .stat-number {
        font-size: 1.5rem;
    }
    
    /* Tables */
    .table-responsive {
        margin: 0 -1rem;
        padding: 0 1rem;
        width: calc(100% + 2rem);
    }
    
    .table {
        font-size: 0.875rem;
    }
    
    .table th,
    .table td {
        padding: 0.5rem 0.25rem;
        white-space: nowrap;
    }
    
    /* Forms */
    .form-control,
    .form-select {
        font-size: 16px; /* Prevents zoom on iOS */
        padding: 0.75rem;
    }
    
    .form-label {
        font-size: 0.875rem;
        margin-bottom: 0.25rem;
    }
    
    /* Buttons */
    .btn {
        padding: 0.75rem 1rem;
        font-size: 0.875rem;
        width: 100%;
        margin-bottom: 0.5rem;
    }
    
    .btn-group .btn {
        width: auto;
        margin-bottom: 0;
    }
    
    /* Page Headers */
    .page-header {
        padding: 1rem 0;
        margin-bottom: 1.5rem;
    }
    
    .page-title {
        font-size: 1.5rem;
        margin-bottom: 0.5rem;
    }
    
    .page-subtitle {
        font-size: 0.875rem;
    }
    
    /* Modals */
    .modal-dialog {
        margin: 0.5rem;
        max-width: calc(100% - 1rem);
    }
    
    .modal-body {
        padding: 1rem;
    }
    
    /* Activity Cards */
    .activity-card {
        margin-bottom: 1rem;
    }
    
    .activity-item {
        padding: 0.75rem 0;
    }
    
    /* Search and Filters */
    .search-section {
        flex-direction: column;
        gap: 1rem;
        margin-bottom: 1.5rem;
    }
    
    .search-section .form-control {
        width: 100%;
    }
    
    /* Quick Actions */
    .quick-action-btn {
        width: 100%;
        margin-bottom: 0.5rem;
        padding: 1rem;
    }
}

/* ===== SMALL MOBILE (576px and below) ===== */
@media (max-width: 576px) {
    .main-content { 
        padding: 0.75rem; 
    }
    
    .card {
        padding: 0.75rem;
        margin-bottom: 0.75rem;
    }
    
    .stat-card {
        padding: 0.75rem;
        margin-bottom: 0.75rem;
    }
    
    .activity-header,
    .activity-body {
        padding: 0.75rem;
    }
    
    .modal-body {
        padding: 0.75rem;
    }
    
    .page-title {
        font-size: 1.25rem;
    }
    
    .sidebar {
        width: 100%;
    }
    
    .sidebar-header {
        padding: 1rem;
    }
    
    .sidebar .nav {
        padding: 0.5rem 0;
    }
    
    .sidebar .nav-link {
        padding: 0.75rem 1rem;
        font-size: 0.875rem;
    }
    
    /* Table improvements for very small screens */
    .table-responsive {
        margin: 0 -0.75rem;
        padding: 0 0.75rem;
        width: calc(100% + 1.5rem);
    }
    
    .table {
        font-size: 0.75rem;
    }
    
    .table th,
    .table td {
        padding: 0.25rem 0.125rem;
    }
    
    /* Form improvements */
    .form-control,
    .form-select {
        padding: 0.625rem;
        font-size: 16px;
    }
    
    /* Button improvements */
    .btn {
        padding: 0.625rem 0.875rem;
        font-size: 0.8125rem;
    }
}

/* ===== SIDEBAR TOGGLE BUTTON ===== */
.sidebar-toggle {
    display: none;
    align-items: center;
    justify-content: center;
    position: fixed;
    left: 12px;
    top: 12px;
    width: 44px;
    height: 44px;
    border-radius: 8px;
    border: none;
    background: var(--accent-blue);
    color: #fff;
    font-size: 18px;
    box-shadow: 0 4px 12px rgba(0,0,0,0.15);
    z-index: 1100;
    cursor: pointer;
    transition: all 0.3s ease;
}

.sidebar-toggle:hover {
    background: var(--accent-purple);
    transform: scale(1.05);
}

@media (max-width: 768px) {
    .sidebar-toggle {
        display: inline-flex;
    }
    
    .sidebar-toggle--nav {
        position: static;
        margin-right: 12px;
        display: inline-flex;
    }
}

/* ===== GRID UTILITIES ===== */
.grid { 
    display: grid; 
    gap: 1rem; 
}

.grid-2-col { 
    grid-template-columns: repeat(2, minmax(0, 1fr)); 
}

.grid-3-col { 
    grid-template-columns: repeat(3, minmax(0, 1fr)); 
}

.grid-4-col { 
    grid-template-columns: repeat(4, minmax(0, 1fr)); 
}

/* ===== TABLE RESPONSIVE ===== */
.table-responsive { 
    width: 100%; 
    overflow-x: auto; 
    -webkit-overflow-scrolling: touch;
}

.card { 
    max-width: 100%; 
}

input, 
select, 
textarea { 
    max-width: 100%; 
    width: 100%; 
}

/* ===== RESPONSIVE UTILITY CLASSES ===== */
@media (max-width: 768px) {
    .d-sm-none { display: none !important; }
    .d-sm-block { display: block !important; }
    .d-sm-flex { display: flex !important; }
    .d-sm-grid { display: grid !important; }
    
    .text-sm-center { text-align: center !important; }
    .text-sm-left { text-align: left !important; }
    .text-sm-right { text-align: right !important; }
    
    .w-sm-100 { width: 100% !important; }
    .w-sm-auto { width: auto !important; }
    
    .p-sm-0 { padding: 0 !important; }
    .p-sm-1 { padding: 0.25rem !important; }
    .p-sm-2 { padding: 0.5rem !important; }
    .p-sm-3 { padding: 1rem !important; }
    
    .m-sm-0 { margin: 0 !important; }
    .m-sm-1 { margin: 0.25rem !important; }
    .m-sm-2 { margin: 0.5rem !important; }
    .m-sm-3 { margin: 1rem !important; }
}

@media (max-width: 576px) {
    .d-xs-none { display: none !important; }
    .d-xs-block { display: block !important; }
    .d-xs-flex { display: flex !important; }
    
    .text-xs-center { text-align: center !important; }
    .text-xs-left { text-align: left !important; }
    
    .w-xs-100 { width: 100% !important; }
}

/* ===== TOUCH IMPROVEMENTS ===== */
@media (hover: none) and (pointer: coarse) {
    .btn,
    .nav-link,
    .sidebar-toggle {
        min-height: 44px;
        min-width: 44px;
    }
    
    .form-control,
    .form-select {
        min-height: 44px;
    }
    
    .table th,
    .table td {
        padding: 0.75rem 0.5rem;
    }
}

/* ===== PRINT STYLES ===== */
@media print {
    .sidebar,
    .sidebar-toggle,
    .top-navbar,
    .btn {
        display: none !important;
    }
    
    .main-content {
        margin-left: 0 !important;
        padding: 0 !important;
    }
    
    .card {
        border: 1px solid #000 !important;
        box-shadow: none !important;
    }
    
    .table {
        border-collapse: collapse !important;
    }
    
    .table th,
    .table td {
        border: 1px solid #000 !important;
    }
}

/* ===== ACCESSIBILITY IMPROVEMENTS ===== */
@media (prefers-reduced-motion: reduce) {
    *,
    *::before,
    *::after {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
    }
}

/* ===== HIGH CONTRAST MODE ===== */
@media (prefers-contrast: high) {
    .card {
        border: 2px solid var(--text-primary);
    }
    
    .btn {
        border: 2px solid currentColor;
    }
    
    .table th,
    .table td {
        border: 1px solid var(--text-primary);
    }
}


