/* ============================================
   BauManager Pro - Main Stylesheet
   ============================================ */

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

:root {
    --primary: #ff6b35;
    --primary-dark: #e55a2b;
    --secondary: #1a1a2e;
    --accent: #ffd23f;
    --success: #06d6a0;
    --warning: #ff9f1c;
    --danger: #ef476f;
    --dark: #16213e;
    --darker: #0f0f23;
    --light: #f7f7f9;
    --gray: #6c757d;
    --gray-light: #e9ecef;
    --sidebar-width: 280px;
    --header-height: 70px;
}

body {
    font-family: 'DM Sans', sans-serif;
    background: var(--light);
    color: var(--dark);
    min-height: 100vh;
    overflow-x: hidden;
}

a {
    text-decoration: none;
    color: inherit;
}

/* ========== SIDEBAR ========== */
.sidebar {
    position: fixed;
    left: 0;
    top: 0;
    width: var(--sidebar-width);
    height: 100vh;
    background: linear-gradient(180deg, var(--secondary) 0%, var(--darker) 100%);
    color: white;
    overflow-y: auto;
    z-index: 1000;
    border-right: 1px solid rgba(255,255,255,0.05);
}

.sidebar::-webkit-scrollbar {
    width: 6px;
}

.sidebar::-webkit-scrollbar-thumb {
    background: rgba(255,255,255,0.2);
    border-radius: 3px;
}

.sidebar-header {
    padding: 25px;
    border-bottom: 1px solid rgba(255,255,255,0.08);
    display: flex;
    align-items: center;
    gap: 15px;
}

.logo-icon {
    width: 48px;
    height: 48px;
    background: linear-gradient(135deg, var(--primary) 0%, var(--warning) 100%);
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 24px;
    box-shadow: 0 4px 15px rgba(255,107,53,0.4);
}

.logo-text h1 {
    font-size: 20px;
    font-weight: 700;
    letter-spacing: -0.5px;
}

.logo-text span {
    font-size: 11px;
    opacity: 0.5;
    font-family: 'Space Mono', monospace;
    letter-spacing: 1px;
}

.nav-section {
    padding: 20px 0;
}

.nav-section-title {
    padding: 0 25px 12px;
    font-size: 10px;
    text-transform: uppercase;
    letter-spacing: 2px;
    opacity: 0.4;
    font-weight: 600;
}

.nav-item {
    display: flex;
    align-items: center;
    padding: 14px 25px;
    color: rgba(255,255,255,0.6);
    text-decoration: none;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    cursor: pointer;
    gap: 14px;
    position: relative;
    margin: 2px 12px;
    border-radius: 10px;
}

.nav-item:hover {
    background: rgba(255,255,255,0.08);
    color: white;
}

.nav-item.active {
    background: linear-gradient(135deg, var(--primary) 0%, var(--primary-dark) 100%);
    color: white;
    box-shadow: 0 4px 15px rgba(255,107,53,0.3);
}

.nav-item i {
    width: 22px;
    font-size: 16px;
    text-align: center;
}

.nav-item .badge {
    margin-left: auto;
    background: var(--danger);
    color: white;
    padding: 3px 10px;
    border-radius: 20px;
    font-size: 11px;
    font-weight: 600;
    font-family: 'Space Mono', monospace;
}

.nav-item .badge.warning {
    background: var(--warning);
    color: var(--dark);
}

.nav-item .badge.success {
    background: var(--success);
}

.nav-divider {
    height: 1px;
    background: rgba(255,255,255,0.08);
    margin: 10px 25px;
}

/* ========== MAIN CONTENT ========== */
.main-content {
    margin-left: var(--sidebar-width);
    min-height: 100vh;
}

/* ========== TOP HEADER ========== */
.top-header {
    background: white;
    padding: 0 30px;
    height: var(--header-height);
    display: flex;
    align-items: center;
    justify-content: space-between;
    border-bottom: 1px solid var(--gray-light);
    position: sticky;
    top: 0;
    z-index: 100;
}

.page-title {
    display: flex;
    align-items: center;
    gap: 15px;
}

.page-title h2 {
    font-size: 22px;
    font-weight: 700;
    color: var(--dark);
}

.page-title .breadcrumb {
    font-size: 13px;
    color: var(--gray);
}

