/* ==========================================================================
   MoonWing Command Center - Modern Tactical Luxury Design System
   Aesthetic: Sharp Geometric / Straight-Edge Luxury (มุมเหลี่ยม ตรง เรียบหรู)
   Color Palette: Deep Slate/Navy Void with Vibrant Tactical Accents (No Glows/Auras)
   ========================================================================== */

@import url('https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700&family=Prompt:wght@300;400;500;600;700&family=JetBrains+Mono:wght@400;500&display=swap');

:root {
    --font-main: 'Inter', 'Prompt', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    --font-mono: 'JetBrains Mono', monospace;

    /* Refined Tactical Slate Palette (Easy on the Eyes, High Clarity, Clean Contrast) */
    --bg-void: #0b0f19;
    --bg-base: #0e1422;
    --bg-surface: #111726;
    --bg-surface-hover: #151e30;
    --bg-elevated: #182238;
    --bg-card: #111726;
    --bg-card-hover: #151e30;
    --bg-glass: #111726;

    /* Clean, Crisp Tactical Borders (Zero Eye Strain) */
    --border-subtle: #1e293b;
    --border-bright: #2d3b55;
    --border-focus: #6366f1;

    /* Vibrant Solid Accent Colors (Rich, Balanced & Eye-Friendly) */
    --color-primary: #6366f1;
    --color-blue: #38bdf8;
    --color-emerald: #10b981;
    --color-amber: #f59e0b;
    --color-purple: #8b5cf6;
    --color-rose: #ef4444;

    /* Crisp Text Hierarchy */
    --text-main: #f8fafc;
    --text-muted: #94a3b8;
    --text-subtle: #64748b;
}

/* Global Reset & Base */
html {
    font-size: 16px;
    -webkit-text-size-adjust: 100%;
    color-scheme: dark;
}

body {
    font-family: var(--font-main);
    background-color: var(--bg-void);
    color: var(--text-main);
    min-height: 100vh;
    letter-spacing: -0.01em;
    line-height: 1.5;
    margin: 0;
    padding: 0;
}

/* Sharp Rectangular System (มุมเหลี่ยม ตรง เรียบหรู) */
*, *::before, *::after {
    border-radius: 0 !important;
}

/* Clean Tactical Scrollbars */
::-webkit-scrollbar {
    width: 6px;
    height: 6px;
}
::-webkit-scrollbar-track {
    background: #0b0f19;
}
::-webkit-scrollbar-thumb {
    background: #1e293b;
}
::-webkit-scrollbar-thumb:hover {
    background: #334155;
}

.custom-scroll::-webkit-scrollbar { width: 5px; height: 5px; }
.custom-scroll::-webkit-scrollbar-track { background: transparent; }
.custom-scroll::-webkit-scrollbar-thumb { background: #1e293b; }
.custom-scroll::-webkit-scrollbar-thumb:hover { background: #334155; }

/* ==========================================================================
   Loading Screen (Universal Animation)
   ========================================================================== */

#loading-screen {
    background: #0b0f19 !important;
    z-index: 99999 !important;
    transition: opacity 0.35s ease-out;
}

.mw-spinner {
    position: relative;
    width: 48px;
    height: 48px;
}

.mw-spinner-ring {
    position: absolute;
    inset: 0;
    border: 3px solid rgba(88, 101, 242, 0.15);
    border-radius: 50% !important; /* Circular spinner ring for natural spinning */
}

.mw-spinner-active {
    position: absolute;
    inset: 0;
    border: 3px solid transparent;
    border-top-color: #5865f2;
    border-right-color: #38bdf8;
    border-radius: 50% !important;
    animation: mwSpin 0.75s cubic-bezier(0.4, 0, 0.2, 1) infinite;
}

.mw-spinner-pulse-dot {
    position: absolute;
    inset: 18px;
    background: #5865f2;
    border-radius: 50% !important;
    animation: mwPulse 1.2s ease-in-out infinite;
}

@keyframes mwSpin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

@keyframes mwPulse {
    0%, 100% { transform: scale(0.6); opacity: 0.4; }
    50% { transform: scale(1.1); opacity: 1; }
}

/* ==========================================================================
   Sharp Cards & Panels (MW Card)
   ========================================================================== */

.mw-glass {
    background: var(--bg-surface);
    border: 1px solid var(--border-subtle);
}

.mw-card {
    background: var(--bg-card);
    border: 1px solid var(--border-subtle);
    border-radius: 0 !important;
    transition: background-color 0.15s ease, border-color 0.15s ease;
    position: relative;
    box-shadow: none !important;
}

.mw-card:hover {
    background: var(--bg-card-hover);
    border-color: var(--border-bright);
}

.mw-panel {
    background: var(--bg-surface);
    border: 1px solid var(--border-subtle);
    border-radius: 0 !important;
    box-shadow: none !important;
}

/* Topbar Header */
.glass-header, .mw-header {
    background: #0b111e;
    border-bottom: 1px solid var(--border-subtle);
}

/* ==========================================================================
   Sharp Tactical Buttons (มุมเหลี่ยม ตรง เรียบหรู)
   ========================================================================== */

.mw-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    font-weight: 600;
    font-size: 0.8125rem;
    line-height: 1.25rem;
    padding: 0.5rem 0.9rem;
    border-radius: 0 !important;
    transition: background-color 0.15s ease, border-color 0.15s ease, color 0.15s ease;
    cursor: pointer;
    user-select: none;
    text-decoration: none;
    border: 1px solid transparent;
    white-space: nowrap;
    box-shadow: none !important;
}

