/* static/css/style.css */

/* --- Apple HIG Inspired Variables --- */
:root {
    /* Light Theme */
    --system-gray-6-light: #f2f2f7; /* Page background */
    --system-gray-5-light: #e5e5ea; /* Subtle borders, separators */
    --system-gray-4-light: #d1d1d6; /* Secondary controls, placeholders */
    --system-gray-3-light: #c7c7cc;
    --system-gray-2-light: #aeaeb2;
    --system-gray-light: #8e8e93;   /* Muted text */
    --label-light: #000000;         /* Primary text */
    --secondary-label-light: rgba(60, 60, 67, 0.6); /* Wie system-gray */
    --tertiary-label-light: rgba(60, 60, 67, 0.3);
    --system-background-light: #ffffff; /* Card background */
    --secondary-system-background-light: #f2f2f7; /* Input background */
    --tertiary-system-background-light: #e5e5ea; /* Segmented control non-active BG */
    --system-blue-light: #007aff;
    --system-green-light: #34c759;
    --system-yellow-light: #ffcc00;
    --system-red-light: #ff3b30;
    --system-orange-light: #ff9500;
    --system-purple-light: #af52de;
    --system-indigo-light: #5856d6;

    /* Dark Theme */
    --system-gray-6-dark: #1c1c1e;  /* Page background */
    --system-gray-5-dark: #2c2c2e;  /* Card background, Input background */
    --system-gray-4-dark: #3a3a3c;  /* Borders, separators */
    --system-gray-3-dark: #48484a;
    --system-gray-2-dark: #636366;
    --system-gray-dark: #8e8e93;    /* Muted text */
    --label-dark: #ffffff;          /* Primary text */
    --secondary-label-dark: rgba(235, 235, 245, 0.6); /* Wie system-gray */
    --tertiary-label-dark: rgba(235, 235, 245, 0.3);
    --system-background-dark: #000000; /* Kann auch sehr dunkelgrau sein */
    --secondary-system-background-dark: #1c1c1e;
    --tertiary-system-background-dark: #3a3a3c; /* Segmented control non-active BG */
    --system-blue-dark: #0a84ff;
    --system-green-dark: #30d158;
    --system-yellow-dark: #ffd60a;
    --system-red-dark: #ff453a;
    --system-orange-dark: #ff9f0a;
    --system-purple-dark: #bf5af2;
    --system-indigo-dark: #5e5ce6;

    /* Status Specific Text Colors (for contrast on colored buttons) */
    --text-on-green-light: #ffffff;
    --text-on-yellow-light: #333333; /* Darker text for yellow */
    --text-on-red-light: #ffffff;
    --text-on-paused-light: #333333; /* Use darker text for yellow pause */
    --text-on-stopped-light: #ffffff;

    --text-on-green-dark: #ffffff;
    --text-on-yellow-dark: #333333; /* Darker text for yellow */
    --text-on-red-dark: #ffffff;
    --text-on-paused-dark: #333333; /* Use darker text for yellow pause */
    --text-on-stopped-dark: #ffffff;

    /* General UI */
    --base-font-size: 16px;
    --default-border-radius: 10px;
    --card-padding: 1rem;
    --control-height: 44px;
    --section-spacing: 2.5rem;
    --card-shadow: 0 1px 1px rgba(0, 0, 0, 0.03), 0 2px 6px rgba(0, 0, 0, 0.04);
    --card-shadow-dark: 0 0 1px rgba(255, 255, 255, 0.05), 0 2px 4px rgba(0, 0, 0, 0.2);
    --control-active-shadow: 0 1px 3px rgba(0,0,0,0.08), 0 1px 2px rgba(0,0,0,0.05);
    --control-active-shadow-dark: 0 1px 1px rgba(0,0,0,0.2), 0 0 0 0.5px rgba(0,0,0,0.3) inset;

    /* Link Button */
    --link-button-size: 36px; /* Größe des Klickbereichs für den Link */
    --link-button-padding: 8px; /* Innenabstand innerhalb des Buttons (wird für Positionierung genutzt) */

    /* Transitions */
    --transition-duration: 0.25s;
    --transition-timing: ease-in-out;
}

/* Apply theme variables */
body {
    background-color: var(--system-gray-6-light);
    color: var(--label-light);
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif, "Apple Color Emoji", "Segoe UI Emoji", "Segoe UI Symbol";
    font-size: var(--base-font-size);
    line-height: 1.5;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    transition: background-color var(--transition-duration) var(--transition-timing), color var(--transition-duration) var(--transition-timing);
}