.header-actions {
    display: flex;
    align-items: center;
    gap: 20px;
}

.search-box {
    display: flex;
    align-items: center;
    background: var(--light);
    border-radius: 10px;
    padding: 10px 16px;
    gap: 10px;
    width: 280px;
    border: 2px solid transparent;
    transition: all 0.3s;
}

.search-box:focus-within {
    border-color: var(--primary);
    background: white;
}

.search-box input {
    border: none;
    background: transparent;
    outline: none;
    width: 100%;
    font-size: 14px;
    color: var(--dark);
}

.search-box i {
    color: var(--gray);
}

.header-btn {
    width: 42px;
    height: 42px;
    border-radius: 10px;
    border: none;
    background: var(--light);
    color: var(--gray);
    cursor: pointer;
    transition: all 0.3s;
    position: relative;
}

.header-btn:hover {
    background: var(--primary);
    color: white;
}

.header-btn .notification-dot {
    position: absolute;
    top: 8px;
    right: 8px;
    width: 10px;
    height: 10px;
    background: var(--danger);
    border-radius: 50%;
    border: 2px solid white;
}

.user-menu {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 8px 12px;
    border-radius: 10px;
    cursor: pointer;
    transition: all 0.3s;
}

.user-menu:hover {
    background: var(--light);
}

.user-avatar {
    width: 38px;
    height: 38px;
    border-radius: 10px;
    background: linear-gradient(135deg, var(--primary), var(--warning));
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    font-weight: 600;
}

.user-info .name {
    font-weight: 600;
    font-size: 14px;
}

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

/* ========== DASHBOARD ========== */
.dashboard {
    padding: 30px;
}

/* Stats Cards */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 20px;
    margin-bottom: 30px;
}

.stat-card {
    background: white;
    border-radius: 16px;
    padding: 24px;
    position: relative;
    overflow: hidden;
    transition: all 0.3s;
    border: 1px solid rgba(0,0,0,0.04);
}

.stat-card:hover {
    transform: translateY(-4px);
    box-shadow: 0 12px 40px rgba(0,0,0,0.1);
}

.stat-card::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    width: 4px;
    height: 100%;
}

.stat-card.projects::before { background: var(--primary); }
.stat-card.invoices::before { background: var(--success); }
.stat-card.mahnungen::before { background: var(--danger); }
.stat-card.maengel::before { background: var(--warning); }

.stat-icon {
    width: 50px;
    height: 50px;
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 22px;
    margin-bottom: 16px;
}

.stat-card.projects .stat-icon { background: rgba(255,107,53,0.1); color: var(--primary); }
.stat-card.invoices .stat-icon { background: rgba(6,214,160,0.1); color: var(--success); }
.stat-card.mahnungen .stat-icon { background: rgba(239,71,111,0.1); color: var(--danger); }
.stat-card.maengel .stat-icon { background: rgba(255,159,28,0.1); color: var(--warning); }

.stat-value {
    font-size: 32px;
    font-weight: 700;
    color: var(--dark);
    margin-bottom: 4px;
    font-family: 'Space Mono', monospace;
}

.stat-label {
    font-size: 13px;
    color: var(--gray);
}

.stat-change {
    position: absolute;
    top: 24px;
    right: 24px;
    font-size: 12px;
    font-weight: 600;
    padding: 4px 10px;
    border-radius: 20px;
}

.stat-change.up {
    background: rgba(6,214,160,0.1);
    color: var(--success);
}

.stat-change.down {
    background: rgba(239,71,111,0.1);
    color: var(--danger);
}

/* Main Grid Layout */
.main-grid {
    display: grid;
    grid-template-columns: 2fr 1fr;
    gap: 25px;
}

/* Cards */
.card {
    background: white;
    border-radius: 16px;
    border: 1px solid rgba(0,0,0,0.04);
    overflow: hidden;
}

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

.card-header h3 {
    font-size: 16px;
    font-weight: 600;
    display: flex;
    align-items: center;
    gap: 10px;
}

.card-header h3 i {
    color: var(--primary);
}

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

.card-body {
    padding: 24px;
}

/* Buttons */
.btn {
    padding: 10px 18px;
    border-radius: 8px;
    border: none;
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s;
    display: inline-flex;
    align-items: center;
    gap: 8px;
    text-decoration: none;
}

