/* =====================================================
   pfx Auftragsplanung – Design System
   ===================================================== */

:root {
    --primary:       #0d6efd;
    --primary-dark:  #0b5ed7;
    --success:       #198754;
    --success-dark:  #146c43;
    --warning:       #ffc107;
    --info:          #0dcaf0;
    --navy:          #1a1f36;
    --navy-mid:      #2d3748;
    --surface:       #f8f9fa;
    --border:        #dee2e6;
    --radius-sm:     0.375rem;
    --radius-md:     0.5rem;
    --radius-lg:     0.75rem;
    --shadow-sm:     0 1px 3px rgba(0,0,0,.08);
    --shadow-md:     0 4px 12px rgba(0,0,0,.10);
    --shadow-lg:     0 12px 40px rgba(0,0,0,.18);
    --transition:    0.2s ease;
}

/* ── Base ────────────────────────────────────────── */
body {
    background-color: var(--surface);
    font-size: 1rem;
    -webkit-font-smoothing: antialiased;
}

/* ── Navbar ──────────────────────────────────────── */
.navbar {
    box-shadow: var(--shadow-sm);
}

.navbar-brand {
    font-size: 1.125rem;
    letter-spacing: -0.01em;
}

/* ── Cards ───────────────────────────────────────── */
.card {
    border-color: var(--border);
    border-radius: var(--radius-lg);
}

.card-header {
    border-bottom-color: var(--border);
    border-radius: var(--radius-lg) var(--radius-lg) 0 0 !important;
}

/* ── Stat Cards ──────────────────────────────────── */
.stat-card {
    border-left: 4px solid;
    border-radius: var(--radius-lg);
    transition: transform var(--transition), box-shadow var(--transition);
}

.stat-card:hover {
    transform: translateY(-3px);
    box-shadow: var(--shadow-md);
}

.stat-card h2 {
    font-size: 2rem;
    font-weight: 700;
    line-height: 1;
}

/* ── Status Panel (Log) ──────────────────────────── */
.status-panel {
    background: linear-gradient(135deg, var(--navy) 0%, var(--navy-mid) 100%);
    color: #fff;
    padding: 1rem;
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-md);
}

.status-log-content {
    max-height: 150px;
    overflow-y: auto;
    font-family: 'Cascadia Code', 'Fira Mono', 'Courier New', monospace;
    font-size: 0.72rem;
    background: rgba(0,0,0,.25);
    padding: 0.75rem;
    border-radius: var(--radius-sm);
    line-height: 1.6;
}

.status-log-content .log-entry {
    margin-bottom: 0.15rem;
    padding: 0.2rem 0;
    border-bottom: 1px solid rgba(255,255,255,.04);
    font-size: 0.8125rem;
}

