/* --- Reset & Basis --- */
*, *::before, *::after {
    box-sizing: border-box;
}

body {
    font-family: Arial, Helvetica, sans-serif;
    background: #f5f5f5;
    margin: 0;
    padding: 10px;
    line-height: 1.6;
    color: #333;
}

/* --- Hauptcontainer --- */
.container {
    max-width: 800px;
    margin: auto;
    background: #fff;
    padding: 20px;
    border-radius: 8px;
    box-shadow: 0 2px 8px rgba(0,0,0,.1);
    width: 100%;
}

/* --- Hilfsklassen --- */
.hidden {
    display: none !important;
}

/* --- Frage-Box (Aktuelle Frage) --- */
.box {
    border: 2px solid #007bff;
    border-radius: 6px;
    padding: 20px;
    text-align: center;
    cursor: pointer;
    position: relative;
    word-wrap: break-word;
    margin-bottom: 20px;
}

.box-header {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 15px;
    margin-bottom: 15px;
}

.box-logo {
    width: 60px;
    height: auto;
    max-width: 25vw;
    flex-shrink: 0;
}

.box .label {
    font-size: 1.1rem;
    color: #555;
}

.box .question {
    font-size: 1.3rem;
    margin-top: 10px;
    font-weight: bold;
    color: #222;
}

/* --- Bewertungsbereich (Hauptseite) --- */
#rating-area {
    margin-top: 20px;
    text-align: center;
}

#rating-area button {
    margin: 5px;
    padding: 10px 15px;
    font-size: 1rem;
    border-radius: 4px;
    border: none;
    cursor: pointer;
    width: 100%;
    max-width: 200px;
    display: inline-block;
    transition: all 0.2s;
    font-weight: 600;
}

/* Gut - Grün */
#rating-area button[data-rating="good"] {
    background-color: #28a745;
    color: white;
}

#rating-area button[data-rating="good"]:hover {
    background-color: #218838;
}

/* Neutral - Grau */
#rating-area button[data-rating="neutral"] {
    background-color: #6c757d;
    color: white;
}

#rating-area button[data-rating="neutral"]:hover {
    background-color: #5a6268;
}

/* Schlecht - Rot */
#rating-area button[data-rating="bad"] {
    background-color: #dc3545;
    color: white;
}

#rating-area button[data-rating="bad"]:hover {
    background-color: #c82333;
}

/* --- Archiv-Liste --- */
#archive-heading {
    margin-top: 30px;
    font-size: 1.5rem;
    color: #333;
}

#archive-list {
    list-style: none;
    padding: 0;
    margin-top: 20px;
}

#archive-list li {
    margin: 10px 0;
    padding: 10px;
    border-bottom: 1px solid #ddd;
    background: #fafafa;
    border-radius: 4px;
}

/* Archiv-Header (Klickbereich) */
.archive-header {
    cursor: pointer;
    padding: 10px;
    background-color: #f9f9f9;
    border: 1px solid #ddd;
    border-radius: 4px;
    margin-bottom: 4px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-size: 0.95rem;
    transition: background-color 0.2s;
}

.archive-header:hover {
    background-color: #eee;
}

.archive-toggle {
    font-weight: bold;
    color: #007bff;
    font-size: 0.9rem;
}

/* Archiv-Details (Versteckter Inhalt) */
.archive-details {
    display: none;
    padding: 10px;
    background-color: #fff;
    border: 1px solid #ddd;
    border-top: none;
    border-radius: 0 0 4px 4px;
    font-size: 0.9rem;
    color: #555;
}

.archive-details.open {
    display: block;
}

/* --- Archiv-Bewertungsbuttons --- */
.archive-rate-btn {
    border: none;
    border-radius: 4px;
    font-size: 0.9rem;
    padding: 8px 12px;
    margin: 4px;
    cursor: pointer;
    transition: all 0.2s;
    font-weight: 600;
    color: white;
}

/* Gut - Grün */
.archive-rate-btn[data-rating="good"] {
    background-color: #28a745;
}

.archive-rate-btn[data-rating="good"]:hover {
    background-color: #218838;
}

/* Neutral - Grau */
.archive-rate-btn[data-rating="neutral"] {
    background-color: #6c757d;
}