.btn-primary {
    background: linear-gradient(135deg, var(--primary), var(--primary-dark));
    color: white;
}

.btn-primary:hover {
    box-shadow: 0 4px 15px rgba(255,107,53,0.4);
    transform: translateY(-2px);
}

.btn-success {
    background: linear-gradient(135deg, var(--success), #05b88a);
    color: white;
}

.btn-danger {
    background: linear-gradient(135deg, var(--danger), #d63d5e);
    color: white;
}

.btn-outline {
    background: transparent;
    border: 2px solid var(--gray-light);
    color: var(--gray);
}

.btn-outline:hover {
    border-color: var(--primary);
    color: var(--primary);
}

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

.btn-lg {
    padding: 14px 28px;
    font-size: 15px;
}

/* Tables */
.data-table {
    width: 100%;
    border-collapse: collapse;
}

.data-table th {
    text-align: left;
    padding: 14px 24px;
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: 1px;
    color: var(--gray);
    font-weight: 600;
    background: var(--light);
}

.data-table td {
    padding: 18px 24px;
    border-bottom: 1px solid var(--gray-light);
    font-size: 14px;
}

.data-table tr {
    cursor: pointer;
    transition: all 0.2s;
}

.data-table tr:hover {
    background: rgba(255,107,53,0.02);
}

.project-info {
    display: flex;
    align-items: center;
    gap: 14px;
}

.project-icon {
    width: 44px;
    height: 44px;
    border-radius: 10px;
    background: linear-gradient(135deg, var(--primary), var(--warning));
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    font-size: 18px;
}

.project-name {
    font-weight: 600;
    color: var(--dark);
    margin-bottom: 3px;
}

.project-address {
    font-size: 12px;
    color: var(--gray);
}

/* Status Badges */
.status-badge {
    padding: 6px 12px;
    border-radius: 20px;
    font-size: 12px;
    font-weight: 600;
    display: inline-block;
}

.status-badge.in_arbeit,
.status-badge.active,
.status-badge.bezahlt,
.status-badge.behoben {
    background: rgba(6,214,160,0.1);
    color: var(--success);
}

.status-badge.anfrage,
.status-badge.entwurf,
.status-badge.offen {
    background: rgba(108,117,125,0.1);
    color: var(--gray);
}

.status-badge.gesendet,
.status-badge.beauftragt,
.status-badge.in_bearbeitung {
    background: rgba(37,99,235,0.1);
    color: #2563eb;
}

.status-badge.ueberfaellig,
.status-badge.abgelehnt,
.status-badge.storniert {
    background: rgba(239,71,111,0.1);
    color: var(--danger);
}

.status-badge.angenommen,
.status-badge.abgeschlossen {
    background: rgba(6,214,160,0.1);
    color: var(--success);
}

.status-badge.wartend,
.status-badge.teilbezahlt {
    background: rgba(255,159,28,0.1);
    color: var(--warning);
}

/* Progress Bar */
.progress-bar {
    width: 120px;
    height: 6px;
    background: var(--gray-light);
    border-radius: 3px;
    overflow: hidden;
}

.progress-fill {
    height: 100%;
    background: linear-gradient(90deg, var(--primary), var(--warning));
    border-radius: 3px;
    transition: width 0.5s ease;
}

.amount {
    font-weight: 600;
    font-family: 'Space Mono', monospace;
}

/* Lists */
.list {
    padding: 0;
}

.list-item {
    padding: 18px 24px;
    border-bottom: 1px solid var(--gray-light);
    display: flex;
    gap: 14px;
    transition: all 0.3s;
    cursor: pointer;
    align-items: flex-start;
}

.list-item:hover {
    background: rgba(255,107,53,0.02);
}

.list-content {
    flex: 1;
}

.list-title {
    font-weight: 600;
    font-size: 14px;
    margin-bottom: 4px;
    color: var(--dark);
}

.list-meta {
    font-size: 12px;
    color: var(--gray);
    display: flex;
    gap: 15px;
}

.list-meta i {
    margin-right: 4px;
}

.list-date {
    font-size: 11px;
    color: var(--gray);
    font-family: 'Space Mono', monospace;
}

.list-empty {
    padding: 30px;
    text-align: center;
    color: var(--gray);
}

/* Priority Dots */
.priority-dot {
    width: 10px;
    height: 10px;
    border-radius: 50%;
    margin-top: 6px;
    flex-shrink: 0;
}

.priority-dot.kritisch,
.priority-dot.hoch { background: var(--danger); }
.priority-dot.mittel { background: var(--warning); }
.priority-dot.niedrig { background: var(--success); }

/* Mahnungen */
.mahnung-item {
    padding: 16px 24px;
    border-bottom: 1px solid var(--gray-light);
    display: flex;
    align-items: center;
    gap: 14px;
    cursor: pointer;
    transition: all 0.2s;
}

.mahnung-item:hover {
    background: rgba(239,71,111,0.02);
}

.mahnung-level {
    width: 36px;
    height: 36px;
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    font-size: 14px;
    font-family: 'Space Mono', monospace;
}

.mahnung-level.level-1 {
    background: rgba(255,159,28,0.1);
    color: var(--warning);
}

.mahnung-level.level-2 {
    background: rgba(255,107,53,0.1);
    color: var(--primary);
}

.mahnung-level.level-3 {
    background: rgba(239,71,111,0.1);
    color: var(--danger);
}

.mahnung-info {
    flex: 1;
}

.mahnung-customer {
    font-weight: 600;
    font-size: 14px;
}

.mahnung-invoice {
    font-size: 12px;
    color: var(--gray);
}

.mahnung-amount {
    font-weight: 700;
    font-family: 'Space Mono', monospace;
    color: var(--danger);
}

/* Quick Actions */
.quick-actions {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 12px;
    padding: 20px 24px;
}

.quick-action {
    padding: 16px;
    border-radius: 12px;
    background: var(--light);
    text-align: center;
    cursor: pointer;
    transition: all 0.3s;
    border: 2px solid transparent;
    text-decoration: none;
    color: inherit;
}

.quick-action:hover {
    border-color: var(--primary);
    background: white;
}

.quick-action i {
    font-size: 24px;
    margin-bottom: 8px;
    color: var(--primary);
    display: block;
}

.quick-action span {
    display: block;
    font-size: 12px;
    font-weight: 600;
    color: var(--dark);
}

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

.form-group label {
    display: block;
    font-size: 13px;
    font-weight: 600;
    margin-bottom: 8px;
    color: var(--dark);
}

.form-control {
    width: 100%;
    padding: 12px 16px;
    border: 2px solid var(--gray-light);
    border-radius: 10px;
    font-size: 14px;
    transition: all 0.3s;
    font-family: 'DM Sans', sans-serif;
}

.form-control:focus {
    outline: none;
    border-color: var(--primary);
}

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

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

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='%236c757d' d='M6 8L1 3h10z'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 16px center;
    padding-right: 40px;
}

/* Modals */
.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0,0,0,0.5);
    backdrop-filter: blur(4px);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 2000;
    opacity: 0;
    visibility: hidden;
    transition: all 0.3s;
}

