/* Reset und Basis-Styles */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, sans-serif;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: #333;
    line-height: 1.6;
    min-height: 100vh;
    padding: 20px;
}

.container {
    max-width: 1400px;
    margin: 0 auto;
    background: white;
    border-radius: 12px;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
    overflow: hidden;
}

/* Header */
header {
    background: linear-gradient(135deg, #434343 0%, #000000 100%);
    color: white;
    padding: 30px;
    text-align: center;
}

header h1 {
    font-size: 2.5em;
    margin-bottom: 10px;
}

header p {
    font-size: 1.1em;
    opacity: 0.9;
}

/* Tabs */
.tabs {
    display: flex;
    background: #f5f5f5;
    border-bottom: 2px solid #ddd;
}

.tab-button {
    flex: 1;
    padding: 15px 20px;
    background: none;
    border: none;
    cursor: pointer;
    font-size: 1em;
    font-weight: 500;
    color: #666;
    transition: all 0.3s ease;
    border-bottom: 3px solid transparent;
}

.tab-button:hover {
    background: #e8e8e8;
    color: #333;
}

.tab-button.active {
    color: #667eea;
    border-bottom-color: #667eea;
    background: white;
}

/* Tab Content */
.tab-content {
    display: none;
    padding: 30px;
    animation: fadeIn 0.3s ease;
}

.tab-content.active {
    display: block;
}

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

/* Section Header */
.section-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 25px;
    padding-bottom: 15px;
    border-bottom: 2px solid #eee;
}

.section-header h2 {
    font-size: 1.8em;
    color: #333;
}

.stats {
    display: flex;
    gap: 10px;
}

.stat-badge {
    background: #667eea;
    color: white;
    padding: 8px 16px;
    border-radius: 20px;
    font-size: 0.9em;
    font-weight: 500;
}

/* Search Box */
.search-box {
    margin-bottom: 20px;
}

.search-box input {
    width: 100%;
    padding: 12px 20px;
    border: 2px solid #ddd;
    border-radius: 8px;
    font-size: 1em;
    transition: border-color 0.3s ease;
}

.search-box input:focus {
    outline: none;
    border-color: #667eea;
}

/* Tabelle */
.table-container {
    overflow-x: auto;
    border-radius: 8px;
    border: 1px solid #ddd;
}

table {
    width: 100%;
    border-collapse: collapse;
    background: white;
}

thead {
    background: #f8f9fa;
}

th {
    padding: 15px;
    text-align: left;
    font-weight: 600;
    color: #333;
    border-bottom: 2px solid #ddd;
    cursor: pointer;
    user-select: none;
    position: relative;
}

th:hover {
    background: #e9ecef;
}

.sort-icon {
    margin-left: 5px;
    opacity: 0.5;
    font-size: 0.8em;
}

td {
    padding: 15px;
    border-bottom: 1px solid #eee;
}

tbody tr {
    transition: background-color 0.2s ease;
}

tbody tr:hover {
    background: #f8f9fa;
}

.rank-badge {
    display: inline-block;
    padding: 4px 12px;
    border-radius: 12px;
    font-size: 0.85em;
    font-weight: 600;
    color: white;
}

.rank-level-1, .rank-level-2, .rank-level-3, .rank-level-4, .rank-level-5 {
    background: #6c757d;
}

.rank-level-6, .rank-level-7, .rank-level-8, .rank-level-9, .rank-level-10, .rank-level-11, .rank-level-12 {
    background: #007bff;
}

.rank-level-13, .rank-level-14, .rank-level-15, .rank-level-16 {
    background: #28a745;
}

.rank-level-17, .rank-level-18, .rank-level-19 {
    background: #ffc107;
}

.rank-level-20, .rank-level-21, .rank-level-22, .rank-level-23,.rank-level-24, .rank-level-25, .rank-level-26, .rank-level-27,.rank-level-28 {
    background: #dc3545;
}

.rank-level-29,.rank-level-30,.rank-level-31 {
    background: #b903ff;
}

/* Action Buttons in Table */
.action-btn {
    padding: 6px 12px;
    margin: 0 3px;
    border: none;
    border-radius: 4px;
    cursor: pointer;
    font-size: 0.85em;
    transition: all 0.3s ease;
}

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

.action-btn.view:hover {
    background: #138496;
}

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

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

/* Formulare */
.form-container {
    max-width: 600px;
    margin: 0 auto;
}

.form-group {
    margin-bottom: 20px;
}

.form-group label {
    display: block;
    margin-bottom: 8px;
    font-weight: 600;
    color: #333;
}

.form-group input,
.form-group select,
.form-group textarea {
    width: 100%;
    padding: 12px;
    border: 2px solid #ddd;
    border-radius: 6px;
    font-size: 1em;
    transition: border-color 0.3s ease;
}

.form-group input:focus,
.form-group select:focus,
.form-group textarea:focus {
    outline: none;
    border-color: #667eea;
}

