:root {
    --bg-primary: #0a0a0f;
    --bg-secondary: #12121a;
    --bg-tertiary: #1a1a2e;
    --bg-card: #16162a;
    --bg-hover: #1e1e3a;
    --accent: #7c3aed;
    --accent-hover: #6d28d9;
    --accent-glow: rgba(124, 58, 237, 0.3);
    --text-primary: #e2e8f0;
    --text-secondary: #94a3b8;
    --text-muted: #64748b;
    --border: #2d2d4a;
    --success: #10b981;
    --warning: #f59e0b;
    --danger: #ef4444;
    --info: #3b82f6;
    --gradient-1: linear-gradient(135deg, #7c3aed, #3b82f6);
    --gradient-2: linear-gradient(135deg, #6d28d9, #4f46e5);
    --shadow: 0 4px 20px rgba(0,0,0,0.4);
    --shadow-glow: 0 0 30px rgba(124, 58, 237, 0.15);
}

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

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
    background: var(--bg-primary);
    color: var(--text-primary);
    min-height: 100vh;
    overflow-x: hidden;
}

body::before {
    content: '';
    position: fixed;
    top: 0; left: 0; right: 0; bottom: 0;
    background: radial-gradient(ellipse at 20% 50%, rgba(124,58,237,0.08) 0%, transparent 50%),
                radial-gradient(ellipse at 80% 20%, rgba(59,130,246,0.06) 0%, transparent 50%);
    pointer-events: none;
    z-index: 0;
}

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

.auth-container {
    display: flex;
    justify-content: center;
    align-items: center;
    min-height: 100vh;
    position: relative;
    z-index: 1;
}

.auth-box {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: 16px;
    padding: 40px;
    width: 100%;
    max-width: 420px;
    box-shadow: var(--shadow), var(--shadow-glow);
}

.auth-box h1 {
    font-size: 28px;
    font-weight: 700;
    text-align: center;
    margin-bottom: 8px;
    background: var(--gradient-1);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.auth-box .subtitle {
    text-align: center;
    color: var(--text-secondary);
    margin-bottom: 32px;
    font-size: 14px;
}

.auth-tabs {
    display: flex;
    gap: 4px;
    background: var(--bg-secondary);
    border-radius: 10px;
    padding: 4px;
    margin-bottom: 28px;
}

.auth-tab {
    flex: 1;
    padding: 10px;
    text-align: center;
    border-radius: 8px;
    cursor: pointer;
    font-size: 14px;
    font-weight: 500;
    color: var(--text-secondary);
    transition: all 0.2s;
    border: none;
    background: none;
}

.auth-tab.active {
    background: var(--accent);
    color: white;
}

.auth-tab:hover:not(.active) {
    color: var(--text-primary);
    background: var(--bg-hover);
}

.form-group {
    margin-bottom: 20px;
}

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

.form-group input, .form-group textarea, .form-group select {
    width: 100%;
    padding: 12px 16px;
    background: var(--bg-secondary);
    border: 1px solid var(--border);
    border-radius: 10px;
    color: var(--text-primary);
    font-size: 14px;
    transition: border-color 0.2s;
    font-family: inherit;
}

.form-group input:focus, .form-group textarea:focus, .form-group select:focus {
    outline: none;
    border-color: var(--accent);
    box-shadow: 0 0 0 3px var(--accent-glow);
}

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

.btn {
    padding: 12px 24px;
    border: none;
    border-radius: 10px;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
    display: inline-flex;
    align-items: center;
    gap: 8px;
    font-family: inherit;
}

.btn-primary {
    background: var(--gradient-1);
    color: white;
    width: 100%;
    justify-content: center;
}

.btn-primary:hover {
    transform: translateY(-1px);
    box-shadow: 0 4px 15px var(--accent-glow);
}

.btn-secondary {
    background: var(--bg-tertiary);
    color: var(--text-primary);
    border: 1px solid var(--border);
}

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

.btn-danger { background: var(--danger); color: white; }
.btn-danger:hover { background: #dc2626; }

.btn-success { background: var(--success); color: white; }
.btn-success:hover { background: #059669; }

.btn-warning { background: var(--warning); color: #000; }
.btn-warning:hover { background: #d97706; }

.btn-sm { padding: 8px 16px; font-size: 12px; }
.btn-xs { padding: 5px 10px; font-size: 11px; border-radius: 6px; }

.btn-group {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
}

/* MAIN LAYOUT */
.app-layout {
    display: flex;
    min-height: 100vh;
    position: relative;
    z-index: 1;
}

.sidebar {
    width: 260px;
    background: var(--bg-secondary);
    border-right: 1px solid var(--border);
    display: flex;
    flex-direction: column;
    position: fixed;
    top: 0;
    left: 0;
    bottom: 0;
    z-index: 100;
    transition: transform 0.3s;
}

.sidebar-header {
    padding: 24px 20px;
    border-bottom: 1px solid var(--border);
}

.sidebar-header h2 {
    font-size: 20px;
    font-weight: 700;
    background: var(--gradient-1);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.sidebar-header p {
    font-size: 12px;
    color: var(--text-muted);
    margin-top: 4px;
}

.sidebar-nav {
    flex: 1;
    padding: 12px;
    overflow-y: auto;
}

.nav-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 16px;
    border-radius: 10px;
    cursor: pointer;
    color: var(--text-secondary);
    font-size: 14px;
    font-weight: 500;
    transition: all 0.2s;
    margin-bottom: 2px;
}

.nav-item:hover {
    background: var(--bg-hover);
    color: var(--text-primary);
}

.nav-item.active {
    background: var(--accent);
    color: white;
}

.nav-item .icon {
    font-size: 18px;
    width: 24px;
    text-align: center;
}

.nav-item .badge {
    margin-left: auto;
    background: var(--danger);
    color: white;
    font-size: 11px;
    padding: 2px 8px;
    border-radius: 12px;
    font-weight: 600;
}

.sidebar-footer {
    padding: 16px;
    border-top: 1px solid var(--border);
}

.sidebar-footer .user-info {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px;
    border-radius: 10px;
    background: var(--bg-tertiary);
}

.sidebar-footer .user-avatar {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    background: var(--gradient-1);
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    font-size: 14px;
}

.sidebar-footer .user-details {
    flex: 1;
    min-width: 0;
}

.sidebar-footer .user-name {
    font-size: 13px;
    font-weight: 600;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.sidebar-footer .user-role {
    font-size: 11px;
    color: var(--text-muted);
}

.main-content {
    flex: 1;
    margin-left: 260px;
    padding: 32px;
    min-height: 100vh;
}

.page-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 32px;
}

.page-header h1 {
    font-size: 28px;
    font-weight: 700;
}

.page-header p {
    color: var(--text-secondary);
    margin-top: 4px;
    font-size: 14px;
}

/* CARDS & STATS */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 16px;
    margin-bottom: 32px;
}

.stat-card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: 14px;
    padding: 24px;
    transition: all 0.2s;
}

.stat-card:hover {
    border-color: var(--accent);
    box-shadow: var(--shadow-glow);
}

.stat-card .stat-icon {
    width: 44px;
    height: 44px;
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 20px;
    margin-bottom: 16px;
}

.stat-card .stat-value {
    font-size: 32px;
    font-weight: 700;
    line-height: 1;
}

.stat-card .stat-label {
    font-size: 13px;
    color: var(--text-secondary);
    margin-top: 4px;
}

.stat-icon.purple { background: rgba(124,58,237,0.15); color: var(--accent); }
.stat-icon.blue { background: rgba(59,130,246,0.15); color: var(--info); }
.stat-icon.green { background: rgba(16,185,129,0.15); color: var(--success); }
.stat-icon.red { background: rgba(239,68,68,0.15); color: var(--danger); }
.stat-icon.yellow { background: rgba(245,158,11,0.15); color: var(--warning); }

/* TABLE */
.card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: 14px;
    overflow: hidden;
}

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

.card-header h3 {
    font-size: 16px;
    font-weight: 600;
}

.table-wrapper {
    overflow-x: auto;
}

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

th {
    text-align: left;
    padding: 14px 20px;
    font-size: 12px;
    font-weight: 600;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.05em;
    border-bottom: 1px solid var(--border);
    background: var(--bg-secondary);
}

td {
    padding: 14px 20px;
    font-size: 14px;
    border-bottom: 1px solid var(--border);
}

tr:hover td {
    background: var(--bg-hover);
}

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

/* STATUS BADGES */
.status-badge {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 5px 12px;
    border-radius: 20px;
    font-size: 12px;
    font-weight: 600;
}

.status-badge.pending { background: rgba(245,158,11,0.15); color: var(--warning); }
.status-badge.in_review { background: rgba(59,130,246,0.15); color: var(--info); }
.status-badge.accepted { background: rgba(16,185,129,0.15); color: var(--success); }
.status-badge.rejected { background: rgba(239,68,68,0.15); color: var(--danger); }

.status-badge::before {
    content: '';
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: currentColor;
}

/* MODAL */
.modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.7);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
    backdrop-filter: blur(4px);
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.2s;
}

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

.modal {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: 16px;
    width: 100%;
    max-width: 560px;
    max-height: 85vh;
    overflow-y: auto;
    box-shadow: var(--shadow);
    transform: translateY(20px);
    transition: transform 0.2s;
}

.modal-overlay.active .modal {
    transform: translateY(0);
}

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

.modal-header h2 { font-size: 20px; font-weight: 700; }

.modal-close {
    width: 32px;
    height: 32px;
    border-radius: 8px;
    border: none;
    background: var(--bg-secondary);
    color: var(--text-secondary);
    cursor: pointer;
    font-size: 18px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.modal-close:hover { background: var(--danger); color: white; }

.modal-body { padding: 24px; }

.modal-footer {
    padding: 16px 24px;
    border-top: 1px solid var(--border);
    display: flex;
    justify-content: flex-end;
    gap: 12px;
}

/* FIELDS BUILDER */
.field-builder {
    border: 1px solid var(--border);
    border-radius: 10px;
    padding: 16px;
    margin-bottom: 12px;
    background: var(--bg-secondary);
    position: relative;
}

.field-builder .field-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 12px;
}

.field-builder .remove-field {
    background: none;
    border: none;
    color: var(--danger);
    cursor: pointer;
    font-size: 18px;
}

.field-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 12px;
}