.modal-overlay.active {
    opacity: 1;
    visibility: visible;
}

.modal {
    background: white;
    border-radius: 20px;
    width: 600px;
    max-width: 90%;
    max-height: 90vh;
    overflow: hidden;
    transform: scale(0.9) translateY(20px);
    transition: all 0.3s;
}

.modal-overlay.active .modal {
    transform: scale(1) translateY(0);
}

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

.modal-header h3 {
    font-size: 20px;
    font-weight: 700;
}

.modal-close {
    width: 36px;
    height: 36px;
    border-radius: 8px;
    border: none;
    background: var(--light);
    cursor: pointer;
    transition: all 0.3s;
}

.modal-close:hover {
    background: var(--danger);
    color: white;
}

.modal-body {
    padding: 24px;
    max-height: 60vh;
    overflow-y: auto;
}

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

/* Utilities */
.text-center { text-align: center; }
.text-right { text-align: right; }
.text-muted { color: var(--gray); }
.text-success { color: var(--success); }
.text-danger { color: var(--danger); }
.text-warning { color: var(--warning); }

.mt-1 { margin-top: 10px; }
.mt-2 { margin-top: 20px; }
.mt-3 { margin-top: 30px; }
.mb-1 { margin-bottom: 10px; }
.mb-2 { margin-bottom: 20px; }
.mb-3 { margin-bottom: 30px; }

