/* desktop-spezifische Styles auf Basis der CSS-Variablen aus _core/core.css */

.desktop-app {
    display: flex;
    flex-direction: column;
    min-height: calc(100vh - 56px);
    --bg-tile: color-mix(in srgb, var(--bg-surface) 88%, transparent);
    --bg-tile-hover: var(--bg-surface);
}

.desktop-app button,
.desktop-app .btn-ghost,
.desktop-app .btn-primary,
.desktop-app .btn-subtle,
.modal button,
.modal .btn-ghost,
.modal .btn-primary {
    border: none;
    border-radius: var(--radius, 8px);
    padding: 0.45rem 0.75rem;
    font-size: 0.875rem;
    font-weight: 500;
    cursor: pointer;
    text-decoration: none;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.35rem;
    transition: transform 0.1s, opacity 0.15s, background 0.15s;
}
.desktop-app button:active,
.modal button:active {
    transform: scale(0.97);
}

.desktop-app .btn-primary,
.modal .btn-primary {
    background: var(--accent);
    color: #fff;
}
.desktop-app .btn-primary:hover,
.modal .btn-primary:hover {
    background: var(--accent-hover, var(--accent));
}

.desktop-app .btn-subtle {
    background: var(--bg-surface);
    color: var(--text-main);
    border: 1px solid var(--border-color);
}
.desktop-app .btn-subtle:hover {
    background: var(--bg-subtle);
}
.desktop-app .btn-subtle.active {
    background: var(--warn, #f59e0b);
    color: #0f172a;
    border-color: var(--warn, #f59e0b);
}

/* GERÄTESPEZIFISCHE SICHTBARKEIT (außerhalb des Bearbeitungsmodus) */
html:not([data-os="windows"]) body:not(.edit-mode) .tile-wrapper[data-is-file="1"] {
    display: none;
}

html[data-mode="alt"][data-platform="desktop"] body:not(.edit-mode) .tile-wrapper[data-has-web="0"],
html[data-mode="alt"][data-platform="android"] body:not(.edit-mode) .tile-wrapper[data-has-web="0"][data-has-android="0"],
html[data-mode="alt"][data-platform="ios"]     body:not(.edit-mode) .tile-wrapper[data-has-web="0"][data-has-ios="0"] {
    display: none;
}

/* MINIMIERTE GRUPPEN-DOCK */
.minimized-dock {
    max-width: 1600px;
    width: 100%;
    margin: 0 auto;
    padding: 0.85rem 1.25rem 0;
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
}
.minimized-dock:empty { display: none; }

.minimized-pill {
    --pill-accent: var(--accent);
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.45rem 0.8rem;
    border-radius: 999px;
    background: color-mix(in srgb, var(--pill-accent) 18%, var(--bg-surface));
    border: 1.5px solid color-mix(in srgb, var(--pill-accent) 55%, var(--border-color));
    color: var(--text-main);
    font-size: 0.85rem;
    font-weight: 600;
    box-shadow: var(--shadow-sm);
    max-width: 100%;
}
.minimized-pill:hover {
    background: color-mix(in srgb, var(--pill-accent) 28%, var(--bg-surface));
    transform: translateY(-1px);
}
.minimized-pill .pill-dot {
    width: 10px;
    height: 10px;
    border-radius: 50%;
    background: var(--pill-accent);
    flex-shrink: 0;
}
.minimized-pill .pill-title {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}
.minimized-pill .pill-count {
    font-size: 0.72rem;
    font-weight: 600;
    padding: 0.1rem 0.42rem;
    border-radius: 999px;
    background: color-mix(in srgb, var(--pill-accent) 25%, transparent);
    color: var(--text-main);
    flex-shrink: 0;
}
.minimized-pill .pill-expand {
    font-size: 0.9rem;
    opacity: 0.75;
    margin-left: 0.1rem;
    flex-shrink: 0;
}

/* ADAPTIVES GRUPPEN-GRID */
.desktop-canvas {
    flex: 1;
    max-width: 1600px;
    width: 100%;
    margin: 0 auto;
    padding: 1.25rem;
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(min(100%, 360px), 1fr));
    gap: 1.25rem;
    align-items: start;
}

.group-card {
    --group-accent: var(--accent);
    background: color-mix(in srgb, var(--group-accent) 12%, var(--bg-surface));
    border: 1px solid color-mix(in srgb, var(--group-accent) 30%, var(--border-color));
    border-radius: calc(var(--radius, 10px) * 1.5);
    padding: 1rem;
    box-shadow: var(--shadow-md);
}
.group-card.is-minimized {
    display: none !important;
}

.group-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.5rem;
    margin-bottom: 0.85rem;
}

