/* =====================================================
   responsive.css - Mobile Compatibility for UCP
   Erstellt: 2024-12-15
   Target: iPhone (375px primary), Tablets (768px)
   ===================================================== */

/* =====================================================
   1. VIEWPORT & BASE FIXES
   ===================================================== */

/* Prevent zoom on input focus (iOS) */
@media (max-width: 767.98px) {

    input[type="text"],
    input[type="email"],
    input[type="password"],
    input[type="number"],
    input[type="tel"],
    input[type="url"],
    textarea,
    select {
        font-size: 16px !important;
    }
}

/* Touch-friendly minimum sizes */
@media (max-width: 767.98px) {

    .btn,
    .nav-link,
    .dropdown-item,
    .list-group-item-action {
        min-height: 44px;
        padding-top: 0.625rem;
        padding-bottom: 0.625rem;
    }
}

/* =====================================================
   2. SIDEBAR / NAVIGATION (Overlay Mode)
   ===================================================== */

/* Mobile: Sidebar as Overlay */
@media (max-width: 991.98px) {

    /* Hide sidebar by default on mobile */
    .app-sidebar {
        position: fixed !important;
        left: -280px !important;
        top: 0 !important;
        height: 100vh !important;
        width: 280px !important;
        z-index: 1050 !important;
        transition: left 0.3s ease-in-out !important;
        background: var(--bs-body-bg) !important;
        box-shadow: 4px 0 20px rgba(0, 0, 0, 0.15) !important;
    }

    /* Show sidebar when open */
    .app-sidebar.show,
    body.sidebar-open .app-sidebar {
        left: 0 !important;
    }

    /* Backdrop when sidebar is open */
    .sidebar-backdrop {
        display: none;
        position: fixed;
        top: 0;
        left: 0;
        width: 100vw;
        height: 100vh;
        background: rgba(0, 0, 0, 0.5);
        z-index: 1040;
        opacity: 0;
        transition: opacity 0.3s ease-in-out;
    }

    .sidebar-backdrop.show,
    body.sidebar-open .sidebar-backdrop {
        display: block;
        opacity: 1;
    }

    /* Main content takes full width */
    .page-content {
        margin-left: 0 !important;
        width: 100% !important;
    }

    /* Ensure hamburger menu is visible */
    .topbar-hamburger {
        display: flex !important;
    }
}

/* Desktop: Hide hamburger if not needed */
@media (min-width: 992px) {
    .sidebar-backdrop {
        display: none !important;
    }
}

/* =====================================================
   3. CONTAINER & LAYOUT
   ===================================================== */

@media (max-width: 767.98px) {
    .container-fluid {
        padding-left: 12px !important;
        padding-right: 12px !important;
    }

    .row {
        margin-left: -6px;
        margin-right: -6px;
    }

    .row>* {
        padding-left: 6px;
        padding-right: 6px;
    }

    /* Cards: Reduce padding on mobile */
    .card-body {
        padding: 1rem !important;
    }

    .card-header {
        padding: 0.75rem 1rem !important;
    }
}

/* Extra small screens (iPhone SE, etc.) */
@media (max-width: 375px) {
    .container-fluid {
        padding-left: 8px !important;
        padding-right: 8px !important;
    }

    .card-body {
        padding: 0.75rem !important;
    }
}

/* =====================================================
   4. TABLES (Horizontal Scroll)
   ===================================================== */

@media (max-width: 767.98px) {
    .table-responsive-mobile {
        display: block;
        width: 100%;
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
    }

    /* Auto-wrap all tables in responsive container */
    .card-body>table,
    .table-responsive>table {
        min-width: 600px;
    }

    /* Alternative: Stack table cells */
    .table-stack-mobile tbody tr {
        display: block;
        margin-bottom: 1rem;
        border: 1px solid var(--bs-border-color);
        border-radius: var(--bs-border-radius);
    }

    .table-stack-mobile tbody td {
        display: block;
        text-align: left;
        padding: 0.5rem 1rem;
        border: none;
        border-bottom: 1px solid var(--bs-border-color-translucent);
    }

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

    .table-stack-mobile tbody td::before {
        content: attr(data-label);
        font-weight: 600;
        display: block;
        margin-bottom: 0.25rem;
        color: var(--bs-secondary-color);
        font-size: 0.75rem;
        text-transform: uppercase;
    }

    .table-stack-mobile thead {
        display: none;
    }
}

/* =====================================================
   5. TYPOGRAPHY
   ===================================================== */

@media (max-width: 767.98px) {

    h1,
    .h1 {
        font-size: 1.75rem;
    }

    h2,
    .h2 {
        font-size: 1.5rem;
    }

    h3,
    .h3 {
        font-size: 1.25rem;
    }

    h4,
    .h4 {
        font-size: 1.1rem;
    }

    .page-title {
        font-size: 1.25rem !important;
    }

    .page-title-box {
        padding: 0.75rem 0 !important;
    }
}