.form-group small {
    display: block;
    margin-top: 5px;
    color: #666;
    font-size: 0.85em;
}

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

/* Buttons */
.btn {
    padding: 12px 24px;
    border: none;
    border-radius: 6px;
    font-size: 1em;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.3s ease;
    flex: 1;
}

.btn-primary {
    background: #667eea;
    color: white;
}

.btn-primary:hover {
    background: #5568d3;
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(102, 126, 234, 0.4);
}

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

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

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

.btn-danger:hover {
    background: #c82333;
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(220, 53, 69, 0.4);
}

/* Messages */
.message {
    margin-top: 20px;
    padding: 15px;
    border-radius: 6px;
    display: none;
}

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

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

/* Info Box */
.info-box {
    background: #e7f3ff;
    border-left: 4px solid #2196F3;
    padding: 15px;
    margin-bottom: 20px;
    border-radius: 4px;
}

.info-box p {
    margin: 5px 0;
}

.info-box strong {
    color: #1976D2;
}

/* Modal */
.modal {
    display: none;
    position: fixed;
    z-index: 1000;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.6);
    animation: fadeIn 0.3s ease;
}

.modal-content {
    background: white;
    margin: 5% auto;
    padding: 30px;
    border-radius: 12px;
    width: 90%;
    max-width: 700px;
    max-height: 80vh;
    overflow-y: auto;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.3);
    animation: slideIn 0.3s ease;
}

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

.close {
    float: right;
    font-size: 28px;
    font-weight: bold;
    color: #aaa;
    cursor: pointer;
    line-height: 1;
}

.close:hover {
    color: #000;
}

.history-item {
    padding: 15px;
    margin: 10px 0;
    background: #f8f9fa;
    border-left: 4px solid #667eea;
    border-radius: 4px;
}

.history-item strong {
    color: #667eea;
}

/* Loading State */
.loading {
    text-align: center;
    padding: 40px !important;
    color: #999;
    font-style: italic;
}

/* Responsive */
@media (max-width: 768px) {
    .tabs {
        flex-wrap: wrap;
    }
    
    .tab-button {
        flex: 0 0 50%;
    }
    
    .form-actions {
        flex-direction: column;
    }
    
    .section-header {
        flex-direction: column;
        align-items: flex-start;
        gap: 15px;
    }
    
    table {
        font-size: 0.9em;
    }
    
    th, td {
        padding: 10px 8px;
    }
}

/* Units Grid */
.units-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
    gap: 20px;
    margin-top: 20px;
}

.unit-card {
    background: white;
    border: 2px solid #e0e0e0;
    border-radius: 8px;
    padding: 20px;
    transition: all 0.3s ease;
    cursor: pointer;
}

.unit-card:hover {
    border-color: #667eea;
    box-shadow: 0 4px 12px rgba(102, 126, 234, 0.2);
    transform: translateY(-2px);
}

.unit-card-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    margin-bottom: 15px;
    border-bottom: 2px solid #f0f0f0;
    padding-bottom: 10px;
}

.unit-card h4 {
    margin: 0;
    color: #333;
    font-size: 1.2em;
}

.unit-type-badge {
    padding: 4px 10px;
    border-radius: 12px;
    font-size: 0.8em;
    font-weight: 600;
    color: white;
}

.unit-type-Gruppe { background: #6c757d; }
.unit-type-Zug { background: #007bff; }
.unit-type-Kompanie { background: #28a745; }
.unit-type-Bataillon { background: #ffc107; color: #333; }
.unit-type-Regiment { background: #dc3545; }

.unit-card-body {
    color: #666;
    font-size: 0.9em;
}

.unit-info-row {
    display: flex;
    justify-content: space-between;
    margin: 8px 0;
}

.unit-card-actions {
    margin-top: 15px;
    padding-top: 15px;
    border-top: 1px solid #f0f0f0;
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
}

.unit-card-actions button {
    flex: 1;
    min-width: 80px;
    padding: 8px 12px;
    font-size: 0.85em;
}

/* Position Badges */
.position-badge {
    display: inline-block;
    padding: 4px 10px;
    border-radius: 12px;
    font-size: 0.85em;
    font-weight: 600;
    color: white;
}

.position-Führer {
    background: #dc3545;
}

.position-Stellvertreter {
    background: #ffc107;
    color: #333;
}

.position-Mitglied {
    background: #6c757d;
}

.unit-members-list {
    margin-top: 15px;
}

.member-item {
    padding: 10px;
    background: #f8f9fa;
    border-radius: 4px;
    margin: 8px 0;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.member-info {
    display: flex;
    gap: 10px;
    align-items: center;
    flex: 1;
}

#unit-form-container {
    background: #f8f9fa;
    padding: 20px;
    border-radius: 8px;
    margin: 20px 0;
}

#unit-form-container h3 {
    margin-top: 0;
    color: #333;
}
