/* ============================================================
   Autonomize AI — Longitude Design System
   Fixed header + sidebar, PPNeue (Inter fallback)
   ============================================================ */

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

button {
    font-family: inherit;
    -webkit-appearance: none;
    appearance: none;
    background: none;
    border: none;
    outline: none;
    padding: 0;
    margin: 0;
    color: inherit;
    cursor: pointer;
}

a { color: var(--primary); text-decoration: none; }
a:hover { text-decoration: underline; }

[x-cloak] { display: none !important; }

@keyframes spin {
    from { transform: rotate(0deg); }
    to   { transform: rotate(360deg); }
}

.spinner {
    display: inline-block;
    width: 20px;
    height: 20px;
    border: 2px solid var(--border);
    border-top-color: var(--primary);
    border-radius: 50%;
    animation: spin 0.65s linear infinite;
    will-change: transform;
    flex-shrink: 0;
}

/* ---------- Token Aliases ---------- */
:root {
    --primary:        var(--gn-primary);
    --primary-dark:   var(--gn-primary-hover);
    --primary-light:  var(--gn-primary-light);
    --primary-xlight: #F5F3FF;

    --header-bg:     var(--gn-brand-deep);
    --header-height: 56px;
    --sidebar-width: 220px;

    --success:        var(--gn-success);
    --success-text:   var(--gn-success-text);
    --success-bg:     var(--gn-success-light);
    --success-bg-light: #ECFDF5;
    --success-border: #A7F3D0;

    --danger:        var(--gn-danger);
    --danger-text:   var(--gn-danger-text);
    --danger-bg:     var(--gn-danger-light);
    --danger-bg-light: #FEF2F2;
    --danger-border: #FECACA;

    --warning:        var(--gn-warning);
    --warning-text:   var(--gn-warning-text);
    --warning-bg:     var(--gn-warning-light);
    --warning-bg-light: #FFFBEB;
    --warning-border: #FDE68A;

    --info:        var(--gn-info);
    --info-text:   var(--gn-info-text);
    --info-bg:     var(--gn-info-light);
    --info-bg-light: #EFF6FF;
    --info-border: #BFDBFE;

    --text:           var(--gn-text-primary);
    --text-secondary: var(--gn-text-secondary);
    --text-muted:     var(--gn-text-muted);

    --bg-page:  #F4F6F9;
    --bg-card:  var(--gn-surface);
    --bg-hover: var(--gn-surface-alt);

    --border:      var(--gn-border);
    --border-dark: var(--gn-border-strong);

    --shadow-sm: var(--gn-shadow-sm);
    --shadow-md: var(--gn-shadow-md);

    --radius-sm:   var(--gn-radius);
    --radius:      var(--gn-radius-lg);
    --radius-lg:   var(--gn-radius-xl);
    --radius-pill: 20px;
}

body {
    font-family: var(--gn-font-sans);
    font-size: 15px;
    line-height: 1.5;
    -webkit-font-smoothing: antialiased;
    background: var(--bg-page);
    color: var(--text);
}

/* ---------- App Layout ---------- */
.app-header {
    position: fixed;
    top: 0; left: 0; right: 0;
    height: var(--header-height);
    background: var(--header-bg);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 24px;
    z-index: 100;
}
.header-left { display: flex; align-items: center; gap: 12px; }
.header-logo {
    font-size: 14px;
    font-weight: 600;
    color: #FFFFFF;
    display: flex;
    align-items: center;
    gap: 10px;
}
.header-divider { width: 1px; height: 20px; background: rgba(255,255,255,0.2); }
.header-right {
    display: flex;
    align-items: center;
    gap: 12px;
    font-size: 12px;
    color: rgba(255,255,255,0.6);
}
.header-user { font-size: 12px; color: rgba(255,255,255,0.85); font-weight: 500; }
.header-logout {
    color: rgba(255,255,255,0.5);
    font-size: 12px;
    text-decoration: none;
    padding: 4px 10px;
    border: 1px solid rgba(255,255,255,0.2);
    border-radius: var(--radius-sm);
    transition: all 0.15s;
}
.header-logout:hover { color: #fff; border-color: rgba(255,255,255,0.4); text-decoration: none; }

/* ---------- Sidebar ---------- */
.app-sidebar {
    position: fixed;
    left: 0;
    top: var(--header-height);
    bottom: 0;
    width: var(--sidebar-width);
    background: #FFFFFF;
    border-right: 1px solid var(--border);
    padding: 16px 12px;
    z-index: 90;
    display: flex;
    flex-direction: column;
    gap: 4px;
    overflow-y: auto;
}
.sidebar-nav-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 12px;
    border-radius: var(--radius);
    font-size: 13px;
    font-weight: 500;
    color: var(--text-secondary);
    text-decoration: none;
    transition: all 0.15s;
    border: none;
    background: none;
    cursor: pointer;
    width: 100%;
    text-align: left;
}
.sidebar-nav-item:hover { background: var(--bg-page); text-decoration: none; color: var(--text); }
.sidebar-nav-item.active { background: var(--primary-light); color: var(--primary); font-weight: 600; }
.sidebar-nav-item svg, .sidebar-nav-item i { width: 18px; height: 18px; flex-shrink: 0; }

