/* ========================================
   GEMBOK-BILLING RESPONSIVE CSS
   Mobile-First Responsive Design
   ======================================== */

/* Base Mobile-First Approach */
* {
    box-sizing: border-box;
}

html {
    font-size: 16px;
    -webkit-text-size-adjust: 100%;
    -ms-text-size-adjust: 100%;
}

body {
    margin: 0;
    padding: 0;
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
    line-height: 1.6;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

/* ========================================
   RESPONSIVE GRID SYSTEM
   ======================================== */
.container-fluid {
    padding-left: 15px;
    padding-right: 15px;
}

.row {
    margin-left: -10px;
    margin-right: -10px;
}

.col-md-3, .col-md-4, .col-md-6, .col-md-8, .col-md-9, .col-md-12 {
    padding-left: 10px;
    padding-right: 10px;
}

/* ========================================
   MOBILE RESPONSIVE STYLES (≤768px)
   ======================================== */
@media (max-width: 768px) {
    /* Typography */
    h1, .h1 { font-size: 1.75rem !important; }
    h2, .h2 { font-size: 1.5rem !important; }
    h3, .h3 { font-size: 1.25rem !important; }
    h4, .h4 { font-size: 1.125rem !important; }
    h5, .h5 { font-size: 1rem !important; }
    h6, .h6 { font-size: 0.875rem !important; }
    
    /* Layout adjustments */
    .container-fluid {
        padding-left: 10px;
        padding-right: 10px;
    }
    
    .main-content {
        padding: 10px !important;
    }
    
    /* Sidebar adjustments */
    .sidebar {
        position: fixed;
        top: 0;
        left: -100%;
        width: 280px;
        height: 100vh;
        z-index: 1050;
        transition: left 0.3s ease;
        background: #fff;
        box-shadow: 2px 0 10px rgba(0,0,0,0.1);
    }
    
    .sidebar.show {
        left: 0;
    }
    
    .sidebar-overlay {
        position: fixed;
        top: 0;
        left: 0;
        width: 100%;
        height: 100%;
        background: rgba(0,0,0,0.5);
        z-index: 1040;
        display: none;
    }
    
    .sidebar-overlay.show {
        display: block;
    }
    
    /* Mobile menu toggle */
    .mobile-menu-toggle {
        display: block !important;
        position: fixed;
        top: 15px;
        left: 15px;
        z-index: 1060;
        background: #007bff;
        color: white;
        border: none;
        border-radius: 50%;
        width: 45px;
        height: 45px;
        font-size: 20px;
        box-shadow: 0 2px 10px rgba(0,0,0,0.2);
    }
    
    /* Cards and panels */
    .card {
        margin-bottom: 15px;
        border-radius: 8px;
    }
    
    .card-body {
        padding: 15px;
    }
    
    .card-header {
        padding: 12px 15px;
    }
    
    /* Tables */
    .table-responsive {
        border-radius: 8px;
        overflow: hidden;
    }
    
    .table {
        font-size: 14px;
    }
    
    .table th,
    .table td {
        padding: 8px 6px;
        font-size: 13px;
    }
    
    /* Forms */
    .form-control,
    .form-select {
        min-height: 44px;
        font-size: 16px; /* Prevents zoom on iOS */
        border-radius: 8px;
    }
    
    .form-label {
        font-size: 14px;
        font-weight: 600;
        margin-bottom: 8px;
    }
    
    /* Buttons */
    .btn {
        min-height: 44px;
        padding: 10px 20px;
        font-size: 14px;
        border-radius: 8px;
        margin-bottom: 8px;
    }
    
    .btn-sm {
        min-height: 38px;
        padding: 8px 16px;
        font-size: 13px;
    }
    
    .btn-lg {
        min-height: 50px;
        padding: 12px 24px;
        font-size: 16px;
    }
    
    /* Modals */
    .modal-dialog {
        margin: 10px;
        max-width: calc(100% - 20px);
    }
    
    .modal-content {
        border-radius: 12px;
    }
    
    .modal-header {
        padding: 15px 20px;
        border-bottom: 1px solid #dee2e6;
    }
    
    .modal-body {
        padding: 20px;
    }
    
    .modal-footer {
        padding: 15px 20px;
        border-top: 1px solid #dee2e6;
    }
    
    /* Navigation */
    .navbar {
        padding: 10px 15px;
    }
    
    .navbar-brand {
        font-size: 1.25rem;
    }
    
    .navbar-nav .nav-link {
        padding: 12px 15px;
        font-size: 16px;
    }
    
    /* Statistics cards */
    .stats-card {
        padding: 15px;
        margin-bottom: 15px;
        border-radius: 12px;
    }
    
    .stats-number {
        font-size: 1.75rem;
    }
    
    /* Alerts */
    .alert {
        padding: 12px 15px;
        border-radius: 8px;
        font-size: 14px;
    }
    
    /* Badges */
    .badge {
        font-size: 0.75rem;
        padding: 6px 10px;
    }
    
    /* Pagination */
    .pagination {
        justify-content: center;
        flex-wrap: wrap;
    }
    
    .page-link {
        min-height: 44px;
        padding: 12px 16px;
        font-size: 14px;
    }
    
    /* Dropdowns */
    .dropdown-menu {
        border-radius: 8px;
        box-shadow: 0 4px 20px rgba(0,0,0,0.15);
    }
    
    .dropdown-item {
        padding: 10px 20px;
        font-size: 14px;
    }
    
    /* Tooltips and popovers */
    .tooltip {
        font-size: 12px;
    }
    
    .popover {
        border-radius: 8px;
        box-shadow: 0 4px 20px rgba(0,0,0,0.15);
    }
    
    /* Utilities */
    .d-none-mobile {
        display: none !important;
    }
    
    .d-block-mobile {
        display: block !important;
    }
    
    .text-center-mobile {
        text-align: center !important;
    }
    
    .mb-mobile-2 {
        margin-bottom: 0.75rem !important;
    }
    
    .mb-mobile-3 {
        margin-bottom: 1rem !important;
    }
    
    .p-mobile-2 {
        padding: 0.75rem !important;
    }
    
    .p-mobile-3 {
        padding: 1rem !important;
    }
}

/* ========================================
   TABLET RESPONSIVE STYLES (769px-1024px)
   ======================================== */
@media (min-width: 769px) and (max-width: 1024px) {
    .container-fluid {
        padding-left: 20px;
        padding-right: 20px;
    }
    
    .stats-number {
        font-size: 1.9rem;
    }
    
    .card-body {
        padding: 20px;
    }
    
    .btn {
        min-height: 42px;
        padding: 10px 18px;
    }
    
    .form-control,
    .form-select {
        min-height: 42px;
    }
}

/* ========================================
   DESKTOP RESPONSIVE STYLES (≥1025px)
   ======================================== */
@media (min-width: 1025px) {
    .container-fluid {
        padding-left: 30px;
        padding-right: 30px;
    }
    
    .main-content {
        padding: 20px 30px !important;
    }
    
    .stats-number {
        font-size: 2.25rem;
    }
    
    .card-body {
        padding: 25px;
    }
    
    .btn {
        min-height: 40px;
        padding: 8px 16px;
    }
    
    .form-control,
    .form-select {
        min-height: 40px;
    }
}

/* ========================================
   TOUCH DEVICE OPTIMIZATIONS
   ======================================== */
@media (hover: none) and (pointer: coarse) {
    /* Larger touch targets */
    .btn {
        min-height: 48px;
        padding: 12px 24px;
    }
    
    .form-control,
    .form-select {
        min-height: 48px;
    }
    
    .nav-link {
        min-height: 48px;
        padding: 12px 20px;
    }
    
    .dropdown-item {
        min-height: 48px;
        padding: 12px 20px;
    }
    
    /* Better touch feedback */
    .btn:active,
    .nav-link:active,
    .dropdown-item:active {
        transform: scale(0.98);
        transition: transform 0.1s ease;
    }
    
    /* Disable hover effects on touch devices */
    .btn:hover,
    .nav-link:hover,
    .dropdown-item:hover {
        transform: none;
    }
}

/* ========================================
   HIGH DPI DISPLAYS
   ======================================== */
@media (-webkit-min-device-pixel-ratio: 2), (min-resolution: 192dpi) {
    .btn,
    .form-control,
    .form-select {
        border-width: 0.5px;
    }
    
    .card {
        border-width: 0.5px;
    }
}

/* ========================================
   DARK MODE SUPPORT
   ======================================== */
@media (prefers-color-scheme: dark) {
    .card,
    .modal-content,
    .dropdown-menu {
        background: #2d3748;
        color: #e2e8f0;
        border-color: #4a5568;
    }
    
    .card-header {
        background: #4a5568;
        border-bottom-color: #718096;
    }
    
    .form-control,
    .form-select {
        background: #4a5568;
        border-color: #718096;
        color: #e2e8f0;
    }
    
    .form-control:focus,
    .form-select:focus {
        background: #4a5568;
        border-color: #63b3ed;
        color: #e2e8f0;
    }
    
    .btn-outline-secondary {
        color: #e2e8f0;
        border-color: #718096;
    }
    
    .btn-outline-secondary:hover {
        background: #718096;
        color: #2d3748;
    }
    
    .table {
        color: #e2e8f0;
    }
    
    .table th,
    .table td {
        border-color: #4a5568;
    }
    
    .table-striped tbody tr:nth-of-type(odd) {
        background: rgba(74, 85, 104, 0.3);
    }
}

/* ========================================
   PRINT STYLES
   ======================================== */
@media print {
    .sidebar,
    .navbar,
    .btn,
    .modal,
    .dropdown-menu {
        display: none !important;
    }
    
    .main-content {
        margin: 0 !important;
        padding: 0 !important;
    }
    
    .card {
        border: 1px solid #000 !important;
        box-shadow: none !important;
    }
    
    .table {
        border: 1px solid #000 !important;
    }
    
    .table th,
    .table td {
        border: 1px solid #000 !important;
    }
}

/* ========================================
   ACCESSIBILITY IMPROVEMENTS
   ======================================== */
/* Focus indicators */
.btn:focus,
.form-control:focus,
.form-select:focus,
.nav-link:focus {
    outline: 2px solid #007bff;
    outline-offset: 2px;
}

/* Screen reader only text */
.sr-only {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
}

/* High contrast mode support */
@media (prefers-contrast: high) {
    .btn,
    .form-control,
    .form-select,
    .card {
        border-width: 2px;
        border-color: #000;
    }
    
    .btn-primary {
        background: #000;
        color: #fff;
    }
    
    .btn-secondary {
        background: #fff;
        color: #000;
        border-color: #000;
    }
}

/* ========================================
   ANIMATION AND TRANSITIONS
   ======================================== */
/* Smooth transitions for mobile */
.card,
.btn,
.form-control,
.form-select {
    transition: all 0.2s ease;
}

/* Loading states */
.loading {
    opacity: 0.6;
    pointer-events: none;
}

.loading::after {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    width: 20px;
    height: 20px;
    margin: -10px 0 0 -10px;
    border: 2px solid #f3f3f3;
    border-top: 2px solid #007bff;
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

/* ========================================
   CUSTOM COMPONENTS
   ======================================== */
/* Mobile-friendly data tables */
.mobile-table {
    display: block;
    width: 100%;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
}

.mobile-table .table {
    min-width: 600px;
}

/* Mobile-friendly search */
.mobile-search {
    position: relative;
    margin-bottom: 15px;
}

.mobile-search .form-control {
    padding-left: 45px;
    border-radius: 25px;
}

.mobile-search .search-icon {
    position: absolute;
    left: 15px;
    top: 50%;
    transform: translateY(-50%);
    color: #6c757d;
    z-index: 10;
}

/* Mobile-friendly filters */
.mobile-filters {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    margin-bottom: 15px;
}

.mobile-filters .form-select,
.mobile-filters .form-control {
    flex: 1;
    min-width: 120px;
}

/* Mobile-friendly actions */
.mobile-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-top: 15px;
}

.mobile-actions .btn {
    flex: 1;
    min-width: 100px;
}

/* Mobile-friendly status indicators */
.status-indicator {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    padding: 4px 8px;
    border-radius: 12px;
    font-size: 12px;
    font-weight: 500;
}

.status-online {
    background: #d4edda;
    color: #155724;
}

.status-offline {
    background: #f8d7da;
    color: #721c24;
}

.status-pending {
    background: #fff3cd;
    color: #856404;
}

/* Mobile-friendly tooltips */
.mobile-tooltip {
    position: relative;
    cursor: help;
}

.mobile-tooltip:hover::after {
    content: attr(data-tooltip);
    position: absolute;
    bottom: 100%;
    left: 50%;
    transform: translateX(-50%);
    background: #333;
    color: white;
    padding: 8px 12px;
    border-radius: 6px;
    font-size: 12px;
    white-space: nowrap;
    z-index: 1000;
    margin-bottom: 5px;
}

/* Mobile-friendly breadcrumbs */
.mobile-breadcrumb {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 8px;
    margin-bottom: 15px;
    font-size: 14px;
}

.mobile-breadcrumb .breadcrumb-item {
    display: flex;
    align-items: center;
}

.mobile-breadcrumb .breadcrumb-item:not(:last-child)::after {
    content: '>';
    margin-left: 8px;
    color: #6c757d;
}

/* Mobile-friendly tabs */
.mobile-tabs {
    display: flex;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    border-bottom: 1px solid #dee2e6;
    margin-bottom: 20px;
}

.mobile-tabs .nav-link {
    white-space: nowrap;
    padding: 12px 20px;
    border: none;
    border-bottom: 2px solid transparent;
    color: #6c757d;
    background: none;
    font-weight: 500;
}

.mobile-tabs .nav-link.active {
    color: #007bff;
    border-bottom-color: #007bff;
}

/* Mobile-friendly accordion */
.mobile-accordion .accordion-item {
    border: 1px solid #dee2e6;
    border-radius: 8px;
    margin-bottom: 10px;
}

.mobile-accordion .accordion-header {
    background: #f8f9fa;
}

.mobile-accordion .accordion-button {
    padding: 15px 20px;
    font-weight: 600;
    border: none;
    background: none;
    width: 100%;
    text-align: left;
    cursor: pointer;
}

.mobile-accordion .accordion-button:not(.collapsed) {
    background: #e9ecef;
    color: #495057;
}

.mobile-accordion .accordion-body {
    padding: 20px;
    border-top: 1px solid #dee2e6;
}

/* Mobile-friendly progress bars */
.mobile-progress {
    height: 8px;
    border-radius: 4px;
    background: #e9ecef;
    overflow: hidden;
    margin: 10px 0;
}

.mobile-progress .progress-bar {
    height: 100%;
    background: linear-gradient(90deg, #007bff, #0056b3);
    border-radius: 4px;
    transition: width 0.3s ease;
}

/* Mobile-friendly alerts */
.mobile-alert {
    padding: 15px;
    border-radius: 8px;
    margin-bottom: 15px;
    border-left: 4px solid;
}

.mobile-alert.alert-info {
    background: #d1ecf1;
    border-color: #17a2b8;
    color: #0c5460;
}

.mobile-alert.alert-success {
    background: #d4edda;
    border-color: #28a745;
    color: #155724;
}

.mobile-alert.alert-warning {
    background: #fff3cd;
    border-color: #ffc107;
    color: #856404;
}

.mobile-alert.alert-danger {
    background: #f8d7da;
    border-color: #dc3545;
    color: #721c24;
}

/* Mobile-friendly badges */
.mobile-badge {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    padding: 6px 12px;
    border-radius: 20px;
    font-size: 12px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.mobile-badge.badge-primary {
    background: #007bff;
    color: white;
}

.mobile-badge.badge-success {
    background: #28a745;
    color: white;
}

.mobile-badge.badge-warning {
    background: #ffc107;
    color: #212529;
}

.mobile-badge.badge-danger {
    background: #dc3545;
    color: white;
}

.mobile-badge.badge-info {
    background: #17a2b8;
    color: white;
}

.mobile-badge.badge-secondary {
    background: #6c757d;
    color: white;
}

/* Mobile-friendly icons */
.mobile-icon {
    width: 20px;
    height: 20px;
    display: inline-block;
    vertical-align: middle;
}

.mobile-icon.icon-sm {
    width: 16px;
    height: 16px;
}

.mobile-icon.icon-lg {
    width: 24px;
    height: 24px;
}

/* Mobile-friendly spacing utilities */
.mobile-spacing {
    margin: 0;
    padding: 0;
}

.mobile-spacing.m-1 { margin: 0.25rem !important; }
.mobile-spacing.m-2 { margin: 0.5rem !important; }
.mobile-spacing.m-3 { margin: 1rem !important; }
.mobile-spacing.m-4 { margin: 1.5rem !important; }
.mobile-spacing.m-5 { margin: 3rem !important; }

.mobile-spacing.p-1 { padding: 0.25rem !important; }
.mobile-spacing.p-2 { padding: 0.5rem !important; }
.mobile-spacing.p-3 { padding: 1rem !important; }
.mobile-spacing.p-4 { padding: 1.5rem !important; }
.mobile-spacing.p-5 { padding: 3rem !important; }

/* Mobile-friendly text utilities */
.mobile-text {
    word-wrap: break-word;
    overflow-wrap: break-word;
}

.mobile-text.truncate {
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.mobile-text.break-all {
    word-break: break-all;
}

.mobile-text.break-word {
    word-break: break-word;
}

/* Mobile-friendly visibility utilities */
@media (max-width: 768px) {
    .mobile-hide {
        display: none !important;
    }
    
    .mobile-show {
        display: block !important;
    }
    
    .mobile-inline {
        display: inline !important;
    }
    
    .mobile-inline-block {
        display: inline-block !important;
    }
    
    .mobile-flex {
        display: flex !important;
    }
    
    .mobile-inline-flex {
        display: inline-flex !important;
    }
}

@media (min-width: 769px) {
    .mobile-hide {
        display: block !important;
    }
    
    .mobile-show {
        display: none !important;
    }
}

/* ========================================
   PERFORMANCE OPTIMIZATIONS
   ======================================== */
/* Reduce motion for users who prefer it */
@media (prefers-reduced-motion: reduce) {
    *,
    *::before,
    *::after {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
    }
}

/* Optimize for high refresh rate displays */
@media (prefers-reduced-motion: no-preference) {
    .smooth-transition {
        transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    }
}

/* ========================================
   PRINT OPTIMIZATIONS
   ======================================== */
@media print {
    .mobile-hide,
    .mobile-show,
    .mobile-inline,
    .mobile-inline-block,
    .mobile-flex,
    .mobile-inline-flex {
        display: inherit !important;
    }
    
    .mobile-spacing {
        margin: inherit !important;
        padding: inherit !important;
    }
    
    .mobile-text {
        word-wrap: inherit;
        overflow-wrap: inherit;
    }
}