/* EMPTY STATE */
.empty-state {
    text-align: center;
    padding: 60px 20px;
    color: var(--text-muted);
}

.empty-state .icon {
    font-size: 48px;
    margin-bottom: 16px;
}

.empty-state h3 {
    font-size: 18px;
    color: var(--text-secondary);
    margin-bottom: 8px;
}

/* TOAST */
.toast-container {
    position: fixed;
    top: 20px;
    right: 20px;
    z-index: 2000;
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.toast {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: 10px;
    padding: 14px 20px;
    font-size: 14px;
    box-shadow: var(--shadow);
    display: flex;
    align-items: center;
    gap: 10px;
    animation: slideIn 0.3s ease;
    max-width: 380px;
}

.toast.success { border-left: 3px solid var(--success); }
.toast.error { border-left: 3px solid var(--danger); }
.toast.info { border-left: 3px solid var(--info); }

@keyframes slideIn {
    from { transform: translateX(100%); opacity: 0; }
    to { transform: translateX(0); opacity: 1; }
}

/* RESPONSIVE */
.mobile-toggle {
    display: none;
    position: fixed;
    top: 16px;
    left: 16px;
    z-index: 200;
    width: 40px;
    height: 40px;
    border-radius: 10px;
    border: 1px solid var(--border);
    background: var(--bg-card);
    color: var(--text-primary);
    font-size: 20px;
    cursor: pointer;
    align-items: center;
    justify-content: center;
}

@media (max-width: 768px) {
    .mobile-toggle { display: flex; }
    .sidebar { transform: translateX(-100%); }
    .sidebar.open { transform: translateX(0); }
    .main-content { margin-left: 0; padding: 20px; padding-top: 64px; }
    .stats-grid { grid-template-columns: repeat(2, 1fr); }
    .field-row { grid-template-columns: 1fr; }
    .page-header { flex-direction: column; gap: 16px; align-items: flex-start; }
}

/* SCROLLBAR */
::-webkit-scrollbar { width: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border); border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: var(--text-muted); }

