/* Mobile Responsive Overrides for ITYWEB Client Portal */
/* Add this AFTER style.css to fix all mobile issues */

/* Tablets (1024px and below) */
@media (max-width: 1024px) {
    .main-content {
        padding: 30px 20px !important;
    }
    
    .header-content {
        padding: 15px 20px !important;
    }
    
    .stats-grid {
        grid-template-columns: repeat(2, 1fr) !important;
        gap: 15px !important;
    }
}

/* Mobile (768px and below) */
@media (max-width: 768px) {
    
    /* ============================================
       FORCE NO OVERFLOW
       ============================================ */
    
    html, body {
        overflow-x: hidden !important;
        max-width: 100vw !important;
    }
    
    * {
        max-width: 100% !important;
        box-sizing: border-box !important;
    }
    
    /* ============================================
       HEADER & NAVIGATION
       ============================================ */
    
    .dashboard-header {
        position: sticky;
        top: 0;
        z-index: 1000;
    }
    
    .header-content {
        flex-direction: column !important;
        gap: 15px !important;
        padding: 15px !important;
    }
    
    .header-logo {
        font-size: 18px !important;
        width: 100% !important;
        justify-content: center !important;
    }
    
    .header-logo span {
        display: inline-block !important;
        max-width: 200px !important;
        overflow: hidden !important;
        text-overflow: ellipsis !important;
        white-space: nowrap !important;
    }
    
    .header-nav {
        width: 100% !important;
        gap: 5px !important;
        flex-wrap: wrap !important;
        justify-content: space-around !important;
    }
    
    .nav-link {
        flex: 1 1 calc(20% - 5px) !important;
        min-width: 60px !important;
        max-width: 70px !important;
        padding: 8px 2px !important;
        font-size: 9px !important;
        flex-direction: column !important;
        text-align: center !important;
        gap: 3px !important;
    }
    
    .nav-link i {
        font-size: 16px !important;
        margin-right: 0 !important;
    }
    
    /* ============================================
       PAGE HEADER
       ============================================ */
    
    .main-content {
        padding: 20px 15px !important;
    }
    
    .page-header {
        margin-bottom: 25px !important;
    }
    
    .page-header h1 {
        font-size: 24px !important;
        word-break: break-word !important;
    }
    
    .page-header p {
        font-size: 14px !important;
    }
    
    /* ============================================
       STATS GRID - 2 COLUMNS ON MOBILE
       ============================================ */
    
    .stats-grid {
        grid-template-columns: 1fr 1fr !important;
        gap: 12px !important;
        margin-bottom: 25px !important;
    }
    
    .stat-card {
        padding: 15px !important;
    }
    
    .stat-card:hover {
        transform: none !important;
    }
    
    .stat-card-header {
        margin-bottom: 10px !important;
    }
    
    .stat-card-title {
        font-size: 11px !important;
    }
    
    .stat-card-icon {
        width: 35px !important;
        height: 35px !important;
        font-size: 16px !important;
    }
    
    .stat-card-value {
        font-size: 24px !important;
        margin-bottom: 3px !important;
    }
    
    .stat-card-change {
        font-size: 11px !important;
    }
    
    /* ============================================
       FORCE ALL INLINE GRIDS TO SINGLE COLUMN
       ============================================ */
    
    [style*="display: grid"] {
        display: block !important;
    }
    
    [style*="display: grid"] > * {
        width: 100% !important;
        margin-bottom: 15px !important;
    }
    
    [style*="grid-template-columns"] {
        display: block !important;
    }
    
    /* ============================================
       CARDS
       ============================================ */
    
    .card {
        margin-bottom: 20px !important;
        border-radius: 12px !important;
    }
    
    .card-header {
        padding: 15px !important;
        flex-direction: column !important;
        align-items: flex-start !important;
        gap: 10px !important;
    }
    
    .card-header h2 {
        font-size: 18px !important;
    }
    
    .card-header .btn {
        width: 100% !important;
    }
    
    .card-header .link {
        width: 100% !important;
        text-align: center !important;
        display: block !important;
        padding: 8px !important;
        background: var(--light) !important;
        border-radius: 8px !important;
    }
    
    .card-body {
        padding: 15px !important;
    }
    
    /* Force all card body content to stack */
    .card-body > div[style*="display: grid"],
    .card-body > div[style*="display: flex"] {
        display: block !important;
    }
    
    .card-body > div[style*="display: grid"] > *,
    .card-body > div[style*="display: flex"] > * {
        width: 100% !important;
        margin-bottom: 10px !important;
    }
    
    /* Nested flex/grid items */
    .card-body [style*="display: flex"] {
        display: block !important;
    }
    
    .card-body [style*="display: flex"] > div {
        width: 100% !important;
        margin-bottom: 10px !important;
    }
    
    /* Support ticket items in card body */
    .card-body > div[style*="padding: 12px"] {
        padding: 12px 0 !important;
    }
    
    .card-body > div[style*="padding: 12px"] > div[style*="display: flex"] {
        display: block !important;
    }
    
    .card-body > div[style*="padding: 12px"] strong {
        display: block !important;
        margin-bottom: 5px !important;
    }
    
    .card-body > div[style*="padding: 12px"] p {
        margin-bottom: 8px !important;
    }
    
    .card-body > div[style*="padding: 12px"] .link {
        display: block !important;
        text-align: center !important;
        padding: 8px !important;
        background: var(--light) !important;
        border-radius: 6px !important;
        margin-top: 10px !important;
    }
    
    /* Center content in card body */
    .card-body > div[style*="text-align: center"] {
        padding: 20px 10px !important;
    }
    
    .card-body > div[style*="text-align: center"] i {
        font-size: 40px !important;
    }
    
    /* ============================================
       TABLES → CARDS
       ============================================ */
    
    .table-responsive {
        overflow: visible !important;
        margin: 0 !important;
        padding: 0 !important;
    }
    
    .table {
        display: block !important;
        border: none !important;
    }
    
    .table thead {
        display: none !important;
    }
    
    .table tbody {
        display: block !important;
    }
    
    .table tbody tr {
        display: block !important;
        background: white;
        border: 2px solid var(--border);
        border-radius: 12px;
        padding: 15px !important;
        margin-bottom: 15px;
        box-shadow: var(--shadow);
    }
    
    .table tbody tr:hover {
        background: white !important;
    }
    
    .table tbody tr td {
        display: block !important;
        padding: 8px 0 !important;
        border: none !important;
        border-bottom: 1px solid var(--light) !important;
        text-align: left !important;
        position: relative !important;
        padding-left: 45% !important;
        min-height: 35px !important;
    }
    
    .table tbody tr td:before {
        content: attr(data-label) ": ";
        position: absolute !important;
        left: 0 !important;
        width: 40% !important;
        padding-right: 10px !important;
        font-weight: 600 !important;
        color: var(--text-secondary) !important;
        font-size: 12px !important;
        word-wrap: break-word !important;
    }
    
    .table tbody tr td:first-child {
        font-weight: 700 !important;
        font-size: 15px !important;
        color: var(--dark) !important;
        padding-left: 0 !important;
        padding: 10px !important;
        padding-bottom: 12px !important;
        border-bottom: 2px solid var(--border) !important;
        margin-bottom: 8px !important;
        background: var(--light) !important;
        border-radius: 8px !important;
    }
    
    .table tbody tr td:first-child:before {
        display: none !important;
    }
    
    .table tbody tr td:last-child {
        padding-left: 0 !important;
        margin-top: 10px !important;
        padding-top: 12px !important;
        border-top: 1px solid var(--border) !important;
        border-bottom: none !important;
    }
    
    .table tbody tr td:last-child:before {
        display: none !important;
    }
    
    .table tbody tr td code {
        display: block !important;
        font-size: 10px !important;
        word-break: break-all !important;
        background: var(--light) !important;
        padding: 6px !important;
        border-radius: 5px !important;
    }
    
    .table tbody tr td .badge {
        font-size: 11px !important;
        padding: 4px 8px !important;
    }
    
    .table tbody tr td .link,
    .table tbody tr td .btn {
        display: block !important;
        width: 100% !important;
        text-align: center !important;
        padding: 10px !important;
        margin: 5px 0 !important;
    }
    
    /* ============================================
       BUTTONS
       ============================================ */
    
    .btn {
        width: 100% !important;
        padding: 12px 20px !important;
        font-size: 14px !important;
        margin-bottom: 10px !important;
        text-align: center !important;
        justify-content: center !important;
    }
    
    .btn:last-child {
        margin-bottom: 0 !important;
    }
    
    .btn i {
        margin-right: 5px !important;
    }
    
    /* ============================================
       FORMS
       ============================================ */
    
    .form-group {
        margin-bottom: 15px !important;
    }
    
    .form-group label {
        font-size: 14px !important;
        margin-bottom: 6px !important;
    }
    
    .form-group input,
    .form-group select,
    .form-group textarea {
        font-size: 16px !important;
        padding: 12px !important;
    }
    
    .form-row {
        flex-direction: column !important;
        gap: 15px !important;
    }
    
    /* ============================================
       BADGES
       ============================================ */
    
    .badge {
        font-size: 11px !important;
        padding: 4px 10px !important;
    }
    
    /* ============================================
       ALERTS
       ============================================ */
    
    .alert {
        padding: 12px 15px !important;
        font-size: 13px !important;
        flex-direction: row !important;
    }
    
    /* ============================================
       AUTH PAGES
       ============================================ */
    
    .auth-page {
        padding: 15px !important;
    }
    
    .auth-container {
        grid-template-columns: 1fr !important;
        border-radius: 15px !important;
    }
    
    .auth-box {
        padding: 30px 20px !important;
    }
    
    .auth-info {
        display: none !important;
    }
    
    .logo {
        margin-bottom: 15px !important;
    }
    
    .logo i {
        font-size: 32px !important;
    }
    
    .logo h1 {
        font-size: 24px !important;
    }
    
    .auth-header h2 {
        font-size: 20px !important;
    }
    
    /* ============================================
       MISC
       ============================================ */
    
    code {
        font-size: 11px !important;
        word-break: break-all !important;
    }
    
    img {
        max-width: 100% !important;
        height: auto !important;
    }
}

/* Small Mobile (480px and below) */
@media (max-width: 480px) {
    .page-header h1 {
        font-size: 20px !important;
    }
    
    .stats-grid {
        grid-template-columns: 1fr !important;
    }
    
    .stat-card-value {
        font-size: 20px !important;
    }
    
    .nav-link {
        font-size: 8px !important;
        min-width: 55px !important;
    }
    
    .nav-link i {
        font-size: 14px !important;
    }
    
    .table tbody tr td {
        padding-left: 50% !important;
    }
    
    .table tbody tr td:before {
        width: 45% !important;
        font-size: 11px !important;
    }
}

/* Touch Devices */
@media (hover: none) and (pointer: coarse) {
    .btn,
    .nav-link,
    .link {
        min-height: 44px !important;
    }
    
    .stat-card:hover {
        transform: none !important;
    }
    
    .table tbody tr:hover {
        background: white !important;
    }
}