/* ============================================================
   Waled Team Portal – CSS v2.1
   ============================================================ */

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

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    font-size: 14px;
    color: #1f2937;
    background: #f3f4f6;
    line-height: 1.5;
}

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

.sidebar {
    width: 230px;
    min-height: 100vh;
    background: linear-gradient(180deg, #1e293b 0%, #0f172a 100%);
    display: flex;
    flex-direction: column;
    flex-shrink: 0;
    position: sticky;
    top: 0;
    height: 100vh;
    overflow-y: auto;
}

.main-content {
    flex: 1;
    padding: 24px;
    overflow-x: hidden;
}

/* ---- Sidebar ---- */
.sidebar-logo {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 20px 16px;
    border-bottom: 1px solid rgba(255,255,255,.08);
}
.logo-icon {
    width: 36px; height: 36px;
    background: linear-gradient(135deg, #3b82f6, #1d4ed8);
    border-radius: 8px;
    display: flex; align-items: center; justify-content: center;
    color: white; font-weight: 700; font-size: 18px;
}
.logo-title { color: white; font-weight: 700; font-size: 15px; }
.logo-sub { color: #94a3b8; font-size: 11px; }

.nav-section { padding: 10px 8px; }
.nav-label { color: #64748b; font-size: 10px; text-transform: uppercase; letter-spacing: .1em; padding: 6px 8px 4px; }
.nav-item {
    display: flex; align-items: center; gap: 9px;
    padding: 9px 12px;
    color: #94a3b8;
    text-decoration: none;
    border-radius: 6px;
    font-size: 13.5px;
    transition: background .15s, color .15s;
    margin-bottom: 1px;
}
.nav-item:hover { background: rgba(255,255,255,.07); color: #e2e8f0; }
.nav-item.active { background: rgba(59,130,246,.25); color: #93c5fd; }

.nav-bottom { margin-top: auto; border-top: 1px solid rgba(255,255,255,.08); padding-top: 10px; }
.user-info { padding: 10px 12px 6px; }
.user-name { color: #e2e8f0; font-weight: 600; font-size: 13px; margin-bottom: 4px; }
.role-badge { font-size: 11px; font-weight: 600; padding: 2px 8px; border-radius: 10px; }

/* ---- Page header ---- */
.page-header {
    display: flex; justify-content: space-between; align-items: flex-start;
    margin-bottom: 20px;
    flex-wrap: wrap; gap: 10px;
}
.page-header h1 { font-size: 22px; font-weight: 700; color: #111827; }

/* ---- Cards ---- */
.card {
    background: white;
    border-radius: 10px;
    border: 1px solid #e5e7eb;
    overflow: hidden;
}
.card-header {
    padding: 14px 20px;
    border-bottom: 1px solid #f3f4f6;
    background: #fafafa;
}
.card-header h3 { font-size: 15px; font-weight: 600; color: #374151; }
.card-body { padding: 20px; }

/* ---- Stats Grid ---- */
.stats-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(180px,1fr)); gap: 16px; margin-bottom: 20px; }
.stat-card {
    background: white; border-radius: 10px; padding: 18px 20px;
    border: 1px solid #e5e7eb;
}
.stat-value { font-size: 28px; font-weight: 700; color: #1f2937; }
.stat-label { color: #9ca3af; font-size: 12px; text-transform: uppercase; letter-spacing: .05em; margin-top: 2px; }

/* ---- Tables ---- */
.table { width: 100%; border-collapse: collapse; }
.table th {
    text-align: left; padding: 10px 14px;
    font-size: 11px; text-transform: uppercase; letter-spacing: .05em;
    color: #6b7280; font-weight: 600;
    border-bottom: 1px solid #e5e7eb;
    background: #f9fafb;
}
.table td { padding: 10px 14px; border-bottom: 1px solid #f3f4f6; vertical-align: middle; }
.table tbody tr:hover { background: #f9fafb; }
.table tbody tr:last-child td { border-bottom: none; }

/* ---- Buttons ---- */
.btn {
    display: inline-flex; align-items: center; gap: 5px;
    padding: 8px 16px; border-radius: 6px; font-size: 13px; font-weight: 500;
    cursor: pointer; border: none; text-decoration: none;
    transition: background .15s, opacity .15s;
}
.btn:disabled { opacity: .5; cursor: not-allowed; }
.btn-primary { background: #2563eb; color: white; }
.btn-primary:hover { background: #1d4ed8; }
.btn-danger { background: #dc2626; color: white; }
.btn-danger:hover { background: #b91c1c; }
.btn-outline { background: transparent; color: #374151; border: 1px solid #d1d5db; }
.btn-outline:hover { background: #f3f4f6; }
.btn-sm { padding: 5px 10px; font-size: 12px; }

/* ---- Forms ---- */
.form-group { margin-bottom: 14px; }
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.form-full { grid-column: 1 / -1; }
.form-group label { display: block; font-size: 12px; font-weight: 600; color: #374151; margin-bottom: 5px; }
.form-group input,
.form-group select,
.form-group textarea {
    width: 100%; padding: 8px 10px;
    border: 1px solid #d1d5db; border-radius: 6px;
    font-size: 13px; font-family: inherit;
    background: white; color: #1f2937;
    transition: border-color .15s;
}
.form-group input:focus,
.form-group select:focus,
.form-group textarea:focus {
    outline: none; border-color: #3b82f6;
    box-shadow: 0 0 0 3px rgba(59,130,246,.1);
}
.form-group textarea { resize: vertical; min-height: 80px; }

/* ---- Badges ---- */
.badge {
    display: inline-block; padding: 2px 8px; border-radius: 12px;
    font-size: 11px; font-weight: 600;
}
.badge-neu               { background: #f3f4f6; color: #6b7280; }
.badge-kontaktiert       { background: #dbeafe; color: #1d4ed8; }
.badge-angebot_angefordert { background: #ede9fe; color: #6d28d9; }
.badge-angebot_versendet { background: #fef3c7; color: #d97706; }
.badge-nachfassen        { background: #ffedd5; color: #ea580c; }
.badge-verhandlung       { background: #cffafe; color: #0891b2; }
.badge-auftrag           { background: #d1fae5; color: #065f46; }
.badge-abgeschlossen     { background: #d1fae5; color: #065f46; }
.badge-verloren          { background: #fee2e2; color: #991b1b; }
.badge-admin    { background: #fee2e2; color: #dc2626; }
.badge-vertrieb { background: #dbeafe; color: #2563eb; }
.badge-metallbau{ background: #fef3c7; color: #d97706; }
.badge-anbieter { background: #d1fae5; color: #059669; }

/* ---- Modals ---- */
.modal-overlay {
    position: fixed; inset: 0;
    background: rgba(0,0,0,.4);
    display: flex; align-items: center; justify-content: center;
    z-index: 1000;
    padding: 20px;
}
.modal {
    background: white; border-radius: 12px;
    width: 100%; max-width: 480px;
    max-height: 90vh; overflow-y: auto;
    box-shadow: 0 20px 60px rgba(0,0,0,.2);
}
.modal-header {
    display: flex; justify-content: space-between; align-items: center;
    padding: 16px 20px; border-bottom: 1px solid #e5e7eb;
}
.modal-header h3 { font-size: 16px; font-weight: 600; }
.modal-close {
    background: none; border: none; font-size: 18px; cursor: pointer;
    color: #9ca3af; padding: 4px;
}
.modal-close:hover { color: #374151; }
.modal form > * { padding: 0 20px; }
.modal form > .form-group { padding: 0 20px; }
.modal form > .form-grid { padding: 0 20px; }
.modal-footer {
    display: flex; gap: 8px; justify-content: flex-end;
    padding: 14px 20px !important; border-top: 1px solid #e5e7eb;
    margin-top: 10px;
}

/* ---- Filter Bar ---- */
.filter-bar {
    display: flex; gap: 10px; flex-wrap: wrap;
    margin-bottom: 16px; align-items: center;
}
.filter-bar input, .filter-bar select {
    padding: 7px 10px; border: 1px solid #d1d5db; border-radius: 6px;
    font-size: 13px; background: white;
}
.filter-bar input { flex: 1; min-width: 200px; }

/* ---- Alerts ---- */
.alert {
    padding: 12px 16px; border-radius: 6px; margin-bottom: 16px;
    font-size: 13px; font-weight: 500;
}
.alert-success { background: #d1fae5; color: #065f46; border: 1px solid #a7f3d0; }
.alert-error { background: #fee2e2; color: #991b1b; border: 1px solid #fecaca; }

/* ---- Login ---- */
.login-page, .login-wrap {
    display: flex; align-items: center; justify-content: center;
    min-height: 100vh;
    background: linear-gradient(135deg, #1e293b 0%, #0f172a 100%);
}
.login-box {
    background: white; border-radius: 14px; padding: 40px;
    width: 100%; max-width: 380px;
    box-shadow: 0 20px 60px rgba(0,0,0,.3);
}
.login-logo { text-align: center; margin-bottom: 28px; font-size: 22px; font-weight: 800; color: #1f2937; }
.login-logo h1 { font-size: 24px; font-weight: 800; color: #1f2937; }
.login-logo p { color: #9ca3af; font-size: 13px; }
.login-error, .alert-err { background: #fee2e2; color: #991b1b; padding: 10px 14px; border-radius: 6px; margin-bottom: 16px; font-size: 13px; }
/* Login form standalone styles (ohne .btn class) */
.btn-primary, button.btn-primary { background: #2563eb; color: white; border: none; border-radius: 6px; padding: 8px 16px; font-size: 13px; font-weight: 500; cursor: pointer; }
.fg { margin-bottom: 14px; }
.fg label { display: block; font-size: 12px; font-weight: 600; color: #374151; margin-bottom: 5px; }
.fg input { width: 100%; padding: 8px 10px; border: 1px solid #d1d5db; border-radius: 6px; font-size: 13px; font-family: inherit; }

/* ---- Detail Grid ---- */
.detail-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(240px,1fr)); gap: 16px; }
.detail-item label { display: block; font-size: 11px; font-weight: 600; text-transform: uppercase; letter-spacing: .05em; color: #9ca3af; margin-bottom: 3px; }
.detail-full { grid-column: 1/-1; }

/* ---- Timeline ---- */
.timeline { padding: 16px 20px; }
.timeline-item { display: flex; gap: 14px; margin-bottom: 18px; position: relative; }
.timeline-item:not(:last-child)::after { content: ''; position: absolute; left: 9px; top: 22px; bottom: -12px; width: 2px; background: #e5e7eb; }
.timeline-dot { width: 20px; height: 20px; border-radius: 50%; flex-shrink: 0; margin-top: 2px; }
.timeline-content { flex: 1; background: #f9fafb; border-radius: 8px; padding: 10px 14px; border: 1px solid #e5e7eb; }
.timeline-header { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; margin-bottom: 5px; }
.timeline-stage { font-size: 11px; font-weight: 600; padding: 2px 8px; border-radius: 10px; }
.timeline-date { font-size: 12px; color: #6b7280; }
.timeline-author { font-size: 11px; color: #9ca3af; margin-left: auto; }
.timeline-delete { color: #dc2626; text-decoration: none; font-size: 12px; opacity: .4; }
.timeline-delete:hover { opacity: 1; }
.timeline-subject { font-weight: 600; font-size: 13px; margin-bottom: 4px; }
.timeline-body { font-size: 13px; color: #374151; white-space: pre-wrap; }

/* ---- File chips ---- */
.file-chip {
    display: inline-flex; align-items: center; gap: 5px;
    padding: 5px 12px; background: #f3f4f6; border-radius: 20px;
    text-decoration: none; color: #374151; font-size: 12.5px;
    border: 1px solid #e5e7eb;
}
.file-chip:hover { background: #e5e7eb; }

/* ---- Calendar ---- */
.cal-grid { display: grid; grid-template-columns: repeat(7,1fr); gap: 2px; }
.cal-head { text-align: center; font-size: 11px; font-weight: 600; color: #9ca3af; padding: 6px; text-transform: uppercase; }
.cal-cell { min-height: 80px; padding: 5px; border: 1px solid #f0f0f0; border-radius: 4px; background: #fff; vertical-align: top; }
.cal-cell.cal-empty { background: #fafafa; border-color: #f5f5f5; }
.cal-cell.cal-today { background: #eff6ff; border-color: #bfdbfe; }
.cal-day-num { font-size: 11px; color: #9ca3af; margin-bottom: 2px; font-weight: 500; }
.cal-today .cal-day-num { font-weight: 700; color: #1d4ed8; }
.cal-event { font-size: 11px; padding: 2px 5px; margin-bottom: 2px; border-radius: 3px; cursor: pointer; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.cal-event:hover { opacity: .75; }
.cal-event.cal-done { opacity: .35; text-decoration: line-through; }

/* ---- Task items ---- */
.task-item { display: flex; align-items: center; gap: 10px; padding: 10px 15px; border-bottom: 1px solid #f3f4f6; cursor: pointer; transition: background .1s; }
.task-item:last-child { border-bottom: none; }
.task-item:hover { background: #f9fafb; }
.task-item.task-overdue .task-title { color: #dc2626; }
.task-dot { width: 10px; height: 10px; border-radius: 50%; flex-shrink: 0; }
.task-body { flex: 1; min-width: 0; }
.task-title { font-size: 13px; font-weight: 500; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.task-meta { font-size: 11px; color: #9ca3af; }
.task-done { background: none; border: 1px solid #d1fae5; color: #059669; border-radius: 50%; width: 24px; height: 24px; cursor: pointer; font-size: 12px; flex-shrink: 0; display: flex; align-items: center; justify-content: center; }
.task-done:hover { background: #d1fae5; }

/* ---- Search highlight ---- */
mark { background: #fef08a; padding: 0 2px; border-radius: 2px; }

/* ---- Spinner ---- */
.spinner { width: 32px; height: 32px; border: 3px solid #e5e7eb; border-top-color: #3b82f6; border-radius: 50%; animation: spin .8s linear infinite; margin: 0 auto; }
@keyframes spin { to { transform: rotate(360deg); } }

/* ---- Scrollbar ---- */
::-webkit-scrollbar { width: 5px; height: 5px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: #d1d5db; border-radius: 3px; }
