/* =========================================
   MODERN UI V3 - Clean & Professional
   Color Scheme: Gold/Black
   ========================================= */

:root {
    --primary: #FFB703;
    --primary-light: #FFCC33;
    --primary-dark: #CC9200;
    --primary-glow: rgba(255, 183, 3, 0.3);
    
    --bg-dark: #0a0a0a;
    --bg-darker: #050505;
    --bg-card: #111111;
    --bg-input: #0d0d0d;
    
    --surface: #161616;
    --surface-hover: #1c1c1c;
    --border: rgba(255, 255, 255, 0.08);
    --border-light: rgba(255, 255, 255, 0.12);
    
    --text-primary: #ffffff;
    --text-secondary: #b0b0b0;
    --text-muted: #666666;
    
    --success: #22c55e;
    --warning: #f59e0b;
    --danger: #ef4444;
    --info: #3b82f6;
    
    --radius-sm: 8px;
    --radius-md: 12px;
    --radius-lg: 16px;
    --radius-xl: 24px;
    
    --shadow-sm: 0 2px 8px rgba(0,0,0,0.3);
    --shadow-md: 0 8px 24px rgba(0,0,0,0.4);
    --shadow-lg: 0 16px 48px rgba(0,0,0,0.5);
    --shadow-glow: 0 0 30px var(--primary-glow);
    
    --font: 'Poppins', -apple-system, BlinkMacSystemFont, sans-serif;
    --transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    -webkit-tap-highlight-color: transparent;
}

html, body {
    height: 100%;
    /* iOS PWA fixes */
    -webkit-overflow-scrolling: touch;
    overscroll-behavior: none;
}

html {
    /* iOS safe area support */
    padding: env(safe-area-inset-top) env(safe-area-inset-right) env(safe-area-inset-bottom) env(safe-area-inset-left);
}

body {
    font-family: var(--font);
    background: var(--bg-darker);
    color: var(--text-primary);
    line-height: 1.6;
    overflow-x: hidden;
    /* Prevent text size adjustment on orientation change */
    -webkit-text-size-adjust: 100%;
    text-size-adjust: 100%;
    /* Smooth scrolling */
    scroll-behavior: smooth;
    /* PWA standalone mode fixes */
    min-height: 100vh;
    min-height: -webkit-fill-available;
}

/* PWA standalone mode adjustments */
@supports (padding: env(safe-area-inset-top)) {
    body {
        padding-top: env(safe-area-inset-top);
        padding-bottom: env(safe-area-inset-bottom);
    }
}

/* Prevent rubber-banding / overscroll */
html, body {
    position: fixed;
    width: 100%;
    height: 100%;
    overflow: hidden;
}

#login-screen,
#dashboard,
.app-body {
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
    height: 100%;
}

/* Scrollbar */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: var(--bg-dark); }
::-webkit-scrollbar-thumb { background: var(--surface); border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: var(--primary); }

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

/* =========================================
   LOADER
   ========================================= */
#loader-wrapper {
    position: fixed;
    inset: 0;
    background: var(--bg-darker);
    z-index: 10000;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 30px;
}

.loader-logo-container img {
    width: 80px;
    animation: pulse 2s ease-in-out infinite;
}

.loader-progress-track {
    width: 180px;
    height: 3px;
    background: var(--surface);
    border-radius: 10px;
    overflow: hidden;
}

.loader-progress-bar {
    height: 100%;
    background: var(--primary);
    animation: loading 1.5s ease-in-out infinite;
}

@keyframes pulse {
    0%, 100% { transform: scale(1); opacity: 0.8; }
    50% { transform: scale(1.05); opacity: 1; filter: drop-shadow(0 0 20px var(--primary)); }
}

@keyframes loading {
    0% { width: 0; }
    50% { width: 100%; }
    100% { width: 0; margin-left: 100%; }
}

/* =========================================
   LOGIN SCREEN - Split Design
   ========================================= */
#login-screen {
    position: fixed;
    inset: 0;
    background: #0a0a0a;
    z-index: 100;
}

.login-wrapper {
    width: 100%;
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    position: relative;
    overflow: hidden;
}

.login-bg-image {
    position: absolute;
    inset: 0;
    background: url('assets/web_bg.jpg') no-repeat center right;
    background-size: cover;
    opacity: 0.9;
}

.login-card-split {
    position: relative;
    z-index: 2;
    display: flex;
    width: 100%;
    max-width: 900px;
    min-height: 450px;
    background: rgba(20, 20, 20, 0.95);
    border-radius: var(--radius-lg);
    overflow: hidden;
    box-shadow: 0 25px 80px rgba(0, 0, 0, 0.6);
}

