/* 
 * HowMany - Responsive Adjustments
 * All media queries are consolidated here.
 */

/* --- 1200px Breakpoint (Widescreen) --- */
@media (min-width: 1200px) {
    .calendar-flyout {
        right: calc(50% - 600px + 2rem);
    }
}

@media (max-width: 1200px) {
    .calendar-flyout {
        right: 2rem;
    }
}

/* --- 992px Breakpoint (Desktop/Tablet) --- */
@media (max-width: 992px) {
    .hero-text {
        grid-template-columns: 1fr;
        gap: 0;
        display: block;
    }

    .auth-section {
        margin: 2rem 0;
    }

    .hero-text h2 {
        font-size: 2rem;
        margin-bottom: 2rem;
    }

    .calendar-flyout {
        position: fixed;
        top: 85px;
        left: 1rem;
        right: 1rem;
        bottom: auto;
        width: auto !important;
        max-height: calc(100vh - 100px);
        overflow-y: auto;
    }
}

/* --- 768px Breakpoint (Tablet/Large Mobile) --- */
@media (max-width: 768px) {

    html {
        -webkit-text-size-adjust: 100%;
        user-select: none;
    }

    html,
    body {
        -webkit-user-select: none;
        /* Safari (iOS/macOS) */
        -moz-user-select: none;
        /* Firefox */
        -ms-user-select: none;
        /* Legacy IE/Edge */
        user-select: none;
        /* Standard (Chrome, Edge) */

        /* Verhindert das Kontextmenü beim langen Drücken auf Bilder/Links in iOS */
        -webkit-touch-callout: none;
    }

    input,
    textarea,
    .selectable {
        -webkit-user-select: text;
        -moz-user-select: text;
        -ms-user-select: text;
        user-select: text;
    }

    body {
        -webkit-tap-highlight-color: transparent;
        color: var(--text-primary);
        font-family: var(--font-main);
        font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
        font-variant-numeric: tabular-nums;
        /* Perfekt für Zahlenlisten/Uhrzeiten */
        letter-spacing: -0.011em;
        /* Kommt dem SF Pro Standard sehr nah */
        line-height: 1.6;
        min-height: 100vh;
        overflow-x: hidden;
        padding-bottom: 1em;
        user-select: auto;

        -webkit-font-smoothing: antialiased;
        -moz-osx-font-smoothing: grayscale;
        text-rendering: optimizeLegibility;

        font-size: 1.0625rem;
        /* Entspricht 17px (iOS Standard Body) */
        line-height: 1.4;
        /* Genug Luft zwischen den Zeilen für Schärfe */
    }




    .hide-mobile {
        display: none !important;
    }

    .hide-mobile-flex {
        display: none !important;
    }

    .show-mobile-only {
        display: block !important;
    }

    .show-mobile-flex {
        display: flex !important;
    }

    .container {
        padding: 0 1rem;
    }

    .notification-wrapper {
        position: relative;
    }

    .emoji-circle {
        bottom: 10px;
        right: 10px;
    }

    .glass-panel {
        padding: 1.5rem;
    }

    .main-header h1 {
        font-size: 2.5rem;
    }

    .site-footer {
        text-align: center;
        padding-bottom: 0;
    }

    .site-footer div[style*="align-items: flex-end"] {
        align-items: center !important;
        margin-top: 1rem;
    }

    .footer-logged-in-content {
        flex-direction: column;
        text-align: center;
    }

    .notification-flyout {
        position: fixed;
        top: 85px;
        left: 1rem;
        right: 1rem;
        width: auto;
        transform: translateY(-20px);
    }

    .calendar-flyout {
        width: calc(100vw - 20px) !important;
        left: 10px;
        right: 10px;
        top: 87px;
    }

    .row {
        flex-direction: column;
        gap: 0.5rem;
    }

    .item-input-group.row {
        flex-direction: row !important;
    }

    .dashboard-header {
        display: none !important;
    }

    .dashboard-greeting .header-logo {
        margin-left: -9px;
        font-size: 2.1rem;
        margin-bottom: 0 !important;
    }

    .logged-in .dashboard-greeting .header-logo {
        margin-left: 20px;
    }

    .dashboard-greeting .header-logo span {
        text-align: left;
        margin: 0;
        font-size: 37px;
    }

    .dashboard-greeting {
        margin-top: 1rem;
        width: 100%;
        overflow: hidden;
    }

    .greeting-user-email {
        word-break: break-all;
    }

    .row>div {
        width: 100% !important;
        flex: none !important;
        min-width: 0;
    }

    .mobile-nav {
        display: flex;
    }

    header.main-header,
    header.dashboard-header {
        position: relative;
        background: #191922;
        backdrop-filter: blur(20px);
        -webkit-backdrop-filter: blur(20px);
        z-index: 1001;
        margin-left: 0;
        margin-right: 0;
        margin-top: 0 !important;
        padding: 0.3rem 0.75rem;
        border-bottom: 1px solid var(--glass-border);
        box-shadow: 0 4px 12px rgba(0, 0, 0, 0.2);
        display: flex;
        justify-content: space-between;
        align-items: center;
        min-height: 70px;
        margin-bottom: 0.75rem;
        padding-top: calc(0.3rem + env(safe-area-inset-top));
    }

    .sticky-header .container {
        display: flex;
        align-items: center;
        gap: 0.75rem;
        width: 100%;
        padding: 0;
        border: none;
    }

    .sticky-header h1 {
        font-size: 1.1rem !important;
        margin: 0 !important;
        white-space: nowrap;
        overflow: hidden;
        text-overflow: ellipsis;
        flex: 1;
    }

    .sticky-header .back-link {
        font-size: 1.2rem;
        color: var(--text-secondary);
        text-decoration: none;
        display: inline-flex;
        align-items: center;
    }

    .dashboard-header h2 {
        font-size: 1rem !important;
        margin: 0 !important;
    }

    .dashboard-header .header-logo .brand-text,
    .dashboard-header .header-logo {
        font-size: 1.1rem;
    }

    .main-header h1,
    .dashboard-header h2 {
        font-size: 1.1rem !important;
        margin: 0 !important;
    }

    .main-header p {
        display: none;
    }

    .dashboard-header .btn-secondary {
        padding: 0.3rem 0.6rem;
        font-size: 0.75rem;
        border-radius: var(--radius-sm);
    }

    .event-action-buttons {
        display: flex;
        gap: 0.75rem;
        flex-wrap: wrap;
        margin-top: 1.5rem;
    }

    .event-action-buttons .btn {
        flex: 1 1 calc(50% - 0.75rem);
        min-width: 120px;
        padding: 0.5rem;
    }

    .section-header {
        margin-bottom: 0.75rem !important;
        margin-top: 0.75rem !important;
        gap: 0.5rem !important;
    }

    .section-header h2 {
        font-size: 1.1rem !important;
        gap: 0.5rem !important;
    }

    .section-header h2 svg {
        width: 18px !important;
        height: 18px !important;
    }

    .section-header .btn {
        padding: 0.35rem 0.7rem !important;
        font-size: 0.8rem !important;
    }

    .event-grid {
        display: flex !important;
        flex-direction: column !important;
        gap: 1rem !important;
        margin-bottom: 2rem !important;
    }

    .event-grid .event-card {
        flex: none !important;
        width: 100% !important;
    }

    .event-card {
        padding: 1.2rem !important;
    }

    .event-card h3 {
        font-size: 1.313rem !important;
        font-weight: 600 !important;
    }

    .event-card h3 .badge {
        font-size: 0.6rem !important;
        padding: 0.1rem 0.35rem !important;
    }

    .event-meta {
        font-size: 0.75rem !important;
        margin-top: 0.15rem !important;
        margin-bottom: 0.4rem !important;
    }

    .event-actions {
        margin-top: 0.4rem !important;
        padding-top: 0.4rem !important;
    }

    .event-actions span {
        font-size: 0.8rem !important;
    }

    .event-actions .btn {
        padding: 0.35rem 0.7rem !important;
        font-size: 0.7rem !important;
    }

    #gdpr-cookie-message {
        left: 15px;
        right: 15px;
        bottom: 85px;
        max-width: none;
    }

    .modal-content {
        padding: 1.5rem;
        border-radius: var(--radius-sm);
    }


    #create-event-modal .explorer-scroll-area,
    #event-explorer-modal .explorer-scroll-area,
    #legal-modal .explorer-scroll-area,
    #settings-modal .modal-content>div:not(.modal-header):not(.auth-toggle-pill),
    #legal-modal .modal-content>div:not(.modal-header),
    #info-overlay .modal-content>div:not(.modal-header) {
        flex: 1 !important;
        overflow-y: auto !important;
        padding: 1.2rem !important;
        padding-bottom: calc(100px + env(safe-area-inset-bottom)) !important;
        -webkit-overflow-scrolling: touch;
        max-height: none !important;
    }

    #create-event-modal .btn-back,
    #event-explorer-modal .btn-back,
    #legal-modal .btn-back {
        margin-right: 0.5rem;
        background: rgba(255, 255, 255, 0.05);
        border: 1px solid var(--glass-border);
        border-radius: 10px;
        width: 40px;
        height: 40px;
        display: flex;
        align-items: center;
        justify-content: center;
    }

    #details-my-order-container {
        margin-top: 1rem;
    }

    #details-my-order-container .glass-panel {
        background: rgba(255, 126, 45, 0.05) !important;
        border-color: rgba(255, 126, 45, 0.3) !important;
    }

    #explorer-view-details:not(.hidden),
    #explorer-view-order:not(.hidden),
    #explorer-view-edit:not(.hidden) {
        display: flex !important;
        flex-direction: column !important;
        flex: 1 1 auto !important;
        height: 100% !important;
        width: 100% !important;
        min-height: 0;
    }

    .explorer-scroll-area {
        flex: 1 1 0% !important;
        min-height: 0;
        overflow-y: auto !important;
        padding: 1.2rem !important;
        padding-bottom: calc(100px + env(safe-area-inset-bottom)) !important;
        -webkit-overflow-scrolling: touch;
        max-height: none !important;
    }

    /* Action Buttons in Detail View: 2 per row */
    #details-event-actions {
        display: grid !important;
        grid-template-columns: 1fr 1fr !important;
        gap: 0.75rem !important;
        width: 100% !important;
    }

    #details-event-actions .btn,
    #details-event-actions .btn-card {
        width: 100% !important;
        margin: 0 !important;
        padding: 0.6rem 0.4rem !important;
        font-size: 0.85rem !important;
        justify-content: center !important;
    }

    #event-explorer-modal .btn-back {
        margin-right: 0.5rem;
        background: rgba(255, 255, 255, 0.05);
        border: 1px solid var(--glass-border);
        border-radius: 10px;
        width: 40px;
        height: 40px;
        display: flex;
        align-items: center;
        justify-content: center;
    }

    #event-explorer-modal .btn-back:active {
        background: rgba(255, 255, 255, 0.15);
        transform: scale(0.95);
    }
}