/* Responsive */
@media (max-width: 1400px) {
    .stats-grid {
        grid-template-columns: repeat(2, 1fr);
    }
    .main-grid {
        grid-template-columns: 1fr;
    }
}

@media (max-width: 768px) {
    .sidebar {
        transform: translateX(-100%);
        transition: transform 0.3s;
    }
    .sidebar.open {
        transform: translateX(0);
    }
    .main-content {
        margin-left: 0;
    }
    .stats-grid {
        grid-template-columns: 1fr;
    }
    .form-row {
        grid-template-columns: 1fr;
    }
}

/* Animations */
@keyframes fadeInUp {
    from {
        opacity: 0;
        transform: translateY(20px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.stat-card, .card {
    animation: fadeInUp 0.5s ease forwards;
}

.stat-card:nth-child(1) { animation-delay: 0.1s; }
.stat-card:nth-child(2) { animation-delay: 0.2s; }
.stat-card:nth-child(3) { animation-delay: 0.3s; }
.stat-card:nth-child(4) { animation-delay: 0.4s; }

/* Page specific */
.page-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 25px;
}

.filters {
    display: flex;
    gap: 10px;
    margin-bottom: 20px;
}

.filter-btn {
    padding: 8px 16px;
    border: 2px solid var(--gray-light);
    background: white;
    border-radius: 8px;
    font-size: 13px;
    cursor: pointer;
    transition: all 0.2s;
}

.filter-btn:hover,
.filter-btn.active {
    border-color: var(--primary);
    color: var(--primary);
}

/* Empty states */
.empty-state {
    text-align: center;
    padding: 60px 20px;
}

.empty-state i {
    font-size: 64px;
    color: var(--gray-light);
    margin-bottom: 20px;
}

.empty-state h3 {
    font-size: 20px;
    margin-bottom: 10px;
    color: var(--dark);
}

.empty-state p {
    color: var(--gray);
    margin-bottom: 20px;
}

/* Toggle Switch */
.toggle-switch { position: relative; width: 50px; height: 26px; display: inline-block; }
.toggle-switch input { opacity: 0; width: 0; height: 0; }
.toggle-slider { position: absolute; cursor: pointer; inset: 0; background: #ccc; border-radius: 26px; transition: 0.3s; }
.toggle-slider:before { content: ""; position: absolute; height: 20px; width: 20px; left: 3px; bottom: 3px; background: white; border-radius: 50%; transition: 0.3s; }
.toggle-switch input:checked + .toggle-slider { background: var(--primary, #ff6b35); }
.toggle-switch input:checked + .toggle-slider:before { transform: translateX(24px); }

/* Trial Banner */
.trial-banner {
    padding: 10px 20px;
    text-align: center;
    font-size: 14px;
    display: flex;
    justify-content: center;
    align-items: center;
}
.trial-banner.trial-info { background: linear-gradient(90deg, #3b82f6, #1d4ed8); color: white; }
.trial-banner.trial-warning { background: linear-gradient(90deg, #f59e0b, #d97706); color: white; }
.trial-banner.trial-critical { background: linear-gradient(90deg, #ef4444, #dc2626); color: white; animation: pulse 2s infinite; }
@keyframes pulse { 0%, 100% { opacity: 1; } 50% { opacity: 0.8; } }
.trial-content { display: flex; align-items: center; gap: 15px; }
.trial-content i { font-size: 18px; }
.trial-btn { background: white; color: #1f2937; padding: 6px 16px; border-radius: 6px; font-weight: 600; text-decoration: none; transition: transform 0.2s; }
.trial-btn:hover { transform: scale(1.05); }

/* filter-btn.active text fix — active filter: white text on the accent colour (was accent on accent) */
.filter-btn.active, .filter-btn.active:hover, .filter-btn.active:focus { color: #fff !important; }

/* F1: filter buttons — active state visible without dynamic-css.php (firm colour still overrides), same look on links and buttons, wrap on small screens */
.filters { flex-wrap: wrap; }
.filter-btn { display: inline-flex; align-items: center; text-decoration: none; white-space: nowrap; font-family: inherit; }
.filter-btn.active { background: var(--primary); border-color: var(--primary); }