/* HIDDEN */
.hidden { display: none !important; }

/* PULSE ANIMATION */
@keyframes pulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.5; }
}

.loading { animation: pulse 1.5s infinite; }

/* REALTIME INDICATOR */
.realtime-indicator {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    font-size: 12px;
    color: var(--success);
}

.realtime-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: var(--success);
    animation: pulse 2s infinite;
}

/* APPLICATION DETAIL */
.app-detail-grid {
    display: grid;
    gap: 12px;
}

.app-detail-item {
    display: flex;
    gap: 12px;
    padding: 12px;
    background: var(--bg-secondary);
    border-radius: 8px;
}

.app-detail-item .label {
    min-width: 120px;
    font-size: 12px;
    color: var(--text-muted);
    font-weight: 500;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.app-detail-item .value {
    font-size: 14px;
}

/* NOTES */
.admin-notes-box {
    background: var(--bg-secondary);
    border: 1px solid var(--border);
    border-radius: 10px;
    padding: 16px;
    margin-top: 12px;
}

.admin-notes-box h4 {
    font-size: 13px;
    color: var(--text-muted);
    margin-bottom: 8px;
}

/* FILTER BAR */
.filter-bar {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
    margin-bottom: 20px;
}

.filter-btn {
    padding: 7px 16px;
    border-radius: 20px;
    border: 1px solid var(--border);
    background: var(--bg-secondary);
    color: var(--text-secondary);
    font-size: 13px;
    cursor: pointer;
    transition: all 0.2s;
}

.filter-btn.active {
    background: var(--accent);
    color: white;
    border-color: var(--accent);
}

.filter-btn:hover:not(.active) {
    border-color: var(--accent);
    color: var(--text-primary);
}

/* FORMS GRID */
.forms-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
    gap: 20px;
}

