/* ═══════════════════════════════════════════════════════════════
   VIVEREA — Responsive / Mobile Overrides
   Breakpoints: 1024px (tablet), 768px (mobile), 480px (small)
   ═══════════════════════════════════════════════════════════════ */

/* ── Global Reset for Mobile ── */
*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; overflow-x: hidden; }
body { overflow-x: hidden; min-width: 0; }
.admin-container, .admin-module, .admin-header-stats { max-width: 100%; width: 100%; box-sizing: border-box; }
img, video, svg { max-width: 100%; height: auto; }
table { max-width: 100%; }
pre, code { overflow-x: auto; word-break: break-all; }

/* ── Fluid Typography ── */
html { font-size: clamp(13px, 0.85rem + 0.25vw, 15px); }

/* ── Hamburger Button (hidden on desktop) ── */
.v-hamburger {
    display: none;
    align-items: center;
    justify-content: center;
    width: 40px;
    height: 40px;
    border: none;
    background: transparent;
    cursor: pointer;
    border-radius: 8px;
    padding: 0;
    flex-shrink: 0;
    -webkit-tap-highlight-color: transparent;
}
.v-hamburger:hover { background: rgba(0,0,0,0.04); }
.v-hamburger svg { width: 22px; height: 22px; stroke: #1F2937; stroke-width: 2; }

/* ── Mobile Nav Overlay (nur bei Hamburger-Klick – aktuell deaktiviert) ── */
.v-mobile-menu {
    display: none !important;
    position: fixed;
    top: 0; left: 0; right: 0; bottom: 0;
    background: #FFFFFF;
    z-index: 200;
    flex-direction: column;
    padding: 0;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
}
.v-mobile-menu.open { display: flex !important; }

/* Mobile-Menü: Einheitlich wie Desktop-Nav ( horizontale Kategorien ) */
.v-mobile-menu-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 1rem 1.25rem;
    border-bottom: 1px solid rgba(0,0,0,0.08);
    flex-shrink: 0;
}
.v-mobile-close {
    width: 40px; height: 40px;
    border: none; background: transparent;
    cursor: pointer; border-radius: 8px;
    display: flex; align-items: center; justify-content: center;
}
.v-mobile-close:hover { background: rgba(0,0,0,0.04); }
.v-mobile-close svg { width: 22px; height: 22px; stroke: #1F2937; stroke-width: 2; }

.v-mobile-menu-links {
    display: flex;
    flex-direction: row;
    flex-wrap: wrap;
    gap: 0;
    padding: 1rem 1.25rem;
    justify-content: center;
    align-items: center;
    border-bottom: 1px solid rgba(0,0,0,0.08);
}
.v-mobile-menu-links a {
    display: flex;
    align-items: center;
    padding: 0.75rem 1rem;
    color: #374151;
    text-decoration: none;
    font-size: 0.875rem;
    font-weight: 500;
    white-space: nowrap;
    border-bottom: 2px solid transparent;
    transition: color 150ms ease, border-color 150ms ease;
}
.v-mobile-menu-links a:hover,
.v-mobile-menu-links a:focus { color: #1F2937; }
.v-mobile-menu-links a.active {
    color: #2563EB;
    font-weight: 600;
    border-bottom-color: #2563EB;
}

.v-mobile-menu-footer {
    padding: 1rem 1.25rem;
    display: flex;
    flex-direction: row;
    align-items: center;
    justify-content: flex-end;
    gap: 0.75rem;
    flex-shrink: 0;
}
.v-mobile-menu-footer .v-user-email-mobile {
    color: #6B7280;
    font-size: 0.8125rem;
}

/* ═══════════════════════════════════════════════════════════════
   NAV: Überlappung verhindern (Einstellungen + E-Mail + Abmelden)
   Center-Nav darf User-Bereich rechts nicht überdecken
   ═══════════════════════════════════════════════════════════════ */
@media (max-width: 1280px) {
    nav {
        flex-wrap: nowrap;
        gap: 0.5rem;
    }
    nav > a:first-of-type { flex-shrink: 0; }
    nav > div[style*="position:absolute"] {
        position: static !important;
        transform: none !important;
        left: auto !important;
        flex: 1;
        min-width: 0;
        max-width: 100%;
        overflow-x: auto;
        overflow-y: hidden;
        scrollbar-width: none;
        -webkit-overflow-scrolling: touch;
        justify-content: center;
        padding: 0 0.5rem;
    }
    nav > div[style*="position:absolute"]::-webkit-scrollbar { display: none; }
    nav > div:last-of-type {
        flex-shrink: 0 !important;
    }
    .v-user-email {
        max-width: 140px;
        overflow: hidden;
        text-overflow: ellipsis;
        white-space: nowrap;
    }
    .v-btn-logout {
        flex-shrink: 0;
        white-space: nowrap;
    }
}

/* ═══════════════════════════════════════════════════════════════
   LAPTOP (max-width: 1400px) – frühe Anpassung bei halber Breite
   ═══════════════════════════════════════════════════════════════ */
@media (max-width: 1400px) {
    .admin-container { padding: 1.75rem 2rem !important; }
    .stats-grid {
        grid-template-columns: repeat(3, 1fr) !important;
        gap: 1rem !important;
    }
    .stat-card { min-width: 0; }
}

/* ═══════════════════════════════════════════════════════════════
   TABLET LANDSCAPE (max-width: 1200px) – halber Bildschirm
   ═══════════════════════════════════════════════════════════════ */
@media (max-width: 1200px) {
    .admin-container { padding: 1.5rem 1.5rem !important; }
    .stats-grid {
        grid-template-columns: repeat(2, 1fr) !important;
        gap: 0.875rem !important;
    }
    .properties-toolbar-sticky {
        flex-wrap: wrap;
        gap: 0.75rem;
    }
    .properties-toolbar-sticky .toolbar-left,
    .properties-toolbar-sticky .toolbar-right {
        flex: 1 1 100%;
        min-width: 0;
    }
    .properties-toolbar-sticky .search-bar-sticky {
        max-width: none;
    }
    .properties-grid {
        grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)) !important;
    }
}

