/* assets/css/layout.css */

/* Global Reset / Basics */
html {
    height: 100%;
    box-sizing: border-box;
}

*,
*:before,
*:after {
    box-sizing: inherit;
}

body {
    height: 100%;
    margin: 0;
    padding: 0;
    padding-top: 50px;
    /* Space for Status Bar */
    display: flex;
    flex-direction: column;
}

/* Main Content Area */
main {
    flex: 1 0 auto;
    /* Grow to fill space */
    width: 100%;
    display: flex;
    flex-direction: column;
}

/* Container Utility */
.container {
    width: 100%;
    max-width: 1400px;
    margin: 0 auto;
    padding: 0 24px;
    /* Generous padding from reference */
    box-sizing: border-box;
}

/* Page Header */
.page-header {
    min-height: 150px;
    height: auto;
    background: #ffffff;
    border-bottom: 1px solid #e2e8f0;
    margin-bottom: 50px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0 40px;
    /* Matching container padding */
    box-sizing: border-box;
    /* No margin bottom by default, content handles spacing */
    position: relative;
    z-index: 1000;
}

/* Typography matching "Objektverwaltung" */
.page-header h1 {
    margin: 0 0 10px 0;
    font-size: 2rem;
    font-weight: 700;
    color: #1a202c;
    letter-spacing: -0.025em;
    line-height: 1;
}

.page-header .ph-breadcrumbs {
    font-size: 0.95rem;
    color: #718096;
}

.page-header .ph-breadcrumbs a {
    color: #3b82f6;
    /* text-primary */
    text-decoration: none;
}

.page-header .ph-breadcrumbs a:hover {
    text-decoration: underline;
}

.page-header .ph-right {
    display: flex;
    align-items: center;
    gap: 15px;
}

@media (max-width: 1024px) {
    .container {
        padding: 0 16px;
    }

    .page-header {
        padding: 16px;
    }
}

@media (max-width: 768px) {
    .page-header {
        min-height: 0;
        padding: 12px 16px;
    }

    .page-header .container {
        display: flex;
        flex-direction: column;
        align-items: flex-start !important;
        gap: 12px;
    }

    .page-header .ph-left h1 {
        font-size: 1.75rem;
        margin-bottom: 6px;
    }

    .page-header .ph-right {
        width: 100%;
        justify-content: flex-start;
        flex-wrap: wrap;
    }
}

/* Footer (Fixed to bottom) */
#global-footer {
    height: 50px;
    background: var(--bar-bg);
    color: var(--bar-fg);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 13px;
    font-family: var(--font-family);
    width: 100%;

    position: fixed;
    bottom: 0;
    left: 0;
    z-index: 100;
    /* Ensure visibility */
}

/* Dashboard / Grid Utilities (Replacing inline styles) */
.dashboard-btn-large {
    min-width: 200px;
}

/* Form & Card Utilities */
.form-center-card {
    max-width: 800px;
    margin: 0 auto;
}

/* Utility Classes matching old inline styles */
.text-main {
    color: #1a202c;
}

.text-muted {
    color: #718096;
}

.text-primary {
    color: #3b82f6;
}

.font-bold {
    font-weight: 700;
}

.flex {
    display: flex;
}

.justify-between {
    justify-content: space-between;
}

.items-center {
    align-items: center;
}

.gap-4 {
    gap: 1rem;
}

.p-lg {
    padding: 2rem;
}

.p-md {
    padding: 1.5rem;
}

.mb-4 {
    margin-bottom: 1rem;
}

.w-full {
    width: 100%;
}

/* --- Map Editor Specific Styles --- */

/* Full Height Layout for Map Editor */
html,
body {
    /* height: 100%; - Already in global reset */
    overflow-x: hidden;
    /* Prevent horizontal scroll globally, specific pages enable vertical */
}

/* Specific body override for map editor page if needed, or rely on flex-grow */
/* .map-editor-page body { overflow: hidden; } */

/* The Main Content Area for Map */
#map-editor-main {
    flex-grow: 1;
    overflow: hidden;
    position: relative;
    display: flex;
    flex-direction: column;
    height: calc(100vh - 250px);
    /* 100vh - 50(Status) - 150(Header) - 50(Footer) */
    min-height: 0;
    /* Crucial for flex nested scrolling */
}

