* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
    background: #f5f5f5;
    min-height: 100vh;
    min-height: -webkit-fill-available; /* iOS Safari */
    padding: 0;
    color: #333;
    /* Verhindert Text-Selektion beim Doppel-Tap (iOS) */
    -webkit-tap-highlight-color: transparent;
    -webkit-touch-callout: none;
    -webkit-user-select: none;
    user-select: none;
    /* Smooth Scrolling für PWA */
    -webkit-overflow-scrolling: touch;
    overscroll-behavior: contain;
}

/* Erlaube Text-Selektion in Input-Feldern */
input, textarea {
    -webkit-user-select: text;
    user-select: text;
}

.container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 20px;
    padding: max(20px, env(safe-area-inset-top)) max(20px, env(safe-area-inset-right)) max(20px, env(safe-area-inset-bottom)) max(20px, env(safe-area-inset-left));
}

/* Header */
.header {
    background: #DC143C;
    padding: 15px 20px;
    border-radius: 10px;
    box-shadow: 0 4px 6px rgba(0, 0, 0, 0.2);
    margin-bottom: 20px;
    display: flex;
    align-items: center;
    gap: 15px;
    /* PWA: Sticky Header */
    position: sticky;
    top: 0;
    z-index: 100;
}

.back-button {
    display: flex;
    align-items: center;
    gap: 5px;
    color: white;
    text-decoration: none;
    padding: 8px 12px;
    border-radius: 8px;
    transition: background-color 0.2s ease;
    flex-shrink: 0;
    -webkit-tap-highlight-color: rgba(255, 255, 255, 0.2);
    touch-action: manipulation;
}

.back-button:hover {
    background-color: rgba(255, 255, 255, 0.1);
}

.back-icon {
    font-size: 24px;
    font-weight: 700;
    line-height: 1;
}

.back-text {
    font-size: 14px;
    font-weight: 500;
}

.header-logo-title {
    display: flex;
    align-items: center;
    gap: 12px;
    flex: 1;
    min-width: 0;
}

.header-logo {
    height: 35px;
    width: auto;
    object-fit: contain;
    flex-shrink: 0;
}

.header-title {
    display: flex;
    flex-direction: column;
    min-width: 0;
    gap: 2px;
}

.header-subtitle {
    color: rgba(255, 255, 255, 0.8);
    font-size: 12px;
    font-weight: 500;
    line-height: 1.2;
    display: none; /* Versteckt auf Desktop */
}

