/* INTELARCH — Frontend Styles */

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

:root {
    --navy:      #1a2d4a;
    --navy-dark: #0f1e35;
    --teal:      #0ea5c9;
    --teal-light:#e0f7fc;
    --bg:        #f4f6f9;
    --white:     #ffffff;
    --border:    #e2e8f0;
    --text:      #1a2d4a;
    --text-muted:#64748b;
    --green:     #16a34a;
    --green-bg:  #f0fdf4;
    --orange:    #d97706;
    --orange-bg: #fffbeb;
    --red:       #dc2626;
    --red-bg:    #fff1f2;
    --blue:      #2563eb;
    --blue-bg:   #eff6ff;
    --radius:    8px;
    --shadow:    0 1px 3px rgba(0,0,0,.08), 0 1px 2px rgba(0,0,0,.05);
    --shadow-md: 0 4px 6px rgba(0,0,0,.07), 0 2px 4px rgba(0,0,0,.05);
    --sidebar-w: 220px;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, sans-serif;
    font-size: 14px;
    line-height: 1.5;
    color: var(--text);
    background: var(--bg);
}

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

/* ── Sidebar ── */
.ia-sidebar {
    width: var(--sidebar-w);
    background: var(--navy);
    display: flex;
    flex-direction: column;
    position: fixed;
    top: 0; left: 0; bottom: 0;
    z-index: 100;
}

.ia-sidebar-logo {
    padding: 24px 20px 16px;
    border-bottom: 1px solid rgba(255,255,255,.08);
}

.ia-sidebar-logo-title {
    font-size: 16px;
    font-weight: 700;
    color: #fff;
    letter-spacing: .5px;
}

.ia-sidebar-logo-sub {
    font-size: 11px;
    color: rgba(255,255,255,.45);
    margin-top: 2px;
}

.ia-nav {
    padding: 12px 0;
    flex: 1;
}

.ia-nav-label {
    font-size: 10px;
    font-weight: 600;
    color: rgba(255,255,255,.3);
    text-transform: uppercase;
    letter-spacing: .8px;
    padding: 8px 20px 4px;
}

.ia-nav a {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 9px 20px;
    color: rgba(255,255,255,.65);
    text-decoration: none;
    font-size: 13.5px;
    transition: background .15s, color .15s;
    border-radius: 0;
}

.ia-nav a:hover,
.ia-nav a.active {
    background: rgba(255,255,255,.08);
    color: #fff;
}

.ia-nav a.active {
    border-right: 3px solid var(--teal);
}

.ia-sidebar-user {
    padding: 14px 20px;
    border-top: 1px solid rgba(255,255,255,.08);
    display: flex;
    align-items: center;
    gap: 10px;
}

.ia-avatar {
    width: 32px; height: 32px;
    border-radius: 50%;
    background: var(--teal);
    display: flex; align-items: center; justify-content: center;
    font-size: 13px; font-weight: 600; color: #fff;
    flex-shrink: 0;
    transition: transform .15s ease;
}

.ia-sidebar-user-name {
    font-size: 13px;
    color: rgba(255,255,255,.8);
    font-weight: 500;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    transition: color .15s ease;
}

.ia-sidebar-user-role {
    font-size: 11px;
    color: rgba(255,255,255,.4);
}

.ia-sidebar-user-link {
    display: flex;
    align-items: center;
    gap: 12px;
    text-decoration: none;
    flex: 1;
    min-width: 0;
    color: inherit;
}

.ia-sidebar-user-link:hover .ia-sidebar-user-name {
    color: #fff;
}

.ia-sidebar-user-link:hover .ia-avatar {
    transform: scale(1.05);
}

/* ── Main content ── */
.ia-main {
    margin-left: var(--sidebar-w);
    flex: 1;
    padding: 32px;
    max-width: 1200px;
}

.ia-page-title {
    font-size: 26px;
    font-weight: 700;
    color: var(--navy);
    margin-bottom: 4px;
}

.ia-page-sub {
    font-size: 13px;
    color: var(--text-muted);
    margin-bottom: 28px;
}

/* ── KPI Cards ── */
.ia-kpi-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 16px;
    margin-bottom: 28px;
}

@media (max-width: 1100px) { .ia-kpi-grid { grid-template-columns: repeat(2, 1fr); } }
@media (max-width: 600px)  { .ia-kpi-grid { grid-template-columns: 1fr; } }

.ia-kpi-card {
    background: var(--white);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 20px;
    box-shadow: var(--shadow);
}

.ia-kpi-label {
    font-size: 11px;
    font-weight: 600;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: .5px;
    margin-bottom: 8px;
}

.ia-kpi-value {
    font-size: 28px;
    font-weight: 700;
    color: var(--navy);
    line-height: 1;
}

.ia-kpi-value.green { color: var(--green); }
.ia-kpi-value.orange { color: var(--orange); }
.ia-kpi-value.red { color: var(--red); }

.ia-kpi-hint {
    font-size: 12px;
    color: var(--text-muted);
    margin-top: 6px;
}

