/* Allgemeine Stile */
body {
    background-color: #f8f9fa;
    font-family: system-ui, -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
}

/* Header-Stile */
header {
    border-bottom: 2px solid #dee2e6;
    padding-bottom: 1rem;
    margin-bottom: 2rem;
}

/* Konfigurationsbereich */
.card {
    box-shadow: 0 0.125rem 0.25rem rgba(0, 0, 0, 0.075);
    border: 1px solid rgba(0, 0, 0, 0.125);
    transition: box-shadow 0.15s ease-in-out;
}

.card:hover {
    box-shadow: 0 0.5rem 1rem rgba(0, 0, 0, 0.15);
}

.card-header {
    background-color: #f8f9fa;
    border-bottom: 1px solid rgba(0, 0, 0, 0.125);
    cursor: pointer;
    transition: background-color 0.15s ease-in-out;
}

.card-header:hover {
    background-color: #e9ecef;
}

/* Wochenkarten */
.week-card {
    margin-bottom: 0.75rem;
    border: 1px solid #dee2e6;
    border-radius: 0.375rem;
    overflow: hidden;
}

.week-card .card-header {
    background-color: #0d6efd;
    color: white;
    font-weight: 600;
}

.week-card .card-body {
    padding: 0.4rem;
}

/* Header-Zeilen - Hidden on all screen sizes */
.header-row {
    display: none;
}

.header-cell {
    display: none;
}

.date-header {
    display: none;
}

/* Tageszeilen - Mobile-first with colored sections */
.day-row {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    padding: 0.75rem;
    margin-bottom: 0.75rem;
    background-color: #ffffff;
    border: 1px solid #dee2e6;
    border-radius: 0.375rem;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
    transition: background-color 0.15s ease-in-out;
}

.day-row:hover {
    background-color: #f8f9fa;
}

.day-row:last-child {
    margin-bottom: 0;
}

/* Sonntags-Hervorhebung */
.day-row.sunday {
    background-color: #f8f9fa;
}

.day-row.sunday:hover {
    background-color: #e9ecef;
}

/* Datum-Anzeige */
.day-date {
    font-weight: 600;
    color: #495057;
    text-align: center;
    padding: 0.375rem;
    border-radius: 0.25rem;
    background-color: #e9ecef;
    font-size: 0.95rem;
    margin-bottom: 0.25rem;
}

.day-date.sunday {
    background-color: #d6d8db;
    color: #6c757d;
}

/* Section titles - Always visible */
.section-title {
    display: block;
    font-size: 0.8rem;
    font-weight: 600;
    color: #495057;
    margin-bottom: 0.375rem;
    padding-bottom: 0.2rem;
    border-bottom: 1px solid #dee2e6;
}

/* Field labels - Always visible */
.field-label {
    display: block;
    font-size: 0.7rem;
    font-weight: 600;
    color: #6c757d;
    margin-bottom: 0.2rem;
}

/* Colored sections - Applied at all screen sizes */
.time-travel-section,
.work-section,
.location-section,
.notes-section {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    padding: 0.5rem;
    background-color: #f8f9fa;
    border-radius: 0.3rem;
    border: 1px solid #e9ecef;
}

.time-travel-section {
    background-color: #e3f2fd;
    border-color: #bbdefb;
}

.work-section {
    background-color: #f3e5f5;
    border-color: #e1bee7;
}

.location-section {
    background-color: #e8f5e8;
    border-color: #c8e6c9;
}

.notes-section {
    background-color: #fce4ec;
    border-color: #f8bbd9;
}

/* Field containers */
.field-container {
    display: flex;
    flex-direction: column;
    margin-bottom: 0.25rem;
}

/* Input groups - Ensure inline layout for copy buttons */
.input-group {
    display: flex;
    flex-direction: row;
    align-items: stretch;
    width: 100%;
}

.input-group .form-control,
.input-group .form-select,
.input-group textarea {
    flex: 1 1 auto;
    min-width: 0;
}

/* Copy buttons - Always inline with inputs */
.copy-btn {
    flex: 0 0 auto;
    padding: 0.25rem 0.4rem;
    font-size: 0.7rem;
    min-width: 32px;
    border-top-left-radius: 0;
    border-bottom-left-radius: 0;
}

