/* ============================================================
   Wohnungsverwaltung – Design System
   Basierend auf ATN Cloud Teal Design
   ============================================================ */

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

body {
    padding-top: 60px;
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
    line-height: 1.6;
    background-color: #f0f9ff;
    color: #1e293b;
}

a {
    color: #0e7490;
    text-decoration: none;
}

a:hover {
    color: #0c4a6e;
    text-decoration: underline;
}

/* ============================================================
   HEADER & NAVIGATION
   ============================================================ */
header {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 60px;
    z-index: 1000;
    background: linear-gradient(135deg, #0c4a6e 0%, #0e7490 100%);
    box-shadow: 0 2px 12px rgba(0, 0, 0, 0.15);
}

nav {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0 20px;
    height: 100%;
}

.nav-brand {
    font-size: 1.2em;
    font-weight: 700;
    color: #fff;
    letter-spacing: -0.02em;
}

.nav-links {
    list-style: none;
    display: flex;
    gap: 4px;
    align-items: center;
}

.nav-links li {
    position: relative;
    padding-bottom: 8px;
    margin-bottom: -8px;
}

.nav-links a {
    color: #e0f2fe;
    text-decoration: none;
    padding: 8px 14px;
    border-radius: 6px;
    transition: all 0.2s;
    font-size: 0.9em;
    font-weight: 500;
    display: block;
}

.nav-links a:hover {
    background: rgba(255, 255, 255, 0.15);
    color: #fff;
    text-decoration: none;
}

.nav-links a.active {
    background: rgba(255, 255, 255, 0.2);
    color: #fff;
    font-weight: 600;
}

/* Submenü */
.sub-menu {
    display: none;
    position: absolute;
    top: 100%;
    left: 50%;
    transform: translateX(-50%);
    background: #fff;
    z-index: 100;
    list-style: none;
    padding: 6px 0;
    margin-top: 0;
    padding-top: 4px;
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.12);
    border-radius: 8px;
    min-width: 180px;
}

.sub-menu a {
    color: #1e293b;
    padding: 10px 16px;
    font-size: 0.85em;
}

.sub-menu a:hover {
    background: #f0f9ff;
    color: #0e7490;
}

.nav-links li:hover > .sub-menu {
    display: block;
}

.nav-user {
    color: #bae6fd;
    font-size: 0.85em;
    padding: 0 8px;
}

/* Hamburger */
.hamburger {
    display: none;
    font-size: 28px;
    cursor: pointer;
    color: #fff;
    background: none;
    border: none;
}

/* ============================================================
   LAYOUT
   ============================================================ */
.page-layout {
    display: grid;
    grid-template-columns: 260px 1fr;
    align-items: start;
    min-height: calc(100vh - 60px);
}

.page-layout.no-sidebar {
    grid-template-columns: 1fr;
}

/* --- Sidebar --- */
.sidebar {
    position: sticky;
    top: 60px;
    height: calc(100vh - 60px);
    overflow-y: auto;
    background: linear-gradient(180deg, #0c4a6e 0%, #0e7490 100%);
    padding: 20px 16px;
    color: #e0f2fe;
}

.sidebar h3 {
    font-size: 0.85em;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: #bae6fd;
    margin-bottom: 12px;
    padding-bottom: 8px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
}

.sidebar-nav {
    list-style: none;
}

.sidebar-nav a {
    display: block;
    padding: 10px 12px;
    color: #e0f2fe;
    border-radius: 6px;
    font-size: 0.9em;
    transition: all 0.2s;
    text-decoration: none;
}

.sidebar-nav a:hover,
.sidebar-nav a.active {
    background: rgba(255, 255, 255, 0.12);
    color: #fff;
    text-decoration: none;
}

.sidebar label {
    display: block;
    font-size: 0.8em;
    color: #bae6fd;
    margin-bottom: 6px;
    margin-top: 14px;
}

.sidebar select,
.sidebar input[type="text"],
.sidebar input[type="number"],
.sidebar input[type="date"] {
    width: 100%;
    padding: 8px 10px;
    border: 1px solid rgba(255, 255, 255, 0.2);
    border-radius: 6px;
    background: rgba(255, 255, 255, 0.1);
    color: #fff;
    font-size: 0.85em;
}

.sidebar select option {
    background: #0c4a6e;
    color: #fff;
}

/* --- Main Content --- */
.main-content {
    padding: 24px;
    height: calc(100vh - 60px);
    overflow: auto;
}

.content-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
}

.content-header h1 {
    font-size: 1.5em;
    font-weight: 700;
    color: #0c4a6e;
}