.archive-rate-btn[data-rating="neutral"]:hover {
    background-color: #5a6268;
}

/* Schlecht - Rot */
.archive-rate-btn[data-rating="bad"] {
    background-color: #dc3545;
}

.archive-rate-btn[data-rating="bad"]:hover {
    background-color: #c82333;
}

/* Statistik-Block für bewertete Fragen */
.archive-rating .success-message {
    font-weight: bold;
    margin: 10px 0;
    padding: 10px;
    border: 1px solid #c3e6cb;
    border-radius: 4px;
    background-color: #d4edda;
    color: #155724;
}

/* --- Accordion (Impressum/Info) --- */
#accordion-section {
    margin-top: 20px;
    margin-bottom: 20px;
}

.accordion-item {
    border: 1px solid #ddd;
    border-radius: 6px;
    margin-bottom: 8px;
    overflow: hidden;
    background: #fafafa;
}

.accordion-header {
    width: 100%;
    padding: 12px 15px;
    background: #f0f0f0;
    border: none;
    cursor: pointer;
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-size: 1rem;
    font-weight: 600;
    color: #333;
    transition: background-color 0.2s;
}

.accordion-header:hover {
    background: #e0e0e0;
}

.accordion-header:focus {
    outline: 2px solid #007bff;
    outline-offset: -2px;
}

.accordion-icon {
    font-size: 0.8rem;
    transition: transform 0.2s;
}

.accordion-content {
    padding: 15px;
    background: #fff;
    border-top: 1px solid #ddd;
    font-size: 0.95rem;
    line-height: 1.5;
    color: #555;
}

.accordion-content.hidden {
    display: none;
}

.accordion-content p {
    margin: 0 0 10px 0;
}

.accordion-content p:last-child {
    margin-bottom: 0;
}

/* --- Toast-Benachrichtigung --- */
#toast-notification {
    visibility: hidden;
    min-width: 250px;
    background-color: #333;
    color: #fff;
    text-align: center;
    border-radius: 4px;
    padding: 16px;
    position: fixed;
    z-index: 1001;
    left: 50%;
    bottom: 30px;
    transform: translateX(-50%);
    font-size: 1rem;
    opacity: 0;
    transition: opacity 0.3s, bottom 0.3s;
    width: 90%;
    max-width: 350px;
}

#toast-notification.show {
    visibility: visible;
    opacity: 1;
    bottom: 50px;
}

#toast-notification.error {
    background-color: #d9534f;
}

/* --- Modal (Admin) --- */
.modal {
    position: fixed;
    top: 0; left: 0; right: 0; bottom: 0;
    background: rgba(0,0,0,0.5);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
    padding: 10px;
}

.modal.hidden {
    display: none !important;
}

.modal-content {
    background: #fff;
    padding: 20px;
    border-radius: 8px;
    width: 90%;
    max-width: 500px;
    max-height: 90vh;
    overflow-y: auto;
    box-shadow: 0 2px 10px rgba(0,0,0,.2);
}

/* --- Admin-Tabelle --- */
#stats-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.9rem;
    display: table;
    margin-top: 15px;
}

#stats-table th, #stats-table td {
    border: 1px solid #ddd;
    padding: 8px;
    text-align: left;
    white-space: nowrap;
}

#stats-table th {
    background-color: #f8f9fa;
    font-weight: 600;
}

/* Sortierbare Spalten */
#stats-table th[data-column] {
    cursor: pointer;
    user-select: none;
    position: relative;
}

#stats-table th[data-column]:hover {
    background-color: #e9ecef;
}

#stats-table th[data-column]::after {
    content: ' ⇅';
    opacity: 0.5;
    margin-left: 4px;
}

#stats-table th[data-column].sort-asc::after {
    content: ' ▲';
    opacity: 1;
}

#stats-table th[data-column].sort-desc::after {
    content: ' ▼';
    opacity: 1;
}

/* --- Section Buttons (Lazy Loading) --- */
.section-buttons {
    display: flex;
    flex-direction: column;
    gap: 10px;
    margin-bottom: 20px;
}

.section-toggle {
    padding: 12px 15px;
    background: #007bff;
    color: white;
    border: none;
    border-radius: 4px;
    cursor: pointer;
    text-align: left;
    font-size: 1rem;
    transition: background-color 0.2s;
    width: 100%;
}