/* ═══════════════════════════════════════════════════════════════
   TABLET (max-width: 1024px)
   ═══════════════════════════════════════════════════════════════ */
@media (max-width: 1024px) {
    .main, .v-container { padding: 2rem 1.25rem !important; }
    .admin-container { padding: 1.5rem 1.25rem !important; }
    .v-user-email { max-width: 100px !important; }
    .stats-grid {
        grid-template-columns: repeat(2, 1fr) !important;
        gap: 0.875rem !important;
    }
    .properties-toolbar-sticky {
        flex-wrap: wrap;
        gap: 0.75rem;
    }
    .properties-toolbar-sticky .toolbar-right {
        flex: 1;
        min-width: 0;
    }
    .properties-grid {
        grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)) !important;
    }
}

/* ═══════════════════════════════════════════════════════════════
   MOBILE (max-width: 768px)
   ═══════════════════════════════════════════════════════════════ */
@media (max-width: 768px) {

    /* ── Navbar: Einheitliches Layout – horizontale Nav wie Desktop, scrollbar ── */
    .v-hamburger { display: none !important; }

    /* Nav-Links sichtbar, horizontal scrollbar (einheitlich wie Desktop) */
    nav [style*="position:absolute"] {
        position: static !important;
        transform: none !important;
        left: auto !important;
        flex: 1;
        min-width: 0;
        overflow-x: auto;
        overflow-y: hidden;
        scrollbar-width: none;
        -webkit-overflow-scrolling: touch;
        justify-content: flex-start;
        padding: 0 0.5rem;
        gap: 0.25rem;
    }
    nav [style*="position:absolute"]::-webkit-scrollbar { display: none; }

    /* Adjust nav height/padding */
    nav[style*="height:72px"] {
        height: 60px !important;
        padding: 0 1rem !important;
    }

    /* Logo smaller */
    nav img[alt="VIVEREA"] {
        height: 36px !important;
    }

    /* ── Typography ── */
    h1, .welcome-title { font-size: 1.375rem !important; }
    h2 { font-size: 1.125rem !important; }
    h3 { font-size: 1rem !important; }

    /* ── Container ── */
    .main { padding: 1.25rem 1rem !important; }
    .admin-container { padding: 1.25rem 1rem !important; }
    .admin-module { padding: 1.25rem 1rem !important; }
    .admin-header-stats { padding: 1rem !important; }

    /* ── Tables: horizontal scroll wrapper ── */
    .table-container, .data-table-wrap {
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
        margin: 0 -1rem;
        padding: 0 1rem;
    }
    table { min-width: 600px; }

    /* ── Buttons: full width on mobile ── */
    .btn-primary-large,
    .btn-hero { width: 100%; text-align: center; }

    /* ── Inputs: taller for touch ── */
    input, select, textarea, .v-input {
        min-height: 48px !important;
        font-size: 16px !important; /* prevents iOS zoom */
    }

    /* ── Cards: stack ── */
    .kpi-grid,
    .stats-grid {
        grid-template-columns: 1fr !important;
        gap: 1rem !important;
    }
    .action-grid {
        grid-template-columns: 1fr !important;
        gap: 1rem !important;
    }
    .bottom-grid {
        grid-template-columns: 1fr !important;
    }
    .insights-grid {
        grid-template-columns: 1fr !important;
    }

    /* ── Quick Actions: wrap ── */
    .qa-grid {
        flex-direction: column !important;
        gap: 0.5rem !important;
    }
    .qa-btn {
        width: 100%;
        justify-content: center;
    }

    /* ── Modals ── */
    .modal-content, .v-modal-body {
        width: 95% !important;
        max-width: none !important;
        margin: 1rem !important;
        max-height: 85vh !important;
    }

    /* ── Toasts ── */
    .v-toast {
        left: 1rem !important;
        right: 1rem !important;
        min-width: unset !important;
        max-width: none !important;
    }

    /* ── Form rows: single column ── */
    .form-row, .form-grid, .form-group-row {
        grid-template-columns: 1fr !important;
        flex-direction: column !important;
    }

    /* ── Landing Page ── */
    .hero-section {
        background-attachment: scroll !important;
        min-height: 80vh !important;
    }
    .hero-box {
        padding: 2rem 1.5rem !important;
        margin: 0 1rem !important;
    }
    .hero-welcome {
        font-size: 1.75rem !important;
    }
    .nav-container {
        padding: 0 1rem !important;
    }
    .features-grid {
        grid-template-columns: 1fr !important;
    }
    .content-section {
        padding: 3rem 1rem !important;
    }
    .section-title {
        font-size: 1.5rem !important;
    }

    /* ── Properties Grid ── */
    .properties-grid {
        grid-template-columns: 1fr !important;
    }

    /* ── Tabs: scrollable ── */
    .v-tabs, .tab-nav {
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
        flex-wrap: nowrap !important;
        scrollbar-width: none;
    }
    .v-tabs::-webkit-scrollbar,
    .tab-nav::-webkit-scrollbar { display: none; }

    /* ── Filter bars & Properties Toolbar ── */
    .filter-bar, .toolbar, .dashboard-header,
    .properties-toolbar-sticky {
        flex-direction: column !important;
        align-items: stretch !important;
        gap: 0.75rem !important;
        top: 60px !important;
    }
    .properties-toolbar-sticky .toolbar-left,
    .properties-toolbar-sticky .toolbar-right {
        width: 100%;
        flex-wrap: wrap;
    }
    .properties-toolbar-sticky .search-bar-sticky {
        max-width: none;
        min-width: 0;
    }
    .properties-toolbar-sticky .toolbar-right {
        flex-direction: column;
        align-items: stretch;
    }
    .properties-toolbar-sticky .filter-select-wrapper {
        width: 100%;
    }
    .properties-toolbar-sticky .filter-select-sticky {
        width: 100%;
    }
    .properties-toolbar-sticky .toolbar-actions {
        flex-wrap: wrap;
        gap: 0.5rem;
    }
    .properties-toolbar-sticky .btn-toolbar {
        flex: 1;
        min-width: 120px;
        justify-content: center;
    }
    .properties-toolbar-sticky .btn-primary {
        flex: 1 1 100%;
    }

    /* ── Command Palette ── */
    .command-palette-content {
        width: 95% !important;
        max-width: none !important;
    }

    /* ── User area in nav ── */
    nav .v-user-email { display: none !important; }
}

