@font-face {
    font-family: 'Inter';
    src: url('fonts/Inter-Regular.woff2') format('woff2');
    font-weight: 400;
    font-style: normal;
}

@font-face {
    font-family: 'Inter';
    src: url('fonts/Inter-Light.woff2') format('woff2');
    font-weight: 300;
    font-style: normal;
}

:root {
    --bg: #121212;
    --text: #e0e0e0;
    --border: #333333;
    --hover: #1e1e1e;
    --accent: #ffffff;
    --input-bg: transparent;
    --danger: #ff4444;
    --green: #2ecc71;
}

* { box-sizing: border-box; margin: 0; padding: 0; }

html {
    height: 100%;
    overflow: hidden;
}

body { 
    font-family: 'Inter', -apple-system, sans-serif;
    background-color: var(--bg); 
    color: var(--text); 
    height: 100%;
    height: 100dvh;
    width: 100%;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    -webkit-font-smoothing: antialiased;
}

.app-container {
    display: flex;
    flex: 1 1 auto;
    width: 100%;
    height: 100%;
    min-height: 0;
    max-height: 100%;
}

/* 1. Linke Spalte (Navigation) - EXAKT 120px */
.col-nav {
    width: 120px;
    border-right: 1px solid var(--border);
    display: flex;
    flex-direction: column;
    padding: 20px 0;
    flex-shrink: 0;
    background-color: var(--bg);
}

.nav-column-container { 
    display: flex; 
    flex-direction: column; 
    gap: 10px; 
}

.nav-item {
    padding: 12px 15px;
    margin-top: 0;
    line-height: 1;
    color: #888;
    text-decoration: none;
    font-size: 0.85rem;
    font-weight: 400;
    letter-spacing: 1px;
    transition: all 0.2s;
    text-transform: uppercase;
    display: flex;
    align-items: center;
}

.nav-item:not(:first-child) {
    margin-top: 10px;
}

.nav-item.active {
    color: var(--accent);
    background-color: #333333;
    border-left: 3px solid var(--accent);
    padding-left: 12px;
}

