@import url('./design-tokens.css');
/* ============================================================================
   UNIFIED WINDOW HEADER SYSTEM
   ============================================================================
   Einheitliches Header-Design für ALLE Fenster im Expertaizer.

   Version: 1.0.0
   Erstellt: 17. Dezember 2025

   VERWENDUNG:
   -----------
   HTML-Struktur für neue Fenster:

   <div id="my-window" class="unified-window brain-window">
       <div class="unified-header drag-handle">
           <div class="unified-header-title">
               <img src="images/App-Topbar/My-Icon.png" alt="" class="unified-header-icon">
               <span>Fenster-Titel</span>
           </div>
           <div class="unified-header-controls controls">
               <button type="button" class="unified-ctrl-btn" data-action="minimize" data-tooltip="Minimieren">−</button>
               <button type="button" class="unified-ctrl-btn" data-action="fullscreen" data-tooltip="Vollbild">⛶</button>
               <button type="button" class="unified-ctrl-btn unified-close-btn" data-action="close" data-tooltip="Schließen">✕</button>
           </div>
       </div>
       <div class="unified-content">
           <!-- Fensterinhalt -->
       </div>
   </div>

   ============================================================================ */

/* ============================================================================
   DESIGN TOKENS (Referenz zu design-tokens.css)
   ============================================================================ */
:root {
    /* Header spezifische Tokens */
    --header-height: 44px;
    --header-padding: 10px 16px;
    --header-font-size: var(--text-lg);
    --header-icon-size: 28px;
    --header-btn-size: 30px;
    --header-btn-gap: 6px;

    /* Header Farben (basierend auf Corporate Blue) */
    --header-bg: linear-gradient(180deg, rgba(25, 30, 45, 0.98), rgba(20, 25, 38, 0.95));
    --header-border: rgba(var(--color-primary-rgb), 0.25);
    --header-border-hover: rgba(var(--color-primary-rgb), 0.4);
    --header-text: #ffffff;
    --header-text-subtitle: #94a3b8;
    --window-bg: rgba(10, 15, 25, 0.85);
    --window-border: rgba(255, 255, 255, 0.1);

    /* Control Button Farben */
    --ctrl-btn-bg: rgba(255, 255, 255, 0.06);
    --ctrl-btn-border: rgba(255, 255, 255, 0.1);
    --ctrl-btn-text: rgba(255, 255, 255, 0.7);
    --ctrl-btn-hover-bg: rgba(255, 255, 255, 0.12);
    --ctrl-btn-hover-text: #ffffff;

    /* Close Button Spezial */
    --close-btn-hover-bg: rgba(239, 68, 68, 0.25);
    --close-btn-hover-border: rgba(239, 68, 68, 0.5);
    --close-btn-hover-text: #f87171;

    /* Fullscreen Button Spezial */
    --fullscreen-btn-hover-bg: rgba(var(--color-primary-rgb), 0.2);
    --fullscreen-btn-hover-border: rgba(var(--color-primary-rgb), 0.4);
    --fullscreen-btn-hover-text: #38bdf8;

    /* Minimize Button Spezial */
    --minimize-btn-hover-bg: rgba(251, 191, 36, 0.2);
    --minimize-btn-hover-border: rgba(251, 191, 36, 0.4);
    --minimize-btn-hover-text: #fbbf24;

    /* Tooltip */
    --tooltip-bg: rgba(15, 23, 42, 0.98);
    --tooltip-border: rgba(var(--color-primary-rgb), 0.3);
    --tooltip-text: #e2e8f0;
    --tooltip-font-size: var(--text-xs);
}

/* ============================================================================
   UNIFIED WINDOW - Container Basis
   ============================================================================ */
.unified-window {
    /* Wenn das Fenster als Flexbox genutzt wird, MUSS die Richtung Column sein,
       damit der Header oben bleibt. display:none/block/flex wird via JS gesteuert. */
    flex-direction: column !important;
}

/* ============================================================================
   UNIFIED HEADER - Basis Styling
   ============================================================================ */

.unified-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: var(--header-padding);
    min-height: var(--header-height);
    background: var(--header-bg);
    border-bottom: 1px solid var(--header-border);
    border-radius: var(--radius-lg, 12px) var(--radius-lg, 12px) 0 0;
    cursor: move;
    user-select: none;
    flex-shrink: 0;
    position: relative;
    z-index: 10; /* Über dem Content, damit Buttons klickbar bleiben */
    overflow: visible; /* Für Tooltips */
    transition: border-color 0.2s ease, background 0.2s ease;

    /* Subtiler Glanz-Effekt */
    box-shadow:
        0 2px 8px rgba(0, 0, 0, 0.15),
        inset 0 1px 0 rgba(255, 255, 255, 0.06);
}