.header h1 {
    color: white;
    font-size: 24px;
    font-weight: 700;
    margin: 0;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.user-info {
    display: flex;
    align-items: center;
    gap: 15px;
}

.user-info span {
    color: white;
    font-weight: 500;
}

.user-name-desktop {
    color: rgba(255, 255, 255, 0.9);
    font-size: 14px;
    font-weight: 400;
    margin-top: 2px;
}

.logout-button {
    display: flex;
    align-items: center;
    gap: 6px;
    color: white;
    text-decoration: none;
    padding: 8px 12px;
    border-radius: 8px;
    transition: background-color 0.2s ease;
    flex-shrink: 0;
    -webkit-tap-highlight-color: rgba(255, 255, 255, 0.2);
    touch-action: manipulation;
    background: rgba(255, 255, 255, 0.1);
    border: 1px solid rgba(255, 255, 255, 0.2);
}

.logout-button:hover {
    background-color: rgba(255, 255, 255, 0.2);
    border-color: rgba(255, 255, 255, 0.3);
}

.logout-icon {
    font-size: 20px;
    line-height: 1;
}

.logout-text {
    font-size: 14px;
    font-weight: 500;
}

.header-actions {
    display: flex;
    gap: 10px;
}

/* Login Box */
.login-box {
    background: white;
    padding: 40px;
    border-radius: 16px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
    max-width: 400px;
    margin: 100px auto;
    border-top: 4px solid #DC143C;
    /* PWA: Smooth Animation */
    animation: fadeIn 0.3s ease;
}

.login-logo {
    text-align: center;
    margin-bottom: 20px;
}

.login-logo .logo-image {
    max-width: 200px;
    height: auto;
}

@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(-10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* Footer */
.main-footer {
    margin-top: 40px;
    padding: 20px;
    text-align: center;
    border-top: 1px solid #e9ecef;
    background: #f8f9fa;
}

.main-footer a {
    color: #DC143C;
    text-decoration: none;
    font-size: 14px;
    transition: color 0.2s ease;
}

.main-footer a:hover {
    color: #B8122F;
    text-decoration: underline;
}

.login-box h1 {
    color: #DC143C;
    text-align: center;
    margin-bottom: 10px;
    font-weight: 700;
}

.login-box h2 {
    color: #666;
    text-align: center;
    margin-bottom: 30px;
    font-size: 20px;
    font-weight: normal;
}

.login-box form {
    margin-top: 0;
}

.login-box .btn-primary {
    margin-top: 20px;
    width: 100%;
}

/* Dashboard */
.dashboard-box {
    background: white;
    padding: 30px;
    border-radius: 10px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
}

.dashboard-box h2 {
    color: #DC143C;
    margin-bottom: 20px;
    font-weight: 600;
}

.table-list {
    display: grid;
    gap: 15px;
}

.table-card {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 20px;
    background: #f8f9fa;
    border: 2px solid #e9ecef;
    border-radius: 12px;
    text-decoration: none;
    color: #333;
    transition: all 0.2s ease;
    -webkit-tap-highlight-color: rgba(220, 20, 60, 0.1);
    touch-action: manipulation;
}

.table-card:hover {
    background: #fff5f5;
    border-color: #DC143C;
    transform: translateX(5px);
    box-shadow: 0 2px 8px rgba(220, 20, 60, 0.2);
}

.table-card:active {
    transform: translateX(3px) scale(0.98);
    box-shadow: 0 1px 4px rgba(220, 20, 60, 0.15);
}

.table-name {
    font-size: 18px;
    font-weight: 600;
    color: #DC143C;
}

.table-arrow {
    font-size: 24px;
    color: #DC143C;
}

/* Form Box */
.form-box {
    background: white;
    padding: 30px;
    border-radius: 10px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
    margin-bottom: 20px;
}

.form-box h2 {
    color: #DC143C;
    margin-bottom: 20px;
    font-weight: 600;
}

.form-row {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
    gap: 20px;
    margin-bottom: 20px;
}

.form-group {
    display: flex;
    flex-direction: column;
    margin-bottom: 20px;
}

.form-group:last-of-type {
    margin-bottom: 0;
}

.form-group label {
    margin-bottom: 8px;
    color: #555;
    font-weight: 500;
}

.form-group input,
.form-group textarea {
    padding: 12px;
    border: 2px solid #e9ecef;
    border-radius: 8px;
    font-size: 16px; /* Verhindert Zoom auf iOS */
    transition: border-color 0.2s ease, box-shadow 0.2s ease;
    -webkit-appearance: none;
    appearance: none;
}

.form-group input:focus,
.form-group textarea:focus {
    outline: none;
    border-color: #DC143C;
    box-shadow: 0 0 0 3px rgba(220, 20, 60, 0.1);
}

.form-group textarea {
    resize: vertical;
    font-family: inherit;
}

.form-actions {
    display: flex;
    gap: 10px;
    margin-top: 20px;
}

/* Buttons */
.btn {
    padding: 10px 20px;
    border: none;
    border-radius: 8px;
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    text-decoration: none;
    display: inline-block;
    transition: all 0.2s ease;
    /* PWA: Touch-freundlich */
    -webkit-tap-highlight-color: rgba(220, 20, 60, 0.2);
    touch-action: manipulation;
    user-select: none;
    min-height: 44px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
}

.btn-primary {
    background: #DC143C;
    color: white;
    font-weight: 600;
}

.btn-primary:hover,
.btn-primary:active {
    background: #B8122F;
    transform: translateY(-1px);
    box-shadow: 0 4px 8px rgba(220, 20, 60, 0.4);
}

.btn-primary:active {
    transform: translateY(0);
    box-shadow: 0 2px 4px rgba(220, 20, 60, 0.3);
}

.btn-secondary {
    background: #333;
    color: white;
    font-weight: 500;
}

.btn-secondary:hover {
    background: #1a1a1a;
}

.header .btn-secondary {
    background: rgba(255, 255, 255, 0.2);
    color: white;
    border: 1px solid rgba(255, 255, 255, 0.3);
}

.header .btn-secondary:hover {
    background: rgba(255, 255, 255, 0.3);
    border-color: rgba(255, 255, 255, 0.5);
}

.btn-small {
    padding: 5px 12px;
    font-size: 12px;
}

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

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

.btn-delete {
    background: #dc3545;
    color: white;
}

.btn-delete:hover {
    background: #c82333;
}

/* Messages */
.message {
    padding: 15px 20px;
    border-radius: 5px;
    margin-bottom: 20px;
    font-weight: 500;
}

.message.success {
    background: #d4edda;
    color: #155724;
    border: 1px solid #c3e6cb;
}

.message.error {
    background: #f8d7da;
    color: #721c24;
    border: 1px solid #f5c6cb;
}

.error-message {
    background: #f8d7da;
    color: #721c24;
    padding: 12px;
    border-radius: 5px;
    margin-bottom: 20px;
    border: 1px solid #f5c6cb;
}

.info-message {
    color: #666;
    font-style: italic;
    padding: 20px;
    text-align: center;
}

/* Termine Liste */
.termine-list {
    background: white;
    padding: 30px;
    border-radius: 10px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
}

.termine-list-header {
    margin-bottom: 20px;
}

.termine-list h2 {
    color: #DC143C;
    margin-bottom: 15px;
    font-weight: 600;
}

.filter-controls {
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
    align-items: center;
    margin-bottom: 20px;
    padding: 15px;
    background: #f8f9fa;
    border-radius: 8px;
}

.filter-group {
    flex: 1;
    min-width: 150px;
}

.search-input {
    width: 100%;
    padding: 10px 15px;
    border: 2px solid #e9ecef;
    border-radius: 8px;
    font-size: 14px;
    transition: border-color 0.2s ease, box-shadow 0.2s ease;
}

.search-input:focus {
    outline: none;
    border-color: #DC143C;
    box-shadow: 0 0 0 3px rgba(220, 20, 60, 0.1);
}

.filter-select {
    width: 100%;
    padding: 10px 15px;
    border: 2px solid #e9ecef;
    border-radius: 8px;
    font-size: 14px;
    background: white;
    cursor: pointer;
    transition: border-color 0.2s ease, box-shadow 0.2s ease;
    -webkit-appearance: none;
    appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'%3E%3Cpath fill='%23333' d='M6 9L1 4h10z'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 12px center;
    padding-right: 35px;
}

.filter-select:focus {
    outline: none;
    border-color: #DC143C;
    box-shadow: 0 0 0 3px rgba(220, 20, 60, 0.1);
}

.termine-table {
    width: 100%;
    border-collapse: collapse;
    margin-top: 20px;
}

.termine-table thead {
    background: #DC143C;
    color: white;
}

.termine-table th,
.termine-table td {
    padding: 12px;
    text-align: left;
    border-bottom: 1px solid #e9ecef;
}

.termine-table tbody tr:hover {
    background: #fff5f5;
}

.termine-table .actions {
    display: flex;
    gap: 5px;
}

/* Desktop: Cards verstecken */
@media (min-width: 769px) {
    .termine-cards {
        display: none;
    }
}

/* Responsive - Mobile First PWA Design */
@media (max-width: 768px) {
    body {
        padding: 0;
    }
    
    .container {
        padding: 10px;
        padding: max(10px, env(safe-area-inset-top)) max(10px, env(safe-area-inset-right)) max(10px, env(safe-area-inset-bottom)) max(10px, env(safe-area-inset-left));
    }
    
    .header {
        flex-direction: row;
        gap: 10px;
        padding: 12px 15px;
        border-radius: 0;
        margin: 0 0 15px 0;
        position: sticky;
        top: 0;
        align-items: center;
    }
    
    .back-button {
        padding: 8px;
        min-width: 44px;
        justify-content: center;
    }
    
    .back-text {
        display: none; /* Nur Symbol auf Mobile */
    }
    
    .back-icon {
        font-size: 28px;
    }
    
    .header-logo-title {
        flex-direction: row;
        gap: 10px;
        align-items: center;
        flex: 1;
        min-width: 0;
    }
    
    .header-logo {
        height: 30px;
        flex-shrink: 0;
    }
    
    .header-title {
        flex: 1;
        min-width: 0;
        display: flex;
        flex-direction: column;
    }
    
    .header-subtitle {
        display: block; /* Zeige auf Mobile */
        font-size: 10px;
    }
    
    .header h1 {
        font-size: 16px;
        white-space: nowrap;
        overflow: hidden;
        text-overflow: ellipsis;
        line-height: 1.2;
    }
    
    .user-name-desktop {
        display: none; /* Verstecke auf Mobile */
    }
    
    .logout-button {
        padding: 8px;
        min-width: 44px;
        min-height: 44px;
        justify-content: center;
        align-items: center;
    }
    
    .logout-text {
        display: none; /* Nur Symbol auf Mobile */
    }
    
    .logout-icon {
        font-size: 24px;
    }
    
    /* Alte user-info Styles für Kompatibilität */
    .user-info {
        display: none; /* Verstecke alte user-info auf Mobile */
    }
    
    .login-logo .logo-image {
        max-width: 150px;
    }
    
    .main-footer {
        margin-top: 20px;
        padding: 15px;
        font-size: 12px;
    }
    
    .user-info {
        flex-direction: column;
        gap: 10px;
        width: 100%;
    }
    
    .user-info span {
        font-size: 14px;
    }
    
    .header .btn-secondary {
        width: 100%;
    }
    
    .form-row {
        grid-template-columns: 1fr;
    }
    
    .form-box,
    .dashboard-box,
    .termine-list {
        padding: 20px 15px;
        border-radius: 0;
        margin: 0 0 15px 0;
    }
    
    .termine-list-header {
        margin-bottom: 15px;
    }
    
    .termine-list h2 {
        font-size: 20px;
        margin-bottom: 12px;
    }
    
    .filter-controls {
        flex-direction: column;
        gap: 10px;
        padding: 12px;
    }
    
    .filter-group {
        width: 100%;
        min-width: 0;
    }
    
    .search-input,
    .filter-select {
        width: 100%;
        font-size: 16px; /* Verhindert Zoom auf iOS */
    }
    
    #reset-filters {
        width: 100%;
    }
    
    .login-box {
        margin: 50px auto;
        padding: 30px 20px;
        border-radius: 0;
        max-width: 100%;
    }
    
    /* Tabelle auf mobilen Geräten verstecken */
    .termine-table {
        display: none;
    }
    
    /* Card-Ansicht für Termine auf mobilen Geräten */
    .termine-cards {
        display: block;
    }
    
    .termine-card {
        background: white;
        border: 1px solid #e9ecef;
        border-left: 4px solid #DC143C;
        border-radius: 8px;
        padding: 16px;
        margin-bottom: 12px;
        box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
        transition: transform 0.2s ease, box-shadow 0.2s ease;
    }
    
    .termine-card:active {
        transform: scale(0.98);
        box-shadow: 0 1px 2px rgba(0, 0, 0, 0.1);
    }
    
    .termine-card-header {
        display: flex;
        justify-content: space-between;
        align-items: flex-start;
        margin-bottom: 12px;
        flex-wrap: wrap;
        gap: 10px;
    }
    
    .termine-card-date {
        font-weight: 700;
        color: #DC143C;
        font-size: 18px;
    }
    
    .termine-card-weekday {
        background: #DC143C;
        color: white;
        padding: 6px 12px;
        border-radius: 6px;
        font-size: 13px;
        font-weight: 600;
        white-space: nowrap;
    }
    
    .termine-card-title {
        font-weight: 600;
        font-size: 18px;
        color: #333;
        margin-bottom: 10px;
        line-height: 1.4;
    }
    
    .termine-card-info {
        color: #666;
        font-size: 14px;
        margin-bottom: 12px;
        line-height: 1.5;
    }
    
    .termine-card-details {
        display: flex;
        flex-direction: column;
        gap: 8px;
        margin-bottom: 12px;
        font-size: 14px;
    }
    
    .termine-card-detail {
        display: flex;
        align-items: flex-start;
        gap: 8px;
        color: #555;
    }
    
    .termine-card-detail strong {
        color: #333;
        font-weight: 600;
        min-width: 70px;
    }
    
    .termine-card-actions {
        display: flex;
        gap: 8px;
        margin-top: 12px;
        flex-wrap: wrap;
    }
    
    .termine-card-actions .btn {
        flex: 1;
        min-width: 0;
        text-align: center;
        padding: 10px 16px;
        font-size: 14px;
    }
    
    .termine-card-actions form {
        flex: 1;
        min-width: 0;
        display: flex;
    }
    
    .termine-card-actions form button {
        width: 100%;
    }
    
    .table-list {
        gap: 12px;
    }
    
    .table-card {
        padding: 16px;
        border-radius: 8px;
    }
    
    .table-name {
        font-size: 16px;
    }
    
    .btn {
        padding: 12px 20px;
        font-size: 16px;
        /* Touch-freundliche Buttons */
        min-height: 44px;
        display: flex;
        align-items: center;
        justify-content: center;
    }
    
    .btn-small {
        padding: 10px 16px;
        font-size: 14px;
        min-height: 44px;
    }
}

/* Tablet-Anpassungen */
@media (max-width: 1024px) and (min-width: 769px) {
    .termine-table {
        font-size: 14px;
    }
    
    .termine-table th,
    .termine-table td {
        padding: 10px 8px;
    }
    
    .termine-table .actions {
        flex-direction: column;
        gap: 5px;
    }
    
    .termine-table .actions .btn {
        width: 100%;
    }
}

