/* ==========================================================================
   Alarmly Design System
   Carbon-inspiriert: flache Ebenen, 1px-Rahmen, keine runden Ecken,
   IBM Plex, Rostorange als einzige Akzentfarbe.
   ========================================================================== */

@font-face {
    font-family: "IBM Plex Sans";
    font-style: normal;
    font-weight: 400;
    font-display: swap;
    src: url("../fonts/IBMPlexSans-Regular.woff2") format("woff2");
}

@font-face {
    font-family: "IBM Plex Sans";
    font-style: normal;
    font-weight: 600;
    font-display: swap;
    src: url("../fonts/IBMPlexSans-SemiBold.woff2") format("woff2");
}

/* --------------------------------------------------------------------------
   Tokens
   -------------------------------------------------------------------------- */

:root {
    --font-sans: "IBM Plex Sans", "Segoe UI", system-ui, -apple-system, sans-serif;
    --font-mono: "Cascadia Mono", "IBM Plex Mono", Consolas, monospace;

    --color-bg: #f4f4f4;
    --color-layer: #ffffff;
    --color-layer-hover: #e8e8e8;
    --color-field: #f4f4f4;
    --color-text: #161616;
    --color-text-secondary: #525252;
    --color-text-placeholder: #6f6f6f;
    --color-border: #8d8d8d;
    --color-border-subtle: #e0e0e0;
    --color-action: #c2410c;
    --color-action-hover: #9a3412;
    --color-on-action: #ffffff;
    --color-link: #9a3412;
    --color-link-hover: #7c2d12;
    --color-focus: #c2410c;
    --color-danger: #da1e28;
    --color-danger-hover: #ba1b23;
    --color-success: #24a148;

    --header-bg: #161616;
    --header-text: #f4f4f4;
    --header-border: #393939;
    --header-hover: #2c2c2c;

    --overlay: rgba(22, 22, 22, 0.6);
    --shadow-dialog: 0 8px 24px rgba(0, 0, 0, 0.35);

    --space-1: 0.25rem;
    --space-2: 0.5rem;
    --space-3: 0.75rem;
    --space-4: 1rem;
    --space-5: 1.5rem;
    --space-6: 2rem;
    --space-7: 3rem;

    --header-height: 3rem;
}

html[data-theme="dark"] {
    --color-bg: #161616;
    --color-layer: #262626;
    --color-layer-hover: #333333;
    --color-field: #262626;
    --color-text: #f4f4f4;
    --color-text-secondary: #c6c6c6;
    --color-text-placeholder: #8d8d8d;
    --color-border: #6f6f6f;
    --color-border-subtle: #393939;
    --color-action: #ff9a62;
    --color-action-hover: #ffb784;
    --color-on-action: #161616;
    --color-link: #ffb784;
    --color-link-hover: #ffd0b0;
    --color-focus: #ffffff;
    --color-danger: #ff8389;
    --color-danger-hover: #ffb3b8;
    --color-success: #42be65;

    --header-bg: #161616;
    --header-text: #f4f4f4;
    --header-border: #393939;
    --header-hover: #2c2c2c;

    --overlay: rgba(0, 0, 0, 0.7);
    --shadow-dialog: 0 8px 24px rgba(0, 0, 0, 0.55);
}

/* --------------------------------------------------------------------------
   Base
   -------------------------------------------------------------------------- */

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

html {
    color-scheme: light;
}

html[data-theme="dark"] {
    color-scheme: dark;
}

body {
    margin: 0;
    min-height: 100vh;
    background: var(--color-bg);
    color: var(--color-text);
    font-family: var(--font-sans);
    font-size: 1rem;
    line-height: 1.5;
    -webkit-font-smoothing: antialiased;
}

h1,
h2,
h3 {
    margin: 0;
    font-weight: 600;
    line-height: 1.25;
}

h2 {
    font-size: 1.5rem;
    letter-spacing: -0.01em;
}

p {
    margin: 0 0 var(--space-4);
}

a {
    color: var(--color-link);
    text-decoration: underline;
    text-underline-offset: 0.15em;
}

a:hover {
    color: var(--color-link-hover);
}

:focus-visible {
    outline: 2px solid var(--color-focus);
    outline-offset: 2px;
}

::selection {
    background: var(--color-action);
    color: var(--color-on-action);
}

/* --------------------------------------------------------------------------
   App shell
   -------------------------------------------------------------------------- */

.app-header {
    position: sticky;
    top: 0;
    z-index: 100;
    background: var(--header-bg);
    border-bottom: 1px solid var(--header-border);
    color: var(--header-text);
}

.app-header__inner {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: var(--space-4);
    height: var(--header-height);
    max-width: 1600px;
    margin: 0 auto;
    padding: 0 clamp(1rem, 3vw, 2rem);
}