.mw-btn:active {
    transform: translateY(1px);
}

/* Primary Button (Discord Indigo) */
.mw-btn-primary {
    background: #5865f2;
    color: #ffffff;
    border: 1px solid #4752c4;
}
.mw-btn-primary:hover {
    background: #4752c4;
    color: #ffffff;
}

/* Success Button (Tactical Emerald) */
.mw-btn-success {
    background: #10b981;
    color: #ffffff;
    border: 1px solid #059669;
}
.mw-btn-success:hover {
    background: #059669;
}

/* Purple Button (Quick Event / Special Action) */
.mw-btn-purple {
    background: #8b5cf6;
    color: #ffffff;
    border: 1px solid #7c3aed;
}
.mw-btn-purple:hover {
    background: #7c3aed;
}

/* Amber Button */
.mw-btn-amber {
    background: #f59e0b;
    color: #0b111e;
    font-weight: 700;
    border: 1px solid #d97706;
}
.mw-btn-amber:hover {
    background: #d97706;
    color: #ffffff;
}

/* Danger Button */
.mw-btn-danger {
    background: #ef4444;
    color: #ffffff;
    border: 1px solid #dc2626;
}
.mw-btn-danger:hover {
    background: #dc2626;
}

/* Ghost / Secondary Buttons */
.mw-btn-ghost {
    background: #0f172a;
    color: #cbd5e1;
    border: 1px solid var(--border-subtle);
}
.mw-btn-ghost:hover {
    background: #16223d;
    color: #ffffff;
    border-color: var(--border-bright);
}

.mw-btn-secondary {
    background: #14203a;
    color: #e2e8f0;
    border: 1px solid var(--border-subtle);
}
.mw-btn-secondary:hover {
    background: #1c2c50;
    color: #ffffff;
    border-color: var(--border-bright);
}

/* ==========================================================================
   Navigation Tabs (Sharp Straight Tabs)
   ========================================================================== */

.mw-nav-tabs {
    display: flex;
    align-items: center;
    gap: 0.25rem;
    padding: 0.25rem;
    background: #0d1527;
    border: 1px solid var(--border-subtle);
    border-radius: 0 !important;
}

.mw-nav-tab {
    display: flex;
    align-items: center;
    gap: 0.45rem;
    padding: 0.4rem 0.8rem;
    border-radius: 0 !important;
    font-size: 0.8125rem;
    font-weight: 600;
    color: var(--text-muted);
    transition: background-color 0.15s ease, color 0.15s ease, border-color 0.15s ease;
    text-decoration: none;
    white-space: nowrap;
    border: 1px solid transparent;
}

.mw-nav-tab:hover {
    color: #ffffff;
    background: #16223d;
    border-color: var(--border-subtle);
}

.mw-nav-tab.active {
    color: #ffffff;
    background: #1e2c4f;
    border: 1px solid #3b82f6;
}

/* ==========================================================================
   Form Inputs & Selects (Sharp Rectangular)
   ========================================================================== */

.mw-input, .mw-select, input[type="text"]:not(.party-name-input), input[type="number"]:not(.party-limit-input):not(#global-limit), input[type="search"], select, textarea {
    background: #090e1a !important;
    border: 1px solid var(--border-subtle) !important;
    border-radius: 0 !important;
    padding: 0.55rem 0.875rem;
    font-size: 0.85rem;
    color: #ffffff;
    transition: border-color 0.15s ease;
    outline: none;
    box-shadow: none !important;
}

