/* G2 Auth — Fluent 2 Design System */

/* ── Design Tokens ── */
:root {
    --fluent-primary: #0078d4;
    --fluent-primary-hover: #106ebe;
    --fluent-primary-pressed: #005a9e;
    --fluent-bg: linear-gradient(135deg, #f0f4f8 0%, #e4e9f0 100%);
    --fluent-surface: rgba(255, 255, 255, 0.72);
    --fluent-surface-solid: #ffffff;
    --fluent-surface-hover: rgba(255, 255, 255, 0.85);
    --fluent-border: rgba(0, 0, 0, 0.06);
    --fluent-shadow: 0 2px 8px rgba(0, 0, 0, 0.08);
    --fluent-shadow-hover: 0 4px 16px rgba(0, 0, 0, 0.12);
    --fluent-shadow-depth: 0 8px 32px rgba(0, 0, 0, 0.14);
    --fluent-radius: 8px;
    --fluent-radius-sm: 6px;
    --fluent-font: 'Segoe UI Variable', 'Segoe UI', -apple-system, BlinkMacSystemFont, Roboto, sans-serif;
    --fluent-text: #242424;
    --fluent-text-secondary: #616161;
    --fluent-text-tertiary: #9e9e9e;
    --fluent-divider: rgba(0, 0, 0, 0.08);
    --fluent-danger: #d13438;
    --fluent-success: #107c10;
    --fluent-warning: #ffb900;
    --sidebar-width: 260px;
    --toolbar-height: 52px;
    --transition: all 200ms ease;
}

/* ── Reset & Base ── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

html, body {
    height: 100%;
    font-family: var(--fluent-font);
    font-size: 14px;
    line-height: 1.5;
    color: var(--fluent-text);
    background: var(--fluent-bg);
    -webkit-font-smoothing: antialiased;
}

a { color: var(--fluent-primary); text-decoration: none; }
a:hover { text-decoration: underline; }
h1 { font-size: 1.5rem; font-weight: 600; }
h2 { font-size: 1.2rem; font-weight: 600; }

/* ── Login Page ── */
.login-page {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 100vh;
}

.login-card {
    background: var(--fluent-surface-solid);
    border-radius: 12px;
    box-shadow: var(--fluent-shadow-depth);
    padding: 48px 40px;
    text-align: center;
    max-width: 400px;
    width: 90%;
}

.login-card .brand {
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--fluent-primary);
    margin-bottom: 8px;
}

.login-card p {
    color: var(--fluent-text-secondary);
    margin-bottom: 24px;
}

