/* Management Layout */
.management-section {
    background: var(--bg-secondary);
    border-radius: 15px;
    padding: 25px;
}

.section-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 25px;
    flex-wrap: wrap;
    gap: 15px;
}

.section-title {
    color: #ffffff;
    font-size: 20px;
}

.controls {
    display: flex;
    gap: 15px;
    align-items: center;
    flex-wrap: wrap;
}

/* Search */
.search-box {
    position: relative;
}

.search-input {
    padding: 10px 40px 10px 15px;
    background: #3a3f52;
    border: 2px solid #4a4f62;
    border-radius: 8px;
    color: #ffffff;
    width: 250px;
}

.search-input:focus {
    outline: none;
    border-color: var(--color-primary);
}

/* Tables */
.table-container {
    overflow-x: auto;
    scrollbar-width: thin;
    scrollbar-color: #4a4f62 #1a1d29;
}

.table-container::-webkit-scrollbar {
    width: 4px;
    height: 4px;
}

.table-container::-webkit-scrollbar-thumb {
    background: var(--color-primary);
    border-radius: 2px;
}

.table-container::-webkit-scrollbar-track {
    background: rgba(58, 63, 82, 0.3);
    border-radius: 2px;
}

.data-table {
    width: 100%;
    border-collapse: collapse;
    margin-top: 15px;
}

.data-table th,
.data-table td {
    padding: 12px 15px;
    text-align: left;
    border-bottom: 1px solid #3a3f52;
    white-space: nowrap;
}

.data-table th {
    background: #3a3f52;
    color: #e2e5f1;
    font-weight: 600;
    position: sticky;
    top: 0;
}

.data-table td {
    color: #a0a4b8;
}

.data-table tr:hover {
    background: rgba(102, 126, 234, 0.05);
}

/* Action Buttons */
.action-buttons {
    display: flex;
    gap: 8px;
    white-space: nowrap;
}

.action-buttons * {
    touch-action: manipulation !important;
    -webkit-tap-highlight-color: rgba(102, 126, 234, 0.3) !important;
    cursor: pointer !important;
    pointer-events: auto !important;
    z-index: 999 !important;
    transform: translateZ(0) !important;
    -webkit-transform: translateZ(0) !important;
    will-change: transform !important;
}

.btn-icon {
    background: none;
    border: none;
    color: #a0a4b8;
    cursor: pointer;
    padding: 4px;
    border-radius: 4px;
    transition: all 0.3s ease;
    display: flex;
    align-items: center;
    justify-content: center;
}

.btn-icon:hover {
    background: rgba(255, 255, 255, 0.1);
    color: #ffffff;
}

.btn-icon.edit:hover {
    color: #3498db;
}

.btn-icon.delete:hover {
    color: #e74c3c;
}

/* Specific Form Components */
#dateFields {
    display: none;
}

#dateFields.active {
    display: flex;
}

#planField {
    position: relative;
    margin-top: 10px;
    opacity: 0;
    height: 0;
    overflow: hidden;
    transition: opacity 0.3s ease, height 0.3s ease, margin 0.3s ease;
    margin-top: 0;
}

#planField[style*="display: block"] {
    opacity: 1;
    height: auto;
    margin-top: 10px;
}

#planField label {
    color: #e2e5f1;
    font-weight: 600;
    margin-bottom: 8px;
}

#planField .form-help {
    color: #a0a4b8;
    font-size: 12px;
    margin-top: 5px;
    font-style: italic;
}

#planId {
    background: #3a3f52;
    border: 2px solid #4a4f62;
    color: #ffffff;
    transition: border-color 0.3s ease, background-color 0.3s ease;
}

#planId:focus {
    border-color: var(--color-primary);
    background: #404761;
}

#planId:required:invalid {
    border-color: #e74c3c;
}

#planId:required:valid {
    border-color: #27ae60;
}

.plan-badge {
    background: rgba(102, 126, 234, 0.2);
    color: var(--color-primary);
    padding: 2px 8px;
    border-radius: 12px;
    font-size: 11px;
    font-weight: bold;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    white-space: nowrap;
}

.plan-badge.no-plan {
    background: rgba(149, 165, 166, 0.2);
    color: #95a5a6;
}

/* Contact History */
.contact-history-section {
    margin-bottom: 25px;
    border-top: 1px solid #3a3f52;
    padding-top: 20px;
}