.login-left {
    flex: 1;
    padding: 60px 50px;
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    justify-content: center;
    background: linear-gradient(135deg, #1a1a1a 0%, #0d0d0d 100%);
    border-right: 1px solid rgba(255, 255, 255, 0.05);
}

.login-logo-large {
    width: 110px;
    margin-top: 20px;
    margin-bottom: 35px;
}

.login-brand {
    display: flex;
    flex-direction: column;
    line-height: 1;
    margin-bottom: 20px;
}

.brand-ops {
    font-size: 4rem;
    font-weight: 800;
    color: var(--primary);
    letter-spacing: -2px;
}

.brand-workspace {
    font-size: 2.5rem;
    font-weight: 300;
    color: #ffffff;
    letter-spacing: 8px;
    margin-top: 5px;
}

.login-tagline {
    color: var(--text-muted);
    font-size: 0.9rem;
    line-height: 1.6;
}

.login-right {
    flex: 1;
    padding: 60px 50px;
    display: flex;
    flex-direction: column;
    justify-content: center;
}

.auth-title {
    font-size: 1.1rem;
    font-weight: 700;
    letter-spacing: 3px;
    margin-bottom: 50px;
    color: var(--text-primary);
}

.auth-form {
    display: flex;
    flex-direction: column;
    gap: 25px;
}

.auth-input-group {
    position: relative;
}

.auth-input-group input {
    width: 100%;
    background: transparent;
    border: none;
    border-bottom: 1px solid rgba(255, 255, 255, 0.2);
    padding: 15px 0;
    padding-right: 40px;
    color: var(--text-primary);
    font-size: 1rem;
    font-family: var(--font);
    transition: var(--transition);
}

.auth-input-group input:focus {
    outline: none;
    border-bottom-color: var(--primary);
}

.auth-input-group input::placeholder {
    color: var(--text-muted);
}

/* ===== FEATURE 2: PASSWORD TOGGLE STYLES ===== */
.password-input-wrapper {
    position: relative;
    display: flex;
    align-items: center;
}

.password-toggle {
    position: absolute;
    right: 10px;
    top: 50%;
    transform: translateY(-50%);
    background: transparent;
    border: none;
    cursor: pointer;
    padding: 5px;
    opacity: 0.6;
    transition: var(--transition);
    z-index: 2;
}

.password-toggle:hover {
    opacity: 1;
}

.eye-icon {
    font-size: 1.1rem;
}

.password-input-wrapper.full-width {
    width: 100%;
}

.password-input-wrapper.full-width input {
    padding-right: 45px;
}

.password-input-wrapper.form-input-wrapper {
    width: 100%;
}

.password-input-wrapper.form-input-wrapper input {
    width: 100%;
    padding-right: 45px;
}

.btn-enter {
    width: 100%;
    background: var(--primary);
    border: none;
    border-radius: 4px;
    padding: 18px 24px;
    color: #000;
    font-weight: 700;
    font-size: 0.9rem;
    font-family: var(--font);
    letter-spacing: 2px;
    cursor: pointer;
    transition: var(--transition);
    margin-top: 20px;
    position: relative;
    overflow: hidden;
}

.btn-enter:hover {
    background: var(--primary-light);
    transform: translateY(-2px);
    box-shadow: 0 10px 30px rgba(255, 183, 3, 0.3);
}

.btn-enter:disabled {
    opacity: 0.7;
    cursor: not-allowed;
    transform: none;
}

/* ===== FEATURE 8: CYBERPUNK SCANNER LOADING ===== */
.btn-enter.processing,
.btn-primary.processing,
.btn-glow.processing {
    pointer-events: none;
    position: relative;
}

.cyberpunk-scanner {
    position: absolute;
    bottom: 0;
    left: 0;
    width: 100%;
    height: 3px;
    background: linear-gradient(90deg, 
        transparent 0%, 
        rgba(255, 255, 255, 0.8) 50%, 
        transparent 100%
    );
    animation: cyberpunk-scan 1.5s ease-in-out infinite;
}

@keyframes cyberpunk-scan {
    0% { transform: translateX(-100%); }
    100% { transform: translateX(100%); }
}

.btn-loading-text {
    animation: pulse-text 1s ease-in-out infinite;
}

@keyframes pulse-text {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.5; }
}

/* Mobile Responsive */
@media (max-width: 768px) {
    .login-card-split {
        flex-direction: column;
        max-width: 400px;
        margin: 20px;
    }
    
    .login-left {
        padding: 40px 30px;
        align-items: center;
        text-align: center;
        border-right: none;
        border-bottom: 1px solid rgba(255, 255, 255, 0.05);
    }
    
    .brand-ops {
        font-size: 3rem;
    }
    
    .brand-workspace {
        font-size: 1.8rem;
        letter-spacing: 5px;
    }
    
    .login-right {
        padding: 40px 30px;
    }
    
    .auth-title {
        text-align: center;
        margin-bottom: 30px;
    }
}