.section-toggle:hover {
    background: #0056b3;
}

.section-toggle:active {
    background: #004085;
}

.section-content {
    margin-top: 20px;
    padding: 15px;
    background: #f9f9f9;
    border-radius: 4px;
    border: 1px solid #ddd;
}

/* --- Filter Bar --- */
.filter-bar {
    display: flex;
    gap: 15px;
    margin-bottom: 15px;
    padding: 10px;
    background: #f0f0f0;
    border-radius: 4px;
    flex-wrap: wrap;
    align-items: center;
}

.filter-bar label {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 0.9rem;
}

.filter-bar select {
    padding: 6px 10px;
    border: 1px solid #ddd;
    border-radius: 4px;
    font-size: 0.9rem;
    min-width: 150px;
}

.filter-bar button {
    padding: 6px 12px;
    background: #28a745;
    color: white;
    border: none;
    border-radius: 4px;
    cursor: pointer;
    font-size: 0.9rem;
}

.filter-bar button:hover {
    background: #218838;
}

/* --- Pagination --- */
.pagination {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 15px;
    margin-top: 20px;
    padding: 10px;
}

.pagination button {
    padding: 8px 16px;
    background: #007bff;
    color: white;
    border: none;
    border-radius: 4px;
    cursor: pointer;
    font-size: 0.9rem;
    transition: background-color 0.2s;
}

.pagination button:hover:not(:disabled) {
    background: #0056b3;
}

.pagination button:disabled {
    background: #ccc;
    cursor: not-allowed;
    opacity: 0.6;
}

#page-info {
    font-size: 0.9rem;
    color: #666;
    min-width: 150px;
    text-align: center;
}

/* --- Tabelle Container für Responsive Design --- */
.table-wrapper {
    overflow-x: auto;
    margin-top: 15px;
    border: 1px solid #ddd;
    border-radius: 4px;
}

#stats-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.9rem;
    min-width: 800px;
    display: table;
}

#stats-table th, #stats-table td {
    border: 1px solid #ddd;
    padding: 8px;
    text-align: left;
    white-space: nowrap;
}

@media (min-width: 1200px) {
    #stats-table th, #stats-table td {
        white-space: normal;
    }
}

/* --- Kategorie-Section --- */
#category-section {
    margin-bottom: 20px;
    padding: 15px;
    background: #f9f9f9;
    border-radius: 4px;
}

/* --- Intensitäts-Level Visualisierung --- */
#intensity-level, #edit-intensity-level {
    width: 80px;
}

.level-indicator {
    display: inline-block;
    padding: 4px 8px;
    border-radius: 4px;
    font-size: 0.85rem;
    margin-left: 10px;
}

.level-low { background: #d4edda; color: #155724; }
.level-medium { background: #fff3cd; color: #856404; }
.level-high { background: #f8d7da; color: #721c24; }

/* --- Formular Elemente --- */
input[type="text"],
input[type="password"],
input[type="number"],
input[type="date"],
textarea,
select {
    padding: 8px 10px;
    border: 1px solid #ddd;
    border-radius: 4px;
    font-size: 1rem;
    width: 100%;
    max-width: 400px;
}

input[type="text"]:focus,
input[type="password"]:focus,
input[type="number"]:focus,
input[type="date"]:focus,
textarea:focus,
select:focus {
    outline: none;
    border-color: #007bff;
    box-shadow: 0 0 0 2px rgba(0,123,255,0.25);
}

textarea {
    resize: vertical;
    min-height: 80px;
}

button {
    padding: 10px 20px;
    background: #007bff;
    color: white;
    border: none;
    border-radius: 4px;
    cursor: pointer;
    font-size: 1rem;
    transition: background-color 0.2s;
}

button:hover {
    background: #0056b3;
}

button:active {
    background: #004085;
}

/* --- Media Queries --- */

/* Tablet & Desktop (ab 600px) */
@media (min-width: 600px) {
    #rating-area button {
        width: auto;
        max-width: none;
    }
    
    #stats-table {
        display: table;
    }
    
    .box-logo {
        width: 80px;
        max-width: 100px;
    }
    
    .filter-bar {
        flex-wrap: nowrap;
    }
    
    .filter-bar select {
        min-width: 180px;
    }
}

/* Mobile (unter 480px) */
@media (max-width: 480px) {
    body {
        padding: 5px;
    }
    
    .container {
        padding: 15px;
    }
    
    h1 {
        font-size: 1.5rem;
    }
    
    h2 {
        font-size: 1.2rem;
    }
    
    input[type="text"], 
    input[type="password"], 
    textarea {
        width: 100%;
        padding: 8px;
        margin-bottom: 10px;
    }
    
    button {
        width: 100%;
        margin: 5px 0;
    }
    
    .box-header {
        flex-direction: row;
        gap: 10px;
    }
    
    .box-logo {
        width: 40px;
        max-width: 20vw;
    }
    
    .box .label {
        font-size: 1rem;
    }
    
    .accordion-header {
        padding: 10px 12px;
        font-size: 0.95rem;
    }
    
    .accordion-content {
        padding: 12px;
        font-size: 0.9rem;
    }
    
    .section-toggle {
        font-size: 0.95rem;
        padding: 10px 12px;
    }
    
    .filter-bar {
        flex-direction: column;
        align-items: stretch;
    }
    
    .filter-bar label {
        flex-direction: column;
        align-items: flex-start;
    }
    
    .filter-bar select {
        width: 100%;
        min-width: auto;
    }
    
    .pagination {
        flex-direction: column;
        gap: 10px;
    }
    
    .pagination button {
        width: 100%;
    }
    
    #page-info {
        width: 100%;
    }
}