.contact-history-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 15px;
}

.contact-history-header h4 {
    color: var(--color-primary);
    font-size: 16px;
    margin: 0;
}

.contact-history-container {
    max-height: 300px;
    overflow-y: auto;
    border: 1px solid #4a4f62;
    border-radius: 8px;
    padding: 10px;
    background: rgba(58, 63, 82, 0.3);
}

.contact-history-container::-webkit-scrollbar {
    width: 4px;
}

.contact-history-container::-webkit-scrollbar-thumb {
    background: var(--color-primary);
    border-radius: 2px;
}

.contact-history-container::-webkit-scrollbar-track {
    background: rgba(58, 63, 82, 0.3);
    border-radius: 2px;
}

.contact-entry {
    background: #3a3f52;
    border-radius: 8px;
    padding: 12px;
    margin-bottom: 10px;
    border-left: 3px solid var(--color-primary);
}

.contact-entry:last-child {
    margin-bottom: 0;
}

.contact-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 8px;
}

.contact-date {
    color: var(--color-primary);
    font-weight: 600;
    font-size: 14px;
}

.contact-note {
    color: #e2e5f1;
    font-size: 14px;
    line-height: 1.4;
    white-space: pre-wrap;
}

/* Opening Hours Display */
.opening-hours-display, .languages-display {
    min-height: 40px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 10px 15px;
    background: #3a3f52;
    border: 2px solid #4a4f62;
    border-radius: 10px;
    transition: border-color 0.3s ease;
}

.opening-hours-display:hover, .languages-display:hover {
    border-color: var(--color-primary);
}

.opening-hours-content, .languages-content {
    flex: 1;
    min-height: 20px;
}

.opening-hours-empty, .languages-empty {
    color: #a0a4b8;
    font-style: italic;
    font-size: 14px;
}

.opening-hours-list, .languages-list {
    color: #e2e5f1;
    font-size: 14px;
    line-height: 1.4;
}

.opening-hours-item, .languages-item {
    margin-bottom: 4px;
}

.opening-hours-item:last-child, .languages-item:last-child {
    margin-bottom: 0;
}

.languages-more {
    color: var(--color-primary);
    font-style: italic;
    font-size: 12px;
}

.opening-hours-actions, .languages-actions {
    display: flex;
    gap: 8px;
    margin-left: 15px;
}

.btn-manage-hours-compact, .btn-manage-languages-compact {
    background: #667eea;
    color: white;
    border: none;
    padding: 8px 16px;
    border-radius: 6px;
    font-size: 12px;
    cursor: pointer;
    white-space: nowrap;
    transition: all 0.3s ease;
    display: flex;
    align-items: center;
    gap: 6px;
}

.btn-manage-hours-compact:hover, .btn-manage-languages-compact:hover {
    background: #5a6fd8;
    transform: translateY(-1px);
}

.btn-edit-hours, .btn-edit-languages {
    background: #3498db;
    color: white;
    border: none;
    padding: 6px 12px;
    border-radius: 4px;
    font-size: 11px;
    cursor: pointer;
    transition: background 0.3s ease;
}

.btn-edit-hours:hover, .btn-edit-languages:hover {
    background: #2980b9;
}

.btn-clear-hours, .btn-clear-languages {
    background: #e74c3c;
    color: white;
    border: none;
    padding: 6px 12px;
    border-radius: 4px;
    font-size: 11px;
    cursor: pointer;
    transition: background 0.3s ease;
}

.btn-clear-hours:hover, .btn-clear-languages:hover {
    background: #c0392b;
}

/* Priority Styling */
.priority-select {
    position: relative;
}

.priority-select select {
    background-color: #3a3f52;
    border: 2px solid #4a4f62;
}

.priority-select select[value="urgent"] {
    border-color: #e74c3c;
    background-color: rgba(231, 76, 60, 0.1);
}

.priority-select select[value="high"] {
    border-color: #f39c12;
    background-color: rgba(243, 156, 18, 0.1);
}

.priority-select select[value="medium"] {
    border-color: #3498db;
    background-color: rgba(52, 152, 219, 0.1);
}

.priority-select select[value="low"] {
    border-color: #95a5a6;
    background-color: rgba(149, 165, 166, 0.1);
}

/* Status Select Styling */
#ratingStatus {
    background: #3a3f52;
    border: 2px solid #4a4f62;
    color: #ffffff;
    transition: border-color 0.3s ease;
}