/* ============================================================
   CARDS
   ============================================================ */
.card {
    background: #fff;
    border-radius: 12px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.07);
    padding: 24px;
    margin-bottom: 20px;
}

.card-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 16px;
    padding-bottom: 12px;
    border-bottom: 1px solid #e2e8f0;
}

.card-header h2 {
    font-size: 1.1em;
    font-weight: 600;
    color: #0c4a6e;
}

/* ============================================================
   TABELLEN
   ============================================================ */
table {
    width: 100%;
    border-collapse: collapse;
}

thead th {
    position: sticky;
    top: 0;
    z-index: 2;
    background: #0e7490;
    color: #fff;
    padding: 12px 16px;
    text-align: left;
    font-size: 0.85em;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.03em;
    white-space: nowrap;
}

thead th:first-child {
    border-radius: 8px 0 0 0;
}

thead th:last-child {
    border-radius: 0 8px 0 0;
}

tbody td {
    padding: 12px 16px;
    border-bottom: 1px solid #e2e8f0;
    font-size: 0.9em;
    color: #334155;
}

tbody tr:hover {
    background: #f0f9ff;
}

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

/* Zahlen rechts ausrichten */
td.number, th.number {
    text-align: right;
    font-variant-numeric: tabular-nums;
}

/* ============================================================
   BUTTONS
   ============================================================ */
.btn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 8px 16px;
    border: none;
    border-radius: 8px;
    font-size: 0.9em;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s;
    text-decoration: none;
    line-height: 1.4;
}

.btn:hover {
    text-decoration: none;
    transform: translateY(-1px);
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.12);
}

.btn-primary {
    background: #0e7490;
    color: #fff;
}

.btn-primary:hover {
    background: #0c4a6e;
    color: #fff;
}

.btn-success {
    background: #16a34a;
    color: #fff;
}

.btn-success:hover {
    background: #15803d;
    color: #fff;
}

.btn-danger {
    background: #dc2626;
    color: #fff;
}

.btn-danger:hover {
    background: #b91c1c;
    color: #fff;
}

.btn-warning {
    background: #f59e0b;
    color: #fff;
}

.btn-warning:hover {
    background: #d97706;
    color: #fff;
}

.btn-secondary {
    background: #e2e8f0;
    color: #475569;
}

.btn-secondary:hover {
    background: #cbd5e1;
    color: #334155;
}

.btn-sm {
    padding: 5px 10px;
    font-size: 0.8em;
}

.btn-lg {
    padding: 12px 24px;
    font-size: 1em;
}

/* ============================================================
   FORMULARE
   ============================================================ */
.form-group {
    margin-bottom: 16px;
}

.form-group label {
    display: block;
    font-size: 0.85em;
    font-weight: 600;
    color: #475569;
    margin-bottom: 6px;
}

.form-control {
    width: 100%;
    padding: 10px 14px;
    border: 1px solid #cbd5e1;
    border-radius: 8px;
    font-size: 0.9em;
    font-family: inherit;
    transition: border-color 0.2s, box-shadow 0.2s;
    background: #fff;
    color: #1e293b;
}

.form-control:focus {
    outline: none;
    border-color: #0e7490;
    box-shadow: 0 0 0 3px rgba(14, 116, 144, 0.15);
}

.form-control.error {
    border-color: #dc2626;
    box-shadow: 0 0 0 3px rgba(220, 38, 38, 0.1);
}

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 12 12'%3E%3Cpath fill='%23475569' d='M6 8L1 3h10z'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 12px center;
    padding-right: 36px;
}

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

.form-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 16px;
}

.form-actions {
    display: flex;
    gap: 10px;
    margin-top: 20px;
    padding-top: 16px;
    border-top: 1px solid #e2e8f0;
}

.form-hint {
    font-size: 0.8em;
    color: #94a3b8;
    margin-top: 4px;
}

/* ============================================================
   FLASH MESSAGES
   ============================================================ */
.flash-message {
    padding: 12px 16px;
    border-radius: 8px;
    font-size: 0.9em;
    margin-bottom: 16px;
}

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

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

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

.flash-info {
    background: #f0f9ff;
    color: #0e7490;
    border: 1px solid #bae6fd;
}

/* ============================================================
   STATUS-BADGES
   ============================================================ */
.badge {
    display: inline-block;
    padding: 3px 10px;
    border-radius: 20px;
    font-size: 0.75em;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.03em;
}