.unified-header:hover {
    border-bottom-color: var(--header-border-hover);
}

/* Fullscreen Mode: Keine abgerundeten Ecken */
.unified-window.fullscreen .unified-header,
.base-window.fullscreen .unified-header {
    border-radius: 0;
}

/* ============================================================================
   HEADER TITLE
   ============================================================================ */

.unified-header-title {
    display: flex;
    align-items: center;
    gap: 10px;
    font-size: var(--header-font-size);
    font-weight: 600;
    color: var(--header-text);
    letter-spacing: 0.3px;
    pointer-events: none; /* Titel nicht klickbar für besseres Drag */
}

/* Icon im Header (PNG/SVG) */
.unified-header-icon {
    width: var(--header-icon-size);
    height: var(--header-icon-size);
    flex-shrink: 0;
    object-fit: contain;
}

/* Emoji-Icon Alternative */
.unified-header-title .icon-emoji {
    font-size: var(--text-2xl);
    line-height: 1;
}

/* Optionaler Subtitle */
.unified-header-subtitle {
    font-size: var(--text-sm);
    font-weight: 400;
    color: var(--header-text-subtitle);
    margin-left: 8px;
}

/* ============================================================================
   HEADER CONTROLS (Button-Container)
   ============================================================================ */

.unified-header-controls {
    display: flex;
    align-items: center;
    gap: var(--header-btn-gap);
    pointer-events: auto; /* Buttons bleiben klickbar */
}

/* ============================================================================
   CONTROL BUTTONS - Basis
   ============================================================================ */

.unified-ctrl-btn {
    position: relative;
    width: var(--header-btn-size);
    height: var(--header-btn-size);
    border: 1px solid var(--ctrl-btn-border);
    border-radius: var(--radius-sm, 6px);
    background: var(--ctrl-btn-bg);
    color: var(--ctrl-btn-text);
    font-size: var(--text-base);
    font-family: inherit;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s ease;
    outline: none;

    /* Verhindert Text-Selektion beim Drag */
    -webkit-user-select: none;
    user-select: none;
}

.unified-ctrl-btn:hover {
    background: var(--ctrl-btn-hover-bg);
    color: var(--ctrl-btn-hover-text);
    transform: scale(1.05);
}

.unified-ctrl-btn:active {
    transform: scale(0.95);
}

.unified-ctrl-btn:focus-visible {
    outline: 2px solid var(--color-primary, var(--color-primary));
    outline-offset: 2px;
}

/* ============================================================================
   CONTROL BUTTONS - Spezifische Hover-Farben
   ============================================================================ */

/* Minimize Button (−) */
.unified-ctrl-btn[data-action="minimize"]:hover {
    background: var(--minimize-btn-hover-bg);
    border-color: var(--minimize-btn-hover-border);
    color: var(--minimize-btn-hover-text);
}

/* Fullscreen Button (⛶) */
.unified-ctrl-btn[data-action="fullscreen"]:hover {
    background: var(--fullscreen-btn-hover-bg);
    border-color: var(--fullscreen-btn-hover-border);
    color: var(--fullscreen-btn-hover-text);
}

/* Close Button (✕) */
.unified-close-btn:hover,
.unified-ctrl-btn[data-action="close"]:hover {
    background: var(--close-btn-hover-bg);
    border-color: var(--close-btn-hover-border);
    color: var(--close-btn-hover-text);
}

/* ============================================================================
   CSS-TOOLTIPS (statt native title="...")
   ============================================================================

   WICHTIG: Tooltips werden INNERHALB des Fensters angezeigt, nicht außerhalb!
   Das verhindert das "Tooltip außerhalb des Fensters"-Problem.
   ============================================================================ */

.unified-ctrl-btn[data-tooltip]::after {
    content: attr(data-tooltip);
    position: absolute;

    /* Position: UNTER dem Button, innerhalb des Fensters */
    top: calc(100% + 6px);
    left: 50%;
    transform: translateX(-50%);

    /* Styling */
    padding: 5px 10px;
    background: var(--tooltip-bg);
    border: 1px solid var(--tooltip-border);
    border-radius: var(--radius-sm, 6px);
    color: var(--tooltip-text);
    font-size: var(--tooltip-font-size);
    font-weight: 500;
    white-space: nowrap;
    z-index: var(--z-dropdown);

    /* Animation */
    opacity: 0;
    visibility: hidden;
    pointer-events: none;
    transition: opacity 0.15s ease, visibility 0.15s ease;

    /* Schatten */
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
}

/* Kleiner Pfeil nach oben */
.unified-ctrl-btn[data-tooltip]::before {
    content: '';
    position: absolute;
    top: calc(100% + 2px);
    left: 50%;
    transform: translateX(-50%);

    /* Dreieck */
    border: 5px solid transparent;
    border-bottom-color: var(--tooltip-border);

    /* Animation */
    opacity: 0;
    visibility: hidden;
    pointer-events: none;
    transition: opacity 0.15s ease, visibility 0.15s ease;
    z-index: 1001;
}