#ratingStatus:focus {
    border-color: #667eea;
}

#ratingStatus[value="neu"] {
    border-color: #3498db;
    background-color: rgba(52, 152, 219, 0.1);
}

#ratingStatus[value="akzeptiert"] {
    border-color: #27ae60;
    background-color: rgba(39, 174, 96, 0.1);
}

#ratingStatus[value="abgelehnt"] {
    border-color: #e74c3c;
    background-color: rgba(231, 76, 60, 0.1);
}

/* Notes Textarea */
.notes-textarea {
    min-height: 150px;
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    line-height: 1.5;
    resize: vertical;
}

/* Compact Rating Modal */
.compact-rating-modal {
    max-width: 600px;
    width: 90%;
}

.compact-rating-info {
    background: #3a3f52;
    border-radius: 10px;
    padding: 20px;
    margin-bottom: 20px;
    border-left: 4px solid #667eea;
}

.rating-summary {
    display: flex;
    gap: 15px;
    align-items: center;
    margin-bottom: 15px;
    flex-wrap: wrap;
}

.rating-stars-display {
    color: #f1c40f;
    font-size: 20px;
    letter-spacing: 2px;
}

.rating-patient {
    color: #ffffff;
    font-weight: 600;
    font-size: 16px;
}

.rating-date {
    color: #a0a4b8;
    font-size: 14px;
}

.rating-comment {
    background: var(--bg-secondary);
    padding: 15px;
    border-radius: 6px;
    color: #e2e5f1;
    line-height: 1.4;
    max-height: 120px;
    overflow-y: auto;
    font-style: italic;
    border-left: 3px solid #667eea;
}

.compact-rating-controls {
    background: rgba(102, 126, 234, 0.05);
    border-radius: 10px;
    padding: 20px;
    margin-bottom: 20px;
}

/* Responsive */
@media (max-width: 768px) {
    .section-header {
        flex-direction: column;
        align-items: stretch;
    }

    .controls {
        width: 100%;
        flex-direction: column;
        align-items: stretch;
        gap: 10px;
    }

    .search-input {
        width: 100%;
    }

    .filter-select {
        width: 100%;
    }

    .data-table th,
    .data-table td {
        padding: 10px 8px;
        font-size: 13px;
    }

    .action-buttons {
        flex-direction: column;
        gap: 4px;
    }

    .action-buttons .btn {
        width: 100%;
        padding: 8px 12px;
        font-size: 12px;
    }

    .contact-history-header {
        flex-direction: column;
        align-items: stretch;
        gap: 10px;
    }

    .opening-hours-display, .languages-display {
        flex-direction: column;
        align-items: stretch;
        gap: 10px;
    }

    .opening-hours-actions, .languages-actions {
        margin-left: 0;
        justify-content: center;
    }

    .management-section {
        padding: 15px;
    }

    .section-title {
        font-size: 18px;
    }

    .rating-summary {
        flex-direction: column;
        align-items: flex-start;
        gap: 10px;
    }

    .compact-rating-modal {
        width: 95%;
        max-width: none;
    }

    .compact-rating-info,
    .compact-rating-controls {
        padding: 15px;
    }
}

@media (max-width: 480px) {
    .main-content {
        padding: 10px;
    }

    .header {
        padding: 12px 15px;
        margin-bottom: 15px;
    }

    .header h1 {
        font-size: 18px;
    }

    .management-section {
        padding: 15px;
    }

    .section-title {
        font-size: 18px;
    }

    .data-table th,
    .data-table td {
        padding: 8px 6px;
        font-size: 12px;
    }

    .compact-rating-info,
    .compact-rating-controls {
        padding: 12px;
    }

    .rating-stars-display {
        font-size: 18px;
    }

    .rating-patient {
        font-size: 14px;
    }

    .rating-date {
        font-size: 12px;
    }

    .languages-actions, .opening-hours-actions {
        flex-direction: row;
        gap: 6px;
    }
    
    .btn-edit-languages, .btn-clear-languages,
    .btn-edit-hours, .btn-clear-hours {
        flex: 1;
        text-align: center;
        padding: 8px 10px;
        font-size: 10px;
    }
    
    .btn-manage-languages-compact, .btn-manage-hours-compact {
        padding: 10px 14px;
    }
}