.badge-success { background: #dcfce7; color: #166534; }
.badge-danger  { background: #fee2e2; color: #991b1b; }
.badge-warning { background: #fef3c7; color: #92400e; }
.badge-info    { background: #e0f2fe; color: #075985; }
.badge-neutral { background: #f1f5f9; color: #64748b; }

/* ============================================================
   DASHBOARD KPI CARDS
   ============================================================ */
.kpi-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 16px;
    margin-bottom: 24px;
}

.kpi-card {
    background: #fff;
    border-radius: 12px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.07);
    padding: 20px;
    text-align: center;
}

.kpi-value {
    font-size: 2em;
    font-weight: 700;
    color: #0c4a6e;
    line-height: 1.2;
}

.kpi-label {
    font-size: 0.8em;
    color: #64748b;
    margin-top: 4px;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

/* ============================================================
   CHECKLISTE (Abrechnung)
   ============================================================ */
.checklist {
    list-style: none;
}

.checklist li {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 0;
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
    font-size: 0.9em;
}

.checklist .check-ok {
    color: #4ade80;
}

.checklist .check-missing {
    color: #f87171;
}

/* ============================================================
   LOGIN
   ============================================================ */
.login-page {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: calc(100vh - 60px);
    padding: 20px;
}

.login-card {
    background: #fff;
    border-radius: 16px;
    box-shadow: 0 4px 24px rgba(0, 0, 0, 0.1);
    padding: 40px;
    width: 100%;
    max-width: 400px;
    text-align: center;
}

.login-card h1 {
    color: #0c4a6e;
    margin-bottom: 8px;
    font-size: 1.5em;
}

.login-card .subtitle {
    color: #64748b;
    font-size: 0.9em;
    margin-bottom: 24px;
}

.login-card .form-group {
    text-align: left;
}

.login-card .btn {
    width: 100%;
    justify-content: center;
    padding: 12px;
    font-size: 1em;
}

.login-error {
    background: #fef2f2;
    color: #991b1b;
    border: 1px solid #fecaca;
    padding: 10px 14px;
    border-radius: 8px;
    font-size: 0.85em;
    margin-bottom: 16px;
}

/* ============================================================
   LEERSTAND / STATUS-ANZEIGEN
   ============================================================ */
.status-leerstand {
    color: #dc2626;
    font-weight: 600;
}

.status-vermietet {
    color: #16a34a;
    font-weight: 600;
}

/* Abrechnung Status */
.status-entwurf    { color: #64748b; }
.status-freigegeben { color: #f59e0b; }
.status-versendet   { color: #0e7490; }
.status-bezahlt     { color: #16a34a; }

/* ============================================================
   ERGEBNIS (Nachzahlung / Guthaben)
   ============================================================ */
.ergebnis-nachzahlung {
    color: #dc2626;
    font-weight: 700;
}

.ergebnis-guthaben {
    color: #16a34a;
    font-weight: 700;
}

/* ============================================================
   UTILITIES
   ============================================================ */
.text-center { text-align: center; }
.text-right  { text-align: right; }
.text-muted  { color: #94a3b8; }
.text-small  { font-size: 0.8em; }
.mt-1  { margin-top: 8px; }
.mt-2  { margin-top: 16px; }
.mt-3  { margin-top: 24px; }
.mb-1  { margin-bottom: 8px; }
.mb-2  { margin-bottom: 16px; }
.mb-3  { margin-bottom: 24px; }
.gap-1 { gap: 8px; }
.gap-2 { gap: 16px; }
.d-flex { display: flex; }
.flex-between { justify-content: space-between; }
.flex-center { align-items: center; }
.flex-wrap { flex-wrap: wrap; }
.hidden { display: none; }

/* ============================================================
   RESPONSIVE
   ============================================================ */
@media (max-width: 1024px) {
    .page-layout {
        grid-template-columns: 1fr;
    }

    .sidebar {
        position: relative;
        top: auto;
        height: auto;
        padding: 16px;
    }

    .main-content {
        height: auto;
        overflow: visible;
    }
}

@media (max-width: 768px) {
    .nav-links {
        display: none;
        flex-direction: column;
        position: absolute;
        top: 60px;
        left: 0;
        right: 0;
        background: #0c4a6e;
        padding: 10px;
        box-shadow: 0 4px 12px rgba(0, 0, 0, 0.2);
    }

    .nav-links.active {
        display: flex;
    }

    .hamburger {
        display: block;
    }

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

    .content-header {
        flex-direction: column;
        align-items: flex-start;
        gap: 10px;
    }

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

    thead th, tbody td {
        padding: 8px 10px;
        font-size: 0.8em;
    }
}

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

    .login-card {
        padding: 24px;
    }
}
