/* Mitgliederverwaltung - Stylesheet */

/* Reset & Base */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

:root {
    --primary-color: #667eea;
    --primary-dark: #5568d3;
    --secondary-color: #764ba2;
    --success-color: #48bb78;
    --danger-color: #f56565;
    --warning-color: #ed8936;
    --info-color: #4299e1;
    --gray-50: #f9fafb;
    --gray-100: #f3f4f6;
    --gray-200: #e5e7eb;
    --gray-300: #d1d5db;
    --gray-400: #9ca3af;
    --gray-500: #6b7280;
    --gray-600: #4b5563;
    --gray-700: #374151;
    --gray-800: #1f2937;
    --gray-900: #111827;
    --sidebar-width: 280px;
    --header-height: 64px;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
    font-size: 14px;
    line-height: 1.6;
    color: var(--gray-800);
    background: var(--gray-50);
}

/* Login Page */
.login-page {
    background: linear-gradient(135deg, var(--primary-color) 0%, var(--secondary-color) 100%);
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
}

.login-container {
    width: 100%;
    max-width: 420px;
}

.login-box {
    background: white;
    border-radius: 12px;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.2);
    padding: 40px;
}

.login-box h1 {
    color: var(--gray-800);
    font-size: 28px;
    margin-bottom: 8px;
}

.login-box .subtitle {
    color: var(--gray-500);
    font-size: 14px;
    margin-bottom: 30px;
}

/* App Layout */
.app-layout {
    display: flex;
    min-height: 100vh;
}

/* Sidebar */
.sidebar {
    width: var(--sidebar-width);
    background: white;
    border-right: 1px solid var(--gray-200);
    position: fixed;
    top: 0;
    left: 0;
    bottom: 0;
    overflow-y: auto;
    z-index: 100;
    transition: transform 0.3s ease;
    display: flex;
    flex-direction: column;
}

.sidebar-header {
    padding: 20px;
    border-bottom: 1px solid var(--gray-200);
}

.sidebar-header h2 {
    font-size: 20px;
    color: var(--gray-800);
    font-weight: 700;
}

.sidebar-header .subtitle {
    font-size: 12px;
    color: var(--gray-500);
    margin-top: 2px;
}

.sidebar-nav {
    padding: 20px 0;
    flex: 1;
    overflow-y: auto;
}

.nav-section {
    margin-bottom: 24px;
}

.nav-section-title {
    font-size: 11px;
    font-weight: 600;
    color: var(--gray-500);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    padding: 0 20px;
    margin-bottom: 8px;
}

.nav-item {
    display: flex;
    align-items: center;
    padding: 10px 20px;
    color: var(--gray-700);
    text-decoration: none;
    transition: all 0.2s;
}

.nav-item:hover {
    background: var(--gray-50);
    color: var(--primary-color);
}

.nav-item.active {
    background: linear-gradient(135deg, var(--primary-color) 0%, var(--secondary-color) 100%);
    color: white;
}

.nav-item svg {
    width: 20px;
    height: 20px;
    margin-right: 12px;
}

.sidebar-footer {
    padding: 20px;
    border-top: 1px solid var(--gray-200);
    background: white;
    margin-top: auto;
}

.user-info {
    display: flex;
    align-items: center;
    margin-bottom: 12px;
}

.user-avatar {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background: linear-gradient(135deg, var(--primary-color) 0%, var(--secondary-color) 100%);
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    font-weight: 600;
    margin-right: 12px;
}

.user-details {
    flex: 1;
}

.user-name {
    font-weight: 600;
    font-size: 14px;
    color: var(--gray-800);
}

.user-role {
    font-size: 12px;
    color: var(--gray-500);
}

/* Main Content */
.main-content {
    flex: 1;
    margin-left: var(--sidebar-width);
    min-height: 100vh;
}

.header {
    height: var(--header-height);
    background: white;
    border-bottom: 1px solid var(--gray-200);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 32px;
    position: sticky;
    top: 0;
    z-index: 50;
}

.header-left h1 {
    font-size: 24px;
    font-weight: 700;
    color: var(--gray-800);
}

.header-right {
    display: flex;
    align-items: center;
    gap: 16px;
}

.content {
    padding: 32px;
}

/* Components */

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

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

label {
    display: block;
    margin-bottom: 6px;
    font-weight: 500;
    color: var(--gray-700);
    font-size: 14px;
}