/* ═══════════════════════════════════════════════════════════════
   SMALL MOBILE (max-width: 480px)
   ═══════════════════════════════════════════════════════════════ */
@media (max-width: 480px) {

    nav[style*="height:72px"],
    nav[style*="height:60px"] {
        height: 56px !important;
        padding: 0 0.75rem !important;
    }

    nav img[alt="VIVEREA"] {
        height: 30px !important;
    }

    .main { padding: 1rem 0.75rem !important; }

    h1, .welcome-title { font-size: 1.25rem !important; }

    .kpi-card { padding: 1rem !important; }
    .kpi-value { font-size: 1.25rem !important; }
    .kpi-label { font-size: 0.6875rem !important; }

    .hero-welcome { font-size: 1.375rem !important; }
    .hero-tagline { font-size: 0.8125rem !important; }
    .hero-box { padding: 1.5rem 1rem !important; }

    .v-btn-logout {
        padding: 0.375rem 0.75rem !important;
        font-size: 0.75rem !important;
    }

    /* Stack action cards completely */
    .action-card { padding: 1rem !important; }

    /* Property drawer: full width on mobile */
    .property-drawer-panel {
        width: 100vw !important;
        max-width: 100vw !important;
    }

    /* Toolbar: kompakter, Buttons kürzer */
    .properties-toolbar-sticky .btn-toolbar {
        padding: 0.5rem 0.75rem;
        font-size: 0.8125rem;
    }
    .properties-toolbar-sticky .btn-toolbar svg {
        width: 16px;
        height: 16px;
    }
    .stat-card { padding: 1rem !important; }
    .stat-card-value { font-size: 1.25rem !important; }
}