.nav-item:hover:not(.active) { color: #bbb; }

/* 2. Mittlere Spalte (Liste) - EXAKT 300px */
.col-list {
    width: 300px;
    border-right: 1px solid var(--border);
    display: flex;
    flex-direction: column;
    padding-top: 20px;
    flex-shrink: 0;
    min-height: 0;
    background-color: var(--bg);
}
.col-list.contacts-list {
    width: 350px;
}

.list-header {
    margin-top: 12px;
    line-height: 1;
    padding: 0 32px 20px 32px;
    border-bottom: 1px solid var(--border);
    font-size: 1rem;
    font-weight: 400;
    color: #aaa;
    letter-spacing: 0.5px;
}

.list-items { flex-grow: 1; min-height: 0; overflow-y: auto; -webkit-overflow-scrolling: touch; }

.col-workspace.projects-workspace {
    display: flex;
    flex-direction: column;
    min-width: 0;
    padding: 0;
    overflow: hidden;
}
.projects-workspace-scroll {
    flex: 1 1 auto;
    min-height: 0;
    padding: 20px 15px;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
}
.project-workspace-actions {
    flex: 0 0 auto;
    display: grid;
    grid-template-columns: repeat(5, minmax(0, 1fr));
    gap: 8px;
    padding: 12px 15px 16px;
    border-top: 1px solid var(--border);
    background: #121212;
    box-shadow: 0 -10px 24px rgba(0,0,0,0.3);
}
.project-workspace-action-form {
    margin: 0;
    min-width: 0;
    display: flex;
}
.project-workspace-actions .btn {
    min-height: 42px;
    padding: 6px 4px;
    font-size: 0.68rem;
    letter-spacing: 0.4px;
    line-height: 1.15;
    text-decoration: none;
    white-space: normal;
}

.list-item {
    padding: 20px 32px;
    border-bottom: 1px solid var(--border);
    display: flex;
    justify-content: space-between;
    align-items: center;
    transition: background-color 0.2s;
}
.list-item:hover { background-color: var(--hover); }
.list-item-content { flex-grow: 1; }
.list-item-title { font-weight: 300; font-size: 1.05rem; color: var(--text); margin-bottom: 4px; }
.list-item-meta { font-size: 0.85rem; color: #666; font-weight: 300; }
.delete-btn { 
    color: #ff4d4d; 
    text-decoration: none; 
    font-size: 1.5rem; 
    padding: 4px 8px; 
    line-height: 1; 
    transition: opacity 0.2s, transform 0.2s; 
    margin-right: -10px;
}
/* Löschvorgänge laufen jetzt über <button> in einem POST-Formular statt
   über <a>-Links (CSRF-Schutz) – hier wird die Browser-Standardoptik des
   Buttons entfernt, damit er optisch identisch zum vorherigen Link bleibt. */
button.delete-btn {
    background: none;
    border: none;
    cursor: pointer;
    font-family: inherit;
}
.list-item .delete-btn {
    transform: translateX(10px);
}
.contacts-list .list-header {
    padding: 0 12px 20px 24px;
}
.contacts-list .list-item {
    display: grid;
    grid-template-columns: minmax(0, 1fr) 36px;
    gap: 4px;
    align-items: center;
    padding: 16px 6px 16px 24px;
}
.contacts-list .list-item-content {
    min-width: 0;
}
.contacts-list .list-item-title {
    display: block;
    margin-bottom: 0;
    color: var(--text);
    text-decoration: none;
    overflow-wrap: break-word;
    word-break: break-word;
}
.company-name-wrap {
    white-space: pre-line;
    overflow-wrap: break-word;
}
.field-hint {
    margin: 6px 0 0;
    font-size: 0.8rem;
    color: #888;
    line-height: 1.35;
}
.has-v-line .field-hint {
    padding-left: 15px;
}
.contacts-list .list-item-delete {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 36px;
    margin: 0;
}
.contacts-list .list-item .delete-btn {
    transform: none;
    margin: 0;
    width: 36px;
    padding: 4px 0;
    text-align: center;
}
.delete-btn:hover { opacity: 0.7; }

.project-report-card {
    position: relative;
    display: flex;
    flex-direction: column;
    flex: 1;
    padding: 10px 12px;
    background: #111;
    border-radius: 4px;
    border: 1px solid #222;
}
.project-report-link {
    display: block;
    color: #ccc;
    font-weight: 500;
    font-size: 0.85em;
    text-decoration: none;
}
.project-report-link::after {
    content: "";
    position: absolute;
    inset: 0;
}
.project-report-status-form {
    position: relative;
    z-index: 1;
    display: flex;
    justify-content: flex-end;
    margin-top: 6px;
}
.project-report-status {
    background: none;
    border: none;
    padding: 0;
    cursor: pointer;
    font: inherit;
    font-size: 0.85em;
    text-transform: uppercase;
    letter-spacing: 1px;
}
.project-report-status.is-draft { color: orange; }
.project-report-status.is-done { color: var(--green); }
.project-report-status:hover { text-decoration: underline; }

/* 3. Rechte Spalte (Arbeitsbereich) */
.col-workspace {
    flex-grow: 1;
    min-width: 0;
    min-height: 0;
    padding: 20px 15px;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
    background-color: var(--bg);
}

.workspace-header {
    margin-top: 12px;
    margin-bottom: 24px;
    line-height: 1;
    font-size: 1.8rem;
    font-weight: 300;
    color: var(--accent);
    letter-spacing: 1px;
    text-transform: uppercase;
}

.section-header {
    margin: 16px 0 8px 0;
    font-size: 1.2rem;
    font-weight: 300;
    color: var(--accent);
    border-bottom: 1px solid var(--border);
    padding-bottom: 4px;
    letter-spacing: 1px;
    text-transform: uppercase;
}

/* Formular-Grid Logik */
.company-block {
    margin-bottom: 20px;
    padding-bottom: 20px;
    border-bottom: 1px solid #555555;
}
.project-contact-picker {
    margin-bottom: 8px;
}
.project-contact-filter {
    position: relative;
    z-index: 3;
    max-width: 420px;
    margin-bottom: 12px;
}
.project-contact-book {
    max-height: calc(100vh - 320px);
    overflow: auto;
    border: 1px solid #2a2a2a;
    background: #111;
}
.project-contact-group-title {
    padding: 8px 14px;
    font-size: 0.7rem;
    letter-spacing: 1.2px;
    text-transform: uppercase;
    color: #888;
    background: #191919;
    border-bottom: 1px solid #2a2a2a;
}
.project-contact-choice {
    display: flex;
    width: 100%;
    text-align: left;
    padding: 12px 14px;
    border: none;
    border-bottom: 1px solid #222;
    background: transparent;
    color: var(--text);
    font: inherit;
    font-size: 0.95rem;
    text-transform: uppercase;
    cursor: pointer;
}
.project-contact-choice:hover {
    background: var(--hover);
    color: #fff;
}
.project-contact-empty,
.project-contact-hint {
    color: #888;
    font-size: 0.8rem;
    line-height: 1.5;
    margin: 10px 0 0;
}
.project-contact-empty {
    padding: 16px 14px;
}

/* Liste der Projektbeteiligten (Smart-Compact Grid) */
.beteiligte-liste {
    margin-top: 16px;
    display: flex;
    flex-direction: column;
}

.company-list-header, .company-list-row {
    display: grid;
    grid-template-columns: 2fr 1.5fr 1fr 1fr 1.5fr 40px;
    gap: 15px;
    align-items: center;
}
.company-list-header {
    color: #888;
    font-size: 0.8em;
    text-transform: uppercase;
    border-bottom: 1px solid #444;
    padding-bottom: 5px;
    margin-top: 15px;
    margin-bottom: 5px;
}
.company-list-row {
    padding: 4px 0;
    border-bottom: 1px solid #222;
    font-size: 0.85em;
}
.company-list-row a { color: #aaaaaa; text-decoration: none; }
.company-list-row a:hover { color: #ffffff; text-decoration: underline; }
.company-list-row .delete-btn {
    color: #ff4444;
    transform: translateX(-10px);
    display: inline-block;
}
/* Stift-Symbol zum Bearbeiten von Ansprechpartnern – bewusst nicht rot
   (das bleibt dem Löschen-X vorbehalten), damit beide Aktionen klar unterscheidbar sind. */
.company-list-row .edit-btn {
    color: var(--accent);
    text-decoration: none;
    font-size: 1.15em;
    line-height: 1;
    padding: 4px 6px;
    display: inline-block;
    transform: translateX(-10px);
    transition: opacity 0.2s, color 0.2s;
}
.company-list-row .edit-btn:hover {
    color: #ffffff;
    text-decoration: none;
    opacity: 0.9;
}

.form-grid-50-50 {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 24px;
    margin-bottom: 24px;
}

.form-grid-4-col {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 12px;
    margin-bottom: 12px;
    align-items: flex-end; /* Damit die Buttons bündig abschließen */
}

.form-grid-3-col {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 12px;
    margin-bottom: 12px;
    align-items: flex-end;
}

.contact-firm-row {
    row-gap: 32px;
    align-items: start;
}
.contact-firm-row .form-group {
    padding-top: 16px;
    min-width: 0;
}
.contact-firm-row select {
    padding-right: 22px;
    text-transform: uppercase;
}
.contact-firm-row .form-group:has(.gewerk-select) {
    position: relative;
    z-index: 2;
}
.gewerk-select.is-open,
.open-point-gewerk.is-open {
    position: absolute;
    left: 0;
    right: 0;
    z-index: 40;
    height: auto;
    padding: 6px 8px;
    background-color: #111;
    background-image: none;
    border: 1px solid #444;
    overflow: hidden;
}
.gewerk-select.is-open option,
.open-point-gewerk.is-open option {
    padding: 5px 4px;
    line-height: 1.35;
}
.gewerk-custom-wrap {
    margin-top: 16px;
}
.gewerk-custom-wrap[hidden] {
    display: none;
}
.gewerk-custom-wrap input::placeholder {
    color: #555;
    text-transform: uppercase;
    letter-spacing: 1px;
}

.span-1 { grid-column: span 1; }
.span-2 { grid-column: span 2; }
.span-3 { grid-column: span 3; }
.span-4 { grid-column: span 4; }

.form-group {
    /* Marge unten weg, da das Gap im Grid den Abstand regelt */
    margin-bottom: 0; 
}
.form-group-single {
    /* Für Inputs außerhalb des Grids */
    margin-bottom: 24px;
    max-width: 500px;
}

/* Filigrane vertikale Linien */
.has-v-line {
    position: relative;
}
.has-v-line::before {
    content: "";
    position: absolute;
    left: 0;
    top: 20%;
    height: 60%;
    border-left: 1px solid #333333;
    pointer-events: none;
}

.has-v-line label, .has-v-line input[type="text"], .has-v-line select, .has-v-line textarea.input-contact-name {
    padding-left: 15px;
}

/* Typografie & Input Styling */
label {
    display: block;
    margin-bottom: 2px;
    font-size: 11px;
    color: #888;
    text-transform: uppercase;
    letter-spacing: 1px;
    font-weight: 400;
}

input[type="text"], input[type="time"], input[type="date"], input[type="number"], input[type="password"], select {
    width: 100%;
    padding: 4px 0;
    margin: 0;
    background-color: var(--input-bg);
    border: none;
    border-bottom: 1px solid #333333;
    color: var(--accent);
    font-size: 1rem;
    font-family: 'Inter', sans-serif;
    font-weight: 300;
    outline: none;
    border-radius: 0;
    transition: border-color 0.2s;
}

/* appearance:none nur bei Text/Zahl/Select – bei date/time würde das
   den nativen Kalender-/Uhr-Picker in Chrome/Safari/iPad oft unbenutzbar machen. */
input[type="text"], input[type="number"], input[type="password"], select {
    -webkit-appearance: none;
    appearance: none;
}

input.input-contact-name,
textarea.input-contact-name {
    text-transform: uppercase;
}
textarea.input-contact-name {
    width: 100%;
    min-height: 4.6em;
    padding: 4px 0;
    margin: 0;
    background-color: var(--input-bg);
    border: none;
    border-bottom: 1px solid #333333;
    color: var(--accent);
    font-size: 1rem;
    font-family: 'Inter', sans-serif;
    font-weight: 300;
    outline: none;
    border-radius: 0;
    resize: vertical;
    line-height: 1.35;
    white-space: pre-wrap;
}

input[type="date"], input[type="time"] {
    cursor: pointer;
    color-scheme: dark;
}

input[type="date"]::-webkit-calendar-picker-indicator,
input[type="time"]::-webkit-calendar-picker-indicator {
    cursor: pointer;
    opacity: 0.75;
    filter: invert(1);
}

.picker-icon-btn {
    background: none;
    border: none;
    padding: 0;
    margin: 0 8px 0 0;
    color: #888;
    font-size: 1rem;
    line-height: 1;
    cursor: pointer;
    flex-shrink: 0;
}
.picker-icon-btn:hover {
    color: #fff;
}

input[type="text"]:focus, input[type="time"]:focus, input[type="date"]:focus, input[type="number"]:focus, input[type="password"]:focus, select:focus {
    border-bottom-color: var(--accent);
}

select:focus {
    outline: none;
    background-color: #1a1a1a;
}

select option {
    background-color: #1a1a1a;
    color: #ffffff;
}

select {
    background-image: url("data:image/svg+xml;charset=UTF-8,%3Csvg xmlns='http://www.w3.org/2000/svg' width='24' height='24' viewBox='0 0 24 24' fill='none' stroke='%23888' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='6 9 12 15 18 9'%3E%3C/polyline%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right center;
    background-size: 16px;
    cursor: pointer;
}

input[readonly] { color: #888; border-bottom-color: #333333; }

/* Buttons */
.btn {
    padding: 0 16px;
    min-height: 44px;
    border-radius: 4px;
    font-weight: 400; 
    font-size: 12px;
    font-family: 'Inter', sans-serif;
    cursor: pointer;
    letter-spacing: 1px;
    text-transform: uppercase;
    transition: opacity 0.2s, transform 0.1s;
    width: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    text-align: center;
    white-space: nowrap;
    line-height: normal;
    padding-top: 2px; /* Visual adjustment for font baseline */
    border: none;
}
.btn:hover { opacity: 0.8; }
.btn:active { transform: scale(0.98); }

.btn-outline { background: transparent; color: #ffffff; border: 1px solid #ffffff; }
.btn-outline:hover { color: var(--accent); border-color: var(--accent); }

.btn-success-outline { background: transparent; color: var(--green); border: 1px solid var(--green); }
.btn-primary { background: var(--accent); color: #000; border: none; }

/* Responsive */
@media (max-width: 900px) {
    .app-container {
        position: absolute;
        inset: 0;
        top: env(safe-area-inset-top, 0px);
        right: env(safe-area-inset-right, 0px);
        bottom: env(safe-area-inset-bottom, 0px);
        left: env(safe-area-inset-left, 0px);
        flex-direction: column;
        width: auto;
        height: auto;
        max-height: none;
        overflow-x: hidden;
        overflow-y: auto;
        -webkit-overflow-scrolling: touch;
    }
    .col-nav { width: 100%; flex: 0 0 auto; border-right: none; border-bottom: 1px solid var(--border); flex-direction: row; padding: 0; overflow-x: auto; }
    .col-list {
        width: 100%;
        flex: 0 0 auto;
        border-right: none;
        border-bottom: 1px solid var(--border);
        max-height: 42%;
        min-height: 0;
        overflow: hidden;
    }
    .col-workspace { width: 100%; flex: 0 0 auto; height: auto; padding: 16px; min-height: 0; overflow: visible; }
    .projects-workspace { flex: 1 1 auto; height: 100%; min-height: 0; padding: 0; overflow: hidden; }
    .projects-workspace-scroll { padding: 32px 24px; }
    .project-workspace-actions { grid-template-columns: repeat(5, minmax(0, 1fr)); gap: 6px; padding: 12px 12px 16px; }
    .project-workspace-actions .btn { font-size: 0.58rem; letter-spacing: 0.2px; padding: 6px 2px; }
    .form-grid-50-50 { grid-template-columns: 1fr; gap: 24px; }
    .form-grid-4-col { grid-template-columns: 1fr; gap: 24px; }
    .form-grid-3-col { grid-template-columns: 1fr; gap: 24px; }
    .span-1, .span-2, .span-3, .span-4 { grid-column: span 1; }
}