.input-group-sm .copy-btn {
    border-top-left-radius: 0;
    border-bottom-left-radius: 0;
}

/* Formular-Stile */
.form-control-sm {
    font-size: 0.8rem;
    padding: 0.25rem 0.4rem;
    max-width: 100%;
}

/* Time input specific styling - Fixed width */
input.time-input.form-control-sm,
input[type="time"].form-control-sm {
    width: 75px;
    min-width: 75px;
    max-width: 75px;
    text-align: center;
    font-family: 'Courier New', monospace;
    letter-spacing: 1px;
    flex: 0 0 75px;
}

/* Travel duration input styling - Fixed width */
input[type="number"].form-control-sm {
    width: 75px;
    min-width: 75px;
    max-width: 75px;
    text-align: center;
    flex: 0 0 75px;
}

/* Checkbox styling */
.form-check-input {
    width: 1.2em;
    height: 1.2em;
    margin: 0;
}

.form-check.d-flex {
    min-height: 32px;
    align-items: center;
}

/* Select and textarea styling */
.form-select-sm {
    font-size: 0.8rem;
    padding: 0.25rem 0.4rem;
}

textarea.form-control-sm {
    font-size: 0.8rem;
    padding: 0.25rem 0.4rem;
    line-height: 1.25;
    min-height: 60px;
    resize: vertical;
}

/* Invalid state styling for time inputs */
.time-input.is-invalid {
    border-color: #dc3545;
    background-color: #f8d7da;
}

.time-input.is-invalid:focus {
    border-color: #dc3545;
    box-shadow: 0 0 0 0.2rem rgba(220, 53, 69, 0.25);
}

/* Button-Stile */
.btn {
    transition: all 0.15s ease-in-out;
}

.btn:hover {
    transform: translateY(-1px);
}

.btn-sm {
    padding: 0.25rem 0.5rem;
    font-size: 0.875rem;
}

/* Button group for week actions */
.week-card .btn-group {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
}

/* Save button */
.btn-primary {
    background-color: #0d6efd;
    border-color: #0d6efd;
}

.btn-primary:hover {
    background-color: #0b5ed7;
    border-color: #0a58ca;
}

/* Import button */
.btn-secondary {
    background-color: #6c757d;
    border-color: #6c757d;
}

.btn-secondary:hover {
    background-color: #5c636a;
    border-color: #565e64;
}

/* Export-Button */
.btn-export {
    background-color: #198754;
    border-color: #198754;
}

.btn-export:hover {
    background-color: #157347;
    border-color: #157347;
}

/* Weekend section styles */
.weekend-section {
    border-top: 2px solid #dee2e6;
    padding-top: 0.75rem;
    margin-top: 0.75rem;
}

.weekend-header {
    background-color: #f8f9fa;
    padding: 0.5rem 0.75rem;
    border-radius: 0.3rem;
    cursor: pointer;
    transition: background-color 0.15s ease-in-out;
    border: 1px solid #dee2e6;
}

.weekend-header:hover {
    background-color: #e9ecef;
}

.weekend-header h6 {
    color: #495057;
    font-weight: 600;
}

.weekend-header i.bi-chevron-right {
    transition: transform 0.2s ease-in-out;
}

.weekend-header[aria-expanded="true"] i.bi-chevron-right {
    transform: rotate(90deg);
}

.weekend-body {
    padding: 0.5rem 0;
}

