/* ==========================================================
   REHE Auftragsnummern — Custom Styles
   Ergänzt Pico CSS mit projektspezifischen Anpassungen
   ========================================================== */

:root {
    --brand: #1a73e8;
    --brand-hover: #1557b0;
    --success: #0d9e4f;
    --warning: #e8a817;
    --danger: #d93025;
    --bg-soft: #f8f9fa;
    --border-light: #e0e3e8;
    --radius: 8px;
    --shadow-sm: 0 1px 3px rgba(0,0,0,0.08);
    --shadow-md: 0 4px 12px rgba(0,0,0,0.1);
}

[data-theme="dark"] {
    --brand: #5b9cf6;
    --brand-hover: #7cb3f8;
    --success: #34d67b;
    --warning: #f5c542;
    --danger: #f55c5c;
    --bg-soft: #1a1d23;
    --border-light: #2d3139;
}

/* ==========================================================
   HEADER / NAV
   ========================================================== */

.app-header {
    background: var(--brand);
    padding: 0;
    margin-bottom: 1.5rem;
    box-shadow: var(--shadow-md);
}

.app-header nav {
    padding: 0.6rem 1rem;
    align-items: center;
}

.app-header a,
.app-header span {
    color: #fff !important;
    text-decoration: none;
}

.app-header .brand {
    font-size: 1.15rem;
    letter-spacing: 0.5px;
}

.app-header .brand strong {
    font-weight: 800;
}

.nav-links {
    display: flex;
    gap: 0.25rem;
    list-style: none;
    margin: 0;
    padding: 0;
}

.nav-links a {
    padding: 0.4rem 0.75rem;
    border-radius: var(--radius);
    font-size: 0.9rem;
    transition: background 0.15s;
}

.nav-links a:hover,
.nav-links a.active {
    background: rgba(255,255,255,0.2);
}

.user-badge {
    font-size: 0.85rem;
    opacity: 0.9;
}

.user-badge small {
    opacity: 0.7;
}

.theme-toggle {
    background: rgba(255,255,255,0.15) !important;
    border: 1px solid rgba(255,255,255,0.3) !important;
    color: #fff !important;
    padding: 0.3rem 0.6rem !important;
    font-size: 1.1rem;
    cursor: pointer;
    border-radius: var(--radius);
    margin: 0 !important;
    min-width: auto;
}

.theme-toggle:hover {
    background: rgba(255,255,255,0.25) !important;
}

.btn-sm {
    padding: 0.3rem 0.75rem !important;
    font-size: 0.85rem !important;
}

.app-header .btn-sm {
    color: #fff !important;
    border-color: rgba(255,255,255,0.5) !important;
}

/* ==========================================================
   PAGE HEADER
   ========================================================== */

.page-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 1rem;
    margin-bottom: 1.5rem;
}

.page-header h2 {
    margin: 0;
}

.header-actions {
    display: flex;
    gap: 0.5rem;
    align-items: center;
    flex-wrap: wrap;
}

/* ==========================================================
   FILTER BAR
   ========================================================== */

.filter-bar {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
    align-items: end;
    padding: 1rem;
    background: var(--bg-soft);
    border-radius: var(--radius);
    margin-bottom: 1.5rem;
    border: 1px solid var(--border-light);
}

.filter-bar select,
.filter-bar input {
    margin-bottom: 0;
    min-width: 140px;
    max-width: 200px;
    font-size: 0.85rem;
    padding: 0.45rem 0.6rem;
    height: 40px;
}

.filter-bar input[type="search"] {
    min-width: 180px;
    height: 40px;
}

.btn-filter {
    margin-bottom: 0 !important;
    padding: 0.45rem 1rem !important;
    font-size: 0.85rem !important;
    white-space: nowrap;
    width: auto !important;
    display: inline-block !important;
    height: 40px;
}

.btn-reset {
    font-size: 0.8rem;
    padding: 0.45rem 0.75rem;
    white-space: nowrap;
}

/* ==========================================================
   DATA TABLE
   ========================================================== */

.table-responsive {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    border-radius: var(--radius);
    border: 1px solid var(--border-light);
    box-shadow: var(--shadow-sm);
}

.project-table {
    margin: 0;
    font-size: 0.88rem;
    white-space: nowrap;
}

.project-table th {
    background: var(--bg-soft);
    position: sticky;
    top: 0;
    z-index: 2;
    font-size: 0.8rem;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    padding: 0.6rem 0.75rem;
    border-bottom: 2px solid var(--border-light);
}

.project-table th a {
    color: inherit;
    text-decoration: none;
}

.project-table th a:hover {
    color: var(--brand);
}

.project-table td {
    padding: 0.5rem 0.75rem;
    vertical-align: middle;
}

.project-table tbody tr:hover {
    background: rgba(26, 115, 232, 0.04);
}

[data-theme="dark"] .project-table tbody tr:hover {
    background: rgba(91, 156, 246, 0.08);
}

