/* =================================
   GRUNDSTILE FÜR DIE SEITE
   ================================= */
body {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
    background-color: #f4f4f4;
    color: #333;
    padding: 20px;
}

main {
    max-width: 1000px;
    margin: auto;
    background-color: white;
    padding: 20px;
    border-radius: 8px;
    box-shadow: 0 2px 10px rgba(0,0,0,0.1);
}

/* =================================
   HAUPTLAYOUT DES ZAHNSCHEMAS
   ================================= */

/* Flexbox-Layout für einen Kiefer-Abschnitt (Beschriftung + Zähne) */
.jaw-section {
    display: flex;
    align-items: center; /* Vertikale Zentrierung */
    gap: 15px; /* Abstand zwischen Beschriftung und Schema */
}

/* Styling für den Beschriftungs-Block */
.row-labels {
    display: flex;
    flex-direction: column;
    justify-content: center; /* Verteilt die Labels passend zur Höhe */
	gap: 6px;
    height: 90px; /* Bleibt gleich, da dies die Höhe der 3 Input-Zeilen ist */
    flex-shrink: 0; /* Verhindert, dass der Block schrumpft */
    font-size: 0.9rem;
    font-weight: bold;
    color: #555;
    /* NEU: Breite der Labels anpassen, falls nötig */
    width: 65px; /* Beispielwert, ggf. anpassen, damit der längste Text passt */
    text-align: left; /* NEU: Rechtsbündige Ausrichtung der Labels */
}

/* NEU: Separate Positionierung für die Beschriftung des Oberkiefers */
.jaw-section:first-of-type .row-labels {
    position: relative;
    top: -10px; /* Passen Sie diesen Wert nur für den OK an */
}

/* NEU: Separate Positionierung für die Beschriftung des Unterkiefers */
.jaw-section:last-of-type .row-labels {
    position: relative;
    top: 10px; /* Passen Sie diesen Wert unabhängig für den UK an */
}

/* Container für die Quadranten eines Kiefers */
.quadrants-container {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 2px; /* NEU: Fügt 2px Abstand für die Linie hinzu */
    width: 100%;
    position: relative;
}


/* Die vertikale Linie in der Mitte der Quadranten */
.midline-vertical {
    position: absolute;
    left: 50%;
    top: 0;
    bottom: 0;
    width: 2px;
    background-color: #aaa;
    transform: translateX(-50%);
}

/* Die zentrale horizontale Linie zwischen den Kiefern */
.midline-horizontal-main {
    height: 2px;
    background-color: #aaa;
    margin: 10px 0; /* Abstand nach oben und unten */
}

/* Layout für einen einzelnen Quadranten */
.quadrant {
    display: flex;
    justify-content: flex-start; /* Standard: linksbündig */
}

/* Spezifische Ausrichtung für die rechten Patientenseiten (links am Bildschirm) */
#quadrant-1,
#quadrant-4 {
    justify-content: flex-end; /* Rechtsbündig an der Mittellinie */
}


/* =================================
   ZAHN- & INPUT-STILE
   ================================= */

/* Layout für einen einzelnen Zahn */
.tooth {
    display: flex;
    flex-direction: column; /* Ordnet Nummer und Felder untereinander an */
    align-items: center;
    margin: 2px;
}

.tooth-number {
    font-weight: bold;
    font-size: 0.9rem;
    color: #005A9F;
}

/* Positioniert die Zahnnummern für das "Koordinatenkreuz" */
#quadrant-3 .tooth-number,
#quadrant-4 .tooth-number {
    padding-bottom: 4px; /* Für den Unterkiefer: Nummer oben, Abstand nach unten */
}

#quadrant-1 .tooth-number,
#quadrant-2 .tooth-number {
    order: 1; /* Für den Oberkiefer: Verschiebt Nummer ans Ende (nach unten) */
    padding-top: 4px;
}

/* Stil für die Eingabefelder */
.tooth input[type="text"] {
    width: 35px;
    height: 22px;
    border: 1px solid #ccc;
    text-align: center;
    font-size: 0.8rem;
    padding: 2px;
    margin-bottom: 2px;
    box-sizing: border-box;
}

.tooth input[type="text"]:focus {
    outline: 2px solid #007bff;
    border-color: #007bff;
}

  .legend-container {
    font-family: Arial, sans-serif;
    display: flex;
    flex-wrap: wrap;
    gap: 20px;
    padding: 20px;
    background-color: #f9f9f9;
    border-radius: 8px;
    border: 1px solid #ddd;
  }
  .legend-section {
    flex: 1 1 300px;
  }
  .legend-title {
    font-size: 1.2em;
    font-weight: bold;
    margin-bottom: 10px;
    color: #333;
  }
  .legend-list {
    list-style-type: none;
    padding: 0;
    margin: 0;
  }
  .legend-item {
    margin-bottom: 5px;
    line-height: 1.4;
  }
  .legend-item strong {
    color: #0056b3;
  }
  .signature-section {
    margin-top: 20px;
    padding: 15px;
    border-top: 2px dashed #ccc;
  }
  .signature-section label {
    font-weight: bold;
    margin-right: 10px;
  }
  .signature-section input {
    padding: 8px;
    border: 1px solid #ccc;
    border-radius: 4px;
    width: 250px;
    font-size: 1em;
  }
  .print-button-container {
    margin-top: 20px;
    text-align: right;
  }
  .print-button {
    padding: 10px 20px;
    font-size: 1em;
    color: white;
    background-color: #007bff;
    border: none;
    border-radius: 5px;
    cursor: pointer;
    transition: background-color 0.3s ease;
  }
  .print-button:hover {
    background-color: #0056b3;
  }

/* =================================
   RESPONSIVE ANPASSUNGEN
   ================================= */
@media (max-width: 768px) {
    .tooth input[type="text"] {
        width: 30px; /* Etwas schmalere Felder auf Tablets */
    }
    .quadrants-container {
        gap: 5px;
    }
}

@media (max-width: 600px) {
    body { 
        padding: 5px; 
    }
    main { 
        padding: 10px; 
    }
    
    .tooth input[type="text"] {
        width: 24px; /* Noch schmalere Felder auf Handys */
        height: 20px;
        font-size: 0.7rem;
    }
    .tooth-number {
        font-size: 0.8rem;
    }
}