/**
 * RainShift CRM - Mobile Optimierung
 */

/* Touch-freundliche Mindestgrößen */
@media (max-width: 768px) {
    /* Buttons und Links */
    button, .btn, a.block, select, input[type="submit"] {
        min-height: 44px;
        font-size: 16px; /* Verhindert iOS Zoom */
    }

    input, textarea, select {
        font-size: 16px !important; /* Verhindert iOS Zoom bei Focus */
    }

    /* Tabellen responsive */
    table {
        display: block;
        width: 100%;
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
    }

    table thead {
        display: none;
    }

    table tbody tr {
        display: block;
        margin-bottom: 1rem;
        background: white;
        border-radius: 8px;
        box-shadow: 0 1px 3px rgba(0,0,0,0.1);
        padding: 0.75rem;
    }

    table tbody td {
        display: flex;
        justify-content: space-between;
        align-items: center;
        padding: 0.5rem 0;
        border: none !important;
        border-bottom: 1px solid #f3f4f6 !important;
    }

    table tbody td:last-child {
        border-bottom: none !important;
    }

    table tbody td::before {
        content: attr(data-label);
        font-weight: 600;
        color: #6b7280;
        font-size: 0.75rem;
        text-transform: uppercase;
        flex-shrink: 0;
        margin-right: 1rem;
    }

    /* Grid auf Mobile zu Stack */
    .grid-cols-2, .grid-cols-3, .grid-cols-4,
    .md\\:grid-cols-2, .md\\:grid-cols-3, .md\\:grid-cols-4 {
        grid-template-columns: 1fr !important;
    }

    /* Flex-Wrap */
    .flex-row {
        flex-direction: column !important;
    }

    .gap-4, .gap-6 {
        gap: 0.75rem !important;
    }

    /* Padding reduzieren */
    .p-6 {
        padding: 1rem !important;
    }

    .px-6 {
        padding-left: 1rem !important;
        padding-right: 1rem !important;
    }

    /* Ticket Cards */
    .ticket-card, .bg-white.shadow {
        padding: 1rem !important;
    }

    /* Ticket Detail - Messages */
    .message-bubble {
        max-width: 95% !important;
    }

    /* Forms */
    .form-row, form .flex {
        flex-direction: column !important;
    }

    .form-row > *, form .flex > * {
        width: 100% !important;
    }

    /* Modal/Dialoge */
    .modal, [role="dialog"] {
        width: 95% !important;
        max-width: none !important;
        margin: 1rem !important;
    }

    /* Status-Badges kleiner */
    .badge, .tag, .status-badge {
        font-size: 0.7rem;
        padding: 0.2rem 0.5rem;
    }

    /* Text-Größen */
    h1 {
        font-size: 1.5rem !important;
    }

    h2 {
        font-size: 1.25rem !important;
    }

    /* Hide on Mobile */
    .hide-mobile, .desktop-only {
        display: none !important;
    }

    /* Workflow Editor */
    .workflow-rule, .condition-row, .action-row {
        flex-direction: column !important;
    }

    .workflow-rule > *, .condition-row > *, .action-row > * {
        width: 100% !important;
        margin-bottom: 0.5rem;
    }

    /* Dashboard Stats */
    .stat-card {
        padding: 1rem !important;
    }

    .stat-number {
        font-size: 1.5rem !important;
    }
}

/* Tablet (768px - 1024px) */
@media (min-width: 769px) and (max-width: 1024px) {
    .sidebar {
        width: 220px !important;
    }

    .desktop-sidebar-space {
        width: 220px !important;
    }
}

/* Extra small devices */
@media (max-width: 375px) {
    .page-content {
        padding: 0.5rem !important;
    }

    .notification-dropdown {
        left: 5px !important;
        right: 5px !important;
    }
}

/* Landscape Phone */
@media (max-width: 768px) and (orientation: landscape) {
    .mobile-header {
        padding-top: 0.5rem !important;
        padding-bottom: 0.5rem !important;
    }

    .page-content {
        margin-top: 50px !important;
    }
}

/* Safe Area für Notch-Geräte */
@supports (padding: env(safe-area-inset-top)) {
    .mobile-header {
        padding-top: calc(0.75rem + env(safe-area-inset-top));
    }

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

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

/* Pull-to-refresh Indikator */
.pull-indicator {
    display: none;
    text-align: center;
    padding: 1rem;
    color: #6b7280;
}

/* Swipe Actions für Ticket-Liste */
.swipe-container {
    overflow-x: hidden;
}

.swipe-item {
    transition: transform 0.2s ease;
}

/* Floating Action Button */
.fab {
    position: fixed;
    bottom: calc(1rem + env(safe-area-inset-bottom, 0px));
    right: 1rem;
    width: 56px;
    height: 56px;
    border-radius: 50%;
    background: #3b82f6;
    color: white;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 4px 12px rgba(59, 130, 246, 0.4);
    z-index: 30;
}

@media (min-width: 769px) {
    .fab {
        display: none;
    }
}