.text-right {
    text-align: right !important;
}

.objekt-col {
    max-width: 300px;
    overflow: hidden;
    text-overflow: ellipsis;
}

.sticky-col {
    position: sticky;
    left: 0;
    background: inherit;
    z-index: 1;
    font-weight: 600;
}

.actions-col {
    text-align: center;
    white-space: nowrap;
}

.btn-icon {
    background: none;
    border: none;
    cursor: pointer;
    font-size: 1.1rem;
    padding: 0.2rem 0.4rem;
    border-radius: 4px;
    transition: background 0.15s;
    text-decoration: none;
}

.btn-icon:hover {
    background: rgba(0,0,0,0.08);
}

.btn-danger {
    color: var(--danger) !important;
}

.btn-danger:hover {
    background: rgba(217, 48, 37, 0.1) !important;
}

.inline-form {
    display: inline;
}

/* ==========================================================
   STATUS BADGES
   ========================================================== */

.status-badge {
    display: inline-block;
    padding: 0.2rem 0.6rem;
    border-radius: 999px;
    font-size: 0.78rem;
    font-weight: 600;
    white-space: nowrap;
}

.status-fertig {
    background: rgba(13, 158, 79, 0.12);
    color: var(--success);
}

.status-laufend {
    background: rgba(232, 168, 23, 0.12);
    color: var(--warning);
}

.status-offen {
    background: rgba(0, 0, 0, 0.06);
    color: #666;
}

[data-theme="dark"] .status-offen {
    background: rgba(255, 255, 255, 0.08);
    color: #aaa;
}

/* ==========================================================
   PAGINATION
   ========================================================== */

.pagination {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 1.5rem;
    padding: 1rem 0;
    font-size: 0.9rem;
}

.pagination a {
    padding: 0.4rem 0.8rem;
    background: var(--brand);
    color: #fff;
    border-radius: var(--radius);
    text-decoration: none;
    font-size: 0.85rem;
    transition: background 0.15s;
}

.pagination a:hover {
    background: var(--brand-hover);
}

.pagination .disabled {
    opacity: 0.4;
    cursor: not-allowed;
}

/* ==========================================================
   DASHBOARD
   ========================================================== */

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

.stat-card {
    text-align: center;
    padding: 0;
    border-radius: var(--radius);
    box-shadow: var(--shadow-sm);
    border: 1px solid var(--border-light);
    overflow: hidden;
}

.stat-card header {
    padding: 0.5rem 1rem;
    font-size: 0.8rem;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    background: var(--bg-soft);
    margin: 0;
    border-bottom: 1px solid var(--border-light);
}

.stat-number {
    font-size: 1.8rem;
    font-weight: 700;
    margin: 0;
    padding: 1rem;
    color: var(--brand);
}

/* ==========================================================
   FORMS
   ========================================================== */

.project-form fieldset {
    border: 1px solid var(--border-light);
    border-radius: var(--radius);
    padding: 1.25rem;
    margin-bottom: 1.5rem;
}

.project-form legend {
    font-weight: 700;
    font-size: 0.95rem;
    padding: 0 0.5rem;
}

.grid-2 {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 1rem;
}

.grid-3 {
    display: grid;
    grid-template-columns: 1fr 1fr 1fr;
    gap: 1rem;
}

.form-actions {
    display: flex;
    gap: 0.75rem;
    margin-top: 1rem;
    align-items: center;
}

/* --- Einheitliche Button-Größe überall --- */
.page-header a[role="button"],
.page-header button,
.header-actions a[role="button"],
.header-actions button,
.form-actions a[role="button"],
.form-actions button {
    padding: 0.5rem 1.25rem !important;
    font-size: 0.9rem !important;
    line-height: 1.2 !important;
    width: auto !important;
    margin: 0 !important;
    display: inline-block !important;
    vertical-align: middle;
}

.number-preview {
    display: block;
    font-size: 1.5rem;
    font-weight: 800;
    letter-spacing: 1px;
    color: #999;
    padding: 0.5rem 0;
    transition: color 0.3s;
}

.number-preview.preview-ready {
    color: var(--brand);
}

.number-preview.preview-error {
    color: var(--danger);
    font-size: 1rem;
}

.number-display {
    font-size: 1.3rem;
    font-weight: 700;
    color: var(--brand);
}

.number-display small {
    font-weight: 400;
    opacity: 0.6;
}

/* ==========================================================
   PROJECT DETAIL
   ========================================================== */

.detail-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
    gap: 1rem 2rem;
    margin: 1rem 0;
}

.detail-item label {
    font-size: 0.75rem;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: #888;
    margin-bottom: 0.25rem;
    display: block;
}

.detail-value {
    font-size: 1rem;
    font-weight: 500;
}

.detail-value.money {
    font-variant-numeric: tabular-nums;
    font-weight: 600;
}