body.dark-mode {
    background-color: var(--system-gray-6-dark);
    color: var(--label-dark);
    color-scheme: dark;
}

/* --- General Elements & Transitions --- */
.card, .btn, h1, h2, p, a, span, .lead, .text-muted, body, input, button, .alert, footer,
.status-indicator, .badge, label, .section-title, .section-title-button, .collapse-icon,
.dark-mode-toggle, .controls-section, .card-link {
    transition: background-color var(--transition-duration) var(--transition-timing),
                color var(--transition-duration) var(--transition-timing),
                border-color var(--transition-duration) var(--transition-timing),
                box-shadow var(--transition-duration) var(--transition-timing),
                fill var(--transition-duration) var(--transition-timing),
                stroke var(--transition-duration) var(--transition-timing),
                transform var(--transition-duration) var(--transition-timing),
                opacity var(--transition-duration) var(--transition-timing);
}
.card.status-card:hover {
    transition: transform 0.15s var(--transition-timing),
                box-shadow 0.15s var(--transition-timing),
                border-color 0.15s var(--transition-timing),
                background-color var(--transition-duration) var(--transition-timing),
                color var(--transition-duration) var(--transition-timing);
}
.card-link.domain-link { /* Spezifischerer Übergang für Link-Button */
     transition: background-color var(--transition-duration) var(--transition-timing),
                opacity var(--transition-duration) var(--transition-timing),
                transform 0.1s ease-out; /* Schnellerer Transform auf Klick */
}

/* --- Layout & Typografie --- */
.container-fluid.apple-interface { max-width: 1100px; margin-left: auto; margin-right: auto; }
h1 { color: var(--label-light); font-weight: 600; letter-spacing: -0.01em; }
.lead.text-muted { color: var(--system-gray-light); font-size: 1.1rem; font-weight: 400; }
.section-title {
    font-size: 1.2rem;
    font-weight: 600;
    color: var(--label-light);
    margin-bottom: 1.25rem;
    padding-bottom: 0;
    border-bottom: none;
    display: flex;
    align-items: center;
    gap: 0.6rem;
}
.section-title i { color: var(--system-gray-light); }
.section-title-button {
    font-size: inherit; font-weight: inherit; color: inherit;
    background: none; border: none; padding: 0; width: 100%; text-align: left;
    display: flex; align-items: center; cursor: pointer;
}
.section-title-button:hover { color: var(--system-blue-light); }
.section-title-button .collapse-icon { color: var(--system-gray-3-light); margin-left: auto; transition: transform var(--transition-duration) var(--transition-timing); }
.section-title-button[aria-expanded="true"] .collapse-icon { transform: rotate(180deg); }
.section-title .badge { font-size: 0.75rem; font-weight: 500; padding: 0.2em 0.5em; background-color: var(--system-gray-5-light); color: var(--system-gray-light); }

body.dark-mode h1, body.dark-mode .section-title { color: var(--label-dark); }
body.dark-mode .lead.text-muted { color: var(--system-gray-dark); }
body.dark-mode .section-title i { color: var(--system-gray-dark); }
body.dark-mode .section-title-button:hover { color: var(--system-blue-dark); }
body.dark-mode .section-title-button .collapse-icon { color: var(--system-gray-3-dark); }
body.dark-mode .section-title .badge { background-color: var(--system-gray-4-dark); color: var(--secondary-label-dark); }

/* --- Kontroll-Sektion --- */
.controls-section {
    background-color: rgba(242, 242, 247, 0.8);
    backdrop-filter: blur(20px) saturate(180%);
    -webkit-backdrop-filter: blur(20px) saturate(180%);
    border-radius: 12px;
    padding: 1rem;
    border: 1px solid rgba(0,0,0,0.05);
    margin-bottom: var(--section-spacing);
}
.search-wrapper { position: relative; }
.search-icon { position: absolute; top: 50%; left: 1rem; transform: translateY(-50%); color: var(--system-gray-light); pointer-events: none; }
#search-input {
    background-color: var(--secondary-system-background-light);
    color: var(--label-light);
    border: 1px solid var(--secondary-system-background-light);
    border-radius: 8px;
    padding-left: 2.5rem;
    height: var(--control-height);
    font-size: 1rem;
}
#search-input::placeholder { color: var(--system-gray-light); opacity: 1; }
#search-input:focus {
    background-color: var(--system-background-light);
    border-color: var(--system-blue-light);
    box-shadow: 0 0 0 3px rgba(0, 122, 255, 0.3);
}

