/* ============================================================
   WorkOS — Main Stylesheet
   ============================================================ */

:root {
    --indigo:    #5B48F5;
    --indigo-lt: #EEF0FE;
    --indigo-dk: #3C3489;
    --green:     #1D9E75;
    --green-lt:  #E1F5EE;
    --red:       #E24B4A;
    --red-lt:    #FCEBEB;
    --amber:     #EF9F27;
    --amber-lt:  #FAEEDA;
    --blue:      #378ADD;
    --blue-lt:   #E6F1FB;
    --coral:     #D85A30;
    --coral-lt:  #FAECE7;
    --gray-50:   #F1EFE8;
    --sidebar:   #1A1F2E;
    --border:    rgba(0,0,0,0.1);
    --text:      #1A1A1A;
    --text-muted:#6B7280;
    --text-hint: #9CA3AF;
    --bg:        #F5F5F7;
    --surface:   #FFFFFF;
}

*, *::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: var(--text);
    background: var(--bg);
}

/* ---- Login ------------------------------------------------ */
.login-mode { display: flex; align-items: center; justify-content: center; min-height: 100vh; }
.login-wrap  { width: 100%; max-width: 400px; padding: 20px; }

.login-card {
    background: var(--surface);
    border-radius: 14px;
    border: 0.5px solid var(--border);
    padding: 36px 32px;
}

.login-logo {
    display: flex; align-items: center; gap: 10px;
    margin-bottom: 24px;
}
.logo-icon {
    width: 36px; height: 36px; background: var(--indigo);
    border-radius: 9px; display: flex; align-items: center;
    justify-content: center; color: #fff; font-size: 18px;
}
.logo-text { font-size: 18px; font-weight: 500; }
.login-title { font-size: 20px; font-weight: 500; margin-bottom: 20px; }
.login-hint  { text-align: center; font-size: 12px; color: var(--text-muted); margin-top: 14px; }

/* ---- App layout ------------------------------------------ */
.app-mode { display: flex; height: 100vh; overflow: hidden; }
#app      { display: flex; width: 100%; height: 100vh; overflow: hidden; }

/* ---- Sidebar --------------------------------------------- */
#sidebar {
    width: 220px; min-width: 220px;
    background: var(--sidebar);
    display: flex; flex-direction: column;
    height: 100vh; padding: 0 0 16px;
    overflow-y: auto;
}

