/* *************************************************************** */
/* * BASIS-LAYOUT & TYPOGRAFIE                                   * */
/* *************************************************************** */
body {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
    margin: 20px 40px;
    background-color: #f9f9f9;
    color: #333;
    /* Hintergrundbild */
    background-size: cover;
    background-position: center center;
    background-attachment: fixed;
    background-repeat: no-repeat;
    transition: background-image 0.5s ease-in-out; 
    background-image: 
        linear-gradient(rgba(255, 255, 255, 0.4), rgba(255, 255, 255, 0.4)),
        url('images/igel1.jpg'); 
}

main {
    max-width: 1100px; 
    margin: 0 auto;
    background: rgba(255, 255, 255, 0.9);
    padding: 20px;
    border-radius: 8px;
    box-shadow: 0 4px 12px rgba(0,0,0,0.05);
}

h1, h2 {
    color: #4a694e;
    border-bottom: 2px solid #e0e0e0;
    padding-bottom: 5px;
    text-align: center; 
    margin-top: 0;
}

/* Info-Boxen */
.igel-info-display {
    background-color: #e8f0e9;
    padding: 10px 15px;
    border-radius: 6px;
    border: 1px solid #c8dcc9;
    margin-bottom: 20px;
}
.igel-info-display h3 { margin: 0; color: #3a543e; font-weight: 600; }
.igel-info-display span { font-weight: 700; color: #1a2d1e; }

.info-banner {
    padding: 12px 18px;
    border-radius: 8px;
    font-weight: 600;
    font-size: 1.1em;
    text-align: center;
    margin-bottom: 20px;
    background-color: #e7f3fe; 
    border: 1px solid #b3d7f9;
    color: #0056b3; 
    display: none; 
}

/* *************************************************************** */
/* * HEADER & NAVIGATION                                         * */
/* *************************************************************** */

/* Grid-Layout für die obere Leiste */
.header-nav {
    display: grid;
    grid-template-columns: 1fr auto 1fr; /* Links - Mitte - Rechts */
    align-items: center;
    margin-bottom: 20px;
    padding-bottom: 10px;
    border-bottom: 2px solid #eee;
    width: 100%;
}

.nav-left { display: flex; justify-content: flex-start; gap: 15px; }
.nav-center { display: flex; justify-content: center; }
.nav-right { display: flex; justify-content: flex-end; }

/* Dashboard Header (Logo & Kalender Widget) */
.dashboard-header {
    display: flex;
    align-items: flex-start;
    justify-content: center;
    gap: 40px;
    margin-bottom: 25px;
    flex-wrap: wrap;
}

.overview-logo {
    display: block;
    max-width: 180px;
    height: auto;
    margin: 0;
    flex-shrink: 0;
}

/* Kalender Widget */
.calendar-widget {
    background: #fff;
    border: 1px solid #c8dcc9;
    border-radius: 8px;
    padding: 15px;
    width: 100%;
    max-width: 350px;
    min-height: 120px;
    box-shadow: 0 2px 4px rgba(0,0,0,0.05);
}
.calendar-widget h3 { margin-top: 0; color: #3a543e; font-size: 1.1em; border-bottom: 1px solid #eee; padding-bottom: 5px; text-align: left; }
.calendar-list { list-style: none; padding: 0; margin: 0; }
.mini-termin { padding: 8px 0; border-bottom: 1px dashed #eee; font-size: 0.9em; }
.mini-termin:last-child { border-bottom: none; }
.mini-termin-date { font-weight: bold; color: #555; margin-right: 5px; }

/* *************************************************************** */
/* * FORMULARE & INPUTS                                          * */
/* *************************************************************** */
fieldset { border: 1px solid #ccc; border-radius: 5px; margin-bottom: 20px; padding: 15px; }
legend { font-weight: bold; font-size: 1.1em; color: #4a694e; }
div.form-group { margin-bottom: 15px; }
label { display: block; margin-bottom: 5px; font-weight: 600; }

input[type="text"], input[type="email"], input[type="tel"], input[type="number"],
input[type="date"], input[type="time"], input[type="password"],
input[type="datetime-local"], textarea, select {
    width: 100%;
    padding: 8px;
    box-sizing: border-box;
    border: 1px solid #ccc;
    border-radius: 4px;
    font-size: 1em;
}
textarea { resize: vertical; min-height: 80px; }
.radio-group { display: flex; gap: 15px; flex-wrap: wrap; }
.radio-group label { font-weight: normal; }
.ziel-wahl { display: flex; align-items: center; gap: 10px; }
.ziel-wahl label { margin: 0; font-weight: normal; cursor: pointer; }

/* *************************************************************** */
/* * BUTTONS & TOOLBARS                                          * */
/* *************************************************************** */
button, .nav-button, .back-button, .home-button {
    display: inline-block; padding: 12px 25px; color: white !important; text-decoration: none;
    border: none; border-radius: 8px; cursor: pointer; font-size: 1.05em; font-weight: 700;
    background: linear-gradient(to bottom, #5d8161 0%, #4a694e 100%);
    box-shadow: 0 8px 0 #3a543e, 0 2px 5px rgba(0,0,0,0.2);
    transition: all 0.15s ease-out; text-align: center;
}
button:hover, .nav-button:hover { transform: translateY(-1px); box-shadow: 0 9px 0 #3a543e; }
button:active, .nav-button:active { transform: translateY(6px); box-shadow: 0 2px 0 #3a543e; }

.secondary { background: linear-gradient(to bottom, #7d878f 0%, #6c757d 100%); box-shadow: 0 8px 0 #5a6268; }
.secondary:hover { background: linear-gradient(to bottom, #8d979f 0%, #7c858d 100%); box-shadow: 0 9px 0 #5a6268; }
.secondary:active { background: linear-gradient(to bottom, #6c757d 0%, #7d878f 100%); box-shadow: 0 2px 0 #5a6268; }

.button-group { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.nav-buttons { display: flex; flex-wrap: wrap; gap: 15px; margin-top: 20px; justify-content: center; }

.back-button { background: linear-gradient(to bottom, #7d878f 0%, #6c757d 100%); margin-bottom: 20px; box-shadow: 0 8px 0 #5a6268; }
.back-button:hover { background: linear-gradient(to bottom, #8d979f 0%, #7c858d 100%); box-shadow: 0 9px 0 #5a6268; }
.back-button:active { background: linear-gradient(to bottom, #6c757d 0%, #7d878f 100%); box-shadow: 0 2px 0 #5a6268; }

.home-button {
    float: right; margin-left: 10px; /* Standard für Detailseiten */
}

/* DIE TOOLBAR (Hier fehlte das Flexbox!) */
.toolbar {
    display: flex;
    justify-content: space-between; /* Links Filter, Rechts Aktionen */
    align-items: center;
    flex-wrap: wrap;
    gap: 10px;
    margin-top: 15px;
    padding: 10px;
    background-color: #f4f4f4;
    border-radius: 8px;
    border: 1px solid #ddd;
}

.action-buttons { display: flex; gap: 10px; }

#filter-buttons button { padding: 8px 15px; font-size: 0.95em; }
#filter-buttons button.active { background: linear-gradient(to bottom, #5d8161 0%, #4a694e 100%); box-shadow: 0 6px 0 #3a543e; }
#filter-buttons button:not(.active) { background: linear-gradient(to bottom, #7d878f 0%, #6c757d 100%); box-shadow: 0 6px 0 #5a6268; }

#delete-button { background: linear-gradient(to bottom, #d9534f 0%, #c9302c 100%); box-shadow: 0 8px 0 #a92824; }
#delete-button:hover { background: linear-gradient(to bottom, #e06864 0%, #d44945 100%); }
#delete-button:active { background: linear-gradient(to bottom, #c9302c 0%, #d9534f 100%); box-shadow: 0 2px 0 #a92824; }

#reactivate-button { background: linear-gradient(to bottom, #007bff 0%, #0056b3 100%); box-shadow: 0 8px 0 #004085; }
#reactivate-button:hover { background: linear-gradient(to bottom, #3395ff 0%, #0069d9 100%); }
#reactivate-button:active { background: linear-gradient(to bottom, #0056b3 0%, #007bff 100%); box-shadow: 0 2px 0 #004085; }

/* *************************************************************** */
/* * TABELLEN (WICHTIG: GENERISCHE REGELN WIEDER DA!)            * */
/* *************************************************************** */
table {
    width: 100%;
    border-collapse: collapse;
    margin-top: 20px;
    background-color: #fff;
    box-shadow: 0 2px 4px rgba(0,0,0,0.1);
    table-layout: auto;
}

th, td {
    padding: 12px;
    border: 1px solid #ddd; /* RAHMEN WIEDER DA */
    text-align: left;
    vertical-align: middle;
}

th {
    background-color: #4a694e;
    color: white;
    font-weight: bold;
}

tr:nth-child(even) { background-color: #f9f9f9; }
tr:hover { background-color: #e8f0e9; cursor: pointer; }

.igel-aktiv .clickable-cell { color: #00008B; font-weight: 500; }
.igel-inaktiv .clickable-cell { color: #8B0000; }

/* Spaltenbreiten für Protokoll-Tabelle */
#protokoll-tabelle { table-layout: fixed; }
#protokoll-tabelle th:nth-child(1), #protokoll-tabelle td:nth-child(1) { width: 14%; min-width: 90px; }
#protokoll-tabelle th:nth-child(2), #protokoll-tabelle td:nth-child(2) { width: 10%; min-width: 60px; text-align: center; }
#protokoll-tabelle th:nth-child(3), #protokoll-tabelle td:nth-child(3) { width: 10%; min-width: 70px; text-align: center; }
#protokoll-tabelle th:nth-child(4), #protokoll-tabelle td:nth-child(4) { width: 23%; }
#protokoll-tabelle th:nth-child(5), #protokoll-tabelle td:nth-child(5) { width: 28%; }
#protokoll-tabelle th:nth-child(6), #protokoll-tabelle td:nth-child(6) { width: 5%; min-width: 40px; text-align: center; }
#protokoll-tabelle th:nth-child(7), #protokoll-tabelle td:nth-child(7) { width: 10%; text-align: center; }

/* *************************************************************** */
/* * SPEZIAL-ELEMENTE                                            * */
/* *************************************************************** */
.name-image-container { display: flex; flex-wrap: wrap; gap: 20px; align-items: flex-start; }
.name-upload-column { flex: 1; min-width: 300px; }
.image-preview-column { flex-shrink: 0; }
.name-suggestion { display: flex; align-items: center; gap: 10px; }
.name-suggestion input { flex-grow: 1; width: auto; }
.name-suggestion button { flex-shrink: 0; }
#igel-bild-vorschau, #protokoll-bild-vorschau { width: 250px; height: 250px; border: 2px solid #ccc; border-radius: 8px; object-fit: cover; background-color: #f0f0f0; }
.image-controls, .protokoll-image-controls { display: flex; flex-direction: column; gap: 10px; align-items: center; }
.protokoll-image-controls { align-items: flex-start; }

.upload-zone { height: 125px; border: 3px dashed #4a694e; border-radius: 8px; display: flex; flex-direction: column; justify-content: center; align-items: center; cursor: pointer; }
.upload-zone:hover { background-color: #e8f0e9; border-style: solid; }

/* Chart Toolbar */
.chart-toolbar { display: flex; justify-content: space-between; align-items: center; flex-wrap: wrap; gap: 20px; padding: 10px; background-color: #f4f4f4; border-radius: 8px; border: 1px solid #ddd; margin-bottom: 20px; }
.chart-nav { display: flex; align-items: center; gap: 10px; }
#chart-info { font-weight: 600; color: #3a543e; min-width: 200px; text-align: center; }
.round-btn { width: 32px; height: 32px; border-radius: 50%; padding: 0; display: flex; align-items: center; justify-content: center; font-size: 1.2em; background: linear-gradient(to bottom, #7d878f 0%, #6c757d 100%); box-shadow: 0 3px 0 #5a6268; color: white; border: none; cursor: pointer; }

/* Unterschrift */
.signature-wrapper { border: 2px solid #ccc; border-radius: 8px; background-color: #fff; width: 100%; max-width: 500px; touch-action: none; }
#signature-pad { width: 100%; height: 200px; cursor: crosshair; display: block; }
.signature-controls { margin-top: 5px; display: flex; justify-content: flex-end; }
#clear-signature-btn { padding: 5px 10px; font-size: 0.8em; background: #f0f0f0; border: 1px solid #ccc; color: #333; }

/* *************************************************************** */
/* * MODAL (POPUP) STYLES                                        * */
/* *************************************************************** */
.modal-overlay { display: none; position: fixed; top: 0; left: 0; width: 100%; height: 100%; background-color: rgba(0, 0, 0, 0.5); z-index: 1000; justify-content: center; align-items: center; }
.modal-content { background-color: #fff; padding: 25px; border-radius: 8px; width: 90%; max-width: 500px; box-shadow: 0 5px 15px rgba(0,0,0,0.3); animation: slideDown 0.3s ease-out; }
@keyframes slideDown { from { transform: translateY(-50px); opacity: 0; } to { transform: translateY(0); opacity: 1; } }
.modal-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 15px; border-bottom: 1px solid #eee; padding-bottom: 10px; }
.modal-header h2 { margin: 0; border: none; text-align: left; }
.close-modal { background: none; border: none; font-size: 1.5em; cursor: pointer; color: #666; box-shadow: none; padding: 0; }
.modal-footer { margin-top: 20px; display: flex; justify-content: space-between; }


/* *************************************************************** */
/* * DRUCK-ANSICHT (DIN A4 & PDF)                                * */
/* *************************************************************** */
.print-page { background-color: white !important; color: black !important; max-width: 210mm; margin: 0 auto; padding: 10mm; box-shadow: none; border-radius: 0; position: relative; }
.print-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 20px; margin-bottom: 20px; border-bottom: 2px solid #333; padding-bottom: 20px; }
.print-section h2 { font-size: 1.2em; border-bottom: 1px solid #999; color: #000; text-align: left; margin-top: 0; }
.print-row { margin-bottom: 8px; font-size: 1.2em; line-height: 1.4; }
.print-label { font-weight: bold; display: inline-block; width: 140px; }
#print-chart-container { width: 100%; height: 200px; margin-top: 10px; border: 1px solid #eee; }
#print-igel-img { max-width: 150px; max-height: 150px; border: 1px solid #ccc; float: right; object-fit: cover; }
#print-signature-img { max-width: 200px; max-height: 80px; display: block; margin-top: 5px; }
#print-protocol-table { width: 100%; border-collapse: collapse; font-size: 0.85em; margin-top: 10px; }
#print-protocol-table th, #print-protocol-table td { border: 1px solid #000; padding: 4px 8px; text-align: left; vertical-align: top; }
#print-protocol-table th { background-color: #eee; font-weight: bold; }
.print-header-logo { position: absolute; top: 0; right: 20mm; width: 30mm; height: auto; }

@media print {
    @page { size: A4; margin: 10mm; }
    body { margin: 0; padding: 0; background: white; }
    .no-print, button, .nav-buttons, .back-button, .home-button { display: none !important; }
    main { box-shadow: none; border: none; width: 100%; max-width: 100%; margin: 0; padding: 0; }
    * { -webkit-print-color-adjust: exact; print-color-adjust: exact; }
}

/* *************************************************************** */
/* * MOBILE & TABLET OPTIMIERUNG (Bis 1024px Breite)             * */
/* *************************************************************** */
@media screen and (max-width: 1024px) {
    body { margin: 10px; }
    main { padding: 15px; width: 100%; box-sizing: border-box; }
    input, textarea, select, button { font-size: 18px !important; padding: 14px; line-height: 1.5; }
    .name-image-container { flex-direction: column; }
    .name-upload-column, .image-preview-column { width: 100%; min-width: 0; }
    
    /* Header für Mobile */
    .header-nav { display: flex; flex-direction: column; gap: 15px; }
    .nav-left, .nav-center, .nav-right { width: 100%; justify-content: center; flex-wrap: wrap; }
    .nav-button, .back-button, .home-button { width: 100%; margin-bottom: 5px; text-align: center; }
    .dashboard-header { flex-direction: column; gap: 20px; }
    
    div[style="overflow-x: auto;"] { border: 1px solid #ccc; -webkit-overflow-scrolling: touch; }
    #chart-container { height: 300px; }
    .upload-zone { height: 150px; }
}