/* ============================================================
   ERC Sonthofen - Mitgliederverwaltung
   Design: Clean, utilitarian sports-club aesthetic
   ============================================================ */

:root {
    --bg: #f5f6f8;
    --bg-card: #ffffff;
    --bg-sidebar: #0f172a;
    --bg-sidebar-hover: #1e293b;
    --bg-sidebar-active: #2563eb;
    --text: #1e293b;
    --text-muted: #64748b;
    --text-sidebar: #94a3b8;
    --text-sidebar-active: #ffffff;
    --border: #e2e8f0;
    --primary: #2563eb;
    --primary-hover: #1d4ed8;
    --primary-light: #eff6ff;
    --danger: #dc2626;
    --danger-hover: #b91c1c;
    --danger-light: #fef2f2;
    --success: #16a34a;
    --success-light: #f0fdf4;
    --warning: #d97706;
    --warning-light: #fffbeb;
    --radius: 8px;
    --radius-lg: 12px;
    --shadow: 0 1px 3px rgba(0,0,0,0.08), 0 1px 2px rgba(0,0,0,0.04);
    --shadow-md: 0 4px 6px rgba(0,0,0,0.06), 0 2px 4px rgba(0,0,0,0.04);
    --font: 'DM Sans', -apple-system, BlinkMacSystemFont, sans-serif;
    --font-mono: 'JetBrains Mono', 'Fira Code', monospace;
    --sidebar-width: 250px;
    --transition: 150ms ease;
}

@import url('https://fonts.googleapis.com/css2?family=DM+Sans:ital,opsz,wght@0,9..40,300;0,9..40,400;0,9..40,500;0,9..40,600;0,9..40,700;1,9..40,400&display=swap');

/* Reset */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

html { font-size: 15px; }
body {
    font-family: var(--font);
    background: var(--bg);
    color: var(--text);
    line-height: 1.6;
    min-height: 100vh;
}

a { color: var(--primary); text-decoration: none; }
a:hover { text-decoration: underline; }

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

/* Sidebar */
.sidebar {
    width: var(--sidebar-width);
    background: var(--bg-sidebar);
    display: flex;
    flex-direction: column;
    position: fixed;
    top: 0;
    left: 0;
    bottom: 0;
    z-index: 100;
    transition: transform var(--transition);
}

.sidebar-brand {
    padding: 1.5rem 1.25rem;
    border-bottom: 1px solid rgba(255,255,255,0.08);
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.sidebar-brand-icon {
    width: 36px;
    height: 36px;
    background: var(--primary);
    border-radius: var(--radius);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.1rem;
}

.sidebar-brand-text {
    color: #fff;
    font-weight: 700;
    font-size: 1rem;
    line-height: 1.2;
}

.sidebar-brand-text small {
    display: block;
    font-weight: 400;
    font-size: 0.7rem;
    color: var(--text-sidebar);
    letter-spacing: 0.5px;
    text-transform: uppercase;
    margin-top: 2px;
}

.sidebar-nav {
    flex: 1;
    padding: 1rem 0.75rem;
    overflow-y: auto;
}

.sidebar-nav-label {
    color: var(--text-sidebar);
    font-size: 0.65rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 1px;
    padding: 0.75rem 0.5rem 0.4rem;
    margin-top: 0.5rem;
}

.sidebar-nav a {
    display: flex;
    align-items: center;
    gap: 0.7rem;
    padding: 0.6rem 0.75rem;
    border-radius: var(--radius);
    color: var(--text-sidebar);
    font-size: 0.9rem;
    font-weight: 400;
    transition: all var(--transition);
    text-decoration: none;
    margin-bottom: 2px;
}

.sidebar-nav a:hover {
    background: var(--bg-sidebar-hover);
    color: #fff;
    text-decoration: none;
}

.sidebar-nav a.active {
    background: var(--bg-sidebar-active);
    color: var(--text-sidebar-active);
    font-weight: 500;
}

.sidebar-nav a svg {
    width: 18px;
    height: 18px;
    opacity: 0.7;
    flex-shrink: 0;
}

.sidebar-nav a.active svg { opacity: 1; }

.sidebar-footer {
    padding: 1rem 1.25rem;
    border-top: 1px solid rgba(255,255,255,0.08);
}

.sidebar-user {
    display: flex;
    align-items: center;
    gap: 0.6rem;
    color: var(--text-sidebar);
    font-size: 0.85rem;
}

.sidebar-user-avatar {
    width: 32px;
    height: 32px;
    background: var(--bg-sidebar-hover);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 600;
    font-size: 0.75rem;
    color: #fff;
}

.sidebar-user-info { flex: 1; min-width: 0; }
.sidebar-user-name { color: #fff; font-weight: 500; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.sidebar-user-role { font-size: 0.7rem; text-transform: uppercase; letter-spacing: 0.5px; }

.sidebar-logout {
    color: var(--text-sidebar) !important;
    font-size: 0.8rem;
    padding: 0.3rem 0.5rem;
    border-radius: 4px;
}

.sidebar-logout:hover { background: var(--bg-sidebar-hover); color: #fff !important; }

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

.page-header {
    background: var(--bg-card);
    border-bottom: 1px solid var(--border);
    padding: 1.25rem 2rem;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    position: sticky;
    top: 0;
    z-index: 50;
}

.page-title {
    font-size: 1.25rem;
    font-weight: 700;
    color: var(--text);
}

.page-title small {
    font-weight: 400;
    color: var(--text-muted);
    font-size: 0.85rem;
    margin-left: 0.5rem;
}

.page-body {
    padding: 1.5rem 2rem;
}

/* Cards */
.card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow);
}

.card-header {
    padding: 1rem 1.25rem;
    border-bottom: 1px solid var(--border);
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
}

.card-header h2, .card-header h3 {
    font-size: 1rem;
    font-weight: 600;
}

.card-body { padding: 1.25rem; }

/* Stats grid */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 1rem;
    margin-bottom: 1.5rem;
}