.app-brand {
    display: flex;
    align-items: center;
    gap: 0.625rem;
    min-width: 0;
    color: inherit;
    text-decoration: none;
}

.app-brand:hover {
    color: inherit;
    text-decoration: none;
}

.app-brand__mark {
    display: grid;
    place-items: center;
    flex: none;
    width: 1.5rem;
    height: 1.5rem;
    background: var(--color-action);
    color: var(--color-on-action);
    font-size: 0.875rem;
    font-weight: 600;
    line-height: 1;
}

.app-brand__name {
    font-size: 1rem;
    font-weight: 600;
    letter-spacing: 0.01em;
    white-space: nowrap;
}

.app-brand__subtitle {
    padding-left: 0.625rem;
    border-left: 1px solid var(--header-border);
    color: #c6c6c6;
    font-size: 0.8125rem;
    white-space: nowrap;
}

.app-header__actions {
    display: flex;
    align-items: center;
    gap: 0.25rem;
    flex: none;
}

.app-header .icon-button {
    color: var(--header-text);
}

.app-header .icon-button:hover {
    background: var(--header-hover);
}

.app-header .icon-button:focus-visible {
    outline-color: #ffffff;
}

@media (max-width: 480px) {
    .app-brand__subtitle {
        display: none;
    }
}

/* --------------------------------------------------------------------------
   Buttons and icons
   -------------------------------------------------------------------------- */

.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: var(--space-2);
    min-height: 2.5rem;
    padding: 0 1rem;
    border: 1px solid transparent;
    border-radius: 0;
    background: transparent;
    color: var(--color-text);
    font-family: inherit;
    font-size: 0.875rem;
    font-weight: 600;
    line-height: 1.2;
    text-align: center;
    text-decoration: none;
    cursor: pointer;
    transition: background-color 0.11s ease, border-color 0.11s ease, color 0.11s ease;
}

.btn:hover {
    text-decoration: none;
}

.btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.btn svg {
    flex: none;
    width: 1rem;
    height: 1rem;
}

.btn--primary {
    background: var(--color-action);
    color: var(--color-on-action);
}

.btn--primary:hover {
    background: var(--color-action-hover);
    color: var(--color-on-action);
}

.btn--secondary {
    border-color: var(--color-action);
    color: var(--color-action);
}

.btn--secondary:hover {
    background: var(--color-action);
    color: var(--color-on-action);
}

.btn--ghost {
    color: var(--color-text);
}

.btn--ghost:hover {
    background: var(--color-layer-hover);
}

.btn--sm {
    min-height: 2rem;
    padding: 0 var(--space-3);
    font-size: 0.8125rem;
}

.btn--lg {
    min-height: 3rem;
    padding: 0 1.25rem;
    font-size: 1rem;
}

.btn--block {
    width: 100%;
}

.icon-button {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 2.5rem;
    height: 2.5rem;
    padding: 0;
    border: 1px solid transparent;
    border-radius: 0;
    background: transparent;
    color: var(--color-text);
    cursor: pointer;
    transition: background-color 0.11s ease, color 0.11s ease;
}

.icon-button:hover {
    background: var(--color-layer-hover);
}

.icon-button svg {
    display: block;
    width: 1.25rem;
    height: 1.25rem;
}

.icon-button--danger {
    color: var(--color-danger);
    font-size: 1.25rem;
    line-height: 1;
}

.icon-button--danger:hover {
    background: var(--color-danger);
    color: #ffffff;
}

.icon-button .icon-sun {
    display: none;
}

html[data-theme="dark"] .icon-button .icon-sun {
    display: block;
}

html[data-theme="dark"] .icon-button .icon-moon {
    display: none;
}

/* --------------------------------------------------------------------------
   Workspace and panels
   -------------------------------------------------------------------------- */

.workspace {
    display: grid;
    grid-template-columns: minmax(0, 5fr) minmax(0, 7fr);
    gap: var(--space-5);
    align-items: start;
}

.panel {
    min-width: 0;
    background: var(--color-layer);
    border: 1px solid var(--color-border-subtle);
}

.panel__header {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: space-between;
    gap: var(--space-3);
    padding: var(--space-4) var(--space-5);
    border-bottom: 1px solid var(--color-border-subtle);
}

.panel__title {
    font-size: 1.25rem;
}

.panel__title-note {
    margin-left: var(--space-2);
    color: var(--color-text-secondary);
    font-size: 0.8125rem;
    font-weight: 400;
}

.panel__actions {
    display: flex;
    flex-wrap: wrap;
    gap: var(--space-2);
}

.panel__body {
    padding: var(--space-5);
}

.panel--preview .panel__body {
    padding: var(--space-3);
    background: var(--color-bg);
}

.section-title {
    margin-bottom: var(--space-5);
    font-size: 1.5rem;
}