/* ===== TABLET BREAKPOINT (768px - 1199px) ===== */
@media (min-width: 768px) {

    /* HIGH DENSITY MULTI-COLUMN LAYOUT - 2x2 grid */
    .day-row {
        display: grid;
        grid-template-columns: 80px repeat(2, minmax(260px, 300px));
        grid-auto-rows: 1fr;
        gap: 0.4rem;
        padding: 0.4rem;
        margin-bottom: 0.5rem;
        align-items: stretch;
    }

    /* Date takes first column, spans all rows */
    .day-date {
        grid-column: 1;
        grid-row: 1 / -1;
        text-align: center;
        padding: 0.3rem;
        font-size: 0.85rem;
        min-width: 80px;
    }

    /* Explicitly position each section in 2x2 grid */
    .time-travel-section {
        grid-column: 2;
        grid-row: 1;
    }

    .work-section {
        grid-column: 3;
        grid-row: 1;
    }

    .location-section {
        grid-column: 2;
        grid-row: 2;
    }

    .notes-section {
        grid-column: 3;
        grid-row: 2;
    }

    /* Tighter section spacing */
    .time-travel-section,
    .work-section,
    .location-section,
    .notes-section {
        gap: 0.3rem;
        padding: 0.35rem;
        max-width: 300px;
        height: 100%;
        align-self: stretch;
    }

    .section-title {
        font-size: 0.75rem;
        margin-bottom: 0.25rem;
    }

    .field-label {
        font-size: 0.68rem;
        margin-bottom: 0.15rem;
    }

    .field-container {
        margin-bottom: 0.2rem;
    }

    /* Time inputs inline in time-travel section */
    .time-travel-section {
        display: grid;
        grid-template-columns: 1fr 1fr;
        gap: 0.3rem;
    }

    .time-travel-section .section-title {
        grid-column: 1 / -1;
    }

    /* Travel duration on second row, first column - right-aligned */
    .time-travel-section .field-container:nth-child(4) {
        grid-column: 1;
        justify-self: end;
    }

    /* Transport mode spans both columns */
    .time-travel-section .field-container:has(select) {
        grid-column: 1 / -1;
    }

    /* Copy button sizing */
    .copy-btn {
        padding: 0.2rem 0.3rem;
        font-size: 0.68rem;
        min-width: 28px;
    }

    .week-card {
        margin-bottom: 0.6rem;
    }

    .week-card .card-body {
        padding: 0.35rem;
    }
}

/* ===== DESKTOP BREAKPOINT (1200px+) ===== */
@media (min-width: 1200px) {

    /* ULTRA HIGH DENSITY - 4 columns in one row */
    .day-row {
        grid-template-columns: 90px minmax(320px, 380px) repeat(3, minmax(250px, 290px));
        grid-auto-rows: 1fr;
        gap: 0.35rem;
        padding: 0.35rem;
        margin-bottom: 0.4rem;
    }

    .day-date {
        grid-column: 1;
        grid-row: 1;
        min-width: 90px;
        font-size: 0.8rem;
        padding: 0.25rem;
    }

    /* All sections in one row */
    .time-travel-section {
        grid-column: 2;
        grid-row: 1;
    }

    .work-section {
        grid-column: 3;
        grid-row: 1;
    }

    .location-section {
        grid-column: 4;
        grid-row: 1;
    }

    .notes-section {
        grid-column: 5;
        grid-row: 1;
    }

    /* Ultra-compact sections */
    .work-section,
    .location-section,
    .notes-section {
        gap: 0.25rem;
        padding: 0.3rem;
        max-width: 290px;
        display: flex;
        flex-direction: column;
        height: 100%;
        align-self: stretch;
    }

    /* Time travel section needs more width for horizontal layout */
    .time-travel-section {
        gap: 0.25rem;
        padding: 0.3rem;
        max-width: 380px;
        display: grid;
        grid-template-areas:
            "title title title"
            "departure return travel"
            "transport transport transport";
        grid-template-columns: 1fr 1fr 1fr;
        justify-content: space-between;
        height: 100%;
        align-self: stretch;
    }

    .time-travel-section .section-title {
        grid-area: title;
    }

    .time-travel-section .field-container:nth-child(2) {
        grid-area: departure;
    }

    .time-travel-section .field-container:nth-child(3) {
        grid-area: return;
    }

    .time-travel-section .field-container:nth-child(4) {
        grid-area: travel;
        justify-self: end;
    }

    .time-travel-section .field-container:nth-child(5) {
        grid-area: transport;
    }

    .section-title {
        font-size: 0.72rem;
        margin-bottom: 0.2rem;
        padding-bottom: 0.15rem;
    }

    .field-label {
        font-size: 0.65rem;
        margin-bottom: 0.1rem;
    }

    .field-container {
        margin-bottom: 0.15rem;
    }

    /* Tighter copy buttons */
    .copy-btn {
        padding: 0.18rem 0.28rem;
        font-size: 0.65rem;
        min-width: 26px;
    }

    .week-card {
        margin-bottom: 0.5rem;
    }

    .week-card .card-body {
        padding: 0.3rem;
    }
}