.form-card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: 14px;
    padding: 24px;
    transition: all 0.2s;
}

.form-card:hover {
    border-color: var(--accent);
    box-shadow: var(--shadow-glow);
    transform: translateY(-2px);
}

.form-card-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 12px;
}

.form-card-icon {
    font-size: 28px;
}

.form-card h3 {
    font-size: 18px;
    font-weight: 600;
    margin-bottom: 6px;
}

.form-card p {
    font-size: 13px;
    color: var(--text-muted);
    margin-bottom: 12px;
    min-height: 20px;
}

.form-card-meta {
    display: flex;
    gap: 12px;
    flex-wrap: wrap;
    font-size: 12px;
    color: var(--text-secondary);
    margin-bottom: 16px;
}

.form-card-meta span {
    background: var(--bg-secondary);
    padding: 3px 10px;
    border-radius: 12px;
}

.form-card-actions {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
}

/* SETTINGS */
.settings-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(400px, 1fr));
    gap: 20px;
}

.settings-card {
    height: fit-content;
}

/* FULL PAGE MODAL */
.modal-fullpage {
    max-width: 900px;
    width: 95vw;
    max-height: 92vh;
}

/* FORM ROWS */
.form-row-2 {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 16px;
}

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

.divider {
    height: 1px;
    background: var(--border);
    margin: 20px 0;
}

.section-label {
    font-size: 14px;
    font-weight: 600;
    color: var(--text-secondary);
    margin-bottom: 12px;
    display: block;
}