.view-switch {
    display: none;
    background: var(--color-layer);
    border-bottom: 1px solid var(--color-border-subtle);
}

.view-switch__button {
    flex: 1;
    min-height: 3rem;
    padding: 0 var(--space-3);
    border: 0;
    border-bottom: 2px solid transparent;
    background: transparent;
    color: var(--color-text-secondary);
    font-family: inherit;
    font-size: 0.875rem;
    font-weight: 600;
    cursor: pointer;
}

.view-switch__button:hover {
    color: var(--color-text);
}

.view-switch__button[aria-pressed="true"] {
    border-bottom-color: var(--color-action);
    color: var(--color-text);
}

@media (max-width: 1023px) {
    .workspace {
        grid-template-columns: 1fr;
    }

    .view-switch {
        display: flex;
    }

    .is-hidden-mobile {
        display: none !important;
    }
}

/* --------------------------------------------------------------------------
   Form fields
   -------------------------------------------------------------------------- */

.field {
    display: flex;
    flex-direction: column;
    gap: 0.375rem;
    margin-bottom: 1.25rem;
}

.field:last-child {
    margin-bottom: 0;
}

.field__label {
    color: var(--color-text-secondary);
    font-size: 0.75rem;
    font-weight: 600;
    letter-spacing: 0.02em;
}

.field__input,
.field__textarea {
    width: 100%;
    min-height: 2.5rem;
    padding: var(--space-2) var(--space-3);
    border: 1px solid transparent;
    border-bottom: 1px solid var(--color-border);
    border-radius: 0;
    background: var(--color-field);
    color: var(--color-text);
    font-family: inherit;
    font-size: 0.875rem;
    line-height: 1.5;
}

.field__textarea {
    min-height: 5.5rem;
    resize: vertical;
}

.field__input::placeholder,
.field__textarea::placeholder {
    color: var(--color-text-placeholder);
}

.field__input:hover,
.field__textarea:hover {
    border-bottom-color: var(--color-text);
}

.field__input:focus,
.field__textarea:focus {
    outline: 2px solid var(--color-focus);
    outline-offset: -2px;
    border-bottom-color: transparent;
}

.field__row {
    display: flex;
    align-items: stretch;
    gap: var(--space-2);
    margin-bottom: var(--space-2);
}

.field__row .field__input {
    flex: 1 1 auto;
    min-width: 0;
}

.field__add {
    align-self: flex-start;
    margin-top: var(--space-1);
}

.hint {
    margin: var(--space-3) 0 0;
    color: var(--color-text-secondary);
    font-size: 0.8125rem;
    line-height: 1.4;
}

.muted {
    color: var(--color-text-secondary);
}

/* --------------------------------------------------------------------------
   Help dialog
   -------------------------------------------------------------------------- */

.help-dialog {
    width: min(36rem, calc(100vw - 2rem));
    max-height: min(90vh, 44rem);
    margin: auto;
    padding: 0;
    border: 1px solid var(--color-border-subtle);
    border-radius: 0;
    background: var(--color-layer);
    color: var(--color-text);
    box-shadow: var(--shadow-dialog);
    overflow: auto;
}

.help-dialog::backdrop {
    background: var(--overlay);
}

.help-dialog__header {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: var(--space-3);
    padding: var(--space-4) var(--space-5);
    border-bottom: 1px solid var(--color-border-subtle);
}

.help-dialog__title {
    font-size: 1.25rem;
}

.help-dialog__body {
    padding: var(--space-5);
}

.help-dialog__intro {
    color: var(--color-text-secondary);
}

.help-dialog__footer {
    display: flex;
    justify-content: flex-end;
    padding: var(--space-4) var(--space-5);
    border-top: 1px solid var(--color-border-subtle);
}

.help-steps {
    display: grid;
    gap: var(--space-3);
    margin: var(--space-5) 0;
    padding-left: 1.25rem;
}

.help-steps li {
    padding-left: var(--space-1);
}

.help-steps li::marker {
    color: var(--color-action);
    font-weight: 600;
}

.help-steps strong {
    font-weight: 600;
}

.help-dialog__note {
    margin: 0;
    padding: var(--space-3) var(--space-4);
    border-left: 2px solid var(--color-action);
    background: var(--color-bg);
    color: var(--color-text-secondary);
    font-size: 0.875rem;
}

.help-dialog__version {
    margin: var(--space-4) 0 0;
    color: var(--color-text-placeholder);
    font-family: var(--font-mono);
    font-size: 0.75rem;
}

/* --------------------------------------------------------------------------
   Utilities
   -------------------------------------------------------------------------- */

.visually-hidden {
    position: absolute !important;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
}

@media (prefers-reduced-motion: reduce) {
    *,
    *::before,
    *::after {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
    }
}