/* =====================================================
   6. MODALS & DROPDOWNS
   ===================================================== */

@media (max-width: 767.98px) {
    .modal-dialog {
        margin: 0.5rem;
        max-width: calc(100% - 1rem);
    }

    .modal-lg,
    .modal-xl {
        max-width: calc(100% - 1rem);
    }

    /* Dropdowns: Full width on mobile */
    .dropdown-menu {
        max-width: calc(100vw - 2rem);
    }
}

/* =====================================================
   7. FORMS
   ===================================================== */

@media (max-width: 767.98px) {

    /* Stack form groups */
    .row.g-3>.col-md-6,
    .row.g-3>.col-md-4,
    .row.g-3>.col-lg-6 {
        flex: 0 0 100%;
        max-width: 100%;
    }

    /* Make form controls full width */
    .form-control,
    .form-select {
        width: 100%;
    }

    /* Input groups: Stack on very small screens */
    .input-group {
        flex-wrap: wrap;
    }

    .input-group>.form-control {
        flex: 1 1 100%;
        margin-bottom: 0.5rem;
    }
}

/* =====================================================
   8. BUTTONS & ACTIONS
   ===================================================== */

@media (max-width: 575.98px) {

    /* Button groups: Stack vertically */
    .btn-group-mobile-stack {
        flex-direction: column;
        width: 100%;
    }

    .btn-group-mobile-stack .btn {
        width: 100%;
        margin-bottom: 0.5rem;
        border-radius: var(--bs-border-radius) !important;
    }

    /* Action buttons in cards/headers */
    .card-header .btn-group,
    .card-header .d-flex.gap-2 {
        flex-wrap: wrap;
        gap: 0.5rem !important;
    }
}

/* =====================================================
   9. UTILITIES
   ===================================================== */

/* Hide on mobile */
@media (max-width: 767.98px) {
    .d-mobile-none {
        display: none !important;
    }
}

/* Show only on mobile */
@media (min-width: 768px) {
    .d-mobile-only {
        display: none !important;
    }
}

/* Text truncate on mobile */
@media (max-width: 767.98px) {
    .text-truncate-mobile {
        overflow: hidden;
        text-overflow: ellipsis;
        white-space: nowrap;
        max-width: 200px;
    }
}

/* =====================================================
   10. FRAMAIL SPECIFIC
   ===================================================== */

@media (max-width: 767.98px) {

    /* Mail list: Full width, compact */
    .mail-list-container {
        padding: 0 !important;
    }

    .mail-row {
        padding: 0.75rem !important;
    }

    .mail-row .mail-subject {
        font-size: 0.9rem;
        max-width: calc(100vw - 100px);
        overflow: hidden;
        text-overflow: ellipsis;
        white-space: nowrap;
    }

    .mail-row .mail-preview {
        display: none;
    }

    .mail-row .mail-date {
        font-size: 0.75rem;
    }

    /* Compose: Full screen feel */
    .compose-container {
        padding: 0 !important;
    }

    .compose-container .card {
        border-radius: 0 !important;
        border-left: none !important;
        border-right: none !important;
    }

    /* Detail view: Stack sender/actions */
    .mail-detail-header {
        flex-direction: column;
        gap: 0.75rem;
    }

    .mail-detail-actions {
        width: 100%;
        justify-content: flex-start;
    }
}

/* =====================================================
   11. DASHBOARD / INDEX SPECIFIC
   ===================================================== */

@media (max-width: 767.98px) {

    /* Stats cards: 2 per row */
    .stats-grid .col-xl-3,
    .stats-grid .col-lg-3,
    .stats-grid .col-md-6 {
        flex: 0 0 50%;
        max-width: 50%;
    }

    /* Widget cards: Full width */
    .widget-card {
        margin-bottom: 1rem;
    }
}

@media (max-width: 375px) {

    /* Very small: 1 per row */
    .stats-grid .col-xl-3,
    .stats-grid .col-lg-3,
    .stats-grid .col-md-6 {
        flex: 0 0 100%;
        max-width: 100%;
    }
}

/* =====================================================
   12. TOPBAR ADJUSTMENTS
   ===================================================== */

@media (max-width: 767.98px) {
    .topbar {
        padding: 0 0.5rem !important;
    }

    .topbar .dropdown-toggle::after {
        display: none;
    }

    /* Hide username, show only avatar */
    .topbar .user-name {
        display: none;
    }

    /* Compact notification icons */
    .topbar .nav-link {
        padding: 0.5rem !important;
    }
}