/* =========================================
   DASHBOARD LAYOUT
   ========================================= */
.app-container {
    display: flex;
    flex-direction: column;
    min-height: 100vh;
}

/* Header */
.app-header {
    height: 70px;
    background: var(--bg-card);
    border-bottom: 1px solid var(--border);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 30px;
    position: sticky;
    top: 0;
    z-index: 100;
}

.header-left {
    display: flex;
    align-items: center;
    gap: 15px;
}

.header-logo {
    width: 40px;
}

.header-title {
    font-weight: 700;
    font-size: 1.1rem;
    color: var(--primary);
}

.header-center {
    flex: 1;
    max-width: 400px;
    margin: 0 40px;
}

.search-box {
    position: relative;
    width: 100%;
}

.search-box .search-icon {
    position: absolute;
    left: 15px;
    top: 50%;
    transform: translateY(-50%);
    opacity: 0.5;
}

.search-box input {
    width: 100%;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    padding: 12px 15px 12px 45px;
    color: var(--text-primary);
    font-family: var(--font);
    transition: var(--transition);
}

.search-box input:focus {
    outline: none;
    border-color: var(--primary);
}

.search-box input::placeholder {
    color: var(--text-muted);
}

.header-right {
    display: flex;
    align-items: center;
    gap: 15px;
}

.icon-btn {
    width: 42px;
    height: 42px;
    border-radius: var(--radius-md);
    background: var(--surface);
    border: 1px solid var(--border);
    color: var(--text-secondary);
    font-size: 1.2rem;
    cursor: pointer;
    transition: var(--transition);
    display: flex;
    align-items: center;
    justify-content: center;
}

.icon-btn:hover {
    background: var(--primary);
    color: #000;
    border-color: var(--primary);
}

.icon-btn.spin span {
    animation: spin 1s linear infinite;
}

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

.logout-btn:hover {
    background: var(--danger);
    border-color: var(--danger);
    color: #fff;
}

.user-dropdown {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 8px 15px;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
}

.user-avatar {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    background: var(--primary);
    color: #000;
    font-weight: 700;
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
}

.user-avatar img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.user-name-header {
    font-weight: 500;
    font-size: 0.9rem;
}

/* App Body */
.app-body {
    display: flex;
    flex: 1;
}

/* Sidebar */
.app-sidebar {
    width: 220px;
    background: var(--bg-card);
    border-right: 1px solid var(--border);
    padding: 25px 15px;
    flex-shrink: 0;
}

.sidebar-nav {
    list-style: none;
}

.sidebar-nav li {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 14px 18px;
    border-radius: var(--radius-md);
    color: var(--text-secondary);
    cursor: pointer;
    transition: var(--transition);
    margin-bottom: 8px;
}

.sidebar-nav li:hover {
    background: var(--surface);
    color: var(--text-primary);
}

.sidebar-nav li.active {
    background: var(--primary);
    color: #000;
    font-weight: 600;
}

.nav-icon {
    font-size: 1.2rem;
}

/* Main Content */
.app-main {
    flex: 1;
    padding: 30px;
    overflow-y: auto;
    background: var(--bg-darker);
}

/* Cards */
.card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    margin-bottom: 25px;
    overflow: hidden;
}

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

.card-header h3 {
    font-size: 1rem;
    font-weight: 600;
    display: flex;
    align-items: center;
    gap: 10px;
}

.card-body {
    padding: 25px;
}

.accent-card {
    border-left: 3px solid var(--primary);
}

/* Tab Group */
.tab-group {
    display: flex;
    gap: 5px;
    background: var(--surface);
    padding: 4px;
    border-radius: var(--radius-sm);
    flex-wrap: wrap;
}

.tab-btn {
    padding: 8px 16px;
    border: none;
    background: transparent;
    color: var(--text-secondary);
    font-family: var(--font);
    font-size: 0.85rem;
    font-weight: 500;
    border-radius: 6px;
    cursor: pointer;
    transition: var(--transition);
}

.tab-btn:hover {
    color: var(--text-primary);
}

.tab-btn.active {
    background: var(--primary);
    color: #000;
}

/* Form Elements */
.form-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 15px;
    margin-bottom: 15px;
}

.form-row.three-col {
    grid-template-columns: 1fr 1fr 1fr;
}

.form-group {
    margin-bottom: 0;
}

.form-group label {
    display: block;
    font-size: 0.8rem;
    color: var(--text-muted);
    margin-bottom: 8px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.form-input {
    width: 100%;
    background: var(--bg-input);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    padding: 14px 16px;
    color: var(--text-primary);
    font-family: var(--font);
    font-size: 0.95rem;
    transition: var(--transition);
}

.form-input:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px var(--primary-glow);
}