#guild-search-input {
    padding-left: 2.75rem !important;
}

.mw-input:focus, .mw-select:focus, input:focus, select:focus, textarea:focus {
    border-color: #5865f2 !important;
    background: #0d1527 !important;
}

/* Mobile Bottom Navigation Dock */
.mw-bottom-dock {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    height: 56px;
    background: #0b111e;
    border-top: 1px solid var(--border-subtle);
    display: none;
    align-items: center;
    justify-content: space-around;
    z-index: 40;
    padding: 0 0.5rem;
}

@media (max-width: 1024px) {
    .mw-bottom-dock {
        display: flex;
    }
    .has-bottom-dock {
        padding-bottom: 64px !important;
    }
}

.mw-dock-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 2px;
    color: var(--text-subtle);
    font-size: 0.65rem;
    font-weight: 600;
    text-decoration: none;
    padding: 0.35rem 0.5rem;
    border-radius: 0 !important;
    transition: color 0.15s ease;
    min-width: 48px;
}
.mw-dock-item i {
    font-size: 1rem;
}
.mw-dock-item:hover, .mw-dock-item.active {
    color: #ffffff;
}
.mw-dock-item.active {
    color: #38bdf8;
}

/* Sub-Toolbar */
.mw-sub-toolbar {
    background: #0d1527;
    border-bottom: 1px solid var(--border-subtle);
    padding: 0.5rem 1rem;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.75rem;
    flex-wrap: wrap;
    z-index: 20;
}

/* ==========================================================================
   Role Card & Editor Elements (Sharp)
   ========================================================================== */

.role-card {
    transition: background-color 0.15s ease, border-color 0.15s ease;
    border: 1px solid var(--border-subtle);
    background: #111726;
    border-radius: 0 !important;
}
.role-card:hover {
    border-color: var(--border-bright);
    background: #151e30;
}
.role-card.active {
    border: 2px solid #6366f1; 
    background-color: #172238; 
}

/* Header Icon Button */
.header-icon-btn {
    transition: border-color 0.15s;
    border: 2px dashed #2d3b55;
    border-radius: 0 !important;
}
.header-icon-btn:hover {
    border-color: #38bdf8; 
}
.header-icon-btn.selecting {
    border-color: #f59e0b; 
}

/* Party Name & Limit Inputs in Editor (Neat & Balanced) */
.party-name-input {
    width: 190px !important;
    max-width: 220px !important;
    height: 30px !important;
    padding: 0 0.6rem !important;
    font-size: 0.75rem !important; /* 12px text-xs */
    font-weight: 600 !important;
    background: #090e1a !important;
    border: 1px solid var(--border-subtle) !important;
    border-radius: 0 !important;
    color: #f8fafc !important;
    transition: border-color 0.15s ease, background-color 0.15s ease !important;
    outline: none !important;
    box-shadow: none !important;
}
.party-name-input:focus {
    border-color: #6366f1 !important;
    background: #111726 !important;
}

.party-limit-box {
    display: inline-flex !important;
    align-items: center !important;
    background: #090e1a !important;
    border: 1px solid var(--border-subtle) !important;
    border-radius: 0 !important;
    height: 30px !important;
    padding: 0 0.5rem !important;
    gap: 0.35rem !important;
    transition: border-color 0.15s ease, background-color 0.15s ease !important;
}
.party-limit-box:focus-within {
    border-color: #6366f1 !important;
    background: #111726 !important;
}

.party-limit-input {
    width: 28px !important;
    height: 100% !important;
    padding: 0 !important;
    margin: 0 !important;
    border: none !important;
    background: transparent !important;
    font-size: 0.75rem !important; /* 12px text-xs */
    font-weight: 600 !important;
    text-align: center !important;
    color: #f8fafc !important;
    outline: none !important;
    box-shadow: none !important;
}

/* Global Limit Input */
#global-limit {
    height: 28px !important;
    width: 54px !important;
    padding: 0 0.35rem !important;
    font-size: 0.75rem !important;
    font-weight: 600 !important;
    text-align: center !important;
    background: #090e1a !important;
    border: 1px solid var(--border-subtle) !important;
    border-radius: 0 !important;
    color: #f8fafc !important;
    outline: none !important;
}
#global-limit:focus {
    border-color: #6366f1 !important;
    background: #111726 !important;
}

/* Modal Overlay */
.modal-overlay {
    background-color: rgba(4, 7, 13, 0.85);
}

.no-select {
    user-select: none;
}