/* Map Editor Container */
.map-editor-container {
    display: flex;
    flex-direction: column;
    flex-grow: 1;
    overflow: hidden;
    min-height: 0;
}

/* Grid & Rulers */
.map-editor-grid {
    display: grid;
    grid-template-columns: 25px 1fr;
    grid-template-rows: 25px 1fr;
    flex: 1;
    /* Grow and shrink properly */
    min-width: 0;
    /* Allow shrinking below content size */
    background: #fff;
    overflow: hidden;
    position: relative;
    min-height: 0;
}

.ruler-corner {
    background: #f8f9fa;
    border-bottom: 1px solid #ccc;
    border-right: 1px solid #ccc;
    z-index: 10;
}

.ruler-h {
    position: relative;
    overflow: hidden;
    background: #f8f9fa;
    border-bottom: 1px solid #ccc;
}

.ruler-v {
    position: relative;
    overflow: hidden;
    background: #f8f9fa;
    border-right: 1px solid #ccc;
}

.map-viewport {
    position: relative;
    overflow: hidden;
    cursor: grab;
    background: white;
    width: 100%;
    height: 100%;
}

.map-viewport:active {
    cursor: grabbing;
}

/* SVG Elements */
path.room-shape {
    transition: all 0.2s;
    cursor: pointer;
    vector-effect: non-scaling-stroke;
}

path.room-shape:hover {
    fill-opacity: 0.5 !important;
    stroke-width: 2px !important;
}

text.room-label {
    pointer-events: none;
    user-select: none;
    font-family: sans-serif;
    font-size: 12px;
}

#gridOverlay {
    pointer-events: none;
}

/* Map Card Specifics */
.map-card {
    border: none !important;
    box-shadow: none !important;
    height: 100%;
    display: flex;
    flex-direction: column;
}

/* Map Editor Container */
#map-editor-layout {
    display: block !important;
    position: relative !important;
    width: 100% !important;
    height: 100% !important;
    padding: 0 !important;
    overflow: hidden !important;
}

/* Map Grid - Base Layer */
#map-editor-layout>.map-editor-grid {
    position: absolute !important;
    top: 0;
    left: 0;
    width: 100% !important;
    height: 100% !important;
    z-index: 1;
}

/* Sidebar - Overlay Layer */
#map-editor-layout>#editor-sidebar {
    position: absolute !important;
    top: 0;
    right: 0;
    width: 280px !important;
    height: 100% !important;
    padding: 25px;
    z-index: 100;

    background-color: #ffffff !important;
    border-left: 1px solid #cbd5e1 !important;
    box-shadow: -2px 0 10px rgba(0, 0, 0, 0.1) !important;

    transition: transform 0.3s ease;
    transform: translateX(0);
}

/* Collapsed State */
#map-editor-layout>#editor-sidebar.collapsed {
    transform: translateX(100%);
}

/* Sidebar Toggle Handle */
.sidebar-toggle {
    position: absolute;
    top: 50%;
    right: 280px;
    transform: translateY(-50%);
    z-index: 101;

    width: 20px;
    height: 40px;
    background: #fff;
    border: 1px solid #cbd5e1;
    border-right: none;
    border-radius: 4px 0 0 4px;
    cursor: pointer;

    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: -2px 0 5px rgba(0, 0, 0, 0.1);
    transition: right 0.3s ease;
}

/* Toggle moves with sidebar */
#editor-sidebar.collapsed+.sidebar-toggle,
.sidebar-toggle.collapsed {
    right: 0 !important;
}

/* Helper for empty states */
#map-editor-layout>.flex-center,
#map-editor-layout>.absolute {
    position: absolute !important;
    top: 0;
    left: 0;
    width: 100% !important;
    height: 100% !important;
    z-index: 50;
    /* Above map, below sidebar */
}

/* Sidebar Overrides */
button.active {
    background-color: #e0f2fe !important;
    border-left: 4px solid #3b82f6 !important;
    color: #1d4ed8 !important;
    font-weight: bold;
}

/* Utility Extensions */
.flex-shrink-0 {
    flex-shrink: 0 !important;
}

.flex-nowrap {
    flex-wrap: nowrap !important;
}

.min-w-0 {
    min-width: 0 !important;
}