.form-input::placeholder {
    color: var(--text-muted);
}

.form-input.textarea {
    min-height: 100px;
    resize: vertical;
}

/* ===== FEATURE 4: MULTI-SELECT DROPDOWN ===== */
.multi-select-container {
    position: relative;
    width: 100%;
}

.multi-select-trigger {
    display: flex;
    align-items: center;
    justify-content: space-between;
    background: var(--bg-input);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    padding: 14px 16px;
    color: var(--text-primary);
    cursor: pointer;
    transition: var(--transition);
}

.multi-select-trigger:hover {
    border-color: var(--primary);
}

.multi-select-trigger .placeholder {
    color: var(--text-muted);
}

.dropdown-arrow {
    font-size: 0.7rem;
    color: var(--text-muted);
    transition: var(--transition);
}

.multi-select-dropdown {
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    margin-top: 5px;
    z-index: 100;
    box-shadow: var(--shadow-md);
    max-height: 300px;
    overflow: hidden;
    display: flex;
    flex-direction: column;
}

.multi-select-search {
    padding: 10px;
    border-bottom: 1px solid var(--border);
}

.multi-select-search input {
    width: 100%;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    padding: 10px 12px;
    color: var(--text-primary);
    font-family: var(--font);
    font-size: 0.9rem;
}

.multi-select-search input:focus {
    outline: none;
    border-color: var(--primary);
}

.multi-select-options {
    flex: 1;
    overflow-y: auto;
    padding: 5px;
}

.multi-select-option {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 15px;
    border-radius: var(--radius-sm);
    cursor: pointer;
    transition: var(--transition);
}

.multi-select-option:hover {
    background: var(--surface);
}

.multi-select-option input[type="checkbox"] {
    width: 18px;
    height: 18px;
    accent-color: var(--primary);
    cursor: pointer;
}

.multi-select-option .option-name {
    flex: 1;
    font-weight: 500;
}

.multi-select-option .option-role {
    font-size: 0.75rem;
    color: var(--text-muted);
    padding: 3px 8px;
    background: var(--surface);
    border-radius: 4px;
}

/* Rich Text Editor */
.editor-container {
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    background: var(--bg-input);
    overflow: hidden;
    margin-bottom: 15px;
}

.editor-toolbar {
    display: flex;
    gap: 4px;
    padding: 8px 12px;
    background: var(--surface);
    border-bottom: 1px solid var(--border);
    flex-wrap: wrap;
}

.editor-toolbar button {
    background: transparent;
    border: 1px solid var(--border);
    border-radius: 4px;
    padding: 6px 12px;
    color: var(--text-secondary);
    font-family: var(--font);
    font-size: 0.8rem;
    cursor: pointer;
    transition: var(--transition);
}

.editor-toolbar button:hover {
    background: var(--primary);
    color: #000;
    border-color: var(--primary);
}

.toolbar-divider {
    width: 1px;
    background: var(--border);
    margin: 0 8px;
}

.editor-content {
    min-height: 120px;
    max-height: 400px;
    overflow-y: auto;
    padding: 15px;
    color: var(--text-primary);
    font-family: var(--font);
    font-size: 0.95rem;
    line-height: 1.6;
    outline: none;
}

.editor-content:empty:before {
    content: attr(data-placeholder);
    color: var(--text-muted);
    pointer-events: none;
}

.editor-content:focus {
    box-shadow: inset 0 0 0 2px var(--primary-glow);
}

.editor-content ul,
.editor-content ol {
    margin-left: 20px;
    margin-bottom: 10px;
}

.editor-content li {
    margin-bottom: 5px;
}

.form-input:disabled {
    opacity: 0.6;
    cursor: not-allowed;
}

select.form-input {
    appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' fill='%23666' viewBox='0 0 16 16'%3E%3Cpath d='M8 11L3 6h10z'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 16px center;
    padding-right: 40px;
}

.btn-primary {
    background: var(--primary);
    border: none;
    border-radius: var(--radius-sm);
    padding: 14px 24px;
    color: #000;
    font-family: var(--font);
    font-weight: 600;
    font-size: 0.9rem;
    cursor: pointer;
    transition: var(--transition);
    position: relative;
    overflow: hidden;
}

.btn-primary:hover {
    background: var(--primary-light);
    transform: translateY(-1px);
    box-shadow: var(--shadow-glow);
}

.btn-primary:disabled {
    opacity: 0.7;
    cursor: not-allowed;
    transform: none;
}

.btn-full {
    width: 100%;
    margin-top: 20px;
}

/* Dashboard Grid */
.dashboard-grid {
    display: grid;
    grid-template-columns: 2fr 1fr;
    gap: 25px;
}

