:root {
    --bg-color: #0d0e10;
    --sidebar-bg: #111214;
    --card-bg: #151619;
    --accent-color: #4ADE80;
    --accent-glow: rgba(74, 222, 128, 0.15);
    --text-primary: #f1f1f1;
    --text-secondary: #8b8e92;
    --input-bg: #1a1b1e;
    --border-color: #26282c;
    --error-color: #f87171;
    --success-color: #34d399;
    --font-main: 'Inter', sans-serif;
    --font-mono: 'JetBrains Mono', monospace;
}

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

body {
    background-color: var(--bg-color);
    color: var(--text-primary);
    font-family: var(--font-main);
    min-height: 100vh;
    overflow-x: hidden;
}

/* Background refinement */
body::before {
    content: '';
    position: fixed;
    top: 0; left: 0; width: 100%; height: 100%;
    background: url('../img/minecraft_bg_blur.png') no-repeat center center/cover;
    opacity: 0.1;
    z-index: -1;
    filter: grayscale(0.5);
}

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

/* Sidebar - Flat & Bordered */
.sidebar {
    width: 280px;
    background-color: var(--sidebar-bg);
    border-right: 1px solid var(--border-color);
    padding: 40px 20px;
    display: flex;
    flex-direction: column;
    position: fixed;
    height: 100vh;
}

.brand { display: flex; align-items: center; gap: 12px; margin-bottom: 48px; padding: 0 10px; }
.brand-logo { 
    width: 36px; height: 36px; background: var(--accent-color); 
    border-radius: 8px; display: flex; align-items: center; justify-content: center; 
    color: #000; font-weight: 900; font-size: 1.2rem;
}
.brand-name { font-weight: 800; font-size: 1.1rem; letter-spacing: -0.5px; }