input[type="text"],
input[type="email"],
input[type="password"],
input[type="date"],
input[type="number"],
textarea,
select {
    width: 100%;
    padding: 10px 12px;
    border: 1px solid var(--gray-300);
    border-radius: 6px;
    font-size: 14px;
    font-family: inherit;
    transition: border-color 0.2s, box-shadow 0.2s;
}

input:focus,
textarea:focus,
select:focus {
    outline: none;
    border-color: var(--primary-color);
    box-shadow: 0 0 0 3px rgba(102, 126, 234, 0.1);
}

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

.input-hint {
    font-size: 12px;
    color: var(--gray-500);
    margin-top: 4px;
}

/* Buttons */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 10px 20px;
    border: none;
    border-radius: 6px;
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s;
    text-decoration: none;
    gap: 8px;
}

.btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.btn-primary {
    background: linear-gradient(135deg, var(--primary-color) 0%, var(--secondary-color) 100%);
    color: white;
}

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

.btn-secondary {
    background: var(--gray-200);
    color: var(--gray-700);
}

.btn-secondary:hover:not(:disabled) {
    background: var(--gray-300);
}

.btn-success {
    background: var(--success-color);
    color: white;
}

.btn-danger {
    background: var(--danger-color);
    color: white;
}

.btn-sm {
    padding: 6px 12px;
    font-size: 13px;
}

.btn-block {
    width: 100%;
}

.btn-group {
    display: flex;
    gap: 8px;
}

/* Alerts */
.alert {
    padding: 12px 16px;
    border-radius: 6px;
    margin-bottom: 20px;
    font-size: 14px;
}

.alert-success {
    background: #f0fdf4;
    color: #166534;
    border: 1px solid #bbf7d0;
}

.alert-error {
    background: #fef2f2;
    color: #991b1b;
    border: 1px solid #fecaca;
}

.alert-warning {
    background: #fffbeb;
    color: #92400e;
    border: 1px solid #fde68a;
}

.alert-info {
    background: #eff6ff;
    color: #1e40af;
    border: 1px solid #bfdbfe;
}

/* Cards */
.card {
    background: white;
    border-radius: 8px;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
    margin-bottom: 24px;
}

.card-header {
    padding: 20px 24px;
    border-bottom: 1px solid var(--gray-200);
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.card-title {
    font-size: 18px;
    font-weight: 600;
    color: var(--gray-800);
}

.card-body {
    padding: 24px;
}

/* Tables */
.table-container {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    position: relative;
}

table {
    width: 100%;
    border-collapse: collapse;
    table-layout: fixed;
    min-width: 800px; /* Ensure table doesn't compress too much */
}

thead {
    background: var(--gray-50);
}

th {
    padding: 12px;
    text-align: left;
    font-weight: 600;
    font-size: 12px;
    color: var(--gray-600);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    border-bottom: 2px solid var(--gray-200);
    position: relative;
    overflow: hidden;
    white-space: nowrap;
    text-overflow: ellipsis;
}

/* Resizable column handle */
th .resize-handle {
    position: absolute;
    right: 0;
    top: 0;
    bottom: 0;
    width: 5px;
    cursor: col-resize;
    user-select: none;
    z-index: 10;
}

th .resize-handle:hover,
th .resize-handle.active {
    background: var(--primary-color);
}

/* Draggable column */
th.draggable {
    cursor: move;
}

th.dragging {
    opacity: 0.5;
    background: var(--gray-200);
}

th.drag-over {
    border-left: 3px solid var(--primary-color);
}

td {
    padding: 12px;
    border-bottom: 1px solid var(--gray-200);
    overflow: hidden;
    white-space: nowrap;
    text-overflow: ellipsis;
}

tr:hover {
    background: var(--gray-50);
}

/* Email Composer Layout */
.email-composer-grid {
    display: grid;
    grid-template-columns: 70% 30%;
    gap: 24px;
    align-items: start;
}

@media (min-width: 1200px) {
    .email-composer-grid {
        grid-template-columns: 75% 25%;
    }
}

/* Email Composer Sidebar - prevent overflow */
.email-composer-grid > div:last-child {
    min-width: 0;
    overflow: hidden;
}

/* Member Detail View Grid */
.member-detail-grid {
    display: grid;
    grid-template-columns: 1fr 320px;
    gap: 20px;
}

@media (max-width: 1200px) {
    .member-detail-grid {
        grid-template-columns: 1fr 280px;
    }
}

@media (max-width: 1024px) {
    .member-detail-grid {
        grid-template-columns: 1fr;
    }
}

/* Member detail cards - prevent overflow */
.member-detail-grid .card {
    min-width: 0;
    overflow: hidden;
}

.member-detail-grid .card-body {
    min-width: 0;
    overflow: hidden;
}

.member-detail-grid .card-body table {
    table-layout: fixed;
    width: 100%;
    min-width: 0;
}

.member-detail-grid .card-body table td {
    word-wrap: break-word;
    overflow-wrap: break-word;
    white-space: normal;
    overflow: hidden;
}

.email-composer-grid .card {
    min-width: 0;
    overflow: hidden;
}

.email-composer-grid .card-body {
    min-width: 0;
    overflow-x: hidden;
    overflow-y: auto;
    max-height: 70vh;
    word-wrap: break-word;
}

.email-composer-grid .card-body code,
.email-composer-grid .card-body pre {
    word-wrap: break-word;
    white-space: pre-wrap;
    overflow-wrap: break-word;
}

/* Mobile Card View */
.members-card-view {
    display: none;
}

.member-card {
    background: white;
    border: 1px solid var(--gray-200);
    border-radius: 8px;
    padding: 16px;
    margin-bottom: 12px;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.05);
    transition: box-shadow 0.2s;
}