.detail-value.number-highlight {
    font-size: 1.4rem;
    font-weight: 800;
    color: var(--brand);
    letter-spacing: 1px;
}

.full-width {
    grid-column: 1 / -1;
}

.detail-meta {
    text-align: right;
    opacity: 0.6;
}

/* ==========================================================
   FLASH MESSAGES
   ========================================================== */

.flash {
    padding: 0.75rem 1rem;
    border-radius: var(--radius);
    margin-bottom: 1rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-size: 0.9rem;
    transition: opacity 0.3s, transform 0.3s;
    animation: slideIn 0.3s ease-out;
}

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

.flash-success {
    background: rgba(13, 158, 79, 0.1);
    color: var(--success);
    border: 1px solid rgba(13, 158, 79, 0.3);
}

.flash-error {
    background: rgba(217, 48, 37, 0.1);
    color: var(--danger);
    border: 1px solid rgba(217, 48, 37, 0.3);
}

.flash-close {
    background: none;
    border: none;
    font-size: 1.3rem;
    cursor: pointer;
    color: inherit;
    opacity: 0.6;
    padding: 0 0.25rem;
}

.flash-close:hover {
    opacity: 1;
}

/* ==========================================================
   LOGIN PAGE
   ========================================================== */

.login-page {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 100vh;
    background: var(--bg-soft);
}

.login-page .container {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 100vh;
    width: 100%;
}

.login-card {
    max-width: 400px;
    width: 100%;
    padding: 2rem;
    border-radius: 12px;
    box-shadow: var(--shadow-md);
}

.login-card header {
    text-align: center;
    margin-bottom: 1.5rem;
    padding: 0;
}

.login-card header h1 {
    font-size: 1.5rem;
    margin-bottom: 0.25rem;
    color: var(--brand);
}

.login-card header p {
    opacity: 0.6;
    font-size: 0.9rem;
}

/* ==========================================================
   ADMIN TABLES
   ========================================================== */

.admin-table {
    font-size: 0.9rem;
}

.admin-table .role-badge {
    display: inline-block;
    padding: 0.15rem 0.5rem;
    border-radius: 999px;
    font-size: 0.75rem;
    font-weight: 600;
    text-transform: capitalize;
}

.role-admin { background: rgba(26,115,232,0.12); color: var(--brand); }
.role-bearbeiter { background: rgba(232,168,23,0.12); color: var(--warning); }
.role-projektleiter { background: rgba(13,158,79,0.12); color: var(--success); }
.role-benutzer { background: rgba(0,0,0,0.06); color: #888; }

.inactive-row { opacity: 0.5; }

/* ==========================================================
   EMPTY STATE
   ========================================================== */

.empty-state {
    text-align: center;
    padding: 3rem 1rem;
    font-size: 1.1rem;
    color: #888;
}

/* ==========================================================
   FOOTER
   ========================================================== */

footer {
    text-align: center;
    padding: 1.5rem 0;
    margin-top: 2rem;
    opacity: 0.5;
    font-size: 0.8rem;
}

/* ==========================================================
   STRIPED TABLE (Pico override)
   ========================================================== */

.striped tbody tr:nth-child(even) {
    background: var(--bg-soft);
}

/* ==========================================================
   HAMBURGER / MOBILE NAV
   ========================================================== */

.mobile-toggle {
    display: none;
}

.hamburger {
    background: rgba(255,255,255,0.15) !important;
    border: 1px solid rgba(255,255,255,0.3) !important;
    color: #fff !important;
    font-size: 1.3rem;
    padding: 0.25rem 0.6rem !important;
    cursor: pointer;
    border-radius: var(--radius);
    margin: 0 !important;
    min-width: auto;
    line-height: 1;
}

/* ==========================================================
   RESPONSIVE — MOBILE
   ========================================================== */

@media (max-width: 768px) {
    .app-header nav {
        flex-wrap: wrap;
        gap: 0.5rem;
    }

    .mobile-toggle {
        display: inline-block;
    }

    .nav-links {
        display: none;
        width: 100%;
        flex-direction: column;
        gap: 0;
        padding-top: 0.5rem;
        border-top: 1px solid rgba(255,255,255,0.2);
        order: 10;
    }

    .nav-links.open {
        display: flex !important;
    }

    .nav-links a {
        padding: 0.6rem 0.75rem;
        display: block;
    }

    .page-header {
        flex-direction: column;
        align-items: flex-start;
    }

    .filter-bar {
        flex-direction: column;
        padding: 0.75rem;
    }

    .filter-bar select,
    .filter-bar input {
        max-width: none;
        min-width: auto;
    }

    .grid-2,
    .grid-3 {
        grid-template-columns: 1fr;
    }

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

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

    .header-actions {
        width: 100%;
    }

    .project-table {
        font-size: 0.8rem;
    }

    .project-table th,
    .project-table td {
        padding: 0.4rem 0.5rem;
    }
}

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

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

    .stat-number {
        font-size: 1.4rem;
    }
}