.login-buttons {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

/* ── Buttons ── */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 10px 20px;
    border-radius: var(--fluent-radius);
    border: 1px solid var(--fluent-border);
    background: var(--fluent-surface-solid);
    color: var(--fluent-text);
    font-size: 0.9rem;
    font-weight: 500;
    cursor: pointer;
    transition: var(--transition);
    text-decoration: none;
}
.btn:hover { background: var(--fluent-surface-hover); box-shadow: var(--fluent-shadow); text-decoration: none; }
.btn-primary { background: var(--fluent-primary); color: #fff; border-color: transparent; }
.btn-primary:hover { background: var(--fluent-primary-hover); }
.btn-danger { background: var(--fluent-danger); color: #fff; border-color: transparent; }
.btn-danger:hover { background: var(--fluent-danger); opacity: 0.9; }
.btn-sm { padding: 6px 12px; font-size: 0.8rem; }
.btn-google { border-color: #dadce0; }
.btn-google:hover { background: #f8f9fa; }
.btn-microsoft { border-color: #dadce0; }
.btn-microsoft:hover { background: #f8f9fa; }

/* ── App Shell ── */
.app-shell { display: flex; height: 100vh; overflow: hidden; }

/* ── Sidebar ── */
.sidebar {
    width: var(--sidebar-width);
    height: 100vh;
    background: var(--fluent-surface);
    backdrop-filter: blur(20px) saturate(1.5);
    border-right: 1px solid var(--fluent-border);
    display: flex;
    flex-direction: column;
    flex-shrink: 0;
}

.sidebar-brand {
    padding: 16px 20px;
    font-size: 1.1rem;
    font-weight: 700;
    color: var(--fluent-primary);
    display: flex;
    align-items: center;
    gap: 10px;
    border-bottom: 1px solid var(--fluent-divider);
}
.sidebar-brand i { font-size: 1.4rem; }

.sidebar-nav { flex: 1; padding: 12px 8px; overflow-y: auto; }
.sidebar-nav a {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px 16px;
    border-radius: var(--fluent-radius-sm);
    color: var(--fluent-text);
    text-decoration: none;
    font-size: 0.9rem;
    transition: var(--transition);
}
.sidebar-nav a:hover { background: rgba(0, 0, 0, 0.04); }
.sidebar-nav a.active { background: rgba(0, 120, 212, 0.08); color: var(--fluent-primary); font-weight: 600; }
.sidebar-home-link { margin-bottom: 8px; font-weight: 600; }
.sidebar-section { font-size: 0.75rem; font-weight: 600; color: var(--fluent-text-tertiary); padding: 16px 16px 4px; text-transform: uppercase; letter-spacing: 0.05em; }

.sidebar-footer {
    padding: 12px 16px;
    border-top: 1px solid var(--fluent-divider);
    font-size: 0.8rem;
    color: var(--fluent-text-secondary);
}

/* ── Main Area ── */
.main-area { flex: 1; display: flex; flex-direction: column; overflow: hidden; }

.toolbar {
    height: var(--toolbar-height);
    background: var(--fluent-surface);
    backdrop-filter: blur(20px);
    border-bottom: 1px solid var(--fluent-border);
    display: flex;
    align-items: center;
    padding: 0 20px;
    gap: 12px;
    flex-shrink: 0;
}
.toolbar-spacer { flex: 1; }
.toolbar-user { display: flex; align-items: center; gap: 8px; font-size: 0.85rem; }

.content { flex: 1; padding: 24px; overflow-y: auto; }

.page-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 24px;
}

/* ── Cards ── */
.card {
    background: var(--fluent-surface-solid);
    border-radius: var(--fluent-radius);
    box-shadow: var(--fluent-shadow);
    border: 1px solid var(--fluent-border);
    padding: 20px;
    margin-bottom: 16px;
}

/* ── Table ── */
.table-container { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; }
th, td { padding: 10px 14px; text-align: left; border-bottom: 1px solid var(--fluent-divider); }
th { font-weight: 600; font-size: 0.8rem; text-transform: uppercase; letter-spacing: 0.03em; color: var(--fluent-text-secondary); }
tr:hover { background: rgba(0, 0, 0, 0.02); }

/* ── Badge ── */
.badge {
    display: inline-block;
    padding: 2px 8px;
    border-radius: 12px;
    font-size: 0.75rem;
    font-weight: 600;
}
.badge-active { background: #e6f4ea; color: var(--fluent-success); }
.badge-inactive { background: #fde7e9; color: var(--fluent-danger); }
.badge-pending { background: #fff8e1; color: #b8860b; }
.badge-admin { background: #e8eaf6; color: #3f51b5; }

/* ── Modal ── */
.modal-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.4);
    backdrop-filter: blur(4px);
    z-index: 200;
    align-items: center;
    justify-content: center;
}
.modal-overlay.active { display: flex; }
.modal-dialog {
    background: var(--fluent-surface-solid);
    border-radius: 12px;
    box-shadow: var(--fluent-shadow-depth);
    max-width: 500px;
    width: 90%;
    max-height: 80vh;
    overflow-y: auto;
}
.modal-header {
    padding: 20px 24px 12px;
    font-weight: 600;
    font-size: 1.1rem;
    border-bottom: 1px solid var(--fluent-divider);
}
.modal-body { padding: 16px 24px; }
.modal-footer {
    padding: 12px 24px 20px;
    display: flex;
    justify-content: flex-end;
    gap: 8px;
}

/* ── Form ── */
.form-group { margin-bottom: 16px; }
.form-group label { display: block; font-weight: 600; font-size: 0.85rem; margin-bottom: 4px; }
.form-group input:not([type="checkbox"]), .form-group select, .form-group textarea {
    width: 100%;
    padding: 8px 12px;
    border: 1px solid var(--fluent-border);
    border-radius: var(--fluent-radius-sm);
    font-size: 0.9rem;
    font-family: var(--fluent-font);
    outline: none;
    transition: var(--transition);
}
.form-group input:not([type="checkbox"]):focus, .form-group select:focus {
    border-color: var(--fluent-primary);
    box-shadow: 0 0 0 1px var(--fluent-primary);
}

/* ── Tabs ── */
.tabs { display: flex; gap: 0; border-bottom: 1px solid var(--fluent-divider); margin-bottom: 20px; }
.tab {
    padding: 10px 20px;
    cursor: pointer;
    font-size: 0.9rem;
    font-weight: 500;
    color: var(--fluent-text-secondary);
    border-bottom: 2px solid transparent;
    transition: var(--transition);
}
.tab:hover { color: var(--fluent-text); }
.tab.active { color: var(--fluent-primary); border-bottom-color: var(--fluent-primary); font-weight: 600; }

.tab-panel { display: none; }
.tab-panel.active { display: block; }

/* ── App Grid ── */
.app-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(440px, 1fr)); gap: 16px; }
.app-card {
    background: var(--fluent-surface-solid);
    border-radius: var(--fluent-radius);
    box-shadow: var(--fluent-shadow);
    border: 1px solid var(--fluent-border);
    padding: 20px;
    display: flex;
    flex-direction: column;
    gap: 8px;
    transition: var(--transition);
}
.app-card:hover { box-shadow: var(--fluent-shadow-hover); transform: translateY(-1px); }
.app-card-header { display: flex; align-items: center; gap: 12px; }
.app-card-logo { width: 40px; height: 40px; border-radius: 8px; object-fit: cover; background: #f0f0f0; display: flex; align-items: center; justify-content: center; font-size: 1.2rem; color: var(--fluent-primary); }
.app-card-name { font-weight: 600; font-size: 1rem; }
.app-card-desc { font-size: 0.85rem; color: var(--fluent-text-secondary); }
.app-card-meta { font-size: 0.75rem; color: var(--fluent-text-tertiary); margin-top: auto; }

/* ── Checkbox list ── */
.checkbox-list { display: flex; flex-direction: column; gap: 6px; max-height: 200px; overflow-y: auto; padding: 8px; border: 1px solid var(--fluent-border); border-radius: var(--fluent-radius-sm); }
.checkbox-list label { display: flex; align-items: center; gap: 8px; font-size: 0.85rem; cursor: pointer; }
.checkbox-list label input[type="checkbox"] { flex-shrink: 0; }

/* ── Toast ── */
.toast {
    position: fixed;
    bottom: 20px;
    right: 20px;
    padding: 12px 20px;
    border-radius: var(--fluent-radius);
    background: var(--fluent-surface-solid);
    box-shadow: var(--fluent-shadow-depth);
    font-size: 0.9rem;
    z-index: 300;
    display: none;
}
.toast.show { display: block; animation: slideIn 200ms ease; }
.toast.error { border-left: 4px solid var(--fluent-danger); }
.toast.success { border-left: 4px solid var(--fluent-success); }

@keyframes slideIn {
    from { transform: translateY(20px); opacity: 0; }
    to { transform: translateY(0); opacity: 1; }
}

/* ── Newsletter Sub-Tabs ── */
.nl-tabs { display: flex; gap: 0; border-bottom: 1px solid var(--fluent-divider); margin-bottom: 20px; }
.nl-tab {
    padding: 10px 20px;
    cursor: pointer;
    font-size: 0.9rem;
    font-weight: 500;
    color: var(--fluent-text-secondary);
    border-bottom: 2px solid transparent;
    transition: var(--transition);
}
.nl-tab:hover { color: var(--fluent-text); }
.nl-tab.active { color: var(--fluent-primary); border-bottom-color: var(--fluent-primary); font-weight: 600; }

/* ── Quill Editor — Fluent 2 override ── */
.ql-toolbar.ql-snow {
    border: 1px solid var(--fluent-border);
    border-radius: var(--fluent-radius-sm) var(--fluent-radius-sm) 0 0;
    background: #f8f9fb;
    font-family: var(--fluent-font);
}
.ql-container.ql-snow {
    border: 1px solid var(--fluent-border);
    border-top: none;
    border-radius: 0 0 var(--fluent-radius-sm) var(--fluent-radius-sm);
    font-family: var(--fluent-font);
    font-size: 0.95rem;
}
#newsletter-editor .ql-editor {
    min-height: 300px;
    line-height: 1.7;
}

/* ── Home / MyPage ── */
.home-page {
    min-height: 100vh;
    background: var(--fluent-bg);
    display: flex;
    flex-direction: column;
}

.home-topbar {
    background: var(--fluent-surface);
    backdrop-filter: blur(20px) saturate(1.5);
    border-bottom: 1px solid var(--fluent-border);
    padding: 12px 32px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-shrink: 0;
}

.home-topbar-brand {
    display: flex;
    align-items: center;
    gap: 10px;
    font-size: 1.1rem;
    font-weight: 700;
    color: var(--fluent-primary);
}
.home-topbar-brand i { font-size: 1.3rem; }

.home-topbar-actions {
    display: flex;
    align-items: center;
    gap: 12px;
}

.home-topbar-user {
    font-size: 0.85rem;
    color: var(--fluent-text-secondary);
}

.home-content {
    flex: 1;
    max-width: 960px;
    width: 100%;
    margin: 0 auto;
    padding: 40px 24px;
}

.home-welcome {
    margin-bottom: 32px;
}
.home-welcome h1 {
    font-size: 1.8rem;
    font-weight: 600;
    color: var(--fluent-text);
    margin-bottom: 4px;
}
.home-welcome p {
    color: var(--fluent-text-secondary);
    font-size: 1rem;
}

.home-apps-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: 20px;
}

.home-app-card {
    background: var(--fluent-surface-solid);
    border-radius: 12px;
    box-shadow: var(--fluent-shadow);
    border: 1px solid var(--fluent-border);
    padding: 24px;
    display: flex;
    flex-direction: column;
    gap: 16px;
    transition: var(--transition);
}
.home-app-card:hover {
    box-shadow: var(--fluent-shadow-hover);
    transform: translateY(-2px);
}

.home-app-card-icon {
    width: 56px;
    height: 56px;
    border-radius: 12px;
    background: linear-gradient(135deg, #e8eaf6, #f0f4f8);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.5rem;
    color: var(--fluent-primary);
}

.home-app-card-body { flex: 1; }

.home-app-card-name {
    font-weight: 600;
    font-size: 1.1rem;
    margin-bottom: 4px;
}

.home-app-card-desc {
    font-size: 0.85rem;
    color: var(--fluent-text-secondary);
    line-height: 1.5;
}

.home-app-card-btn {
    width: 100%;
    text-align: center;
}

.home-empty {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 12px;
    padding: 60px 24px;
    text-align: center;
}
.home-empty h2 { font-size: 1.2rem; color: var(--fluent-text-secondary); }
.home-empty p { color: var(--fluent-text-tertiary); max-width: 400px; }

/* ── Group Tree ── */
.group-tree { padding: 4px 0; }

.group-tree-node {
    padding: 8px 12px;
    border-radius: var(--fluent-radius-sm);
    transition: var(--transition);
}
.group-tree-node:hover { background: rgba(0, 0, 0, 0.02); }

.group-tree-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
}

.group-tree-info {
    display: flex;
    align-items: center;
    gap: 8px;
    min-width: 0;
}

.group-tree-toggle {
    width: 20px;
    height: 20px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    border-radius: 4px;
    font-size: 0.7rem;
    color: var(--fluent-text-secondary);
    flex-shrink: 0;
    transition: var(--transition);
}
.group-tree-toggle:hover { background: rgba(0, 0, 0, 0.06); }

.group-tree-name {
    font-weight: 600;
    font-size: 0.9rem;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.group-tree-key {
    font-size: 0.75rem;
    color: var(--fluent-text-tertiary);
    font-family: 'Cascadia Code', 'Consolas', monospace;
}

.group-tree-meta {
    display: flex;
    gap: 12px;
    font-size: 0.75rem;
    color: var(--fluent-text-secondary);
    flex-shrink: 0;
}

.group-tree-actions {
    display: flex;
    gap: 4px;
    flex-shrink: 0;
}

.group-tree-children {
    margin-left: 20px;
    padding-left: 12px;
    border-left: 2px solid var(--fluent-divider);
}

/* ── Responsive ── */
@media (max-width: 768px) {
    .sidebar { display: none; }
    .app-grid { grid-template-columns: 1fr; }
    .home-apps-grid { grid-template-columns: 1fr; }
    .home-topbar { padding: 12px 16px; }
    .home-content { padding: 24px 16px; }
}