/* Hover: Tooltip anzeigen */
.unified-ctrl-btn[data-tooltip]:hover::after,
.unified-ctrl-btn[data-tooltip]:hover::before {
    opacity: 1;
    visibility: visible;
}

/* ============================================================================
   SETTINGS BUTTON (Optional im Header)
   ============================================================================ */

.unified-settings-btn {
    background: transparent;
    border: none;
}

.unified-settings-btn:hover {
    background: rgba(var(--color-primary-rgb), 0.15);
    border-color: rgba(var(--color-primary-rgb), 0.3);
    color: #38bdf8;
}

/* Settings Icon */
.unified-settings-btn .settings-icon {
    width: 16px;
    height: 16px;
    transition: transform 0.3s ease;
}

.unified-settings-btn:hover .settings-icon {
    transform: rotate(45deg);
}

/* ============================================================================
   WINDOW CONTENT AREA
   ============================================================================ */

.unified-content {
    flex: 1;
    overflow: auto;
    position: relative;
    min-height: 0; /* Wichtig für Flex-Overflow */
}

/* ============================================================================
   THEME SUPPORT
   ============================================================================ */

/* Dark / Default Theme */
body[data-theme="dark"] .unified-header {
    --header-bg: linear-gradient(180deg, rgba(20, 25, 40, 0.98), rgba(15, 20, 32, 0.96));
    --header-border: rgba(var(--color-primary-rgb), 0.3);
}

/* Neon Theme */
body[data-theme="neon"] .unified-header {
    --header-bg: linear-gradient(180deg, rgba(30, 15, 45, 0.98), rgba(25, 12, 38, 0.95));
    --header-border: rgba(255, 100, 255, 0.25);
    --header-border-hover: rgba(255, 100, 255, 0.4);
}

/* Solar Theme */
body[data-theme="solar"] .unified-header {
    --header-bg: linear-gradient(180deg, rgba(45, 30, 15, 0.98), rgba(38, 25, 12, 0.95));
    --header-border: rgba(255, 180, 100, 0.25);
    --header-border-hover: rgba(255, 180, 100, 0.4);
}

/* ============================================================================
   GLASSMORPHISM VARIANT
   ============================================================================ */

.unified-header.glassmorphism-header {
    background: linear-gradient(180deg,
        rgba(var(--color-primary-rgb), 0.12) 0%,
        rgba(2, 132, 199, 0.06) 100%);
    backdrop-filter: blur(var(--glass-blur-md));
    -webkit-backdrop-filter: blur(var(--glass-blur-md));
}

/* ============================================================================
   COMPATIBILITY LAYER
   ============================================================================

   Diese Klassen mappen alte Klassen auf das neue System für sanfte Migration.
   ============================================================================ */

/* Alte brain-header, ps-header, kc-header → erben automatisch von unified-header wenn beide Klassen gesetzt */

/* Alte window-btn → unified-ctrl-btn */
.window-btn.use-unified {
    width: var(--header-btn-size);
    height: var(--header-btn-size);
    border-radius: var(--radius-sm, 6px);
}

/* ============================================================================
   RESPONSIVE ADJUSTMENTS
   ============================================================================ */

@media (max-width: 768px) {
    :root {
        --header-height: 40px;
        --header-padding: 8px 12px;
        --header-font-size: 13px;
        --header-icon-size: 20px;
        --header-btn-size: 26px;
    }

    .unified-header-subtitle {
        display: none; /* Subtitle auf Mobile ausblenden */
    }
}

@media (max-width: 480px) {
    :root {
        --header-btn-gap: var(--spacing-xs);
    }

    /* Auf sehr kleinen Screens nur Close-Button zeigen */
    .unified-ctrl-btn[data-action="minimize"] {
        display: none;
    }
}

/* ============================================================================
   UTILITY CLASSES
   ============================================================================ */

/* Header ohne Icon */
.unified-header-title.no-icon .unified-header-icon {
    display: none;
}

/* Header mit nur Close-Button */
.unified-header-controls.close-only .unified-ctrl-btn:not([data-action="close"]) {
    display: none;
}

/* Header ohne Minimize */
.unified-header-controls.no-minimize .unified-ctrl-btn[data-action="minimize"] {
    display: none;
}

/* Kompakter Header */
.unified-header.compact {
    --header-height: 36px;
    --header-padding: 6px 12px;
    --header-font-size: 13px;
    --header-btn-size: 24px;
}

/* ============================================================================
   END OF UNIFIED WINDOW HEADER SYSTEM
   ============================================================================ */