/* --- Admin-Spezifische Styles --- */
#login-section {
    max-width: 400px;
    margin: 0 auto;
    padding: 20px;
    background: #f9f9f9;
    border-radius: 4px;
}

#login-msg {
    margin-top: 10px;
    color: #d9534f;
    font-weight: bold;
}

#add-msg, #category-msg, #edit-msg, #schedule-msg {
    margin-top: 10px;
    font-weight: bold;
}

#add-msg:empty, #category-msg:empty, #edit-msg:empty, #schedule-msg:empty {
    display: none;
}

.btn-edit, .btn-edit-schedule, .btn-add-schedule, .btn-edit-category {
    padding: 5px 10px;
    font-size: 0.85rem;
    margin-right: 5px;
}

.btn-edit {
    background: #17a2b8;
    color: white;
}

.btn-edit:hover {
    background: #138496;
}

.btn-edit-schedule {
    background: #ffc107;
    color: black;
}

.btn-edit-schedule:hover {
    background: #e0a800;
}

.btn-add-schedule {
    background: #28a745;
    color: white;
}

.btn-add-schedule:hover {
    background: #218838;
}

.btn-edit-category {
    background: #6c757d;
    color: white;
}

.btn-edit-category:hover {
    background: #5a6268;
}

/* --- Logout Button --- */
#logout-btn {
    background: #dc3545;
    float: right;
    margin-bottom: 20px;
}

#logout-btn:hover {
    background: #c82333;
}

/* --- Clearfix für Float --- */
.clearfix::after {
    content: "";
    display: table;
    clear: both;
}

#stats-table th[data-column].sort-asc::after {
    content: ' ▲';
    opacity: 1;
}

#stats-table th[data-column].sort-desc::after {
    content: ' ▼';
    opacity: 1;
}

/* Obere Pagination */
.pagination-top {
    margin-bottom: 10px;
}

.pagination-bottom {
    margin-top: 20px;
}

/* Filter-Bar mit mehr Optionen */
.filter-bar {
    display: flex;
    gap: 15px;
    margin-bottom: 15px;
    padding: 10px;
    background: #f0f0f0;
    border-radius: 4px;
    flex-wrap: wrap;
    align-items: center;
}

.filter-bar label {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 0.9rem;
}

.filter-bar select {
    padding: 6px 10px;
    border: 1px solid #ddd;
    border-radius: 4px;
    font-size: 0.9rem;
    min-width: 150px;
}

/* Responsive: Filter-Bar auf Mobile */
@media (max-width: 768px) {
    .filter-bar {
        flex-direction: column;
        align-items: stretch;
    }
    
    .filter-bar label {
        flex-direction: column;
        align-items: flex-start;
    }
    
    .filter-bar select {
        width: 100%;
        min-width: auto;
    }
}