/* Class Icon Containers */
.class-icon-container {
    display: flex;
    flex-wrap: wrap;
    gap: 4px;
    padding: 4px;
    background-color: #0b0f19;
    border: 1px solid var(--border-subtle);
    border-radius: 0 !important;
    min-height: 36px;
    align-items: center;
}

.class-icon-wrapper {
    position: relative;
    width: 28px;
    height: 28px;
    padding: 1px;
    background: #14203a;
    border: 1px solid var(--border-subtle);
    border-radius: 0 !important;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: context-menu;
    transition: transform 0.15s;
}
.class-icon-wrapper:hover {
    transform: scale(1.08);
    z-index: 10;
}
.class-icon-wrapper img {
    width: 100%;
    height: 100%;
    object-fit: contain;
}

/* Emoji Picker in Right Panel */
.emoji-item {
    width: 58px !important;
    height: 58px !important;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 2px;
    background-color: #0d1527 !important;
    border: 1px solid var(--border-subtle) !important;
    border-radius: 0 !important;
    cursor: pointer;
    transition: background-color 0.15s ease, border-color 0.15s ease;
    min-height: 54px;
}
.emoji-item:hover {
    background-color: #16223d;
    border-color: var(--border-bright);
    z-index: 10;
}
.emoji-item:active {
    transform: scale(0.95);
}
.emoji-item img {
    width: 28px;
    height: 28px;
    object-fit: contain;
    margin-bottom: 2px;
}
.emoji-item span {
    font-size: 10px;
    color: #94a3b8;
    line-height: 1;
    text-align: center;
    width: 100%;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

/* Discord Mention */
.discord-mention {
    border-radius: 0 !important;
    padding: 0 4px;
    font-weight: 500;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    font-size: 13px;
    margin-right: 4px;
    background-color: rgba(88, 101, 242, 0.2);
    color: #c9cdfb;
    border: 1px solid rgba(88, 101, 242, 0.3);
}
.discord-mention:hover {
    background-color: #5865f2;
    color: #ffffff;
}

/* Notify Badge */
.notify-badge {
    font-size: 10px;
    padding: 2px 6px;
    border-radius: 0 !important;
    background: #14203a;
    color: #94a3b8;
    display: flex;
    align-items: center;
    gap: 4px;
    border: 1px solid var(--border-subtle);
}

/* Discord Embed Preview Container (Sharp Luxury) */
.discord-embed-container {
    background-color: #2b2d31;
    border-radius: 0 !important;
    border-left-width: 4px !important;
}

/* Day Slots & Event Cards (Sharp) */
.day-slot {
    border-radius: 0 !important;
}

/* Stat Cards (Sharp) */
.stat-card {
    border-radius: 0 !important;
    box-shadow: none !important;
}

/* Input number spin removal */
input[type=number]::-webkit-inner-spin-button, 
input[type=number]::-webkit-outer-spin-button { 
    -webkit-appearance: none; 
    margin: 0; 
}
input[type=number] {
    -moz-appearance: textfield; 
}

.preview-class-icon {
    width: 24px !important;
    height: 24px !important;
    object-fit: contain;
}
.preview-class-icon-lg,
.class-icon-lg {
    width: 28px !important;
    height: 28px !important;
    object-fit: contain;
    vertical-align: middle;
    margin-right: 8px;
}

#preview-footer-section h4 { font-size: 11px !important; }
#waitlist-preview-list { font-size: 10px !important; }
#waitlist-preview-list img { width: 12px !important; height: 12px !important; }

.waitlist-text-normal {
    font-weight: 400 !important;
    display: inline-flex;
    align-items: center;
    gap: 4px;
}

.guild-emoji-group {
    padding-bottom: 8px;
}
.guild-emoji-group span {
    user-select: none;
    pointer-events: none;
}
.guild-emoji-group > div:first-child,
.guild-emoji-group-header {
    background: #0d1527;
    border-bottom: 1px solid var(--border-subtle);
}

/* Touch & Mobile Utilities */
.touch-target {
    min-height: 40px;
    min-width: 40px;
}
* { -webkit-tap-highlight-color: transparent; }

@media (max-width: 640px) {
    .emoji-item {
        width: 48px !important;
        height: 48px !important;
    }
    .emoji-item img { width: 22px; height: 22px; }
    .emoji-item span { font-size: 8px; }
    .class-icon-wrapper { width: 24px; height: 24px; }
    .class-icon-container { gap: 3px; padding: 4px; min-height: 32px; }
    .discord-mention { font-size: 12px; }
}