/* --- Segmented Control (Mit farbigen aktiven Buttons) --- */
.filter-segmented-control {
    background-color: var(--tertiary-system-background-light);
    border-radius: 8px;
    padding: 3px;
    display: inline-flex;
    box-shadow: inset 0 1px 1px rgba(0,0,0,0.04);
}
.filter-segmented-control label.btn {
    font-weight: 500;
    font-size: 0.9rem;
    border-radius: 6px !important;
    padding: 0.4rem 1rem;
    border: none;
    color: var(--system-gray-light);
    background-color: transparent;
    box-shadow: none !important;
    margin: 0 !important;
    line-height: 1.4;
    flex-grow: 1;
    text-align: center;
    transition: background-color 0.3s ease, color 0.3s ease, box-shadow 0.3s ease;
}
.filter-segmented-control label.btn:not(.active):hover {
    color: var(--label-light);
}
.filter-segmented-control .btn-check:checked + label.btn {
    background-color: var(--system-background-light);
    color: var(--label-light);
    font-weight: 600;
    box-shadow: var(--control-active-shadow) !important;
}
.filter-segmented-control .btn-check:checked + label[for="filterRunning"] {
    background-color: var(--system-green-light);
    color: var(--text-on-green-light);
}
.filter-segmented-control .btn-check:checked + label[for="filterPaused"] {
    background-color: var(--system-yellow-light);
    color: var(--text-on-paused-light);
}
.filter-segmented-control .btn-check:checked + label[for="filterStopped"] {
    background-color: var(--system-red-light);
    color: var(--text-on-stopped-light);
}


/* --- Karten-Styling (Apple Style) --- */
.container-item { opacity: 1; transform: translateY(0); transition: opacity 0.3s ease, transform 0.3s ease; }
.container-item.item-hidden { opacity: 0; transform: translateY(8px); pointer-events: none; }
.card.status-card {
    border-radius: var(--default-border-radius);
    box-shadow: var(--card-shadow);
    background-color: var(--system-background-light);
    border: none;
    overflow: hidden;
    position: relative;
}
.card.status-card:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.08);
}
.status-indicator {
    display: inline-block;
    width: 10px;
    height: 10px;
    border-radius: 50%;
    background-color: var(--system-gray-4-light);
    margin-right: 0.6rem;
    flex-shrink: 0;
    vertical-align: middle;
    box-shadow: 0 0 0 0 rgba(var(--system-gray-4-light), 0.7);
    transition: background-color var(--transition-duration) var(--transition-timing), box-shadow var(--transition-duration) var(--transition-timing);
}
.status-indicator.status-running {
    background-color: var(--system-green-light);
    box-shadow: 0 0 5px 1px rgba(52, 199, 89, 0.6);
}
.status-indicator.status-starting {
    background-color: var(--system-blue-light);
     box-shadow: 0 0 5px 1px rgba(0, 122, 255, 0.6);
}
.status-indicator.status-paused {
    background-color: var(--system-yellow-light);
}
.status-indicator.status-stopped {
    background-color: var(--system-red-light);
}
.status-indicator.status-restarting {
    background-color: var(--system-purple-light);
    box-shadow: 0 0 5px 1px rgba(175, 82, 222, 0.6);
}

.card-body {
    padding: var(--card-padding);
    display: flex;
    align-items: center;
}
.card-title.status-name {
    color: var(--label-light);
    font-weight: 500;
    font-size: 1rem;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    flex-grow: 1;
    display: inline-block;
    margin-top: 0 !important;
    margin-bottom: 0 !important;
    margin-left: 0;
    margin-right: 0; 
    flex-shrink: 0;
    padding: 5px;
    vertical-align: middle;
    /* Mehr Platz zum rechten Rand lassen, damit der Button nicht überlappt */
    margin-right: calc(var(--link-button-size) + 5px);
    
}

/* Kartenlink (Größerer Klickbereich) */
.card-link.domain-link {
    position: absolute;
    top: 50%;
    right: calc(var(--card-padding) - var(--link-button-padding) / 2);
    transform: translateY(-50%);
    width: var(--link-button-size);
    height: var(--link-button-size);
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--system-blue-light);
    text-decoration: none;
    background-color: transparent;
    border: none;
    border-radius: 50%;
    padding: 0;
    margin: 0;
    cursor: pointer;
    opacity: 0.75;
    /* Transition wird oben global definiert und hier spezifischer */
}

