:root {
    --bg-color: #050508;
    --card-bg: rgba(255, 255, 255, 0.03);
    --card-bg-hover: rgba(255, 255, 255, 0.06);
    --border-color: rgba(255, 255, 255, 0.12);
    --border-color-active: rgba(255, 255, 255, 0.3);
    --text-color: #f5f5f7;
    --text-muted: #86868b;
    --gradient: linear-gradient(135deg, #00d2ff 0%, #3a7bd5 50%, #8e2de2 100%);
    --gradient-danger: linear-gradient(135deg, #ff512f 0%, #dd2476 100%);
    --gradient-success: linear-gradient(135deg, #11998e 0%, #38ef7d 100%);
    --gradient-warning: linear-gradient(135deg, #f12711 0%, #f5af19 100%);
    --font-stack: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
}

* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
    user-select: none;
    -webkit-user-select: none;
}

body {
    background-color: var(--bg-color);
    color: var(--text-color);
    font-family: var(--font-stack);
    height: 100vh;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    padding: 10px;
}

header {
    text-align: center;
    padding: 5px 0 10px 0;
}

header h1 {
    font-size: 1.8rem;
    background: var(--gradient);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    font-weight: 800;
    letter-spacing: -0.5px;
}

/* Controls Panel */
.controls-panel {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 15px;
    padding: 10px;
    background: var(--card-bg);
    border: 1px solid var(--border-color);
    border-radius: 12px;
    margin-bottom: 12px;
    backdrop-filter: blur(10px);
}

.control-group {
    display: flex;
    gap: 10px;
}

/* Buttons styling */
button, .file-upload-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    background: var(--gradient);
    border: none;
    color: white;
    padding: 10px 18px;
    border-radius: 8px;
    font-weight: 600;
    font-size: 0.85rem;
    box-shadow: 0 4px 10px rgba(58, 123, 213, 0.15);
    cursor: pointer;
    transition: all 0.2s ease;
    text-align: center;
    white-space: nowrap;
}

button:hover, .file-upload-btn:hover {
    transform: translateY(-1px);
    box-shadow: 0 6px 15px rgba(58, 123, 213, 0.25);
}

button:active, .file-upload-btn:active {
    transform: translateY(1px);
    opacity: 0.95;
}

.file-upload-btn input[type="file"] {
    display: none;
}

.btn-primary { background: var(--gradient); }
.btn-secondary { background: rgba(255, 255, 255, 0.08); border: 1px solid var(--border-color); }
.btn-secondary:hover { background: rgba(255, 255, 255, 0.12); }
.btn-success { background: var(--gradient-success); box-shadow: 0 4px 10px rgba(56, 239, 125, 0.15); }
.btn-warning { background: var(--gradient-warning); box-shadow: 0 4px 10px rgba(245, 175, 25, 0.15); }
.btn-danger { background: var(--gradient-danger); box-shadow: 0 4px 10px rgba(221, 36, 118, 0.15); }

.btn-warning.editing {
    background: linear-gradient(135deg, #11998e, #38ef7d);
    box-shadow: 0 4px 10px rgba(56, 239, 125, 0.2);
}

/* App Main Container */
.app-container {
    display: flex;
    flex: 1;
    gap: 15px;
    overflow: hidden;
}

/* Seating Area */
.seating-area {
    flex: 1;
    display: flex;
    flex-direction: column;
    background: var(--card-bg);
    border: 1px solid var(--border-color);
    border-radius: 16px;
    padding: 15px;
    overflow-y: auto; /* Vertikal scrollbar machen */
}

/* Stage */
.stage {
    text-align: center;
    background: rgba(255, 255, 255, 0.05);
    border: 2px solid var(--border-color);
    border-radius: 8px;
    padding: 10px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 2px;
    font-size: 0.95rem;
    margin-bottom: 20px;
    box-shadow: inset 0 0 15px rgba(255,255,255,0.02);
}

/* Rows container */
.rows-container {
    display: flex;
    gap: 15px;
    flex-shrink: 0; /* Verhindert das Schrumpfen des Sitzplans */
    height: 700px; /* Feste proportionale Höhe für den Sitzplan */
}

.row-block {
    flex: 1;
    display: flex;
    flex-direction: column;
    background: rgba(255, 255, 255, 0.015);
    border: 1px solid rgba(255, 255, 255, 0.05);
    border-radius: 12px;
    padding: 10px;
    overflow: hidden;
}

.row-title {
    text-align: center;
    font-weight: 700;
    font-size: 0.9rem;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 1px;
    margin-bottom: 10px;
}

/* Row Grid */
.row-grid {
    flex: 1;
    display: grid;
    grid-template-columns: 1.6fr 0.6fr 1.6fr;
    grid-template-rows: repeat(70, 1fr);
    gap: 2px 8px;
    overflow: hidden;
    height: 100%;
}

/* Table Card */
.table-cell {
    grid-column: 2;
    background: rgba(255, 255, 255, 0.06);
    border: 2px solid var(--text-muted);
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--text-muted); /* Sets SVG text color dynamically via currentColor */
    box-shadow: 0 4px 10px rgba(0,0,0,0.3);
    z-index: 2;
    padding: 2px;
}

/* Seat Slot */
.seat-slot {
    border: 1px dashed rgba(255, 255, 255, 0.15);
    border-radius: 6px;
    display: flex;
    align-items: center;
    justify-content: center;
    position: relative;
    transition: all 0.2s ease;
    background: rgba(0, 0, 0, 0.15);
    overflow: hidden;
}

.seat-slot:hover {
    border-color: var(--border-color-active);
    background: rgba(255, 255, 255, 0.02);
}

.seat-slot.drag-over {
    border-color: #00d2ff;
    background: rgba(0, 210, 255, 0.08);
    box-shadow: 0 0 10px rgba(0, 210, 255, 0.2);
}

.seat-slot::before {
    content: attr(data-label);
    position: absolute;
    font-size: 0.65rem;
    color: rgba(255, 255, 255, 0.15);
    font-weight: bold;
    pointer-events: none;
    z-index: 1;
}

.seat-slot.occupied::before {
    display: none;
}

/* Drag & Drop Items */
.item {
    width: 100%;
    height: 100%;
    background: var(--gradient);
    border-radius: 6px;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 2px 6px;
    cursor: grab;
    touch-action: none;
    position: relative;
    z-index: 3;
    font-weight: 600;
    text-align: center;
    word-break: break-word;
    font-size: 0.78rem;
    box-shadow: 0 2px 5px rgba(0,0,0,0.3);
    transition: transform 0.1s ease;
}

.item:hover {
    filter: brightness(1.08);
}

.item.selected {
    box-shadow: 0 0 0 2px #00d2ff, 0 0 12px rgba(0, 210, 255, 0.7);
    filter: brightness(1.15);
    z-index: 4;
}

.item.selected::after {
    content: "✓";
    position: absolute;
    top: 2px;
    right: 4px;
    font-size: 0.65rem;
    font-weight: 900;
    color: #ffffff;
    text-shadow: 0 0 4px #000;
}

.item.dragging {
    opacity: 0.5;
    transform: scale(1.02);
}

.item.drag-placeholder {
    opacity: 0.25;
}

/* Sidebar / Pool List */
.sidebar {
    width: 250px;
    background: var(--card-bg);
    border: 1px solid var(--border-color);
    border-radius: 16px;
    padding: 15px;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.sidebar-header {
    margin-bottom: 15px;
    border-bottom: 1px solid var(--border-color);
    padding-bottom: 10px;
}

.sidebar-header h2 {
    font-size: 1.1rem;
    font-weight: 700;
    letter-spacing: 0.5px;
    color: var(--text-color);
}

.counter-box {
    display: flex;
    justify-content: space-between;
    margin-top: 8px;
    font-size: 0.78rem;
    color: var(--text-muted);
}

.counter-item strong {
    color: #00d2ff;
    font-weight: 700;
}

.pool-column {
    flex: 1;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.pool-items {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 8px;
    overflow-y: auto;
    padding-right: 5px;
    min-height: 50px;
}

.pool-items::-webkit-scrollbar {
    width: 6px;
}

.pool-items::-webkit-scrollbar-track {
    background: rgba(255, 255, 255, 0.01);
}

.pool-items::-webkit-scrollbar-thumb {
    background: rgba(255, 255, 255, 0.1);
    border-radius: 3px;
}

.pool-items::-webkit-scrollbar-thumb:hover {
    background: rgba(255, 255, 255, 0.2);
}

.pool-items .item {
    height: 42px;
    min-height: 42px;
}

.pool-footer {
    margin-top: 15px;
}

.btn-add {
    width: 100%;
    height: 42px;
    background: rgba(255, 255, 255, 0.05);
    border: 1px dashed var(--border-color);
    box-shadow: none;
    font-size: 1.2rem;
}

.btn-add:hover {
    background: rgba(255, 255, 255, 0.08);
    border-color: var(--border-color-active);
}

/* Edit Mode Container */
.item-edit-container {
    display: flex;
    align-items: center;
    width: 100%;
    gap: 6px;
    height: 100%;
}

.item input {
    flex: 1;
    background: transparent;
    border: none;
    border-bottom: 2px solid white;
    color: white;
    text-align: center;
    font-size: 0.8rem;
    font-weight: 700;
    outline: none;
    padding: 2px 0;
    min-width: 0;
}

.btn-delete {
    background: #ff3b30;
    border: none;
    color: white;
    width: 20px;
    height: 20px;
    border-radius: 50%;
    font-size: 0.75rem;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    box-shadow: 0 2px 4px rgba(0,0,0,0.3);
    flex-shrink: 0;
    transition: transform 0.1s ease;
}

.btn-delete:active {
    transform: scale(0.9);
}

/* Touch & Multi-Item Drag Proxy */
#drag-proxy {
    position: fixed;
    top: -9999px;
    left: -9999px;
    pointer-events: none;
    z-index: 99999;
    background: transparent;
    display: none;
    flex-direction: column;
    gap: 4px;
    padding: 0;
    width: 140px;
}

#drag-proxy .proxy-item {
    width: 100%;
    height: 36px;
    background: var(--gradient);
    border-radius: 6px;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 2px 6px;
    font-weight: 600;
    text-align: center;
    word-break: break-word;
    font-size: 0.78rem;
    box-shadow: 0 4px 12px rgba(0,0,0,0.5), 0 0 8px rgba(0, 210, 255, 0.4);
    color: var(--text-color);
    font-family: var(--font-stack);
    border: 1px solid rgba(255, 255, 255, 0.4);
}

#drag-proxy .proxy-gap {
    width: 100%;
    height: 36px;
    background: transparent;
    border: none;
}

/* Parking Area Styles */
.parking-area {
    margin-top: 20px;
    padding: 15px;
    background: rgba(255, 255, 255, 0.02);
    border: 1px dashed var(--border-color);
    border-radius: 12px;
    flex-shrink: 0;
}

.parking-title {
    font-size: 1.05rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 1px;
    color: rgba(255, 255, 255, 0.8);
    margin-bottom: 15px;
    border-left: 3px solid #00d2ff;
    padding-left: 8px;
}

.parking-grid {
    display: grid;
    grid-template-columns: repeat(6, 1fr);
    gap: 12px;
}

.parking-col {
    background: rgba(255, 255, 255, 0.015);
    border: 1px solid rgba(255, 255, 255, 0.05);
    border-radius: 8px;
    padding: 8px;
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.parking-col::before {
    content: "Spalte " attr(data-col);
    font-size: 0.72rem;
    text-transform: uppercase;
    letter-spacing: 1px;
    text-align: center;
    color: rgba(0, 210, 255, 0.75);
    margin-bottom: 6px;
    font-weight: 700;
}

.parking-col .seat-slot {
    height: 38px;
    border-radius: 6px;
    background: rgba(255, 255, 255, 0.02);
}

.parking-col .seat-slot::before {
    content: "#" attr(data-slot);
    position: absolute;
    left: 8px;
    top: 50%;
    transform: translateY(-50%);
    font-size: 0.65rem;
    color: rgba(255, 255, 255, 0.15);
    font-weight: 700;
}

.parking-col .seat-slot .item {
    font-size: 0.75rem;
    padding: 0 8px 0 24px;
    display: flex;
    align-items: center;
    justify-content: center;
}

/* Dynamic Island (Notification system) */
#dynamic-island {
    position: fixed;
    top: 15px;
    left: 50%;
    transform: translateX(-50%);
    background: #000;
    border: 1px solid rgba(255, 255, 255, 0.15);
    color: white;
    padding: 10px 20px;
    border-radius: 20px;
    z-index: 10000;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 10px 30px rgba(0,0,0,0.8);
    transition: all 0.4s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

.dynamic-island-collapsed {
    width: 150px;
    height: 35px;
    opacity: 0;
    pointer-events: none;
    transform: translateX(-50%) scale(0.8) translateY(-20px);
}

.dynamic-island-expanded {
    width: auto;
    min-width: 250px;
    height: auto;
    opacity: 1;
    border-radius: 24px;
}

.island-content {
    display: flex;
    align-items: center;
    gap: 10px;
}

.island-text {
    font-size: 0.85rem;
    font-weight: 600;
    white-space: nowrap;
}

/* Burger menu button */
.burger-menu-btn {
    display: none;
    position: fixed;
    bottom: 20px;
    right: 20px;
    z-index: 1001;
    width: 50px;
    height: 50px;
    border-radius: 50%;
    background: var(--gradient);
    border: none;
    cursor: pointer;
    box-shadow: 0 4px 15px rgba(58, 123, 213, 0.4);
    flex-direction: column;
    justify-content: center;
    align-items: center;
    gap: 4px;
}

.burger-menu-btn .bar {
    width: 20px;
    height: 2px;
    background-color: white;
    transition: 0.3s;
    border-radius: 1px;
}

.burger-menu-btn.active .bar:nth-child(1) {
    transform: translateY(6px) rotate(45deg);
}

.burger-menu-btn.active .bar:nth-child(2) {
    opacity: 0;
}

.burger-menu-btn.active .bar:nth-child(3) {
    transform: translateY(-6px) rotate(-45deg);
}


/* Media Queries for Responsiveness (iPhone / Mobile Portrait) */
@media (max-width: 768px) {
    body {
        overflow-y: auto;
        height: auto;
        min-height: 100vh;
        padding-bottom: 80px;
    }

    .controls-panel {
        flex-direction: column;
        align-items: stretch;
    }

    .control-group {
        flex-direction: column;
    }

    .app-container {
        flex-direction: column;
        overflow: visible;
    }

    .seating-area {
        overflow: visible;
        height: auto;
    }

    .rows-container {
        flex-direction: column;
        gap: 20px;
        overflow: visible;
    }

    .row-block {
        height: 80vh; /* Set height for each row grid to make it scrollable on mobile */
    }

    .row-grid {
        height: calc(100% - 30px);
    }

    .sidebar {
        position: fixed;
        top: 0;
        right: -340px;
        width: 300px;
        height: 100vh;
        z-index: 1000;
        border-radius: 0;
        box-shadow: -5px 0 25px rgba(0,0,0,0.5);
        transition: right 0.3s ease-in-out;
    }

    .sidebar.active {
        right: 0;
    }

    .burger-menu-btn {
        display: flex;
    }
}

/* Virtual Fullscreen fallback (if native is blocked by iframe/browser) */
body.virtual-fullscreen {
    padding: 0 !important;
    margin: 0 !important;
    overflow: hidden !important;
    width: 100vw !important;
    height: 100vh !important;
}

body.virtual-fullscreen .controls-panel {
    border-radius: 0;
    border-left: none;
    border-right: none;
    border-top: none;
    margin-bottom: 5px;
}

body.virtual-fullscreen .app-container {
    height: calc(100vh - 120px) !important;
}

/* Custom Context Menu for Colors */
.context-menu {
    position: fixed;
    z-index: 100000;
    background: rgba(10, 10, 15, 0.95);
    border: 1px solid rgba(255, 255, 255, 0.15);
    border-radius: 12px;
    padding: 10px;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.6), 0 0 15px rgba(0, 210, 255, 0.1);
    display: none;
    width: 180px;
    backdrop-filter: blur(10px);
    animation: fadeIn 0.1s ease-out;
}

.context-menu-title {
    font-size: 0.72rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 1px;
    color: rgba(255, 255, 255, 0.4);
    margin-bottom: 8px;
    text-align: center;
}

.color-palette {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 8px;
    margin-bottom: 8px;
}

.color-btn {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    border: 2px solid rgba(255, 255, 255, 0.15);
    cursor: pointer;
    transition: transform 0.15s cubic-bezier(0.175, 0.885, 0.32, 1.275), border-color 0.15s ease;
}

.color-btn:hover {
    transform: scale(1.15);
    border-color: rgba(255, 255, 255, 0.8);
}

.context-menu-reset {
    width: 100%;
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 6px;
    color: rgba(255, 255, 255, 0.8);
    font-size: 0.75rem;
    font-weight: 600;
    padding: 6px;
    cursor: pointer;
    transition: background 0.15s ease, color 0.15s ease;
}

.context-menu-reset:hover {
    background: rgba(255, 255, 255, 0.1);
    color: white;
}

@keyframes fadeIn {
    from { opacity: 0; transform: translateY(-5px); }
    to { opacity: 1; transform: translateY(0); }
}

/* PDF Export Styles */
.pdf-mode {
    background: #ffffff !important;
    color: #000000 !important;
    padding: 30px !important;
    width: 1200px !important; /* Fixed width for high-quality landscape A4 format */
    height: auto !important;
    box-sizing: border-box !important;
    border-radius: 0 !important;
    box-shadow: none !important;
    display: flex !important;
    flex-direction: column !important;
    gap: 30px !important;
}

.pdf-mode .stage {
    background: #eef1f6 !important;
    border: 2px solid #cfd7e3 !important;
    color: #1a1e29 !important;
    box-shadow: none !important;
    font-weight: 700 !important;
}

.pdf-mode .table-cell {
    background: #f7f9fc !important;
    border: 2px solid #cfd7e3 !important;
    color: #1a1e29 !important; /* Passes dark color directly to SVG text fill */
    box-shadow: none !important;
}

.pdf-mode .seat-slot {
    border: none !important; /* Hide dashed borders on empty seats */
    background: transparent !important; /* Hide backgrounds on empty seats */
}

.pdf-mode .seat-slot::before {
    content: "" !important; /* Hide slot indices */
    display: none !important;
}

.pdf-mode .item {
    color: #ffffff !important; /* Keep white text for good contrast on color backgrounds */
    text-shadow: 0 1px 2px rgba(0, 0, 0, 0.3) !important;
    border: 1px solid rgba(0, 0, 0, 0.1) !important;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1) !important;
}

/* Fallback gradient for uncolored items in PDF mode to keep it premium but readable */
.pdf-mode .item:not([style*="background"]) {
    background: linear-gradient(135deg, #373b4e 0%, #1e2130 100%) !important;
    border-color: #1e2130 !important;
}