/* ---------- Main Content ---------- */
.app-main { margin-left: var(--sidebar-width); padding-top: var(--header-height); min-height: 100vh; }
.main-content { padding: 24px 28px; max-width: 1400px; margin: 0 auto; }

/* ---------- Page Header ---------- */
.page-header { margin-bottom: 20px; }
.page-title { font-size: 20px; font-weight: 700; color: var(--text); margin-bottom: 4px; }
.page-subtitle { font-size: 13px; color: var(--text-secondary); }

/* ---------- Stat Cards ---------- */
.stat-card-grid   { display: grid; grid-template-columns: repeat(5, 1fr); gap: 14px; margin-bottom: 24px; }
.stat-card-grid-4 { display: grid; grid-template-columns: repeat(4, 1fr); gap: 14px; margin-bottom: 24px; }
.stat-card-grid-3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 14px; margin-bottom: 24px; }
.stat-card-grid-2 { display: grid; grid-template-columns: repeat(2, 1fr); gap: 14px; margin-bottom: 24px; }

.stat-card {
    background: white;
    border-radius: var(--radius-lg);
    padding: 18px;
    border: 1px solid var(--border);
    transition: box-shadow 0.15s;
}
.stat-card:hover { box-shadow: 0 2px 8px rgba(0,0,0,0.06); }
.stat-icon {
    width: 36px; height: 36px;
    border-radius: 10px;
    display: flex; align-items: center; justify-content: center;
    margin-bottom: 12px;
}
.stat-icon-purple { background: var(--primary-light); color: var(--primary); }
.stat-icon-yellow { background: var(--warning-bg); color: #D97706; }
.stat-icon-green  { background: var(--success-bg-light); color: var(--success); }
.stat-icon-red    { background: var(--danger-bg); color: var(--danger); }
.stat-icon-blue   { background: var(--info-bg); color: var(--info); }
.stat-value { font-size: 26px; font-weight: 700; line-height: 1; margin-bottom: 4px; color: var(--text); }
.stat-label { font-size: 11px; font-weight: 600; color: var(--text-secondary); margin-bottom: 6px; }

/* ---------- Section / Cards ---------- */
.section-block { margin-bottom: 20px; }
.section-title {
    font-size: 14px; font-weight: 600; color: var(--text);
    margin-bottom: 12px; display: flex; align-items: center; gap: 8px;
}
.card {
    background: white;
    border-radius: var(--radius-lg);
    padding: 20px;
    border: 1px solid var(--border);
}

/* ---------- Data Tables ---------- */
.table-wrapper {
    overflow-x: auto;
    border-radius: var(--radius-lg);
    border: 1px solid var(--border);
    background: white;
}
.data-table { width: 100%; border-collapse: collapse; font-size: 12px; }
.data-table thead { background: var(--bg-page); }
.data-table th {
    padding: 10px 14px;
    text-align: left;
    font-size: 10px; font-weight: 600; color: var(--text-muted);
    text-transform: uppercase; letter-spacing: 0.5px;
    border-bottom: 1px solid var(--border);
    white-space: nowrap;
}
.data-table td {
    padding: 12px 14px;
    border-bottom: 1px solid var(--border);
    color: var(--text);
    vertical-align: middle;
}
.data-table tbody tr:last-child td { border-bottom: none; }
.data-table tbody tr:hover { background: var(--bg-hover); }
.data-table tbody tr.clickable-row { cursor: pointer; }

/* ---------- Badges ---------- */
.badge {
    display: inline-block;
    padding: 2px 8px;
    border-radius: var(--radius-pill);
    font-size: 10px; font-weight: 600;
    text-transform: uppercase; white-space: nowrap; letter-spacing: 0.3px;
}
.badge-approved    { background: var(--success-bg); color: var(--success-text); }
.badge-denied      { background: var(--danger-bg); color: var(--danger-text); }
.badge-pending     { background: var(--warning-bg); color: var(--warning-text); }
.badge-in-progress, .badge-in_progress { background: var(--primary-light); color: var(--primary); }
.badge-failed      { background: var(--danger-bg); color: var(--danger-text); }

/* ---------- Buttons ---------- */
.btn {
    display: inline-flex; align-items: center; justify-content: center; gap: 6px;
    padding: 6px 14px; font-size: 11px; font-weight: 600;
    border-radius: var(--radius-sm); border: none; cursor: pointer;
    transition: all 0.15s; font-family: inherit; text-decoration: none; white-space: nowrap;
}
.btn:hover { text-decoration: none; }
.btn:disabled { opacity: 0.5; cursor: not-allowed; }
.btn-primary   { background: var(--primary); color: white; }
.btn-primary:hover:not(:disabled) { background: var(--primary-dark); }
.btn-secondary { background: white; color: var(--primary); border: 1.5px solid var(--primary); }
.btn-secondary:hover:not(:disabled) { background: var(--primary-xlight); }
.btn-ghost  { background: none; border: 1px solid var(--border-dark); color: var(--text-secondary); }
.btn-ghost:hover:not(:disabled) { background: var(--bg-hover); color: var(--text); }
.btn-sm { padding: 4px 10px; font-size: 11px; }
.btn-lg { padding: 10px 20px; font-size: 13px; border-radius: var(--radius); }

/* ---------- Filter Pills ---------- */
.filter-pills { display: flex; gap: 8px; margin-bottom: 16px; flex-wrap: wrap; }
.filter-pill {
    padding: 6px 14px;
    border-radius: var(--radius-pill);
    background: white; border: 1px solid var(--border);
    font-size: 12px; color: var(--text-secondary); font-weight: 500;
    cursor: pointer; display: inline-flex; align-items: center; gap: 6px;
    transition: all 0.15s; text-decoration: none;
}
.filter-pill:hover { border-color: var(--border-dark); color: var(--text); text-decoration: none; }
.filter-pill.active { background: var(--primary); color: white; border-color: var(--primary); }

/* ---------- Flash Messages ---------- */
.flash-error {
    background: var(--danger-bg); color: var(--danger-text);
    padding: 10px 20px; text-align: center; font-size: 13px;
}

/* ---------- Login Page ---------- */
.login-page {
    min-height: 100vh; display: flex; align-items: center;
    justify-content: center; background: var(--bg-page);
}
.login-card {
    background: white; border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: 32px; width: 100%; max-width: 400px;
}
.login-header { text-align: center; margin-bottom: 24px; }
.login-title { font-size: 22px; font-weight: 700; color: var(--text); }
.login-subtitle { color: var(--text-secondary); font-size: 13px; margin-top: 4px; }
.login-error {
    background: var(--danger-bg); color: var(--danger-text);
    padding: 8px 12px; border-radius: var(--radius-sm);
    font-size: 12px; margin-bottom: 16px; text-align: center;
}
.login-form { display: flex; flex-direction: column; gap: 12px; }
.login-field { display: flex; flex-direction: column; gap: 4px; }
.login-label { font-size: 12px; font-weight: 600; color: var(--text); }
.login-input {
    padding: 10px 12px; font-size: 14px;
    border: 1px solid var(--border); border-radius: var(--radius-sm);
    background: white; color: var(--text); outline: none; font-family: inherit;
}
.login-input:focus { border-color: var(--primary); box-shadow: 0 0 0 2px var(--primary-light); }
.login-submit-btn {
    padding: 10px; font-size: 14px; font-weight: 600;
    background: var(--primary); color: white; border: none;
    border-radius: var(--radius-sm); cursor: pointer;
    transition: background 0.15s; font-family: inherit;
}
.login-submit-btn:hover { background: var(--primary-dark); }
.login-divider { text-align: center; margin: 16px 0; position: relative; }
.login-divider::before {
    content: ''; position: absolute; left: 0; right: 0; top: 50%;
    height: 1px; background: var(--border);
}
.login-divider-text { position: relative; background: white; padding: 0 12px; font-size: 11px; color: var(--text-muted); }
.login-azure-btn {
    display: flex; align-items: center; justify-content: center; gap: 10px;
    width: 100%; padding: 10px; border: 1px solid var(--border);
    border-radius: var(--radius-sm); background: white; color: var(--text);
    font-size: 14px; font-weight: 600; text-decoration: none;
    transition: background 0.15s; cursor: pointer;
}
.login-azure-btn:hover { background: var(--bg-hover); text-decoration: none; }

/* ---------- RBAC ---------- */
.permission-tags { display: flex; flex-wrap: wrap; gap: 4px; }

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

/* ---------- Responsive ---------- */
@media (max-width: 1024px) { .stat-card-grid, .stat-card-grid-4 { grid-template-columns: repeat(2, 1fr); } }
@media (max-width: 768px) {
    .app-sidebar { display: none; }
    .app-main { margin-left: 0; }
    .stat-card-grid, .stat-card-grid-4, .stat-card-grid-3 { grid-template-columns: 1fr; }
}

@keyframes spin { to { transform: rotate(360deg); } }
.spin { animation: spin 0.8s linear infinite; }