/* FIELD DRAG HANDLE */
.field-drag {
    color: var(--text-muted);
    cursor: grab;
    font-size: 14px;
    user-select: none;
}

/* FIELD HINT */
.field-hint {
    color: var(--text-muted);
    font-size: 11px;
    margin-top: 4px;
    display: block;
}

/* FULLPAGE FIELD */
.fullpage-field {
    margin-bottom: 24px;
}

/* FORM PREVIEW */
.form-preview {
    background: var(--bg-secondary);
    border-radius: 12px;
    padding: 24px;
}

/* CHECKBOX / RADIO */
.checkbox-group, .radio-group {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.checkbox-label, .radio-label {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 14px;
    color: var(--text-primary);
    cursor: pointer;
}

.checkbox-label input, .radio-label input {
    width: auto;
}

/* FILE GRID */
.file-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(120px, 1fr));
    gap: 8px;
    margin-top: 8px;
}

.file-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 6px;
    padding: 12px;
    border-radius: 10px;
    border: 1px solid var(--border);
    background: var(--bg-secondary);
    cursor: pointer;
    transition: all 0.2s;
    font-size: 11px;
    color: var(--text-muted);
    text-align: center;
}

.file-item:hover {
    border-color: var(--accent);
}

.file-item.active {
    border-color: var(--success);
    background: rgba(16,185,129,0.1);
}

/* RESPONSIVE ADDITIONS */
@media (max-width: 768px) {
    .settings-grid { grid-template-columns: 1fr; }
    .forms-grid { grid-template-columns: 1fr; }
    .form-row-2, .form-row-3 { grid-template-columns: 1fr; }
    .modal-fullpage { max-width: 100%; width: 100%; max-height: 100vh; border-radius: 0; }
}

/* SVG ICON */
.icon-svg {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    vertical-align: middle;
}

.icon-svg svg {
    width: 100%;
    height: 100%;
    fill: none;
    stroke: currentColor;
    stroke-width: 2;
    stroke-linecap: round;
    stroke-linejoin: round;
}

.nav-item .icon .icon-svg {
    width: 18px;
    height: 18px;
}

/* ROLES GRID */
.roles-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
    gap: 20px;
}

.role-card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: 14px;
    padding: 24px;
    transition: all 0.2s;
}

.role-card:hover {
    border-color: var(--accent);
    box-shadow: var(--shadow-glow);
}

.role-card-header {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 16px;
}

.role-color-dot {
    width: 14px;
    height: 14px;
    border-radius: 50%;
    flex-shrink: 0;
}

.role-card-header h3 {
    font-size: 18px;
    font-weight: 600;
}

.role-permissions {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    margin-bottom: 16px;
    min-height: 28px;
}

.perm-badge {
    display: inline-flex;
    align-items: center;
    padding: 3px 10px;
    border-radius: 12px;
    font-size: 11px;
    font-weight: 500;
    background: rgba(124,58,237,0.12);
    color: var(--accent);
    text-transform: capitalize;
}

.role-card-actions {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
}

/* USER ROLES BADGES */
.user-roles-list {
    display: flex;
    flex-wrap: wrap;
    gap: 4px;
}

.user-role-badge {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 2px 8px;
    border-radius: 10px;
    font-size: 11px;
    font-weight: 600;
    background: var(--bg-secondary);
    border: 1px solid var(--border);
}

@media (max-width: 768px) {
    .roles-grid { grid-template-columns: 1fr; }
}

/* DISCORD HELP STEPS */
.discord-help-step {
    display: flex;
    gap: 14px;
    align-items: flex-start;
    padding: 14px 0;
    border-bottom: 1px solid var(--border);
}

.discord-help-step:last-of-type {
    border-bottom: none;
    padding-bottom: 0;
}

.step-number {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    background: var(--accent);
    color: white;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    font-size: 14px;
    flex-shrink: 0;
}