/* ===== EXTRA LARGE SCREENS (1400px+) ===== */
@media (min-width: 1400px) {

    /* MAXIMUM DENSITY */
    .day-row {
        grid-template-columns: 100px minmax(340px, 400px) repeat(3, minmax(270px, 300px));
        grid-auto-rows: 1fr;
        gap: 0.3rem;
        padding: 0.3rem;
    }

    .day-date {
        min-width: 100px;
    }

    /* Sections maintain their max-width and equal height */
    .time-travel-section {
        max-width: 400px;
        height: 100%;
        align-self: stretch;
    }

    .work-section,
    .location-section,
    .notes-section {
        max-width: 300px;
        height: 100%;
        align-self: stretch;
    }
}

/* ===== MOBILE SPECIFIC (max-width: 767px) ===== */
@media (max-width: 767px) {

    /* Maintain touch-friendly sizing on mobile */
    .form-control-sm,
    .form-select-sm {
        min-height: 38px;
        font-size: 1rem;
    }

    textarea.form-control-sm {
        min-height: 70px;
        font-size: 1rem;
    }

    .copy-btn {
        min-width: 38px;
        padding: 0.4rem;
        font-size: 0.75rem;
    }

    .day-date {
        font-size: 1rem;
        padding: 0.4rem;
    }

    /* Ensure sections have adequate spacing on mobile */
    .time-travel-section,
    .work-section,
    .location-section,
    .notes-section {
        gap: 0.6rem;
        padding: 0.6rem;
        margin-bottom: 0.5rem;
    }

    .section-title {
        font-size: 0.85rem;
        margin-bottom: 0.4rem;
    }

    .field-label {
        font-size: 0.75rem;
        margin-bottom: 0.25rem;
    }

    .field-container {
        margin-bottom: 0.4rem;
    }

    /* Mobile time inputs */
    input.time-input.form-control-sm,
    input[type="time"].form-control-sm {
        width: 70px;
        min-width: 70px;
        max-width: 70px;
        flex: 0 0 70px;
    }

    input[type="number"].form-control-sm {
        width: 70px;
        min-width: 70px;
        max-width: 70px;
        flex: 0 0 70px;
    }
}

/* ===== SMALL MOBILE (max-width: 576px) ===== */
@media (max-width: 576px) {
    .container-fluid {
        padding-left: 0.5rem;
        padding-right: 0.5rem;
    }

    .week-card {
        margin-bottom: 0.75rem;
    }

    .btn-sm {
        font-size: 0.8rem;
        padding: 0.2rem 0.4rem;
    }

    /* Smaller time inputs on very small screens */
    input.time-input.form-control-sm,
    input[type="time"].form-control-sm {
        width: 65px;
        min-width: 65px;
        max-width: 65px;
        flex: 0 0 65px;
    }

    input[type="number"].form-control-sm {
        width: 65px;
        min-width: 65px;
        max-width: 65px;
        flex: 0 0 65px;
    }

    .copy-btn {
        min-width: 36px;
        padding: 0.35rem;
    }
}

/* Tooltip-Stile */
.tooltip {
    font-size: 0.875rem;
}

/* Ladeindikator */
.loading {
    opacity: 0.6;
    pointer-events: none;
}

/* Spezielle Stile für Kalender */
#calendarContainer {
    min-height: 400px;
}

.week-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.week-number {
    background-color: rgba(255, 255, 255, 0.2);
    padding: 0.25rem 0.5rem;
    border-radius: 0.25rem;
    font-size: 0.875rem;
}

/* Footer-Stile */
footer {
    border-top: 2px solid #dee2e6;
    padding-top: 2rem;
    margin-top: 3rem;
}

/* Animationen */
@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(10px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.week-card {
    animation: fadeIn 0.3s ease-in-out;
}

/* Fokus-Stile für Barrierefreiheit */
.btn:focus,
.form-control:focus,
.form-check-input:focus {
    box-shadow: 0 0 0 0.2rem rgba(13, 110, 253, 0.25);
    border-color: #86b7fe;
}

/* Druck-Stile */
@media print {
    body {
        background-color: white;
        font-size: 12pt;
    }

    .btn,
    .card-header[data-bs-toggle="collapse"],
    footer {
        display: none !important;
    }

    .week-card {
        break-inside: avoid;
        box-shadow: none;
        border: 1px solid #000;
    }

    .day-row {
        page-break-inside: avoid;
    }
}