.tasks-card, .leaderboard-card {
    height: calc(100vh - 280px);
    min-height: 400px;
    display: flex;
    flex-direction: column;
}

.tasks-card .card-body,
.leaderboard-card .card-body {
    flex: 1;
    overflow: hidden;
    padding: 0;
}

.task-list, .leaderboard-list {
    height: 100%;
    overflow-y: auto;
    padding: 20px;
}

/* Task Items */
.task-item {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    padding: 20px;
    margin-bottom: 15px;
    transition: var(--transition);
    position: relative;
}

.task-item:hover {
    border-color: var(--primary);
    transform: translateY(-2px);
    box-shadow: var(--shadow-sm);
}

/* FEATURE 1: Just Updated Animation */
.task-item.just-updated {
    animation: pulse-border 2s ease-out;
}

@keyframes pulse-border {
    0% { border-color: var(--primary); box-shadow: 0 0 20px var(--primary-glow); }
    100% { border-color: var(--border); box-shadow: none; }
}

.task-item .task-header {
    display: flex;
    justify-content: space-between;
    font-size: 0.75rem;
    color: var(--text-muted);
    margin-bottom: 10px;
}

.task-item h4 {
    font-size: 1rem;
    margin-bottom: 8px;
}

.task-item .task-desc {
    color: var(--text-secondary);
    font-size: 0.9rem;
    margin-bottom: 15px;
    line-height: 1.6;
    white-space: pre-wrap;
    word-wrap: break-word;
}

.task-item .task-desc ul,
.task-item .task-desc ol {
    margin-left: 20px;
    margin-top: 8px;
    margin-bottom: 8px;
}

.task-item .task-desc li {
    margin-bottom: 4px;
}

.task-item .task-desc b,
.task-item .task-desc strong {
    color: var(--text-primary);
    font-weight: 600;
}

.task-item .task-desc i,
.task-item .task-desc em {
    font-style: italic;
}

.task-item .task-desc u {
    text-decoration: underline;
}

.task-item .task-footer {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.status-badge {
    padding: 5px 12px;
    border-radius: 20px;
    font-size: 0.7rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    display: inline-flex;
    align-items: center;
    gap: 6px;
}

/* FEATURE 1: Status Pulse Indicator */
.status-pulse {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: currentColor;
    animation: status-pulse 2s ease-in-out infinite;
}

@keyframes status-pulse {
    0%, 100% { opacity: 1; transform: scale(1); }
    50% { opacity: 0.5; transform: scale(0.8); }
}

.status-Pending { background: rgba(245, 158, 11, 0.15); color: var(--warning); }
.status-Submitted { background: rgba(59, 130, 246, 0.15); color: var(--info); }
.status-Approved { background: rgba(34, 197, 94, 0.15); color: var(--success); }
.status-Changes { background: rgba(239, 68, 68, 0.15); color: var(--danger); }

.points-badge {
    color: var(--primary);
    font-weight: 700;
    font-size: 0.9rem;
}

/* Submit Work Button */
.btn-submit-work {
    width: 100%;
    margin-top: 15px;
    padding: 12px;
    background: transparent;
    border: 1px dashed var(--primary);
    border-radius: var(--radius-sm);
    color: var(--primary);
    font-family: var(--font);
    font-weight: 600;
    font-size: 0.85rem;
    cursor: pointer;
    transition: var(--transition);
}

.btn-submit-work:hover {
    background: var(--primary);
    color: #000;
    border-style: solid;
}

/* Task Feedback & Submission */
.task-feedback {
    background: rgba(239, 68, 68, 0.1);
    border-left: 3px solid var(--danger);
    padding: 12px 15px;
    margin-bottom: 15px;
    border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
    font-size: 0.85rem;
    color: var(--text-secondary);
}

.task-submission {
    margin-bottom: 15px;
}

.task-submission a {
    color: var(--primary);
    text-decoration: none;
    font-size: 0.85rem;
}

.task-submission a:hover {
    text-decoration: underline;
}

/* Review List */
.review-list {
    max-height: 400px;
    overflow-y: auto;
}

.review-item {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    padding: 20px;
    margin-bottom: 15px;
}

.review-item-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 10px;
}

.submission-link {
    color: var(--info);
    text-decoration: none;
    font-size: 0.85rem;
}

.submission-link:hover {
    text-decoration: underline;
}

.btn-review {
    background: var(--primary);
    border: none;
    border-radius: var(--radius-sm);
    padding: 8px 20px;
    color: #000;
    font-family: var(--font);
    font-weight: 600;
    font-size: 0.85rem;
    cursor: pointer;
    transition: var(--transition);
}

.btn-review:hover {
    background: var(--primary-light);
}

/* Leaderboard */
.leader-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 15px;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    margin-bottom: 10px;
    transition: var(--transition);
}

.leader-row:hover {
    border-color: var(--primary-glow);
}