.member-card:active {
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.1);
}

.member-card-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    margin-bottom: 12px;
    padding-bottom: 12px;
    border-bottom: 1px solid var(--gray-200);
}

.member-card-title {
    flex: 1;
}

.member-card-name {
    font-size: 16px;
    font-weight: 600;
    color: var(--gray-800);
    margin-bottom: 4px;
}

.member-card-number {
    font-size: 13px;
    color: var(--gray-500);
}

.member-card-actions {
    display: flex;
    gap: 8px;
}

.member-card-body {
    display: grid;
    gap: 8px;
}

.member-card-field {
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-size: 14px;
}

.member-card-label {
    color: var(--gray-600);
    font-weight: 500;
    flex-shrink: 0;
    margin-right: 12px;
}

.member-card-value {
    color: var(--gray-800);
    text-align: right;
    word-break: break-word;
}

.member-card-checkbox {
    position: absolute;
    top: 16px;
    left: 16px;
}

.member-card.selected {
    border-color: var(--primary-color);
    background: #f8f9ff;
}

/* Stats Grid */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
    gap: 24px;
    margin-bottom: 32px;
}

.stat-card {
    background: white;
    border-radius: 8px;
    padding: 20px;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
}

.stat-label {
    font-size: 13px;
    color: var(--gray-500);
    font-weight: 500;
    margin-bottom: 8px;
}

.stat-value {
    font-size: 32px;
    font-weight: 700;
    color: var(--gray-800);
    line-height: 1.2;
}

.stat-icon {
    width: 48px;
    height: 48px;
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    margin-bottom: 16px;
}

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

.modal.active {
    display: flex;
}

.modal-content {
    background: white;
    border-radius: 12px;
    max-width: 600px;
    width: 90%;
    max-height: 90vh;
    overflow-y: auto;
}