/* Property drawer: full width on tablet/mobile */
@media (max-width: 768px) {
    .property-drawer-panel {
        width: 100vw !important;
        max-width: 100vw !important;
    }
}

/* ═══════════════════════════════════════════════════════════════
   TOUCH OPTIMIZATION
   ═══════════════════════════════════════════════════════════════ */
@media (hover: none) and (pointer: coarse) {
    button, a, [role="button"], .v-nav-item {
        min-height: 44px;
        min-width: 44px;
    }
    /* Übersicht: voller Screenshot bleibt oben bündig (kein erzwungenes 44×44 auf dem Button) */
    .uebersicht-page .feature-saas-shot-btn {
        min-height: unset !important;
        min-width: unset !important;
    }
    input, select, textarea {
        font-size: 16px !important;
    }
}

/* ═══════════════════════════════════════════════════════════════
   SAFE AREA (Notch / Dynamic Island)
   ═══════════════════════════════════════════════════════════════ */
@supports (padding-top: env(safe-area-inset-top)) {
    nav[style*="sticky"] {
        padding-top: env(safe-area-inset-top) !important;
    }
    .v-mobile-menu {
        padding-top: env(safe-area-inset-top);
        padding-bottom: env(safe-area-inset-bottom);
    }
}

/* ═══════════════════════════════════════════════════════════════
   GLOBAL ADAPTIVE SCALE (Desktop / Laptop / Tablet / Mobile)
   Ziel: konsistente Größen auf allen Viewports
   ═══════════════════════════════════════════════════════════════ */

.admin-container,
.main,
.v-container {
    width: min(100%, 1600px);
    margin-inline: auto;
}

.admin-module,
.settings-card,
.panel,
.action-card,
.kpi-card {
    overflow-wrap: anywhere;
}

.module-header {
    gap: 0.75rem;
}
.module-header h2 {
    font-size: clamp(1.2rem, 1rem + 1.4vw, 1.75rem) !important;
    line-height: 1.2;
}

.settings-grid {
    grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
    gap: clamp(0.9rem, 0.7rem + 0.8vw, 1.5rem);
}

.table-container,
.data-table-wrap,
.table-wrap {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
}

@media (max-width: 1366px) {
    .admin-container { padding: 1.5rem 1.5rem !important; }
    .admin-module { padding: 1.5rem !important; }
}

@media (max-width: 1200px) {
    .admin-container { padding: 1.25rem 1.25rem !important; }
    .admin-module { padding: 1.25rem !important; border-radius: 16px; }
    .module-header { padding: 1rem !important; }
    .tickets-kanban { grid-template-columns: 1fr !important; }
}

@media (max-width: 1024px) {
    .admin-container,
    .main,
    .v-container { padding: 1rem !important; }
    .admin-module { padding: 1rem !important; }
    .module-header {
        flex-direction: column;
        align-items: flex-start !important;
    }
    .module-header > * { width: 100%; }
    .module-header .btn,
    .module-header button {
        width: 100%;
        justify-content: center;
    }
}

@media (max-width: 768px) {
    .admin-dashboard-section { padding: 1rem 0 !important; }
    .settings-card { padding: 1rem !important; }
    .settings-card h3 { font-size: 1rem !important; }
    .settings-card .form-group label { font-size: 0.82rem !important; }
    .settings-card .form-group input,
    .settings-card .form-group select {
        font-size: 0.95rem !important;
        min-height: 44px !important;
    }
}

/* Laptop / Surface: schmalere Viewports, mehr Inhalt sichtbar */
@media (max-width: 1280px) and (min-width: 769px) {
    .admin-nav-container {
        padding-inline: clamp(0.75rem, 2.2vw, 1.75rem) !important;
    }
}

@supports (min-height: 100dvh) {
    .admin-dashboard-wrapper {
        min-height: 100dvh;
    }
}