.group-title-wrap {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    min-width: 0;
}

.group-header-right {
    display: flex;
    align-items: center;
    gap: 0.35rem;
    flex-shrink: 0;
}

.group-controls {
    display: flex;
    align-items: center;
    gap: 0.35rem;
}

.group-dot {
    width: 10px;
    height: 10px;
    border-radius: 50%;
    background: var(--group-accent);
    flex-shrink: 0;
}

.group-header h2 {
    font-size: 0.95rem;
    font-weight: 600;
    letter-spacing: 0.01em;
    color: var(--text-main);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.group-count-badge {
    font-size: 0.72rem;
    color: var(--text-muted);
    background: var(--bg-subtle);
    padding: 0.1rem 0.45rem;
    border-radius: 999px;
}

.group-drag-handle {
    cursor: grab;
    color: var(--text-muted);
    font-size: 1.1rem;
    user-select: none;
}

.btn-minimize {
    font-weight: 700;
    min-width: 28px;
    height: 28px;
    padding: 0;
}

/* KACHEL-RASTER INNERHALB EINER GRUPPE */
.tiles-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(84px, 1fr));
    gap: 0.7rem;
    min-height: 88px;
}

.tile-wrapper {
    position: relative;
}

.app-tile {
    position: relative;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    text-align: center;
    text-decoration: none;
    color: var(--text-main);
    background: var(--bg-tile);
    border: 1px solid var(--border-color);
    border-radius: calc(var(--radius, 10px) * 1.3);
    padding: 0.7rem 0.4rem;
    aspect-ratio: 1 / 1;
    transition: transform 0.15s ease, background 0.15s ease, box-shadow 0.15s ease;
}

.app-tile:hover {
    transform: translateY(-2px);
    background: var(--bg-tile-hover);
    box-shadow: var(--shadow-md);
}

.tile-icon {
    width: 38px;
    height: 38px;
    display: flex;
    align-items: center;
    justify-content: center;
    margin-bottom: 0.4rem;
}

.tile-icon img {
    width: 36px;
    height: 36px;
    object-fit: contain;
    border-radius: 8px;
}

.tile-fallback {
    width: 36px;
    height: 36px;
    border-radius: 10px;
    background: var(--group-accent);
    color: #fff;
    font-weight: 700;
    font-size: 0.95rem;
    display: flex;
    align-items: center;
    justify-content: center;
}

.tile-fallback.tile-emoji {
    font-size: 1.2rem;
    background: color-mix(in srgb, var(--group-accent) 22%, var(--bg-surface));
    color: var(--text-main);
}