.card-link.domain-link:hover {
    color: var(--system-blue-light);
    opacity: 1;
    background-color: rgba(0, 122, 255, 0.1);
}

.card-link.domain-link:active {
    transform: translateY(-50%) scale(0.92);
    background-color: rgba(0, 122, 255, 0.15);
}

.card-link.domain-link i {
    font-size: 0.9em;
    display: block;
    line-height: 1;
}

/* --- Footer --- */
.footer.text-muted { color: var(--tertiary-label-light) !important; font-size: 0.8rem; border-top: 1px solid var(--system-gray-5-light); }

/* --- Placeholder & Messages --- */
.placeholder-item .card { background-color: var(--system-gray-5-light); min-height: 70px; box-shadow: none; }
.placeholder-card .card-body { background-color: transparent !important; }
.placeholder-glow .placeholder { background-color: var(--system-gray-4-light); }
.no-items-message {
    background-color: var(--secondary-system-background-light);
    color: var(--system-gray-light);
    padding: 1.5rem;
    text-align: center;
    border-radius: var(--default-border-radius);
    border: 1px dashed var(--system-gray-4-light);
    margin-top: 1rem;
}

/* --- Dark Mode Toggle Button --- */
.dark-mode-toggle {
    position: fixed;
    top: 1rem;
    right: 1rem;
    z-index: 1050;
    width: 40px;
    height: 40px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0;
    font-size: 1.1rem;
    background-color: var(--secondary-system-background-light);
    color: var(--system-gray-light);
    border: 1px solid var(--system-gray-5-light);
    box-shadow: 0 1px 3px rgba(0,0,0,0.05);
    cursor: pointer;
}
.dark-mode-toggle:hover {
    color: var(--label-light);
    background-color: var(--system-gray-5-light);
}


/* --- Dark Mode Overrides --- */
body.dark-mode {
    /* Re-map colors */
    --label-light: var(--label-dark);
    --secondary-label-light: var(--secondary-label-dark);
    --tertiary-label-light: var(--tertiary-label-dark);
    --system-gray-light: var(--system-gray-dark);
    --system-gray-2-light: var(--system-gray-2-dark);
    --system-gray-3-light: var(--system-gray-3-dark);
    --system-gray-4-light: var(--system-gray-4-dark);
    --system-gray-5-light: var(--system-gray-5-dark);
    --system-gray-6-light: var(--system-gray-6-dark);
    --system-background-light: var(--system-gray-5-dark);
    --secondary-system-background-light: var(--system-gray-6-dark);
    --tertiary-system-background-light: var(--tertiary-system-background-dark);
    --system-blue-light: var(--system-blue-dark);
    --system-green-light: var(--system-green-dark);
    --system-yellow-light: var(--system-yellow-dark);
    --system-red-light: var(--system-red-dark);
    --system-purple-light: var(--system-purple-dark);
    --card-shadow: var(--card-shadow-dark);

    /* Map text contrast colors */
    --text-on-green-light: var(--text-on-green-dark);
    --text-on-yellow-light: var(--text-on-yellow-dark);
    --text-on-red-light: var(--text-on-red-dark);
    --text-on-paused-light: var(--text-on-paused-dark);
    --text-on-stopped-light: var(--text-on-stopped-dark);
}

/* Dark Mode spezifische Anpassungen */
.dark-mode .controls-section {
    background-color: rgba(28, 28, 30, 0.75);
    border: 1px solid rgba(255,255,255,0.08);
}

.dark-mode #search-input {
    background-color: var(--secondary-system-background-dark);
    border-color: var(--secondary-system-background-dark);
    color: var(--label-dark);
}
.dark-mode #search-input::placeholder { color: var(--system-gray-dark); }
.dark-mode #search-input:focus {
    background-color: var(--system-gray-5-dark);
    border-color: var(--system-blue-dark);
     box-shadow: 0 0 0 3px rgba(10, 132, 255, 0.3);
}