/* --- 600px Breakpoint (Medium Mobile) --- */
@media (max-width: 600px) {

    .messenger-sidebar {
        width: 100%;
    }

    input[type="date"],
    input[type="time"] {
        padding: 0.875rem 0.75rem;
        font-size: 0.95rem;
    }

    .share-box {
        flex-direction: column;
        align-items: stretch !important;
        text-align: center;
        gap: 1.25rem !important;
    }

    .share-box>div {
        width: 100%;
        display: flex;
        flex-direction: column;
        align-items: center;
        gap: 0.5rem;
    }

    .share-box div[style*="display:flex"] {
        flex-direction: column;
        width: 100%;
    }

    .share-box .btn {
        width: 100%;
    }

    .share-box .share-link {
        font-size: 0.85rem;
        padding: 0.875rem;
        margin: 0.25rem 0;
        width: 100%;
        text-align: center;
    }

    .container {
        padding-bottom: 80px;
    }

    .glass-panel {
        border-radius: 20px;
        margin-left: -0;
        margin-right: -5px;
    }

    .btn:active {
        transform: scale(0.96) !important;
        opacity: 0.9;
    }

    .event-card:active {
        transform: scale(0.98);
        background: rgba(255, 255, 255, 0.05);
    }





    table,
    thead,
    tbody,
    th,
    td,
    tr {
        display: block;
    }

    thead tr {
        position: absolute;
        top: -9999px;
        left: -9999px;
    }

    tr {
        margin-bottom: 1.5rem;
        border: 1px solid var(--glass-border);
        border-radius: var(--radius-sm);
        padding: 0.5rem;
        background: rgba(255, 255, 255, 0.01);
    }

    td {
        border: none;
        border-bottom: 1px solid rgba(255, 255, 255, 0.05);
        position: relative;
        padding-left: 50% !important;
        text-align: right !important;
        min-height: 2.5rem;
        display: flex;
        align-items: center;
        justify-content: flex-end;
    }

    td:last-child {
        border-bottom: 0;
    }

    td:before {
        position: absolute;
        left: 1rem;
        width: 45%;
        padding-right: 10px;
        white-space: nowrap;
        content: attr(data-label);
        font-weight: 600;
        color: var(--text-secondary);
        text-align: left;
    }

    .col-main-name {
        font-size: 1.1rem;
        color: var(--text-primary);
        border-bottom: 2px solid var(--primary) !important;
        margin-bottom: 0.75rem;
        padding-bottom: 0.5rem;
        flex-direction: column;
        align-items: flex-start !important;
        padding-left: 1rem !important;
    }

    .col-main-name:before {
        display: none !important;
    }

    .col-order-details {
        text-align: left !important;
        display: block !important;
        height: auto !important;
        padding-top: 2.2rem !important;
        padding-left: 1rem !important;
    }

    .col-order-details:before {
        top: 0.5rem;
        width: 100%;
    }

    .table-responsive {
        overflow: hidden;
    }
}