.nav-label { font-size: 0.7rem; text-transform: uppercase; letter-spacing: 1.5px; color: #4b5563; margin: 32px 10px 16px; font-weight: 700; }
.nav-item { 
    display: flex; align-items: center; gap: 12px; padding: 12px 16px; 
    color: var(--text-secondary); text-decoration: none; border-radius: 10px; 
    transition: all 0.2s ease; margin-bottom: 4px; font-weight: 500; font-size: 0.95rem;
}
.nav-item:hover { background-color: rgba(255, 255, 255, 0.03); color: var(--text-primary); }
.nav-item.active { 
    background-color: var(--accent-glow); 
    color: var(--accent-color); 
    box-shadow: inset 0 0 0 1px var(--accent-color);
}
.nav-item i { width: 18px; height: 18px; opacity: 0.8; }

.user-pill { 
    display: flex; align-items: center; gap: 12px; padding: 12px; 
    background: var(--input-bg); border: 1px solid var(--border-color); border-radius: 12px;
}
.user-pill img { width: 32px; height: 32px; border-radius: 8px; }
.user-pill-info p { font-size: 0.85rem; font-weight: 700; margin-bottom: 2px; }
.user-pill-info a { font-size: 0.75rem; color: var(--error-color); text-decoration: none; font-weight: 600; opacity: 0.8; }

/* Main Wrapper */
.main-wrapper { flex: 1; margin-left: 280px; display: flex; flex-direction: column; }

.top-bar {
    height: 70px; padding: 0 48px; display: flex; align-items: center; justify-content: space-between;
    border-bottom: 1px solid var(--border-color); background-color: var(--bg-color);
}
.breadcrumb { font-size: 0.85rem; color: var(--text-secondary); display: flex; align-items: center; gap: 8px; }
.breadcrumb i { width: 14px; }
.active-view { color: var(--text-primary); font-weight: 700; }

.discord-btn {
    display: flex; align-items: center; gap: 10px; background-color: #5865F2; color: white;
    padding: 10px 20px; border-radius: 10px; font-weight: 700; font-size: 0.85rem;
    text-decoration: none; transition: 0.2s;
}

.content-area { padding: 64px 48px; max-width: 1400px; margin: 0 auto; width: 100%; }

/* Grid Cards - Flat & Bordered */
.apps-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(320px, 1fr)); gap: 24px; }
.app-card {
    background-color: var(--card-bg); border: 1px solid var(--border-color);
    border-radius: 16px; padding: 32px; text-decoration: none; color: inherit;
    transition: all 0.25s ease; position: relative;
}
.app-card:hover { border-color: var(--accent-color); background: #1a1b1e; }

.app-card-icon { 
    width: 48px; height: 48px; border: 1px solid var(--border-color); border-radius: 12px;
    display: flex; align-items: center; justify-content: center; font-size: 1.4rem; color: var(--accent-color);
    margin-bottom: 20px;
}
.app-card-content h3 { font-size: 1.15rem; margin-bottom: 10px; }
.app-card-content p { color: var(--text-secondary); font-size: 0.9rem; line-height: 1.6; }

.status-badge { 
    font-size: 0.65rem; font-family: var(--font-mono); padding: 5px 12px; border-radius: 4px; 
    border: 1px solid var(--border-color); background: rgba(0,0,0,0.2); 
    color: var(--text-secondary); font-weight: 700; text-transform: uppercase;
}

/* Forms - Bordered Focus */
.form-container { 
    max-width: 800px; margin: 0 auto; background-color: var(--card-bg); 
    border: 1px solid var(--border-color); border-radius: 20px; padding: 48px;
}
.form-group { margin-bottom: 24px; }
label { display: block; margin-bottom: 10px; font-size: 0.9rem; font-weight: 600; color: var(--text-secondary); }
input, select, textarea { 
    width: 100%; padding: 14px 18px; background-color: var(--input-bg); 
    border: 1px solid var(--border-color); border-radius: 10px; color: var(--text-primary); 
    font-size: 0.95rem; font-family: inherit; transition: 0.2s; 
}
input:focus, select:focus, textarea:focus { 
    outline: none; border-color: var(--accent-color); 
    background-color: #1f2023;
}

.submit-btn, button.submit-btn, a.submit-btn { 
    display: inline-flex; align-items: center; justify-content: center; gap: 10px;
    height: 48px; padding: 0 28px; background: linear-gradient(135deg, var(--accent-color), #22c55e); 
    color: #050505; border: none; border-radius: 10px; 
    font-size: 0.9rem; font-weight: 700; cursor: pointer; transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1); 
    text-decoration: none; outline: none; letter-spacing: -0.2px;
}
.submit-btn:hover, button.submit-btn:hover, a.submit-btn:hover { 
    filter: brightness(1.1); transform: translateY(-1px); 
    box-shadow: 0 4px 12px rgba(0,0,0,0.1); 
}

/* Button Variants */
.btn-danger { 
    background: linear-gradient(135deg, #f87171, #ef4444) !important; 
    color: white !important; 
}
.btn-danger:hover { 
    filter: brightness(1.1) !important; 
    box-shadow: 0 4px 12px rgba(0,0,0,0.1) !important; 
}
.btn-full { width: 100%; }
.btn-small { height: 38px; padding: 0 16px; font-size: 0.8rem; }

/* Premium Custom Select */
.select-wrapper { position: relative; width: 100%; }
.select-wrapper select { 
    appearance: none; -webkit-appearance: none; cursor: pointer; 
    padding-right: 44px !important; z-index: 2; position: relative;
    background-image: none !important;
}
.select-wrapper .select-arrow {
    position: absolute; right: 18px; top: 50%; transform: translateY(-50%);
    width: 16px; height: 16px; pointer-events: none; opacity: 0.4;
    color: var(--text-primary); z-index: 3; transition: 0.2s;
}
.select-wrapper:focus-within .select-arrow { opacity: 1; color: var(--accent-color); transform: translateY(-50%) rotate(180deg); }

/* Global Custom Select Enhancements */
select option { background: var(--card-bg); color: var(--text-primary); padding: 12px; }

/* Toast */
.toast {
    position: fixed; bottom: 32px; right: 32px; padding: 18px 32px; border-radius: 10px;
    background: var(--card-bg); border: 1px solid var(--border-color); border-left: 4px solid var(--accent-color);
    display: none; z-index: 100; font-size: 0.9rem; font-weight: 600;
}

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

/* Dashboard Improvements */
.history-row {
    display: grid; grid-template-columns: auto 1fr auto; align-items: center; gap: 20px;
    padding: 20px; background: var(--input-bg); border: 1px solid var(--border-color); border-radius: 12px;
    margin-bottom: 12px;
}
.history-skin { width: 44px; height: 44px; border-radius: 8px; border: 1px solid var(--border-color); }

/* Dropdown Submenu */
.nav-item-dropdown { overflow: hidden; }
.dropdown-content { 
    display: none; padding-left: 32px; flex-direction: column; gap: 4px; margin-top: 4px;
}
.nav-item-dropdown.open .dropdown-content { display: flex; }
.nav-item-dropdown.open .dropdown-arrow { transform: rotate(180deg); }
.dropdown-item {
    padding: 10px 16px; font-size: 0.85rem; color: var(--text-secondary);
    text-decoration: none; border-radius: 8px; transition: 0.2s;
}
.dropdown-item:hover { color: var(--accent-color); background: var(--accent-glow); }
.dropdown-item.active { color: var(--accent-color); font-weight: 700; }
.dropdown-arrow { width: 14px !important; margin-left: auto; transition: 0.3s; }

/* Handbook */
.handbook-viewer iframe { width: 100%; height: 100%; border: none; filter: invert(0); }

/* Custom PDF Viewer Theme */
.handbook-container {
    background: var(--card-bg);
    border: 1px solid var(--border-color);
    border-radius: 24px;
    overflow: hidden;
    display: flex;
    flex-direction: column;
    height: calc(100vh - 250px);
    box-shadow: 0 20px 50px rgba(0,0,0,0.5);
}
.handbook-toolbar {
    padding: 12px 32px;
    background: rgba(0,0,0,0.4);
    backdrop-filter: blur(10px);
    border-bottom: 1px solid var(--border-color);
    display: flex;
    justify-content: space-between;
    align-items: center;
    z-index: 10;
}
.handbook-content {
    flex: 1;
    background: #1a1a1a;
}

/* Light Mode Overrides */
/* Light Mode Variables */
body.light-mode {
    --bg-color: #f8fafc;
    --sidebar-bg: #ffffff;
    --card-bg: #ffffff;
    --accent-color: #16a34a;
    --accent-glow: rgba(22, 163, 74, 0.1);
    --text-primary: #1e293b;
    --text-secondary: #64748b;
    --input-bg: #f1f5f9;
    --border-color: #e2e8f0;
}

body.light-mode { background-color: var(--bg-color); color: var(--text-primary); }
body.light-mode .sidebar { background-color: var(--sidebar-bg); }
body.light-mode .top-bar { background-color: var(--sidebar-bg); }
/* --- LIGHT MODE OVERRIDES --- */
body.light-mode { 
    background-color: #f1f5f9 !important; 
    color: #1e293b !important; 
    --text-primary: #1e293b;
    --text-secondary: #64748b;
    --border-color: #e2e8f0;
    --card-bg: #ffffff;
    --input-bg: #f8fafc;
    --sidebar-bg: #ffffff;
}

body.light-mode .sidebar { 
    background-color: #ffffff !important; 
    border-right: 1px solid #e2e8f0 !important;
}

body.light-mode .sidebar .nav-item { color: #475569 !important; }
body.light-mode .sidebar .nav-item.active { background: var(--accent-glow) !important; color: var(--accent-color) !important; }
body.light-mode .sidebar .nav-item:hover:not(.active) { background: #f1f5f9 !important; }
body.light-mode .sidebar .nav-label { color: #94a3b8 !important; }

body.light-mode .top-bar { 
    background-color: rgba(255, 255, 255, 0.8) !important; 
    border-bottom: 1px solid #e2e8f0 !important;
}

body.light-mode .form-container, 
body.light-mode .app-card, 
body.light-mode .submission-card,
body.light-mode .user-manage-card { 
    background-color: #ffffff !important; 
    border: 1px solid #e2e8f0 !important;
    box-shadow: 0 4px 6px -1px rgba(0,0,0,0.05), 0 2px 4px -1px rgba(0,0,0,0.03) !important;
}

body.light-mode input, 
body.light-mode select, 
body.light-mode textarea { 
    background-color: #f8fafc !important; 
    color: #1e293b !important; 
    border: 1px solid #e2e8f0 !important;
}

body.light-mode .modal-content { 
    background-color: #ffffff !important; 
    color: #1e293b !important;
    border: 1px solid #e2e8f0 !important;
    box-shadow: 0 25px 50px -12px rgba(0,0,0,0.15) !important;
}

body.light-mode .user-pill { background: #f8fafc !important; border-color: #e2e8f0 !important; }
body.light-mode .help-card { background: #f8fafc !important; border-color: #e2e8f0 !important; }
body.light-mode .app-card-icon { background: #f1f5f9 !important; border-color: #e2e8f0 !important; }
body.light-mode .theme-toggle { background: #f8fafc !important; border-color: #e2e8f0 !important; }
body.light-mode .markdown-body { color: #334155 !important; }
body.light-mode .section-title { color: #1e293b !important; }

/* Form Builder Draggable Styles */
.field-row.ghost { opacity: 0.4; background: var(--accent-glow); border: 2px dashed var(--accent-color); }
.drag-handle { cursor: grab; color: var(--text-secondary); opacity: 0.4; transition: 0.2s; padding: 4px; }
.drag-handle:hover { opacity: 1; color: var(--accent-color); }
.drag-handle:active { cursor: grabbing; }

.custom-checkbox {
    display: flex; align-items: center; gap: 12px; cursor: pointer; user-select: none;
    padding: 14px 18px; background: var(--input-bg); border: 1px solid var(--border-color);
    border-radius: 12px; transition: 0.2s;
}
.custom-checkbox:hover { border-color: var(--accent-color); background: rgba(74, 222, 128, 0.05); }
.custom-checkbox input { display: none; }
.checkmark {
    width: 22px; height: 22px; border: 2px solid var(--border-color); border-radius: 6px;
    display: flex; align-items: center; justify-content: center; transition: 0.2s;
    background: var(--card-bg); position: relative;
}
.custom-checkbox input:checked + .checkmark { background: var(--accent-color); border-color: var(--accent-color); box-shadow: 0 0 15px var(--accent-glow); }
.checkmark i, .checkmark svg { color: #000; width: 14px; height: 14px; display: none; stroke-width: 3; }
.custom-checkbox input:checked + .checkmark i, .custom-checkbox input:checked + .checkmark svg { display: block; }

/* --- MOBILE RESPONSIVENESS --- */
@media (max-width: 1024px) {
    .sidebar { width: 80px; padding: 32px 10px; }
    .brand-name, .nav-label, .nav-item span, .user-pill-info { display: none; }
    .nav-item { justify-content: center; padding: 16px; }
    .main-wrapper { margin-left: 80px; }
    .top-bar, .content-area { padding: 0 24px; }
}

@media (max-width: 768px) {
    .app-layout { flex-direction: column; }
    .sidebar { 
        width: 100%; height: auto; position: relative; padding: 16px; 
        flex-direction: row; justify-content: space-between; align-items: center;
        border-right: none; border-bottom: 1px solid var(--border-color);
    }
    .brand { margin-bottom: 0; }
    .nav-section { display: none; } /* Hide main nav on mobile, could use hamburger */
    .main-wrapper { margin-left: 0; }
    .content-area { padding: 32px 20px; }
    .view-header { flex-direction: column; align-items: flex-start !important; gap: 20px; }
    
    .submissions-grid, .apps-grid { grid-template-columns: 1fr; }
    .submission-card { grid-template-columns: 1fr !important; }
    .submission-card > a > div { border-right: none !important; border-bottom: 1px solid var(--border-color); }
    
    .form-container { padding: 24px; }
    .user-profile-grid { grid-template-columns: 1fr !important; }
}

/* Custom PDF Viewer Enhancements */
.handbook-container {
    height: 85vh;
    min-height: 600px;
}
.handbook-content iframe {
    background: #1a1a1a;
}

/* UI Switch Styles */
.ui-switch {
    position: relative;
    display: inline-block;
    width: 48px;
    height: 24px;
}
.ui-switch input { opacity: 0; width: 0; height: 0; }
.ui-slider {
    position: absolute; cursor: pointer;
    top: 0; left: 0; right: 0; bottom: 0;
    background-color: var(--input-bg);
    border: 1px solid var(--border-color);
    transition: .3s; border-radius: 34px;
}
.ui-slider:before {
    position: absolute; content: "";
    height: 16px; width: 16px; left: 4px; bottom: 3px;
    background-color: var(--text-secondary);
    transition: .3s; border-radius: 50%;
}
input:checked + .ui-slider { background-color: var(--accent-glow); border-color: var(--accent-color); }
input:checked + .ui-slider:before { transform: translateX(22px); background-color: var(--accent-color); }
/* Modals & Overlays */
.modal-overlay {
    position: fixed;
    top: 0; left: 0;
    width: 100vw;
    height: 100vh;
    background: rgba(0, 0, 0, 0.85);
    backdrop-filter: blur(12px);
    display: none;
    align-items: center;
    justify-content: center;
    z-index: 10000;
}
.modal-content {
    background: #0a0a0a;
    border: 1px solid rgba(255, 255, 255, 0.05);
    border-radius: 32px;
    padding: 48px;
    max-width: 700px;
    width: 90%;
    max-height: 90vh;
    overflow-y: auto;
    position: relative;
    box-shadow: 0 40px 100px rgba(0, 0, 0, 0.8);
    animation: modalSlideUp 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}
@keyframes modalSlideUp {
    from { opacity: 0; transform: translateY(20px) scale(0.95); }
    to { opacity: 1; transform: translateY(0) scale(1); }
}