.leader-info {
    display: flex;
    align-items: center;
    gap: 15px;
}

.rank {
    width: 35px;
    height: 35px;
    border-radius: 50%;
    background: var(--bg-card);
    border: 1px solid var(--border);
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    font-size: 0.9rem;
    color: var(--text-muted);
}

.rank-1 {
    background: var(--primary);
    border-color: var(--primary);
    color: #000;
}

.leader-name {
    font-weight: 600;
    font-size: 0.95rem;
}

.leader-role {
    font-size: 0.75rem;
    color: var(--text-muted);
}

.leader-points {
    font-weight: 800;
    font-size: 1.1rem;
    color: var(--primary);
}

/* Team List */
.team-list {
    max-height: 300px;
    overflow-y: auto;
}

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

.team-row:last-child {
    border-bottom: none;
}

/* ===== FEATURE 5: TEAM TREE VIEW ===== */
.team-tree {
    padding: 20px;
    overflow-x: auto;
}

.tree-container {
    display: flex;
    flex-direction: column;
    align-items: center;
    min-width: 600px;
    padding: 20px 0;
}

.tree-level {
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 20px 0;
}

.level-label {
    font-size: 0.8rem;
    text-transform: uppercase;
    letter-spacing: 2px;
    color: var(--primary);
    margin-bottom: 20px;
    font-weight: 600;
    background: rgba(255, 183, 3, 0.1);
    padding: 8px 20px;
    border-radius: 20px;
}

.tree-nodes {
    display: flex;
    justify-content: center;
    gap: 30px;
    flex-wrap: wrap;
}

.tree-nodes.members-grid {
    max-width: 800px;
}

.tree-connector {
    width: 2px;
    height: 40px;
    background: linear-gradient(to bottom, var(--primary), var(--primary-glow));
    position: relative;
}

.tree-connector::before,
.tree-connector::after {
    content: '';
    position: absolute;
    left: 50%;
    transform: translateX(-50%);
    width: 10px;
    height: 10px;
    background: var(--primary);
    border-radius: 50%;
}

.tree-connector::before {
    top: -5px;
}

.tree-connector::after {
    bottom: -5px;
}

.tree-node {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    padding: 20px;
    min-width: 180px;
    text-align: center;
    transition: var(--transition);
    position: relative;
}

.tree-node:hover {
    border-color: var(--primary);
    transform: translateY(-5px);
    box-shadow: 0 10px 30px rgba(255, 183, 3, 0.2);
}

.tree-node.superadmin {
    border-color: var(--primary);
    background: linear-gradient(135deg, rgba(255, 183, 3, 0.1) 0%, var(--surface) 100%);
}

.tree-node.superadmin::before {
    content: '👑';
    position: absolute;
    top: -10px;
    left: 50%;
    transform: translateX(-50%);
    font-size: 1.2rem;
}

.tree-node.admin {
    border-color: var(--info);
}

.tree-node.empty {
    opacity: 0.5;
    border-style: dashed;
}

.node-avatar {
    width: 60px;
    height: 60px;
    border-radius: 50%;
    background: var(--primary);
    color: #000;
    font-weight: 700;
    font-size: 1.5rem;
    display: flex;
    align-items: center;
    justify-content: center;
    margin: 0 auto 15px;
    overflow: hidden;
}

.node-avatar img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.node-info {
    display: flex;
    flex-direction: column;
    gap: 5px;
}

.node-name {
    font-weight: 600;
    font-size: 0.95rem;
    color: var(--text-primary);
}

.node-role {
    font-size: 0.8rem;
    color: var(--primary);
}

.node-dept {
    font-size: 0.75rem;
    color: var(--text-muted);
}

/* ===== FEATURE 7: ACTIVITY OPS TABLE ===== */
.activity-stats {
    display: flex;
    gap: 15px;
}

.stats-badge {
    background: var(--surface);
    padding: 8px 16px;
    border-radius: var(--radius-sm);
    font-size: 0.85rem;
    color: var(--primary);
    font-weight: 600;
}

.activity-filters {
    display: flex;
    gap: 15px;
    margin-bottom: 20px;
}

.activity-filters .form-input {
    flex: 1;
}

.activity-filters select.form-input {
    max-width: 200px;
}

.activity-table-container {
    overflow-x: auto;
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
}

.activity-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.9rem;
}

.activity-table thead {
    background: var(--surface);
}

.activity-table th {
    padding: 15px 20px;
    text-align: left;
    font-weight: 600;
    font-size: 0.8rem;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: var(--text-muted);
    border-bottom: 1px solid var(--border);
}

.activity-table td {
    padding: 15px 20px;
    border-bottom: 1px solid var(--border);
    color: var(--text-secondary);
}