.tile-label {
    font-size: 0.76rem;
    font-weight: 500;
    line-height: 1.15;
    max-width: 100%;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.tile-badge {
    position: absolute;
    top: 5px;
    right: 6px;
    font-size: 0.65rem;
    color: var(--text-muted);
    opacity: 0.75;
}
.tile-badge.app-badge {
    font-size: 0.62rem;
    opacity: 0.85;
}

/* UNTERE VERWALTUNGSLEISTE */
.bottombar {
    margin-top: auto;
    padding: 1rem 1.25rem 1.5rem;
    border-top: 1px solid var(--border-color);
    background: color-mix(in srgb, var(--bg-surface) 60%, var(--bg-body));
}

.bottombar-inner {
    max-width: 1600px;
    margin: 0 auto;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-wrap: wrap;
    gap: 0.6rem;
}

/* BEARBEITUNGSMODUS & DRAG & DROP */
.edit-only { display: none; }
body.edit-mode .edit-only { display: flex; }
body.edit-mode article.edit-only { display: block; }
body.edit-mode .tile-wrapper { cursor: grab; }

.tile-edit-overlay {
    position: absolute;
    inset: 0;
    background: rgba(15, 23, 42, 0.78);
    border-radius: calc(var(--radius, 10px) * 1.3);
    align-items: center;
    justify-content: center;
    gap: 0.3rem;
    backdrop-filter: blur(2px);
}
.tile-edit-overlay.always-visible { display: flex; }

.tile-edit-overlay button,
.icon-btn {
    background: rgba(255, 255, 255, 0.18);
    color: #fff;
    padding: 0.35rem 0.45rem;
    font-size: 0.8rem;
}
.icon-btn {
    color: var(--text-main);
    background: var(--bg-subtle);
}
.icon-btn:hover {
    opacity: 0.85;
}
.danger {
    background: var(--danger, #ef4444) !important;
    color: #fff !important;
}

.sortable-ghost { opacity: 0.35; }
.is-inactive { opacity: 0.6; }

/* MODALS */
.modal {
    border: 1px solid var(--border-color);
    border-radius: calc(var(--radius, 10px) * 1.5);
    background: var(--bg-surface);
    color: var(--text-main);
    padding: 1.5rem;
    width: min(92vw, 430px);
    margin: auto;
    box-shadow: var(--shadow-md);
}
.modal::backdrop { background: rgba(0, 0, 0, 0.6); backdrop-filter: blur(3px); }
.modal h3 { margin-bottom: 1rem; font-size: 1.1rem; }

.modal label {
    display: flex;
    flex-direction: column;
    gap: 0.35rem;
    font-size: 0.85rem;
    color: var(--text-muted);
    margin-bottom: 0.9rem;
}

.field-hint {
    font-size: 0.74rem;
    color: var(--text-muted);
    opacity: 0.85;
    line-height: 1.35;
}
.field-hint code {
    background: var(--bg-subtle);
    padding: 0.05rem 0.3rem;
    border-radius: 4px;
    font-size: 0.72rem;
}

.modal input[type="text"],
.modal select {
    padding: 0.6rem 0.75rem;
    border-radius: var(--radius, 8px);
    border: 1px solid var(--border-color);
    background: var(--bg-body);
    color: var(--text-main);
    font-size: 0.95rem;
}

.modal .checkbox-row {
    flex-direction: row;
    align-items: center;
    gap: 0.5rem;
    color: var(--text-main);
    cursor: pointer;
}

.color-picker-row { display: flex; align-items: center; gap: 0.75rem; }
.color-swatches { display: flex; gap: 0.4rem; }
.color-swatches button { width: 24px; height: 24px; border-radius: 50%; padding: 0; }

.modal-actions {
    display: flex;
    justify-content: flex-end;
    gap: 0.5rem;
    margin-top: 1.25rem;
}
.modal .btn-ghost {
    color: var(--text-main);
    background: var(--bg-subtle);
}

@media (max-width: 540px) {
    .minimized-dock { padding: 0.65rem 0.75rem 0; gap: 0.4rem; }
    .minimized-pill { padding: 0.42rem 0.72rem; font-size: 0.82rem; }
    .desktop-canvas { padding: 0.75rem; gap: 0.9rem; }
    .tiles-grid { grid-template-columns: repeat(auto-fill, minmax(74px, 1fr)); gap: 0.55rem; }
    .bottombar { padding: 0.85rem 0.75rem 1.25rem; }
}