.dark-mode .filter-segmented-control {
     background-color: var(--tertiary-system-background-dark);
     box-shadow: inset 0 1px 1px rgba(0,0,0,0.25);
}
.dark-mode .filter-segmented-control label.btn {
    color: var(--system-gray-dark);
}
.dark-mode .filter-segmented-control label.btn:not(.active):hover {
    color: var(--label-dark);
}
.dark-mode .filter-segmented-control .btn-check:checked + label.btn {
    background-color: var(--system-gray-2-dark);
    color: var(--label-dark);
    box-shadow: var(--control-active-shadow-dark) !important;
}
/* Colored Active States inherit via variable mapping */

.dark-mode .card.status-card {
    background-color: var(--system-gray-5-dark);
    box-shadow: var(--card-shadow-dark);
}
.dark-mode .card.status-card:hover {
    box-shadow: 0 6px 16px rgba(0, 0, 0, 0.25);
}
.dark-mode .card-title.status-name { color: var(--label-dark); }

.dark-mode .status-indicator { background-color: var(--system-gray-3-dark); box-shadow: none; }
.dark-mode .status-indicator.status-running {
    background-color: var(--system-green-dark);
    box-shadow: 0 0 5px 1px rgba(48, 209, 88, 0.6);
}
.dark-mode .status-indicator.status-starting {
    background-color: var(--system-blue-dark);
    box-shadow: 0 0 5px 1px rgba(10, 132, 255, 0.6);
}
.dark-mode .status-indicator.status-paused { background-color: var(--system-yellow-dark); }
.dark-mode .status-indicator.status-stopped { background-color: var(--system-red-dark); }
.dark-mode .status-indicator.status-restarting {
    background-color: var(--system-purple-dark);
    box-shadow: 0 0 5px 1px rgba(191, 90, 242, 0.6);
}

.dark-mode .card-link.domain-link {
    color: var(--system-blue-dark);
    opacity: 0.75;
}
.dark-mode .card-link.domain-link:hover {
    color: var(--system-blue-dark);
    opacity: 1;
    background-color: rgba(10, 132, 255, 0.15);
}
.dark-mode .card-link.domain-link:active {
    background-color: rgba(10, 132, 255, 0.2);
}

.dark-mode .footer.text-muted { color: var(--tertiary-label-dark) !important; border-top-color: var(--system-gray-4-dark); }
.dark-mode .no-items-message { background-color: transparent; color: var(--system-gray-dark); border: 1px dashed var(--system-gray-4-dark); }
.dark-mode .placeholder-item .card { background-color: var(--system-gray-5-dark); }
.dark-mode .placeholder-glow .placeholder { background-color: var(--system-gray-4-dark); }

.dark-mode .dark-mode-toggle {
    color: var(--system-gray-dark);
    border-color: var(--system-gray-4-dark);
    background-color: var(--system-gray-5-dark);
    box-shadow: 0 1px 2px rgba(0,0,0,0.15);
}
.dark-mode .dark-mode-toggle:hover {
    color: var(--label-dark);
    background-color: var(--system-gray-4-dark);
}


/* --- Responsiveness --- */
@media (max-width: 768px) {
    .container-fluid.apple-interface { padding-left: 1rem; padding-right: 1rem; margin-top: 2rem; margin-bottom: 3rem;}
    h1 { font-size: 1.7rem; }
    .lead { font-size: 1rem; margin-bottom: 2.5rem;}
    .section-title, .section-title-button { font-size: 1.1rem; }
    .controls-section { padding: 0.8rem; border-radius: 10px; }
    #search-input { height: 40px; font-size: 0.95rem; padding-left: 2.2rem; }
    .search-icon { left: 0.8rem; font-size: 0.9rem;}
    .filter-segmented-control { width: 100%; }
    .filter-segmented-control label.btn { font-size: 0.8rem; padding: 0.3rem 0.7rem; }
    .card-body { padding: 0.8rem; }
    .card-title.status-name {
        font-size: 0.95rem;
        /* Abstand zum Button auch mobil anpassen */
        margin-right: calc(var(--link-button-size) - 4px); /* Ggf. etwas weniger Abstand mobil */
    }
    .status-indicator { width: 8px; height: 8px; margin-right: 0.5rem;}

    .card-link.domain-link {
        /* Evtl. Buttongröße mobil leicht anpassen */
        /* --link-button-size: 32px; */ /* Beispiel: Verkleinern */

        /* Positionierung anpassen, falls Padding mobil anders ist */
        right: calc(0.8rem - var(--link-button-padding) / 2); /* Annahme: 0.8rem Card Padding mobil */
    }
     .card-link.domain-link i {
         /* Icon Größe bleibt relativ */
    }
}