.activity-table tbody tr:hover {
    background: var(--surface);
}

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

.activity-table code {
    background: var(--bg-darker);
    padding: 4px 8px;
    border-radius: 4px;
    font-size: 0.8rem;
    color: var(--primary);
}

.action-buttons {
    display: flex;
    gap: 8px;
}

.btn-action {
    width: 35px;
    height: 35px;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    background: var(--bg-card);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: var(--transition);
}

.btn-action.edit:hover {
    background: var(--info);
    border-color: var(--info);
}

.btn-action.delete:hover {
    background: var(--danger);
    border-color: var(--danger);
}

/* Profile Page */
.profile-container {
    max-width: 800px;
    margin: 0 auto;
}

.profile-card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    overflow: hidden;
}

.profile-header-section {
    background: linear-gradient(135deg, var(--surface) 0%, var(--bg-card) 100%);
    padding: 40px;
    display: flex;
    align-items: center;
    gap: 30px;
    border-bottom: 1px solid var(--border);
}

.profile-avatar-wrapper {
    position: relative;
}

.profile-pic-large {
    width: 120px;
    height: 120px;
    border-radius: 50%;
    background: var(--primary);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 3rem;
    font-weight: 700;
    color: #000;
    overflow: hidden;
    border: 4px solid var(--border);
}

.profile-pic-large img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.avatar-edit-btn {
    position: absolute;
    bottom: 5px;
    right: 5px;
    width: 36px;
    height: 36px;
    border-radius: 50%;
    background: var(--primary);
    border: 3px solid var(--bg-card);
    color: #000;
    font-size: 1rem;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: var(--transition);
}

.avatar-edit-btn:hover {
    transform: scale(1.1);
}

.profile-info h2 {
    font-size: 1.5rem;
    margin-bottom: 5px;
}

.profile-info p {
    color: var(--text-muted);
}

.profile-form {
    padding: 40px;
}

.form-section-title {
    color: var(--primary);
    font-size: 0.9rem;
    font-weight: 600;
    margin: 25px 0 15px;
    text-transform: uppercase;
    letter-spacing: 1px;
}

.form-section-title:first-child {
    margin-top: 0;
}

/* Cropper Modal */
.modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.9);
    backdrop-filter: blur(10px);
    z-index: 2000;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
}

.modal-box {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    width: 100%;
    max-width: 600px;
    max-height: 90vh;
    overflow-y: auto;
    padding: 30px;
}

.modal-box h3 {
    margin-bottom: 20px;
}

.modal-actions {
    display: flex;
    justify-content: flex-end;
    gap: 15px;
    margin-top: 20px;
}

.btn-outline {
    background: transparent;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    padding: 12px 24px;
    color: var(--text-secondary);
    font-family: var(--font);
    font-weight: 500;
    cursor: pointer;
    transition: var(--transition);
}

.btn-outline:hover {
    border-color: var(--text-primary);
    color: var(--text-primary);
}

.btn-glow {
    background: var(--primary);
    border: none;
    border-radius: var(--radius-sm);
    padding: 12px 24px;
    color: #000;
    font-family: var(--font);
    font-weight: 600;
    cursor: pointer;
    transition: var(--transition);
    position: relative;
    overflow: hidden;
}

.btn-glow:hover {
    box-shadow: var(--shadow-glow);
}

.btn-glow:disabled {
    opacity: 0.7;
    cursor: not-allowed;
}

/* Toast */
#toast-container {
    position: fixed;
    top: 90px;
    right: 20px;
    z-index: 10000;
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.toast {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    padding: 15px 25px;
    box-shadow: var(--shadow-md);
    animation: slideIn 0.3s ease;
    min-width: 250px;
}

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

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

/* Action Menu */
.action-menu-container { position: relative; }

.menu-btn {
    background: transparent;
    border: none;
    color: var(--text-muted);
    font-size: 1.3rem;
    cursor: pointer;
    padding: 5px 10px;
    border-radius: var(--radius-sm);
}

.menu-btn:hover { background: var(--surface); }

.menu-dropdown {
    position: absolute;
    right: 0;
    top: 100%;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    padding: 8px;
    min-width: 160px;
    box-shadow: var(--shadow-md);
    display: none;
    z-index: 50;
}

.menu-dropdown.show { display: block; }

.menu-item {
    display: block;
    width: 100%;
    padding: 10px 15px;
    background: transparent;
    border: none;
    border-radius: var(--radius-sm);
    color: var(--text-primary);
    font-family: var(--font);
    font-size: 0.9rem;
    text-align: left;
    cursor: pointer;
    transition: var(--transition);
}

.menu-item:hover { background: var(--bg-card); }

/* =========================================
   RESPONSIVE
   ========================================= */