/* ── Cards / Panels ── */
.ia-card {
    background: var(--white);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    margin-bottom: 20px;
}

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

.ia-card-title {
    font-size: 15px;
    font-weight: 600;
    color: var(--navy);
}

.ia-card-body {
    padding: 20px;
}

/* ── Tables ── */
.ia-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 13.5px;
}

.ia-table th {
    text-align: left;
    font-size: 11px;
    font-weight: 600;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: .4px;
    padding: 10px 14px;
    border-bottom: 2px solid var(--border);
    white-space: nowrap;
}

.ia-table td {
    padding: 12px 14px;
    border-bottom: 1px solid var(--border);
    color: var(--text);
    vertical-align: middle;
}

.ia-table tbody tr:last-child td { border-bottom: none; }
.ia-table tbody tr:hover td { background: #fafbfc; }

/* ── Status badges ── */
.ia-badge {
    display: inline-block;
    padding: 2px 10px;
    border-radius: 20px;
    font-size: 11px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: .3px;
}

.ia-badge-green   { background: var(--green-bg);  color: var(--green); }
.ia-badge-orange  { background: var(--orange-bg); color: var(--orange); }
.ia-badge-red     { background: var(--red-bg);    color: var(--red); }
.ia-badge-blue    { background: var(--blue-bg);   color: var(--blue); }
.ia-badge-gray    { background: #f1f5f9;           color: #475569; }

/* ── Buttons ── */
.ia-btn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 8px 16px;
    border-radius: var(--radius);
    font-size: 13.5px;
    font-weight: 500;
    cursor: pointer;
    border: none;
    text-decoration: none;
    transition: opacity .15s;
}

.ia-btn:hover { opacity: .88; }

.ia-btn-primary { background: var(--navy); color: #fff; }
.ia-btn-success { background: var(--green); color: #fff; }
.ia-btn-danger  { background: var(--red);   color: #fff; }
.ia-btn-ghost   { background: transparent; color: var(--text); border: 1px solid var(--border); }

/* ── Forms ── */
.ia-form-group {
    margin-bottom: 18px;
}

.ia-form-label {
    display: block;
    font-size: 13px;
    font-weight: 500;
    color: var(--navy);
    margin-bottom: 6px;
}

.ia-form-label .req { color: var(--red); margin-left: 2px; }

.ia-input,
.ia-select,
.ia-textarea {
    width: 100%;
    padding: 9px 12px;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    font-size: 13.5px;
    color: var(--text);
    background: var(--white);
    outline: none;
    transition: border-color .15s, box-shadow .15s;
}

.ia-input:focus,
.ia-select:focus,
.ia-textarea:focus {
    border-color: var(--teal);
    box-shadow: 0 0 0 3px rgba(14,165,201,.12);
}

.ia-textarea { resize: vertical; min-height: 80px; }

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

@media (max-width: 600px) { .ia-form-row { grid-template-columns: 1fr; } }

/* ── Alerts ── */
.ia-alert {
    padding: 12px 16px;
    border-radius: var(--radius);
    font-size: 13.5px;
    margin-bottom: 16px;
    border-left: 4px solid;
}

.ia-alert-success { background: var(--green-bg); border-color: var(--green); color: #166534; }
.ia-alert-error   { background: var(--red-bg);   border-color: var(--red);   color: #991b1b; }

/* ── Task cards ── */
.ia-task-card {
    background: var(--white);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 16px 20px;
    margin-bottom: 10px;
    box-shadow: var(--shadow);
    display: flex;
    align-items: flex-start;
    gap: 16px;
}

.ia-task-card.prio-hoch   { border-left: 4px solid var(--red); }
.ia-task-card.prio-mittel { border-left: 4px solid var(--orange); }
.ia-task-card.prio-niedrig { border-left: 4px solid #94a3b8; }

.ia-task-content { flex: 1; }
.ia-task-title { font-weight: 600; color: var(--navy); margin-bottom: 4px; }
.ia-task-meta  { font-size: 12px; color: var(--text-muted); display: flex; gap: 12px; flex-wrap: wrap; }
.ia-task-actions { display: flex; gap: 8px; flex-shrink: 0; }

/* ── Utility ── */
.mt-4 { margin-top: 16px; }
.mt-8 { margin-top: 32px; }
.text-muted { color: var(--text-muted); }
.text-right { text-align: right; }
.font-bold { font-weight: 700; }

/* ── Mobile/Tablet Responsiveness ── */
.ia-mobile-header {
    display: none;
    position: fixed;
    top: 0; left: 0; right: 0;
    height: 56px;
    background: var(--navy);
    color: #fff;
    align-items: center;
    justify-content: space-between;
    padding: 0 16px;
    z-index: 101;
    box-shadow: 0 2px 4px rgba(0,0,0,0.1);
}

.ia-menu-toggle {
    background: transparent;
    border: none;
    color: #fff;
    font-size: 24px;
    cursor: pointer;
    padding: 4px 8px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.ia-mobile-title {
    font-size: 15px;
    font-weight: 700;
    letter-spacing: 0.5px;
}

.ia-sidebar-overlay {
    display: none;
    position: fixed;
    top: 0; left: 0; right: 0; bottom: 0;
    background: rgba(15, 30, 53, 0.6);
    z-index: 99;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.3s ease;
}

.ia-sidebar-overlay.active {
    opacity: 1;
    pointer-events: auto;
}

.ia-sidebar-close {
    display: none;
    position: absolute;
    top: 14px; right: 14px;
    background: transparent;
    border: none;
    color: rgba(255,255,255,0.6);
    font-size: 22px;
    cursor: pointer;
}

.ia-sidebar-close:hover {
    color: #fff;
}

@media (max-width: 991px) {
    .ia-mobile-header {
        display: flex;
    }
    
    .ia-sidebar-overlay {
        display: block;
        z-index: 1040;
    }
    
    .ia-sidebar-close {
        display: block;
    }
    
    .ia-sidebar {
        transform: translateX(-100%);
        transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
        box-shadow: 5px 0 25px rgba(0,0,0,0.15);
        z-index: 1050;
        overflow-y: auto;
        -webkit-overflow-scrolling: touch;
    }
    
    .ia-sidebar-logo {
        padding: 24px 40px 16px 20px;
    }
    
    .ia-sidebar.open {
        transform: translateX(0);
    }
    
    .ia-main {
        margin-left: 0;
        padding: 80px 16px 32px;
    }
    
    /* Improve tables on mobile */
    .ia-card-body {
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
    }
}

/* ── Responsive Grids ── */
.ia-grid-3 {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 16px;
}

.ia-grid-2-1 {
    display: grid;
    grid-template-columns: 2fr 1fr;
    gap: 20px;
}

.ia-grid-1-1 {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 20px;
}

@media (max-width: 991px) {
    .ia-grid-3 {
        grid-template-columns: repeat(2, 1fr);
    }
    .ia-grid-2-1,
    .ia-grid-1-1 {
        grid-template-columns: 1fr;
    }
}

@media (max-width: 600px) {
    .ia-grid-3 {
        grid-template-columns: 1fr;
    }
}

/* ── Mobile/Tablet Tables to Cards ── */
@media (max-width: 767px) {
    .ia-table-responsive, 
    .ia-table-responsive thead, 
    .ia-table-responsive tbody, 
    .ia-table-responsive td {
        display: block !important;
        width: 100% !important;
        box-sizing: border-box;
    }

    .ia-table-responsive tr {
        background: var(--white) !important;
        border: 1px solid var(--border) !important;
        border-radius: 12px !important;
        padding: 16px !important;
        margin: 12px 16px 16px !important;
        box-shadow: 0 2px 6px rgba(15, 31, 53, 0.04) !important;
        display: block !important;
        width: auto !important;
    }

    .ia-table-responsive thead {
        display: none !important;
    }

    .ia-table-responsive tbody tr:hover {
        background: #ffffff !important;
    }

    .ia-table-responsive td {
        display: flex !important;
        justify-content: space-between !important;
        align-items: flex-start !important;
        flex-wrap: wrap !important;
        gap: 8px !important;
        padding: 10px 0 !important;
        border-bottom: 1px dashed var(--border) !important;
        font-size: 13.5px !important;
        background: transparent !important;
    }

    .ia-table-responsive td > a,
    .ia-table-responsive td > span,
    .ia-table-responsive td > strong,
    .ia-table-responsive td > div {
        text-align: right !important;
        word-break: break-word !important;
        max-width: 100% !important;
    }

    .ia-table-responsive td:last-child {
        border-bottom: none !important;
    }

    .ia-table-responsive td[data-label]::before {
        content: attr(data-label);
        font-weight: 600;
        color: var(--navy);
        text-align: left;
        margin-right: 16px;
        font-size: 12px;
        text-transform: uppercase;
        letter-spacing: 0.3px;
        flex-shrink: 0;
    }

    .ia-table-responsive td strong {
        font-weight: 600;
    }

    .ia-card-body:has(.ia-table-responsive) {
        padding: 4px 0 !important;
        background: transparent !important;
    }
}

/* ── Mobile adjustments for general tables (stacked metadata details) ── */
@media (max-width: 575px) {
    .ia-table {
        display: block !important;
        width: 100% !important;
    }
    .ia-table tbody,
    .ia-table tr,
    .ia-table td {
        display: block !important;
        width: 100% !important;
        box-sizing: border-box !important;
    }
    .ia-table tr {
        padding: 12px 16px !important;
        border-bottom: 1px solid var(--border) !important;
    }
    .ia-table td {
        padding: 0 !important;
        border-bottom: none !important;
        word-break: break-word !important;
    }
    .ia-table td.text-muted {
        font-size: 11px !important;
        text-transform: uppercase !important;
        letter-spacing: .5px !important;
        margin-bottom: 4px !important;
    }
    .ia-table td:not(.text-muted) {
        font-size: 14px !important;
    }
}