.modal-header {
    padding: 24px;
    border-bottom: 1px solid var(--gray-200);
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.modal-title {
    font-size: 20px;
    font-weight: 600;
    color: var(--gray-800);
}

.modal-body {
    padding: 24px;
}

.modal-footer {
    padding: 20px 24px;
    border-top: 1px solid var(--gray-200);
    display: flex;
    gap: 12px;
    justify-content: flex-end;
}

/* Badge */
.badge {
    display: inline-block;
    padding: 4px 10px;
    border-radius: 12px;
    font-size: 12px;
    font-weight: 500;
}

.badge-success {
    background: #dcfce7;
    color: #166534;
}

.badge-warning {
    background: #fef3c7;
    color: #92400e;
}

.badge-danger {
    background: #fee2e2;
    color: #991b1b;
}

.badge-info {
    background: #dbeafe;
    color: #1e40af;
}

/* Loading Spinner */
.spinner {
    border: 3px solid var(--gray-200);
    border-top-color: var(--primary-color);
    border-radius: 50%;
    width: 40px;
    height: 40px;
    animation: spin 0.8s linear infinite;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

/* Responsive */
/* Mobile Hamburger Button */
.mobile-menu-toggle {
    display: none;
    position: fixed;
    top: 16px;
    left: 16px;
    z-index: 1001;
    background: var(--primary-color);
    color: white;
    border: none;
    border-radius: 8px;
    width: 44px;
    height: 44px;
    cursor: pointer;
    box-shadow: 0 2px 8px rgba(0,0,0,0.2);
    transition: all 0.3s;
}

.mobile-menu-toggle:hover {
    background: var(--primary-dark);
    transform: scale(1.05);
}

.mobile-menu-toggle svg {
    display: block;
    margin: auto;
}

/* Mobile Bottom Navigation */
.mobile-bottom-nav {
    display: none;
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    background: white;
    border-top: 1px solid var(--gray-200);
    box-shadow: 0 -2px 10px rgba(0,0,0,0.1);
    z-index: 1000;
    padding: 8px 0;
}

.mobile-bottom-nav-items {
    display: flex;
    justify-content: space-around;
    align-items: center;
}

.mobile-nav-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 8px 12px;
    color: var(--gray-600);
    text-decoration: none;
    transition: color 0.2s;
    min-width: 60px;
}

.mobile-nav-item:hover,
.mobile-nav-item.active {
    color: var(--primary-color);
}

.mobile-nav-item svg {
    margin-bottom: 4px;
}

/* Tablet adjustments */
@media (max-width: 1024px) {
    table {
        min-width: 600px;
    }

    th, td {
        padding: 10px 8px;
        font-size: 13px;
    }
}

@media (max-width: 768px) {
    .mobile-menu-toggle {
        display: block;
    }

    .mobile-bottom-nav {
        display: block;
    }

    .sidebar {
        position: fixed;
        top: 0;
        left: 0;
        bottom: 0;
        z-index: 1000;
        transform: translateX(-100%);
        transition: transform 0.3s ease;
        box-shadow: 2px 0 10px rgba(0,0,0,0.1);
    }

    .sidebar.mobile-open {
        transform: translateX(0);
    }

    /* Overlay when sidebar is open */
    body.sidebar-open::after {
        content: '';
        position: fixed;
        top: 0;
        left: 0;
        right: 0;
        bottom: 0;
        background: rgba(0,0,0,0.5);
        z-index: 999;
    }

    .main-content {
        margin-left: 0;
        padding-bottom: 70px; /* Space for bottom nav */
    }

    .content {
        padding: 16px; /* Remove top padding overlap */
        padding-top: 16px;
    }

    .page-header {
        padding-top: 60px; /* Space for hamburger button */
    }

    .header {
        padding: 0 16px;
    }

    .stats-grid {
        grid-template-columns: repeat(2, 1fr);
        gap: 12px;
    }

    .stat-card {
        padding: 16px;
    }

    .stat-value {
        font-size: 24px;
    }

    .stat-icon {
        width: 36px;
        height: 36px;
        margin-bottom: 12px;
    }

    .form-row {
        grid-template-columns: 1fr;
    }

    /* Hide desktop-only elements */
    .page-subtitle {
        display: none;
    }

    /* Switch to card view on mobile - only for members page */
    #members-table {
        display: none !important;
    }

    .members-card-view {
        display: block !important;
    }

    /* Dashboard tables remain visible but optimize */
    .table-container table {
        min-width: auto;
        font-size: 13px;
    }

    .table-container th,
    .table-container td {
        padding: 8px 4px;
        font-size: 12px;
    }

    /* Adjust batch toolbar for mobile */
    #batch-toolbar {
        padding: 8px 12px !important;
    }

    #batch-toolbar > div {
        flex-direction: column !important;
        align-items: stretch !important;
        gap: 8px !important;
    }

    #batch-toolbar select,
    #batch-toolbar button {
        width: 100% !important;
        min-width: auto !important;
    }

    /* Mobile filter adjustments */
    .card-body form > div {
        flex-direction: column;
    }

    .card-body form input,
    .card-body form select {
        width: 100%;
    }

    /* Email composer mobile */
    .email-composer-grid {
        grid-template-columns: 1fr !important;
    }

    /* Keep form on top, template vars below on mobile */
    .email-composer-grid > div:first-child {
        order: 1;
    }

    .email-composer-grid > div:last-child {
        order: 2;
    }
}

/* Print Styles */
@media print {
    .sidebar,
    .header-right,
    .btn,
    .modal {
        display: none !important;
    }

    .main-content {
        margin-left: 0;
    }

    .card {
        box-shadow: none;
        border: 1px solid var(--gray-200);
    }
}

/* Checkbox Group für Multi-Select */
.checkbox-group {
    display: flex;
    flex-direction: column;
    gap: 10px;
    padding: 10px;
    background: var(--gray-50);
    border: 1px solid var(--gray-200);
    border-radius: 6px;
}

.checkbox-label {
    display: flex;