@media (max-width: 1024px) {
    .dashboard-grid {
        grid-template-columns: 1fr;
    }
    
    .tasks-card, .leaderboard-card {
        height: auto;
        min-height: 300px;
    }
    
    .activity-filters {
        flex-direction: column;
    }
    
    .activity-filters select.form-input {
        max-width: 100%;
    }
}

@media (max-width: 768px) {
    .app-sidebar {
        position: fixed;
        bottom: 0;
        left: 0;
        right: 0;
        width: 100%;
        height: 70px;
        border-right: none;
        border-top: 1px solid var(--border);
        padding: 10px;
        z-index: 100;
        background: var(--bg-card);
    }
    
    .sidebar-nav {
        display: flex;
        justify-content: space-around;
    }
    
    .sidebar-nav li {
        flex-direction: column;
        padding: 10px 15px;
        gap: 5px;
        margin: 0;
    }
    
    .nav-text {
        font-size: 0.7rem;
    }
    
    .app-main {
        padding: 20px;
        padding-bottom: 90px;
    }
    
    .app-header {
        padding: 0 15px;
    }
    
    .header-center {
        display: none;
    }
    
    .user-name-header {
        display: none;
    }
    
    .form-row, .form-row.three-col {
        grid-template-columns: 1fr;
    }
    
    .profile-header-section {
        flex-direction: column;
        text-align: center;
    }
    
    .login-card {
        margin: 20px;
        padding: 30px;
    }
    
    .tree-container {
        min-width: auto;
        padding: 10px 0;
    }
    
    .tree-nodes {
        flex-direction: column;
        align-items: center;
        gap: 12px;
    }
    
    /* Mobile Team Tree Styles */
    .team-tree {
        padding: 10px;
    }
    
    .tree-level {
        padding: 10px 0;
    }
    
    .level-label {
        font-size: 0.7rem;
        padding: 6px 14px;
        margin-bottom: 12px;
        letter-spacing: 1px;
    }
    
    .tree-node {
        padding: 12px;
        min-width: 140px;
        max-width: 160px;
    }
    
    .tree-node.superadmin::before {
        font-size: 1rem;
        top: -8px;
    }
    
    .node-avatar {
        width: 45px;
        height: 45px;
        font-size: 1.1rem;
        margin-bottom: 10px;
    }
    
    .node-name {
        font-size: 0.85rem;
    }
    
    .node-role {
        font-size: 0.7rem;
    }
    
    .node-dept {
        font-size: 0.65rem;
    }
    
    .tree-connector {
        height: 25px;
    }
    
    .tree-connector::before,
    .tree-connector::after {
        width: 8px;
        height: 8px;
    }
    
    .tree-nodes.members-grid {
        max-width: 100%;
    }
    
    .card-header {
        flex-direction: column;
        align-items: flex-start;
    }
    
    .tab-group {
        width: 100%;
        overflow-x: auto;
    }
    
    /* Mobile Modal Fixes */
    .modal-overlay {
        padding: 15px;
        align-items: flex-start;
        padding-top: calc(30px + env(safe-area-inset-top));
        padding-bottom: env(safe-area-inset-bottom);
    }
    
    .modal-box {
        max-height: 85vh;
        padding: 20px;
        margin-bottom: 20px;
    }
    
    .modal-box h3 {
        font-size: 1.1rem;
    }
    
    .modal-actions {
        flex-direction: column;
        gap: 10px;
    }
    
    .modal-actions button {
        width: 100%;
    }
    
    /* Fix for Review Modal on mobile */
    #review-task-details {
        max-height: 40vh;
        overflow-y: auto;
    }
    
    /* Prevent body scroll when modal is open */
    body.modal-open {
        overflow: hidden;
        position: fixed;
        width: 100%;
    }
    
    /* iOS PWA bottom nav safe area */
    .app-sidebar {
        padding-bottom: calc(10px + env(safe-area-inset-bottom));
        height: calc(70px + env(safe-area-inset-bottom));
    }
    
    /* iOS PWA header safe area */
    .app-header {
        padding-top: env(safe-area-inset-top);
        height: calc(70px + env(safe-area-inset-top));
    }
    
    /* PWA input focus fixes */
    input, textarea, select {
        font-size: 16px !important; /* Prevents iOS zoom on focus */
    }
    
    /* Touch-friendly buttons */
    button, .btn-outline, .btn-glow, .btn-review, .tab-btn {
        min-height: 44px; /* iOS minimum touch target */
    }
}

/* PWA Standalone Mode Specific Fixes */
@media all and (display-mode: standalone) {
    body {
        /* Additional padding for standalone mode */
        padding-top: env(safe-area-inset-top);
    }
    
    .app-header {
        padding-top: env(safe-area-inset-top);
    }
    
    .app-sidebar {
        padding-bottom: env(safe-area-inset-bottom);
    }
}