.status-log-content .log-success { color: #4ade80; }
.status-log-content .log-error   { color: #f87171; }
.status-log-content .log-info    { color: #60a5fa; }

/* ── Preview Box ─────────────────────────────────── */
.preview-box {
    background: var(--surface);
    border: 1.5px dashed #adb5bd;
    border-radius: var(--radius-md);
    padding: 1rem;
    min-height: 160px;
    max-height: 210px;
    overflow-y: auto;
    transition: border-color var(--transition), background var(--transition);
}

.preview-box.has-content {
    border-style: solid;
    border-color: var(--primary);
    background: #fff;
    box-shadow: 0 0 0 3px rgba(13,110,253,.07);
}

/* ── Tables ──────────────────────────────────────── */
.table {
    font-size: 0.9375rem;
}

.table th {
    font-weight: 600;
    text-transform: uppercase;
    font-size: 0.8125rem;
    letter-spacing: 0.6px;
    color: #6c757d;
    white-space: nowrap;
}

.table-hover tbody tr:hover {
    background-color: rgba(13,110,253,.04);
}

/* ── Status Badges ───────────────────────────────── */
.badge-status {
    display: inline-block;
    padding: 0.3rem 0.65rem;
    font-size: 0.8125rem;
    font-weight: 500;
    border-radius: 999px;
    letter-spacing: 0.3px;
}

.badge-ausstehend {
    background-color: #fff8e1;
    color: #795700;
    border: 1px solid #ffe082;
}

.badge-gesendet {
    background-color: #e8f5e9;
    color: #1b5e20;
    border: 1px solid #a5d6a7;
}

/* ── Buttons ─────────────────────────────────────── */
.btn {
    font-weight: 500;
    letter-spacing: 0.01em;
    transition: filter var(--transition), transform var(--transition), box-shadow var(--transition);
}

.btn:active {
    transform: scale(0.97);
}

.btn-primary {
    background: linear-gradient(135deg, var(--primary) 0%, var(--primary-dark) 100%);
    border: none;
    box-shadow: 0 2px 6px rgba(13,110,253,.3);
}

.btn-primary:hover {
    filter: brightness(1.07);
    box-shadow: 0 4px 10px rgba(13,110,253,.35);
}

.btn-success {
    background: linear-gradient(135deg, var(--success) 0%, var(--success-dark) 100%);
    border: none;
    box-shadow: 0 2px 6px rgba(25,135,84,.3);
}

.btn-success:hover {
    filter: brightness(1.07);
}

/* ── Form Controls ───────────────────────────────── */
.form-control,
.form-select {
    border-radius: var(--radius-sm);
    transition: border-color var(--transition), box-shadow var(--transition);
}

.form-control:focus,
.form-select:focus {
    border-color: #86b7fe;
    box-shadow: 0 0 0 0.2rem rgba(13,110,253,.15);
}

textarea.form-control {
    font-family: 'Segoe UI', system-ui, sans-serif;
    line-height: 1.55;
    resize: vertical;
}

/* ── Toast ───────────────────────────────────────── */
.toast {
    background: #fff;
    border: none;
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-lg);
}

/* ── Spinner ─────────────────────────────────────── */
.spinner-sm {
    width: 1rem;
    height: 1rem;
    border-width: 0.125rem;
}

/* ── Animations ──────────────────────────────────── */
@keyframes fadeIn {
    from { opacity: 0; transform: translateY(8px); }
    to   { opacity: 1; transform: translateY(0); }
}

@keyframes shake {
    0%, 100% { transform: translateX(0); }
    10%, 30%, 50%, 70%, 90% { transform: translateX(-4px); }
    20%, 40%, 60%, 80% { transform: translateX(4px); }
}

.fade-in {
    animation: fadeIn 0.25s ease-out both;
}

.shake {
    animation: shake 0.5s ease-in-out both;
}

/* ── Misc ────────────────────────────────────────── */
.form-check-input { cursor: pointer; }

.btn-action {
    padding: 0.25rem 0.5rem;
    font-size: 0.75rem;
    border-radius: var(--radius-sm);
}

/* ── In Bearbeitung (In Work) ────────────────────── */
.in-work-header {
    background: linear-gradient(135deg, rgba(13,110,253,0.08) 0%, rgba(13,110,253,0.04) 100%) !important;
    border-top: 2px solid rgba(13,110,253,0.3);
    border-bottom: 1px solid rgba(13,110,253,0.15);
}

.in-work-header td {
    font-weight: 500;
}

.in-work-row {
    background-color: rgba(13,110,253,0.04) !important;
    border-left: 3px solid var(--primary);
}

.in-work-row:hover {
    background-color: rgba(13,110,253,0.08) !important;
}

.pin-btn {
    padding: 0.2rem 0.4rem;
    font-size: 0.75rem;
    border-radius: var(--radius-sm);
    transition: all 0.2s ease;
}

.pin-btn:hover {
    transform: scale(1.1);
}

.pin-btn:active {
    transform: scale(0.95);
}

.pin-btn.btn-primary {
    box-shadow: 0 2px 4px rgba(13,110,253,0.3);
}

/* ── Login Overlay ───────────────────────────────── */
.login-overlay {
    position: fixed;
    inset: 0;
    background: linear-gradient(135deg, var(--navy) 0%, #0f1535 50%, var(--navy-mid) 100%);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 9999;
    overflow-y: auto;
    padding: 1rem;
}

.login-overlay::before {
    content: '';
    position: absolute;
    inset: 0;
    background: radial-gradient(ellipse at top, rgba(13,110,253,0.15) 0%, transparent 50%),
                radial-gradient(ellipse at bottom, rgba(25,135,84,0.1) 0%, transparent 50%);
    pointer-events: none;
}

.login-container {
    position: relative;
    z-index: 1;
    width: 100%;
    max-width: 420px;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 1.5rem;
    animation: fadeIn 0.5s ease-out both;
}

/* Brand Section */
.login-brand {
    text-align: center;
    color: #fff;
}

.brand-logo {
    width: 64px;
    height: 64px;
    background: linear-gradient(135deg, var(--primary) 0%, var(--primary-dark) 100%);
    border-radius: var(--radius-lg);
    display: flex;
    align-items: center;
    justify-content: center;
    margin: 0 auto 1rem;
    box-shadow: 0 8px 32px rgba(13,110,253,0.4);
}

.brand-logo i {
    font-size: 2rem;
    color: #fff;
}

.brand-title {
    font-size: 1.5rem;
    font-weight: 700;
    margin-bottom: 0.25rem;
    letter-spacing: -0.02em;
}

.brand-subtitle {
    font-size: 0.9375rem;
    opacity: 0.7;
    font-weight: 400;
}

/* Login Card */
.login-card {
    background: rgba(255, 255, 255, 0.97);
    backdrop-filter: blur(20px);
    padding: 2rem 2.25rem;
    border-radius: var(--radius-lg);
    box-shadow: 0 25px 50px -12px rgba(0,0,0,0.35), 0 0 0 1px rgba(255,255,255,0.1);
    width: 100%;
    border: 1px solid rgba(255,255,255,0.2);
}

.login-header {
    text-align: center;
    margin-bottom: 1.75rem;
}

.login-icon {
    width: 56px;
    height: 56px;
    background: linear-gradient(135deg, rgba(13,110,253,0.1) 0%, rgba(13,110,253,0.05) 100%);
    border-radius: var(--radius-md);
    display: flex;
    align-items: center;
    justify-content: center;
    margin: 0 auto 1rem;
}

.login-icon i {
    font-size: 1.75rem;
    color: var(--primary);
}

.login-header h2 {
    font-size: 1.375rem;
    font-weight: 600;
    color: var(--navy);
    margin-bottom: 0.5rem;
}

.login-header p {
    font-size: 0.9375rem;
    color: #6c757d;
    margin-bottom: 0;
}

/* Form Styling */
.login-card .form-floating > .form-control {
    border-radius: var(--radius-md);
    border: 1.5px solid var(--border);
    height: calc(3.5rem + 2px);
    padding: 1rem 1rem 0.5rem 2.75rem;
    font-size: 0.9375rem;
}

.login-card .form-floating > label {
    padding: 1rem 1rem 0.5rem 2.75rem;
    color: #6c757d;
}

.login-card .form-floating > .form-control:focus {
    border-color: var(--primary);
    box-shadow: 0 0 0 4px rgba(13,110,253,0.1);
}

.login-card .form-floating > .form-control:focus + label,
.login-card .form-floating > .form-control:not(:placeholder-shown) + label {
    padding-top: 0.5rem;
    padding-bottom: 0.25rem;
    font-size: 0.75rem;
    color: var(--primary);
}

.login-card .form-floating > label i {
    position: absolute;
    left: -1.75rem;
    top: 50%;
    transform: translateY(-50%);
    font-size: 1rem;
}

.password-field {
    position: relative;
}

.password-field .form-control {
    padding-right: 3rem !important;
}

.password-toggle {
    position: absolute;
    right: 0.75rem;
    top: 50%;
    transform: translateY(-50%);
    background: none;
    border: none;
    color: #6c757d;
    cursor: pointer;
    padding: 0.5rem;
    border-radius: var(--radius-sm);
    transition: all var(--transition);
    z-index: 10;
}

.password-toggle:hover {
    color: var(--primary);
    background: rgba(13,110,253,0.1);
}

.password-toggle:focus {
    outline: 2px solid var(--primary);
    outline-offset: 2px;
}

.password-toggle i {
    font-size: 1.1rem;
}

/* Login Options */
.login-options {
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: 0.75rem;
    margin-bottom: 1.5rem;
}

.login-options .form-check {
    margin-bottom: 0;
}

.login-options .form-check-input:checked {
    background-color: var(--primary);
    border-color: var(--primary);
}

.login-options .form-check-label {
    font-size: 0.875rem;
    color: #495057;
    cursor: pointer;
}

.security-hint {
    font-size: 0.75rem;
    color: #198754;
    font-weight: 500;
}

/* Login Button */
.btn-login {
    border-radius: var(--radius-md);
    padding: 0.875rem 1.5rem;
    font-size: 1rem;
    font-weight: 500;
    position: relative;
    overflow: hidden;
    transition: all 0.3s ease;
}

.btn-login:hover {
    transform: translateY(-2px);
    box-shadow: 0 10px 25px rgba(13,110,253,0.35);
}

.btn-login:active {
    transform: translateY(0);
}

.btn-login .btn-content,
.btn-login .btn-spinner {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
}

.btn-login:disabled {
    opacity: 0.7;
    cursor: not-allowed;
}

/* Login Footer */
.login-footer {
    text-align: center;
    margin-top: 1.5rem;
    padding-top: 1.25rem;
    border-top: 1px solid var(--border);
}

.login-footer p {
    font-size: 0.8125rem;
}

/* Copyright */
.login-copyright {
    text-align: center;
}

/* ── Scrollbar ───────────────────────────────────── */
::-webkit-scrollbar        { width: 6px; height: 6px; }
::-webkit-scrollbar-track  { background: #f1f1f1; border-radius: 3px; }
::-webkit-scrollbar-thumb  { background: #c8c8c8; border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: #a8a8a8; }

/* ── KI-Formular ─────────────────────────────────── */
#aufgabeFormWrapper {
    min-height: 280px;
}

#aufgabeFormPlaceholder {
    min-height: 280px;
    border: 1.5px dashed var(--border);
    border-radius: var(--radius-md);
    background: var(--surface);
}

#aufgabeForm .form-control,
#aufgabeForm .form-select {
    background-color: #fffdf4;
    border-color: #e8d98a;
}

#aufgabeForm .form-control:focus,
#aufgabeForm .form-select:focus {
    background-color: #fff;
    border-color: #86b7fe;
    box-shadow: 0 0 0 0.2rem rgba(13,110,253,.15);
}

/* ── Searchable Dropdown ─────────────────────────── */
.sd-wrapper {
    position: relative;
}
.sd-control {
    display: flex;
    align-items: center;
    gap: 0.3rem;
    background: #fff;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    padding: 0.25rem 0.5rem;
    font-size: 0.8rem;
    cursor: pointer;
    min-height: 2rem;
    user-select: none;
    transition: border-color var(--transition), box-shadow var(--transition);
}
.sd-control:hover { border-color: #adb5bd; }
.sd-control.open, .sd-control:focus-within {
    border-color: #86b7fe;
    box-shadow: 0 0 0 0.2rem rgba(13,110,253,.15);
    outline: none;
}
.sd-label {
    flex: 1;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    color: #212529;
}
.sd-label.placeholder { color: #6c757d; }
.sd-clear {
    display: none;
    background: none;
    border: none;
    padding: 0;
    font-size: 0.75rem;
    color: #adb5bd;
    line-height: 1;
    cursor: pointer;
}
.sd-clear:hover { color: #dc3545; }
.sd-caret { color: #6c757d; font-size: 0.7rem; flex-shrink: 0; transition: transform .15s; }
.sd-control.open .sd-caret { transform: rotate(180deg); }

.sd-dropdown {
    display: none;
    position: absolute;
    top: calc(100% + 3px);
    left: 0;
    right: 0;
    background: #fff;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    box-shadow: var(--shadow-md);
    z-index: 1050;
    max-height: 260px;
    display: none;
    flex-direction: column;
}
.sd-dropdown.open { display: flex; }

.sd-search-wrap {
    padding: 0.4rem 0.5rem;
    border-bottom: 1px solid var(--border);
    flex-shrink: 0;
}
.sd-search {
    width: 100%;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    padding: 0.25rem 0.5rem;
    font-size: 0.8rem;
    outline: none;
}
.sd-search:focus { border-color: #86b7fe; box-shadow: 0 0 0 0.15rem rgba(13,110,253,.15); }

.sd-list {
    overflow-y: auto;
    flex: 1;
    margin: 0;
    padding: 0.25rem 0;
    list-style: none;
}
.sd-list li {
    padding: 0.3rem 0.75rem;
    cursor: pointer;
    font-size: 0.8rem;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.sd-list li:hover, .sd-list li.focused { background: #f0f4ff; }
.sd-list li.selected { background: #e7f0ff; font-weight: 600; }
.sd-list li.sd-empty { color: #6c757d; cursor: default; font-style: italic; }
.sd-list li.sd-empty:hover { background: none; }

/* ── Clickable table rows ────────────────────────── */
.dash-row td { vertical-align: middle; }
.dash-row:hover { background-color: rgba(13,110,253,.04) !important; }

/* ── Pagination compact ──────────────────────────── */
.pagination .page-link {
    padding: 0.3rem 0.6rem;
    font-size: 0.875rem;
    min-width: 2.25rem;
    text-align: center;
}

/* ── Card footer wrap ────────────────────────────── */
.card-footer { flex-wrap: wrap; gap: 0.5rem; }

/* ── Action buttons never full-width ─────────────── */
.btn-action { width: auto !important; margin-bottom: 0 !important; }

/* ── Responsive ──────────────────────────────────── */

/* xs – phones (< 576px) */
@media (max-width: 575.98px) {
    body { font-size: 0.9375rem; }
    .container-fluid { padding-left: 0.6rem; padding-right: 0.6rem; }

    .navbar { padding-top: 0.4rem; padding-bottom: 0.4rem; }
    .navbar-brand { font-size: 1rem; }

    /* Login overlay */
    .login-overlay { padding: 0.75rem; }
    .login-container { gap: 1rem; }

    /* Login brand */
    .brand-logo { width: 56px; height: 56px; }
    .brand-logo i { font-size: 1.75rem; }
    .brand-title { font-size: 1.25rem; }
    .brand-subtitle { font-size: 0.8rem; }

    /* Login card */
    .login-card { padding: 1.5rem 1.25rem; }
    .login-header { margin-bottom: 1.25rem; }
    .login-icon { width: 48px; height: 48px; }
    .login-icon i { font-size: 1.5rem; }
    .login-header h2 { font-size: 1.125rem; }

    /* Login form */
    .login-card .form-floating > .form-control {
        height: calc(3.25rem + 2px);
        padding: 0.875rem 0.875rem 0.375rem 2.5rem;
        font-size: 0.875rem;
    }
    .login-card .form-floating > label {
        padding: 0.875rem 0.875rem 0.375rem 2.5rem;
    }
    .login-card .form-floating > label i {
        left: -1.5rem;
    }

    .login-options {
        flex-direction: column;
        align-items: flex-start;
        gap: 0.5rem;
        margin-bottom: 1.25rem;
    }

    .btn-login {
        padding: 0.75rem 1.25rem;
        font-size: 0.9375rem;
    }

    .login-footer { margin-top: 1.25rem; padding-top: 1rem; }

    /* Card header */
    .card-header h5 { font-size: 0.9rem; }
    .card-header, .card-footer { padding-left: 0.75rem; padding-right: 0.75rem; }

    /* Table tighter */
    .table td, .table th { padding: 0.3rem 0.4rem; font-size: 0.875rem; }

    /* Status log */
    .status-log-content { max-height: 90px; }

    /* Stat cards: 2×2 */
    .stat-card { margin-bottom: 0; }
    .stat-card h2 { font-size: 1.5rem; }

    /* Filter bar: stack to 2 cols */
    .card-body .row > .col-9 { flex: 0 0 75%; max-width: 75%; }
    .card-body .row > .col-3 { flex: 0 0 25%; max-width: 25%; }
}

/* sm – landscape phones (576–767px) */
@media (min-width: 576px) and (max-width: 767.98px) {
    .container-fluid { padding-left: 0.875rem; padding-right: 0.875rem; }
    .table td, .table th { padding: 0.35rem 0.5rem; }
}

/* Touch: larger hit areas */
@media (hover: none) and (pointer: coarse) {
    .dash-row td { padding-top: 0.6rem; padding-bottom: 0.6rem; }
    .page-link { padding: 0.4rem 0.6rem; }
    .form-select, .form-control { min-height: 2.25rem; }
}
