/* ================================================================
   Super-Gateway Portal — Light theme (matches eval-claw WebUI)
   Overrides base.css vars to match app.css ChatGPT-style
   ================================================================ */

:root {
    --bg-primary:    #ffffff;
    --bg-secondary:  #f9f9f9;
    --bg-surface:    #ffffff;
    --bg-input:      #f4f4f4;
    --bg-hover:      #ececec;
    --text-primary:  #0d0d0d;
    --text-secondary:#6e6e80;
    --text-accent:   #0d0d0d;
    --border:        #e5e5e5;
    --accent:        #0d0d0d;
    --accent-hover:  #333333;
    --success:       #10a37f;
    --warning:       #f59e0b;
    --error:         #ef4444;
    --font-sans:     -apple-system, 'Segoe UI', 'Helvetica Neue', Arial, sans-serif;
    --font-mono:     'Söhne Mono', 'Fira Code', 'Cascadia Code', monospace;
    --radius:        8px;
    --radius-lg:     24px;
    --transition:    150ms ease;
    --sidebar-width: 260px;
}

/* ================================================================
   Reset / Base
   ================================================================ */

body {
    margin: 0;
    font-family: var(--font-sans);
    background: var(--bg-primary);
    color: var(--text-primary);
    -webkit-font-smoothing: antialiased;
}

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