.stat-card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: 1.25rem;
    box-shadow: var(--shadow);
    display: flex;
    align-items: flex-start;
    gap: 1rem;
}

.stat-icon {
    width: 42px;
    height: 42px;
    border-radius: var(--radius);
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.stat-icon.blue { background: var(--primary-light); color: var(--primary); }
.stat-icon.green { background: var(--success-light); color: var(--success); }
.stat-icon.amber { background: var(--warning-light); color: var(--warning); }
.stat-icon.red { background: var(--danger-light); color: var(--danger); }

.stat-icon svg { width: 20px; height: 20px; }

.stat-content {}
.stat-value { font-size: 1.6rem; font-weight: 700; line-height: 1.2; }
.stat-label { font-size: 0.8rem; color: var(--text-muted); margin-top: 2px; }

/* Buttons */
.btn {
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
    padding: 0.5rem 1rem;
    border: 1px solid transparent;
    border-radius: var(--radius);
    font-family: var(--font);
    font-size: 0.85rem;
    font-weight: 500;
    cursor: pointer;
    transition: all var(--transition);
    text-decoration: none;
    line-height: 1.4;
    white-space: nowrap;
}

.btn svg { width: 16px; height: 16px; }

.btn-primary { background: var(--primary); color: #fff; }
.btn-primary:hover { background: var(--primary-hover); text-decoration: none; color: #fff; }

.btn-secondary { background: var(--bg); border-color: var(--border); color: var(--text); }
.btn-secondary:hover { background: #e9ecf0; text-decoration: none; }

.btn-danger { background: var(--danger); color: #fff; }
.btn-danger:hover { background: var(--danger-hover); text-decoration: none; color: #fff; }

.btn-sm { padding: 0.35rem 0.7rem; font-size: 0.8rem; }
.btn-sm svg { width: 14px; height: 14px; }

.btn-icon {
    padding: 0.4rem;
    border-radius: var(--radius);
    background: transparent;
    border: 1px solid transparent;
    color: var(--text-muted);
    cursor: pointer;
    transition: all var(--transition);
}

.btn-icon:hover { background: var(--bg); color: var(--text); }

/* Forms */
.form-group {
    margin-bottom: 1rem;
}

.form-label {
    display: block;
    font-size: 0.8rem;
    font-weight: 600;
    color: var(--text);
    margin-bottom: 0.35rem;
}

.form-label .required { color: var(--danger); }

.form-control {
    width: 100%;
    padding: 0.55rem 0.75rem;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    font-family: var(--font);
    font-size: 0.9rem;
    background: var(--bg-card);
    color: var(--text);
    transition: border-color var(--transition), box-shadow var(--transition);
}

.form-control:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(37,99,235,0.1);
}

.form-control::placeholder { color: var(--text-muted); }

select.form-control {
    appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%2364748b' stroke-width='2'%3E%3Cpath d='M6 9l6 6 6-6'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 0.75rem center;
    padding-right: 2rem;
}

.form-row {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    gap: 1rem;
}

.form-check {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.form-check input[type="checkbox"] {
    width: 16px;
    height: 16px;
    accent-color: var(--primary);
}

.form-hint {
    font-size: 0.75rem;
    color: var(--text-muted);
    margin-top: 0.25rem;
}

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

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

thead th {
    background: var(--bg);
    font-size: 0.75rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: var(--text-muted);
    padding: 0.6rem 0.75rem;
    text-align: left;
    border-bottom: 1px solid var(--border);
    white-space: nowrap;
    position: sticky;
    top: 0;
}

thead th a {
    color: inherit;
    text-decoration: none;
    display: inline-flex;
    align-items: center;
    gap: 0.3rem;
}

thead th a:hover { color: var(--text); }

tbody td {
    padding: 0.65rem 0.75rem;
    border-bottom: 1px solid var(--border);
    font-size: 0.88rem;
    vertical-align: middle;
}

tbody tr:hover { background: #f8fafc; }

tbody tr:last-child td { border-bottom: none; }

.table-actions {
    display: flex;
    gap: 0.25rem;
}

/* Badges */
.badge {
    display: inline-flex;
    align-items: center;
    padding: 0.2rem 0.6rem;
    border-radius: 100px;
    font-size: 0.72rem;
    font-weight: 600;
    letter-spacing: 0.3px;
}

.badge-blue { background: var(--primary-light); color: var(--primary); }
.badge-green { background: var(--success-light); color: var(--success); }
.badge-amber { background: var(--warning-light); color: var(--warning); }
.badge-red { background: var(--danger-light); color: var(--danger); }
.badge-gray { background: #f1f5f9; color: var(--text-muted); }

/* Alerts */
.alert {
    padding: 0.8rem 1rem;
    border-radius: var(--radius);
    font-size: 0.88rem;
    margin-bottom: 1rem;
    display: flex;
    align-items: flex-start;
    gap: 0.6rem;
}

.alert svg { width: 18px; height: 18px; flex-shrink: 0; margin-top: 1px; }

.alert-success { background: var(--success-light); color: #15803d; border: 1px solid #bbf7d0; }
.alert-error { background: var(--danger-light); color: #991b1b; border: 1px solid #fecaca; }
.alert-warning { background: var(--warning-light); color: #92400e; border: 1px solid #fde68a; }
.alert-info { background: var(--primary-light); color: #1e40af; border: 1px solid #bfdbfe; }

/* Pagination */
.pagination {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0.75rem 1.25rem;
    border-top: 1px solid var(--border);
    font-size: 0.85rem;
    color: var(--text-muted);
}

.pagination-links {
    display: flex;
    gap: 0.25rem;
}

.pagination-links a,
.pagination-links span {
    padding: 0.35rem 0.65rem;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    font-size: 0.8rem;
    color: var(--text);
    text-decoration: none;
}

.pagination-links a:hover { background: var(--bg); }
.pagination-links span.active {
    background: var(--primary);
    color: #fff;
    border-color: var(--primary);
}

/* Filter bar */
.filter-bar {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
    align-items: flex-end;
    padding: 1rem 1.25rem;
    border-bottom: 1px solid var(--border);
    background: #fafbfc;
    border-radius: var(--radius-lg) var(--radius-lg) 0 0;
}

.filter-bar .form-group { margin-bottom: 0; }

.filter-bar .form-control {
    font-size: 0.82rem;
    padding: 0.45rem 0.65rem;
}

.filter-bar .search-input {
    min-width: 250px;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%2394a3b8' stroke-width='2'%3E%3Ccircle cx='11' cy='11' r='8'/%3E%3Cpath d='M21 21l-4.35-4.35'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: 0.65rem center;
    padding-left: 2.2rem;
}

/* Login page */
.login-page {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    background: linear-gradient(135deg, #0f172a 0%, #1e293b 100%);
    padding: 1rem;
}

.login-card {
    background: var(--bg-card);
    border-radius: var(--radius-lg);
    box-shadow: 0 20px 60px rgba(0,0,0,0.3);
    width: 100%;
    max-width: 400px;
    overflow: hidden;
}

.login-header {
    background: var(--primary);
    padding: 2rem 2rem 1.75rem;
    text-align: center;
    color: #fff;
}

.login-header h1 {
    font-size: 1.4rem;
    font-weight: 700;
    margin-bottom: 0.25rem;
}

.login-header p {
    font-size: 0.85rem;
    opacity: 0.85;
}

.login-body {
    padding: 2rem;
}

.login-body .form-control {
    padding: 0.7rem 0.85rem;
    font-size: 0.95rem;
}

.login-body .btn {
    width: 100%;
    padding: 0.7rem;
    font-size: 0.95rem;
    justify-content: center;
    margin-top: 0.5rem;
}

/* Detail view */
.detail-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: 1.5rem;
}

.detail-section h3 {
    font-size: 0.8rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: var(--text-muted);
    margin-bottom: 0.75rem;
    padding-bottom: 0.5rem;
    border-bottom: 1px solid var(--border);
}

.detail-row {
    display: flex;
    justify-content: space-between;
    padding: 0.4rem 0;
    font-size: 0.88rem;
}

.detail-row dt {
    color: var(--text-muted);
    font-weight: 400;
}

.detail-row dd {
    font-weight: 500;
    text-align: right;
}

/* Upload area */
.upload-area {
    border: 2px dashed var(--border);
    border-radius: var(--radius-lg);
    padding: 2.5rem;
    text-align: center;
    cursor: pointer;
    transition: all var(--transition);
    background: #fafbfc;
}

.upload-area:hover, .upload-area.dragover {
    border-color: var(--primary);
    background: var(--primary-light);
}

.upload-area svg { color: var(--text-muted); margin-bottom: 0.75rem; }
.upload-area p { color: var(--text-muted); font-size: 0.9rem; }
.upload-area .upload-hint { font-size: 0.78rem; color: #94a3b8; margin-top: 0.25rem; }

/* Confirm dialog */
.confirm-overlay {
    position: fixed; inset: 0;
    background: rgba(0,0,0,0.5);
    display: none; align-items: center; justify-content: center;
    z-index: 1000;
}

.confirm-overlay.show { display: flex; }

.confirm-dialog {
    background: var(--bg-card);
    border-radius: var(--radius-lg);
    padding: 1.5rem;
    width: 90%; max-width: 400px;
    box-shadow: 0 20px 60px rgba(0,0,0,0.2);
}

.confirm-dialog h3 { margin-bottom: 0.5rem; }
.confirm-dialog p { color: var(--text-muted); font-size: 0.9rem; margin-bottom: 1.25rem; }
.confirm-dialog .btn-row { display: flex; gap: 0.5rem; justify-content: flex-end; }

/* Mobile hamburger */
.mobile-toggle {
    display: none;
    background: none;
    border: none;
    color: var(--text);
    cursor: pointer;
    padding: 0.5rem;
}

.mobile-toggle svg { width: 24px; height: 24px; }

/* Responsive */
@media (max-width: 768px) {
    :root { --sidebar-width: 0px; }

    .sidebar {
        transform: translateX(-260px);
        width: 260px;
    }

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

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

    .mobile-toggle { display: block; }

    .page-header { padding: 1rem; }
    .page-body { padding: 1rem; }

    .filter-bar {
        flex-direction: column;
    }

    .filter-bar .form-group { width: 100%; }
    .filter-bar .search-input { min-width: auto; }

    .stats-grid { grid-template-columns: 1fr 1fr; }

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

@media (max-width: 480px) {
    .stats-grid { grid-template-columns: 1fr; }
}

/* Utility */
.text-muted { color: var(--text-muted); }
.text-danger { color: var(--danger); }
.text-success { color: var(--success); }
.text-right { text-align: right; }
.text-center { text-align: center; }
.mb-0 { margin-bottom: 0; }
.mb-1 { margin-bottom: 0.5rem; }
.mb-2 { margin-bottom: 1rem; }
.mt-1 { margin-top: 0.5rem; }
.mt-2 { margin-top: 1rem; }
.d-flex { display: flex; }
.gap-1 { gap: 0.5rem; }
.gap-2 { gap: 1rem; }
.items-center { align-items: center; }
.justify-between { justify-content: space-between; }
.flex-wrap { flex-wrap: wrap; }
.w-full { width: 100%; }

/* Scrollbar */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: #cbd5e1; border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: #94a3b8; }

/* IBAN masking */
.iban-masked { font-family: var(--font-mono); font-size: 0.85rem; letter-spacing: 0.5px; }

/* Print */
@media print {
    .sidebar, .page-header, .filter-bar, .pagination, .table-actions, .btn { display: none !important; }
    .main-content { margin-left: 0 !important; }
    .page-body { padding: 0 !important; }
    tbody td { font-size: 0.8rem; padding: 0.3rem 0.5rem; }
}