.sb-logo {
    padding: 18px 16px 14px;
    display: flex; align-items: center; gap: 10px;
    border-bottom: 0.5px solid rgba(255,255,255,0.08);
}
.sb-logo-icon {
    width: 28px; height: 28px; background: var(--indigo);
    border-radius: 7px; display: flex; align-items: center;
    justify-content: center; color: #fff; font-size: 14px;
}
.sb-logo-text { color: #fff; font-size: 14px; font-weight: 500; }
.sb-logo-sub  { color: rgba(255,255,255,0.4); font-size: 11px; }

.tenant-switcher {
    margin: 12px 10px;
    background: rgba(255,255,255,0.06);
    border-radius: 8px; padding: 8px 10px;
    display: flex; align-items: center; gap: 8px;
    border: 0.5px solid rgba(255,255,255,0.1);
}
.tenant-dot  { width: 8px; height: 8px; border-radius: 50%; flex-shrink: 0; background: var(--indigo); }
.tenant-name { color: rgba(255,255,255,0.85); font-size: 12px; font-weight: 500; flex: 1; }

.sb-section {
    padding: 6px 10px 2px;
    color: rgba(255,255,255,0.3);
    font-size: 10px; font-weight: 500;
    letter-spacing: 0.06em; text-transform: uppercase;
    margin-top: 8px;
}
.sb-item {
    display: flex; align-items: center; gap: 9px;
    padding: 7px 12px; margin: 1px 6px;
    border-radius: 7px; cursor: pointer;
    color: rgba(255,255,255,0.55); font-size: 13px;
    text-decoration: none; transition: all 0.1s;
}
.sb-item:hover  { background: rgba(255,255,255,0.07); color: rgba(255,255,255,0.85); }
.sb-item.active { background: var(--indigo); color: #fff; }
.sb-badge {
    margin-left: auto;
    background: rgba(255,255,255,0.15);
    color: rgba(255,255,255,0.7);
    font-size: 10px; padding: 1px 6px;
    border-radius: 10px; font-weight: 500;
}
.sb-item.active .sb-badge { background: rgba(255,255,255,0.25); }

.sb-bottom { margin-top: auto; border-top: 0.5px solid rgba(255,255,255,0.08); padding-top: 8px; }
.sb-user {
    display: flex; align-items: center; gap: 9px;
    padding: 8px 12px; margin: 4px 6px;
    border-radius: 7px; cursor: pointer;
}
.sb-user:hover { background: rgba(255,255,255,0.06); }
.user-av {
    width: 28px; height: 28px; border-radius: 50%;
    background: var(--indigo); display: flex; align-items: center;
    justify-content: center; color: #fff; font-size: 11px;
    font-weight: 500; flex-shrink: 0;
}
.user-name { color: rgba(255,255,255,0.75); font-size: 12px; font-weight: 500; }
.user-role { color: rgba(255,255,255,0.35); font-size: 10px; }
.logout-btn {
    margin-left: auto; background: none; border: none;
    color: rgba(255,255,255,0.3); cursor: pointer; font-size: 16px;
    padding: 4px; border-radius: 5px;
}
.logout-btn:hover { color: rgba(255,255,255,0.7); background: rgba(255,255,255,0.08); }

/* ---- Main area ------------------------------------------- */
#main { flex: 1; display: flex; flex-direction: column; overflow: hidden; }

#topbar {
    background: var(--surface);
    border-bottom: 0.5px solid var(--border);
    padding: 0 24px; height: 52px;
    display: flex; align-items: center; gap: 16px;
    flex-shrink: 0;
}
.top-title  { font-size: 15px; font-weight: 500; }
.top-crumb  { font-size: 12px; color: var(--text-muted); }
.top-search {
    display: flex; align-items: center; gap: 8px;
    background: var(--bg); border: 0.5px solid var(--border);
    border-radius: 8px; padding: 6px 12px; flex: 0 0 220px;
    color: var(--text-muted);
}
.top-search input {
    border: none; background: none; outline: none;
    font-size: 13px; color: var(--text); width: 100%;
}
.top-actions { display: flex; gap: 8px; margin-left: auto; align-items: center; }

.icon-btn {
    width: 32px; height: 32px; border-radius: 7px;
    display: flex; align-items: center; justify-content: center;
    cursor: pointer; color: var(--text-muted);
    border: 0.5px solid var(--border);
    background: var(--surface); position: relative;
}
.icon-btn:hover { background: var(--bg); }
.notif-count {
    position: absolute; top: 4px; right: 4px;
    width: 8px; height: 8px; background: var(--red);
    border-radius: 50%; border: 1.5px solid var(--surface);
}

#content { flex: 1; overflow-y: auto; padding: 20px 24px; }

/* ---- Loading --------------------------------------------- */
.loading-spinner { display: flex; align-items: center; justify-content: center; gap: 8px; height: 200px; color: var(--text-muted); }
.loading-spinner i { font-size: 24px; animation: spin 1s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

/* ---- KPI cards ------------------------------------------- */
.kpi-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 12px; margin-bottom: 16px; }
.kpi-card {
    background: var(--surface); border: 0.5px solid var(--border);
    border-radius: 10px; padding: 14px 16px;
}
.kpi-label { font-size: 11px; color: var(--text-muted); font-weight: 500; text-transform: uppercase; letter-spacing: 0.05em; margin-bottom: 6px; }
.kpi-value { font-size: 24px; font-weight: 500; line-height: 1; }
.kpi-change { font-size: 11px; margin-top: 6px; color: var(--text-muted); }
.kpi-up { color: var(--green); }
.kpi-dn { color: var(--red); }
.kpi-bar { height: 3px; background: var(--border); border-radius: 2px; margin-top: 10px; overflow: hidden; }
.kpi-fill { height: 100%; border-radius: 2px; }

/* ---- Kanban ---------------------------------------------- */
.kanban-wrap { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; }
.k-col { background: var(--bg); border-radius: 10px; padding: 12px; }
.k-col-hd { display: flex; align-items: center; justify-content: space-between; margin-bottom: 10px; }
.k-col-title { font-size: 12px; font-weight: 500; color: var(--text-muted); }
.k-count { background: var(--surface); border: 0.5px solid var(--border); color: var(--text-muted); font-size: 10px; padding: 1px 6px; border-radius: 10px; }

.task-card {
    background: var(--surface); border: 0.5px solid var(--border);
    border-radius: 8px; padding: 10px 12px; margin-bottom: 8px;
    cursor: pointer;
}
.task-card:hover { border-color: rgba(0,0,0,0.2); box-shadow: 0 1px 4px rgba(0,0,0,0.06); }
.task-card.done { opacity: 0.6; }
.task-tag { display: inline-flex; font-size: 10px; padding: 2px 7px; border-radius: 5px; font-weight: 500; margin-bottom: 7px; }
.task-name { font-size: 13px; color: var(--text); line-height: 1.4; margin-bottom: 8px; }
.task-meta { display: flex; align-items: center; gap: 8px; }
.task-pri { font-size: 10px; display: flex; align-items: center; gap: 3px; }
.task-due { font-size: 10px; color: var(--text-muted); display: flex; align-items: center; gap: 3px; }
.task-due.overdue { color: var(--red); }
.task-avatars { display: flex; margin-left: auto; }
.mini-av {
    width: 20px; height: 20px; border-radius: 50%;
    display: flex; align-items: center; justify-content: center;
    font-size: 8px; font-weight: 500;
    border: 1.5px solid var(--surface); margin-left: -5px;
}
.mini-av:first-child { margin-left: 0; }

/* ---- Priority colors ------------------------------------- */
.pri-high { color: var(--red); }
.pri-med  { color: var(--amber); }
.pri-low  { color: var(--green); }

/* ---- Department tags ------------------------------------- */
.tag-eng { background: var(--indigo-lt); color: var(--indigo-dk); }
.tag-des { background: var(--green-lt);  color: #0F6E56; }
.tag-ops { background: var(--amber-lt);  color: #854F0B; }
.tag-mkt { background: var(--coral-lt);  color: #993C1D; }
.tag-gen { background: var(--gray-50);   color: #5F5E5A; }

/* ---- Tables ---------------------------------------------- */
.data-table { width: 100%; border-collapse: collapse; font-size: 12px; }
.data-table th {
    text-align: left; font-size: 10px; font-weight: 500;
    color: var(--text-muted); text-transform: uppercase;
    letter-spacing: 0.05em; padding: 0 8px 8px 0;
    border-bottom: 0.5px solid var(--border);
}
.data-table td { padding: 9px 8px 9px 0; border-bottom: 0.5px solid var(--border); vertical-align: middle; }
.data-table tr:last-child td { border-bottom: none; }
.data-table tr:hover td { background: var(--bg); }

/* ---- Cards ----------------------------------------------- */
.card {
    background: var(--surface); border: 0.5px solid var(--border);
    border-radius: 10px; padding: 14px 16px;
}
.card-hd { font-size: 13px; font-weight: 500; margin-bottom: 14px; display: flex; align-items: center; justify-content: space-between; }
.card-hd a { font-size: 11px; color: var(--indigo); cursor: pointer; font-weight: 400; }
.grid2 { display: grid; grid-template-columns: 1fr 300px; gap: 16px; }
.grid3 { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }

/* ---- Badges ---------------------------------------------- */
.badge { font-size: 10px; padding: 2px 7px; border-radius: 5px; font-weight: 500; }
.badge-success { background: var(--green-lt);  color: #0F6E56; }
.badge-danger  { background: var(--red-lt);    color: #A32D2D; }
.badge-warning { background: var(--amber-lt);  color: #854F0B; }
.badge-info    { background: var(--indigo-lt); color: var(--indigo-dk); }
.badge-neutral { background: var(--gray-50);   color: #5F5E5A; }

/* ---- Forms ----------------------------------------------- */
.form-group { margin-bottom: 14px; }
.form-group label { display: block; font-size: 12px; color: var(--text-muted); margin-bottom: 5px; font-weight: 500; }
.form-group input,
.form-group select,
.form-group textarea {
    width: 100%; padding: 7px 10px;
    border: 0.5px solid var(--border); border-radius: 7px;
    font-size: 13px; color: var(--text);
    background: var(--surface); outline: none;
}
.form-group input:focus,
.form-group select:focus,
.form-group textarea:focus {
    border-color: var(--indigo); box-shadow: 0 0 0 2px rgba(91,72,245,0.1);
}
.form-row-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }

/* ---- Buttons --------------------------------------------- */
.btn-primary {
    background: var(--indigo); color: #fff; border: none;
    border-radius: 8px; padding: 7px 14px;
    font-size: 13px; font-weight: 500; cursor: pointer;
    display: inline-flex; align-items: center; gap: 6px;
}
.btn-primary:hover { background: #4a39e0; }
.btn-ghost {
    background: var(--surface); color: var(--text-muted);
    border: 0.5px solid var(--border); border-radius: 8px;
    padding: 6px 12px; font-size: 12px; cursor: pointer;
    display: inline-flex; align-items: center; gap: 5px;
}
.btn-ghost:hover { background: var(--bg); }
.btn-full { width: 100%; justify-content: center; padding: 10px 14px; }
.btn-sm { padding: 4px 9px; font-size: 11px; }

/* ---- Alerts ---------------------------------------------- */
.alert { padding: 10px 12px; border-radius: 8px; font-size: 13px; margin-bottom: 14px; }
.alert-error { background: var(--red-lt); color: #A32D2D; }
.alert-success { background: var(--green-lt); color: #0F6E56; }

/* ---- Modal ----------------------------------------------- */
.modal-overlay {
    position: fixed; inset: 0;
    background: rgba(0,0,0,0.45);
    display: flex; align-items: center; justify-content: center;
    z-index: 1000;
}
.modal-box {
    background: var(--surface); border-radius: 12px;
    width: 480px; max-width: 95vw;
    box-shadow: 0 8px 32px rgba(0,0,0,0.12);
}
.modal-hd {
    display: flex; align-items: center; justify-content: space-between;
    padding: 16px 20px; border-bottom: 0.5px solid var(--border);
}
.modal-title  { font-size: 14px; font-weight: 500; }
.modal-close  { background: none; border: none; cursor: pointer; font-size: 18px; color: var(--text-muted); }
.modal-body   { padding: 16px 20px; max-height: 65vh; overflow-y: auto; }
.modal-footer { padding: 12px 20px; border-top: 0.5px solid var(--border); display: flex; gap: 8px; justify-content: flex-end; }

/* ---- Progress bars --------------------------------------- */
.prog-bar  { height: 4px; background: var(--border); border-radius: 2px; overflow: hidden; margin-top: 4px; }
.prog-fill { height: 100%; border-radius: 2px; transition: width 0.4s; }

/* ---- Responsive ------------------------------------------ */
@media (max-width: 900px) {
    .kpi-grid { grid-template-columns: repeat(2, 1fr); }
    .kanban-wrap { grid-template-columns: 1fr; }
    .grid2 { grid-template-columns: 1fr; }
}
@media (max-width: 640px) {
    #sidebar { display: none; }
    .kpi-grid { grid-template-columns: 1fr 1fr; }
}