::-webkit-scrollbar { width: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: #d1d1d1; border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: #b0b0b0; }

/* ================================================================
   Layout
   ================================================================ */

.sg-layout {
    display: flex;
    height: 100vh;
}

.sg-main {
    flex: 1;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.sg-main > :first-child {
    flex: 1;
    overflow-y: auto;
}

/* ================================================================
   Sidebar (matches .webui-sidebar)
   ================================================================ */

.sg-sidebar {
    width: var(--sidebar-width);
    background: var(--bg-secondary);
    border-right: 1px solid var(--border);
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.sg-sidebar__brand {
    padding: 16px;
    border-bottom: 1px solid var(--border);
}

.sg-sidebar__brand-name {
    font-size: 16px;
    font-weight: 600;
    color: var(--text-primary);
}

.sg-sidebar__brand-sub {
    font-size: 11px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--text-secondary);
    margin-top: 2px;
}

.sg-sidebar__nav {
    flex: 1;
    overflow-y: auto;
    padding: 8px;
}

.sg-sidebar__item {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 12px;
    border-radius: var(--radius);
    cursor: pointer;
    color: var(--text-secondary);
    font-size: 13px;
    transition: background var(--transition);
    white-space: nowrap;
}

.sg-sidebar__item:hover {
    background: var(--bg-hover);
    color: var(--text-primary);
}

.sg-sidebar__item--active {
    background: var(--bg-hover);
    color: var(--text-primary);
}

.sg-sidebar__item i {
    width: 16px;
    text-align: center;
    font-size: 13px;
}

.sg-sidebar__footer {
    padding: 12px 16px;
    border-top: 1px solid var(--border);
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
}

.sg-sidebar__user {
    font-size: 13px;
    color: var(--text-primary);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    flex: 1;
}

.sg-sidebar__logout {
    color: var(--text-secondary);
    cursor: pointer;
    font-size: 14px;
    padding: 4px;
    border-radius: 4px;
    transition: all var(--transition);
}

.sg-sidebar__logout:hover {
    color: var(--error);
    background: var(--bg-hover);
}

/* ================================================================
   Buttons (matches .webui-btn)
   ================================================================ */

.sg-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    padding: 8px 16px;
    border: none;
    border-radius: var(--radius);
    font-family: var(--font-sans);
    font-size: 13px;
    font-weight: 500;
    cursor: pointer;
    transition: all var(--transition);
    white-space: nowrap;
    background: var(--bg-input);
    color: var(--text-primary);
    border: 1px solid var(--border);
}

.sg-btn:hover {
    background: var(--bg-hover);
}

.sg-btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.sg-btn--primary {
    background: #0d0d0d;
    color: #ffffff;
    border-color: #0d0d0d;
}

.sg-btn--primary:hover {
    background: #333333;
    border-color: #333333;
}

.sg-btn--danger {
    background: var(--error);
    color: #ffffff;
    border-color: var(--error);
}

.sg-btn--danger:hover {
    opacity: 0.85;
}

.sg-btn--ghost {
    background: transparent;
    color: var(--text-secondary);
    border-color: transparent;
}

.sg-btn--ghost:hover {
    background: var(--bg-hover);
    color: var(--text-primary);
}

.sg-btn--success {
    background: transparent;
    color: var(--success);
    border-color: var(--border);
}

.sg-btn--success:hover {
    background: #ecfdf5;
}

.sg-btn--small {
    padding: 4px 10px;
    font-size: 12px;
}

/* ================================================================
   Form Elements (matches .webui-input / .webui-label / .webui-field)
   ================================================================ */

.sg-input {
    width: 100%;
    padding: 8px 12px;
    background: var(--bg-input);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    color: var(--text-primary);
    font-family: var(--font-sans);
    font-size: 14px;
    outline: none;
    transition: border-color var(--transition);
}

.sg-input:focus {
    border-color: var(--accent);
}

.sg-input::placeholder {
    color: var(--text-secondary);
}

.sg-label {
    display: block;
    margin-bottom: 4px;
    font-size: 13px;
    font-weight: 500;
    color: var(--text-secondary);
}

.sg-field {
    margin-bottom: 12px;
}

/* ================================================================
   Cards (matches .webui-card)
   ================================================================ */

.sg-card {
    background: var(--bg-surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 16px;
    margin-bottom: 12px;
}

.sg-card__row {
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.sg-card__label {
    font-size: 12px;
    color: var(--text-secondary);
}

.sg-card__value {
    font-weight: 500;
}

/* ================================================================
   Badges (matches .webui-badge)
   ================================================================ */

.sg-badge {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 2px 8px;
    border-radius: 10px;
    font-size: 11px;
    font-weight: 500;
}

.sg-badge--success { background: #ecfdf5; color: #065f46; }
.sg-badge--warning { background: #fffbeb; color: #92400e; }
.sg-badge--error   { background: #fef2f2; color: #991b1b; }
.sg-badge--info    { background: #eff6ff; color: #1e40af; }
.sg-badge--default { background: var(--bg-input); color: var(--text-secondary); }

.sg-badge__dot {
    width: 6px;
    height: 6px;
    border-radius: 50%;
    display: inline-block;
}

.sg-badge--running  .sg-badge__dot { background: var(--success); }
.sg-badge--running  { background: #ecfdf5; color: #065f46; }
.sg-badge--healthy  .sg-badge__dot { background: var(--success); }
.sg-badge--healthy  { background: #ecfdf5; color: #065f46; }
.sg-badge--stopped  .sg-badge__dot { background: var(--text-secondary); }
.sg-badge--stopped  { background: var(--bg-input); color: var(--text-secondary); }
.sg-badge--creating .sg-badge__dot { background: #2563eb; animation: sg-pulse 1.5s infinite; }
.sg-badge--creating { background: #eff6ff; color: #1e40af; }
.sg-badge--starting .sg-badge__dot { background: var(--success); animation: sg-pulse 1.5s infinite; }
.sg-badge--starting { background: #ecfdf5; color: #065f46; }
.sg-badge--stopping .sg-badge__dot { background: var(--warning); animation: sg-pulse 1.5s infinite; }
.sg-badge--stopping { background: #fffbeb; color: #92400e; }
.sg-badge--error    .sg-badge__dot { background: var(--error); }
.sg-badge--unhealthy .sg-badge__dot { background: var(--warning); }
.sg-badge--unhealthy { background: #fffbeb; color: #92400e; }
.sg-badge--inactive .sg-badge__dot { background: var(--warning); }
.sg-badge--inactive { background: #fffbeb; color: #92400e; }
.sg-badge--unreachable .sg-badge__dot { background: var(--error); }
.sg-badge--unreachable { background: #fef2f2; color: #991b1b; }

@keyframes sg-pulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.3; }
}

/* ================================================================
   Panel (matches .webui-panel)
   ================================================================ */

.sg-panel {
    flex: 1;
    overflow-y: auto;
    padding: 24px;
}

.sg-panel__header {
    margin-bottom: 20px;
}

.sg-panel__title {
    font-size: 20px;
    font-weight: 600;
    margin: 0 0 4px;
}

.sg-panel__subtitle {
    color: var(--text-secondary);
    font-size: 13px;
    margin: 0;
}

.sg-toolbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 16px;
}

/* ================================================================
   Stats Cards
   ================================================================ */

.sg-stats {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(120px, 1fr));
    gap: 12px;
    margin-bottom: 20px;
}

.sg-stats__card {
    background: var(--bg-surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 16px;
    text-align: center;
}

.sg-stats__value {
    font-size: 28px;
    font-weight: 700;
    color: var(--text-primary);
    line-height: 1;
}

.sg-stats__label {
    font-size: 11px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--text-secondary);
    margin-top: 6px;
}

/* ================================================================
   Table (account card list style)
   ================================================================ */

.sg-table {
    width: 100%;
    border-collapse: collapse;
}

.sg-table th {
    text-align: left;
    padding: 8px 12px;
    font-size: 11px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--text-secondary);
    border-bottom: 1px solid var(--border);
}

.sg-table td {
    padding: 10px 12px;
    border-bottom: 1px solid var(--border);
    font-size: 13px;
    color: var(--text-primary);
}

.sg-table tr:last-child td {
    border-bottom: none;
}

.sg-table tr:hover td {
    background: var(--bg-input);
}

.sg-empty {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 40px;
    color: var(--text-secondary);
    gap: 12px;
}

.sg-empty__icon {
    font-size: 48px;
    opacity: 0.3;
}

.sg-empty__text {
    font-size: 15px;
}

/* ================================================================
   Login Page
   ================================================================ */

.sg-login {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 100vh;
    background: var(--bg-primary);
}

.sg-login__card {
    background: var(--bg-surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 32px;
    width: 100%;
    max-width: 400px;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.08);
}

.sg-login__title {
    text-align: center;
    margin: 0 0 4px;
    font-size: 20px;
    font-weight: 600;
    color: var(--text-primary);
}

.sg-login__subtitle {
    text-align: center;
    margin: 0 0 24px;
    color: var(--text-secondary);
    font-size: 13px;
}

.sg-login__divider {
    display: flex;
    align-items: center;
    gap: 12px;
    margin: 20px 0;
    color: var(--text-secondary);
    font-size: 12px;
}

.sg-login__divider::before,
.sg-login__divider::after {
    content: "";
    flex: 1;
    border-top: 1px solid var(--border);
}

.sg-login__oauth-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    width: 100%;
    padding: 8px 16px;
    margin-bottom: 8px;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    background: var(--bg-surface);
    color: var(--text-primary);
    font-family: var(--font-sans);
    font-size: 13px;
    font-weight: 500;
    cursor: pointer;
    transition: background var(--transition);
}

.sg-login__oauth-btn:hover {
    background: var(--bg-input);
}

.sg-login__oauth-btn i {
    font-size: 14px;
}

.sg-login__form {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.sg-login__error {
    background: #fef2f2;
    border: 1px solid #fecaca;
    border-left-width: 4px;
    border-left-color: var(--error);
    color: #991b1b;
    padding: 8px 12px;
    border-radius: var(--radius);
    font-size: 13px;
    margin-bottom: 4px;
}

.sg-login__submit {
    padding: 8px 16px;
    border: none;
    border-radius: var(--radius);
    background: #0d0d0d;
    color: #ffffff;
    font-family: var(--font-sans);
    font-size: 13px;
    font-weight: 500;
    cursor: pointer;
    transition: background var(--transition);
    margin-top: 4px;
}

.sg-login__submit:hover {
    background: #333333;
}

.sg-login__submit:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.sg-login__toggle {
    text-align: center;
    margin-top: 16px;
    font-size: 13px;
    color: var(--text-secondary);
}

.sg-login__toggle a {
    color: var(--text-accent);
    cursor: pointer;
    text-decoration: none;
    font-weight: 500;
}

.sg-login__toggle a:hover {
    text-decoration: underline;
}

/* ================================================================
   Detail View
   ================================================================ */

.sg-detail__back {
    color: var(--text-secondary);
    cursor: pointer;
    font-size: 13px;
    display: inline-flex;
    align-items: center;
    gap: 4px;
    transition: color var(--transition);
}

.sg-detail__back:hover {
    color: var(--text-primary);
}

.sg-detail__info {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 12px;
    margin-bottom: 20px;
}

.sg-detail__field {
    background: var(--bg-surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 12px;
}

.sg-detail__field-label {
    font-size: 11px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--text-secondary);
    margin-bottom: 4px;
}

.sg-detail__field-value {
    font-size: 13px;
    color: var(--text-primary);
    font-family: var(--font-mono);
    word-break: break-all;
}

/* ================================================================
   Log Viewer
   ================================================================ */

.sg-logs {
    background: var(--bg-input);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 12px 16px;
    max-height: 400px;
    overflow-y: auto;
    font-family: var(--font-mono);
    font-size: 12px;
    line-height: 1.6;
    color: var(--text-secondary);
    white-space: pre-wrap;
    word-break: break-all;
}

/* ================================================================
   Vault Key Reveal
   ================================================================ */

.sg-vault-key__warning {
    background: #fffbeb;
    border: 1px solid #fde68a;
    border-left-width: 4px;
    border-left-color: var(--warning);
    color: #92400e;
    padding: 12px;
    border-radius: var(--radius);
    margin-bottom: 16px;
    font-size: 13px;
    text-align: left;
}

.sg-vault-key__box {
    background: var(--bg-input);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 16px;
    margin: 16px 0;
    font-family: var(--font-mono);
    font-size: 14px;
    word-break: break-all;
    color: var(--text-primary);
    position: relative;
    text-align: left;
}

.sg-vault-key__copy {
    position: absolute;
    top: 8px;
    right: 8px;
}

.sg-vault-key__confirm {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    margin: 16px 0;
    font-size: 13px;
    color: var(--text-primary);
}

/* ================================================================
   2FA
   ================================================================ */

.sg-2fa__code-input {
    text-align: center;
    font-size: 24px;
    letter-spacing: 0.5rem;
    padding: 8px 12px;
    background: var(--bg-input);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    color: var(--text-primary);
    font-family: var(--font-mono);
    outline: none;
}

.sg-2fa__code-input:focus {
    border-color: var(--accent);
}

/* ================================================================
   Settings Section (matches .claw-settings-section)
   ================================================================ */

.sg-settings-section {
    margin-bottom: 24px;
}

.sg-settings-section__title {
    font-size: 14px;
    font-weight: 600;
    margin-bottom: 12px;
    color: var(--text-primary);
    display: flex;
    align-items: center;
    gap: 8px;
}

.sg-settings-section__title i {
    width: 16px;
    text-align: center;
    color: var(--text-secondary);
}

/* ================================================================
   Credential status indicators
   ================================================================ */

.sg-cred-status {
    display: inline-flex;
    align-items: center;
    padding: 1px 6px;
    border-radius: 4px;
    font-size: 10px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.03em;
}

.sg-cred-status--configured {
    background: #ecfdf5;
    color: #065f46;
}

.sg-cred-status--modified {
    background: #fffbeb;
    color: #92400e;
}

.sg-cred-status--missing {
    background: var(--bg-input);
    color: var(--text-secondary);
}

/* ================================================================
   Modal override to match app.css light theme
   ================================================================ */

.webui-modal-overlay {
    background: rgba(0, 0, 0, 0.3) !important;
}

.webui-modal {
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.15) !important;
}