/* --- 480px Breakpoint (Small Mobile) --- */
@media (max-width: 480px) {
    .modal-content {
        padding: 1rem;
    }

    .login-page-wrapper {
        margin: 0 auto;
        padding: 0;
    }

    .auth-header h1 {
        font-size: 2rem;
    }

    .auth-toggle-pill {
        margin-bottom: 1.5rem !important;
        gap: 0 !important;
        padding: 6px !important;
    }

    .auth-toggle-pill .toggle-btn {
        padding: 10px 5px !important;
        font-size: 0.95rem !important;
    }

    .emoji-picker-grid {
        grid-template-columns: repeat(5, 1fr) !important;
        gap: 10px !important;
        padding: 15px !important;
    }

    .emoji-option {
        font-size: 1.8rem !important;
        padding: 12px 5px !important;
    }

    .btn-social {
        padding: 12px;
        font-size: 0.95rem;
    }

    .attendance-options {
        flex-direction: column;
    }

    .attendance-option .opt-card {
        flex-direction: row;
        gap: 1rem;
        padding: 1rem;
        text-align: left;
    }

    .calendar-wrapper {
        padding: 1rem;
    }

    .calendar-grid-header {
        font-size: 0.65rem;
    }
}

/* Specific Archive Grid Fixes */
.event-grid.archive-grid {
    display: none !important;
}

.event-grid.archive-grid.shown-archive {
    display: grid !important;
}

@media (max-width: 768px) {
    .event-grid.archive-grid.shown-archive {
        display: flex !important;
        flex-direction: column !important;
    }
}