:root {
    --primary: #4f46e5;
    --primary-hover: #4338ca;
    --bg-color: #0f172a;
    --glass-bg: rgba(30, 41, 59, 0.7);
    --glass-border: rgba(255, 255, 255, 0.1);
    --text-main: #f8fafc;
    --text-muted: #94a3b8;
    --success: #10b981;
    --warning: #f59e0b;
    --danger: #ef4444;
    --font-family: 'Inter', sans-serif;
}

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

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

/* Background Shapes */
.background-shapes {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: -1;
    overflow: hidden;
}

.shape {
    position: absolute;
    border-radius: 50%;
    filter: blur(80px);
    opacity: 0.5;
    animation: float 20s infinite ease-in-out alternate;
}

.shape-1 {
    top: -10%;
    left: -10%;
    width: 40vw;
    height: 40vw;
    background: #4f46e5;
}

.shape-2 {
    bottom: -10%;
    right: -10%;
    width: 35vw;
    height: 35vw;
    background: #0ea5e9;
    animation-delay: -5s;
}

.shape-3 {
    top: 40%;
    left: 50%;
    width: 25vw;
    height: 25vw;
    background: #8b5cf6;
    animation-delay: -10s;
}

@keyframes float {
    0% { transform: translate(0, 0) scale(1); }
    100% { transform: translate(50px, 50px) scale(1.1); }
}

/* Layout */
.app-container {
    display: flex;
    height: 100vh;
    padding: 1rem;
    gap: 1rem;
}

/* Login */
.login-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 100;
}

.login-box {
    width: 100%;
    max-width: 400px;
    padding: 2.5rem;
}

/* Glassmorphism Utilities */
.glass-panel {
    background: var(--glass-bg);
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
    border: 1px solid var(--glass-border);
    border-radius: 16px;
    box-shadow: 0 4px 30px rgba(0, 0, 0, 0.1);
}

/* Sidebar */
.sidebar {
    width: 280px;
    display: flex;
    flex-direction: column;
    padding: 2rem 1.5rem;
    transition: all 0.3s ease;
}

.brand {
    display: flex;
    align-items: center;
    gap: 1rem;
    margin-bottom: 3rem;
}

.logo {
    width: 32px;
    height: 32px;
    background: linear-gradient(135deg, #4f46e5, #0ea5e9);
    border-radius: 8px;
}

.brand h2 {
    font-weight: 700;
    letter-spacing: -0.5px;
}

.nav-menu {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    flex-grow: 1;
}

.nav-item {
    display: flex;
    align-items: center;
    gap: 1rem;
    padding: 1rem;
    color: var(--text-muted);
    text-decoration: none;
    border-radius: 12px;
    transition: all 0.2s ease;
    font-weight: 500;
}

.nav-item:hover {
    background: rgba(255, 255, 255, 0.05);
    color: var(--text-main);
    transform: translateX(4px);
}

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

.user-profile {
    display: flex;
    align-items: center;
    gap: 1rem;
    padding-top: 1.5rem;
    border-top: 1px solid var(--glass-border);
}

.avatar {
    width: 40px;
    height: 40px;
    background: #8b5cf6;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 600;
}

.user-info h4 {
    font-size: 0.9rem;
}

.user-info p {
    font-size: 0.8rem;
    color: var(--text-muted);
}

/* Main Content */
.main-content {
    flex-grow: 1;
    display: flex;
    flex-direction: column;
    overflow-y: auto;
    padding: 1rem 2rem;
}

.topbar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 2rem;
}

.topbar h1 {
    font-size: 2rem;
    font-weight: 600;
}

.date-display {
    color: var(--text-muted);
    font-size: 0.9rem;
}

.view-section {
    display: none;
    animation: fadeIn 0.4s ease forwards;
}

.view-section.active {
    display: block;
}

@keyframes fadeIn {
    from { opacity: 0; transform: translateY(10px); }
    to { opacity: 1; transform: translateY(0); }
}

/* Dashboard */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
    gap: 1.5rem;
}

.stat-card {
    padding: 1.5rem;
}

.stat-card h3 {
    color: var(--text-muted);
    font-size: 1rem;
    font-weight: 500;
    margin-bottom: 1rem;
}

.stat-value {
    font-size: 2.5rem;
    font-weight: 700;
    margin-bottom: 1rem;
}

.stat-unit {
    font-size: 1rem;
    font-weight: 400;
    color: var(--text-muted);
}

.highlight {
    color: var(--warning);
}

.progress-bar {
    height: 6px;
    background: rgba(255, 255, 255, 0.1);
    border-radius: 3px;
    overflow: hidden;
}

.progress {
    height: 100%;
    background: linear-gradient(90deg, #4f46e5, #0ea5e9);
    border-radius: 3px;
}

.mt-2 {
    margin-top: 2rem;
}

.recent-activity {
    padding: 1.5rem;
}

.recent-activity h3 {
    margin-bottom: 1rem;
    font-weight: 600;
}

.activity-list {
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.activity-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 1rem;
    background: rgba(255, 255, 255, 0.03);
    border-radius: 8px;
    border-left: 4px solid var(--primary);
}

/* Forms */
.form-container {
    max-width: 600px;
    margin: 0 auto;
    padding: 2rem;
}

.form-container h2 {
    margin-bottom: 2rem;
}

.form-group {
    margin-bottom: 1.5rem;
}

.form-row {
    display: flex;
    gap: 1rem;
}

.form-row .form-group {
    flex: 1;
}

label {
    display: block;
    margin-bottom: 0.5rem;
    font-weight: 500;
    color: var(--text-muted);
}

input, select, textarea {
    width: 100%;
    padding: 0.75rem 1rem;
    background: rgba(15, 23, 42, 0.6);
    border: 1px solid var(--glass-border);
    border-radius: 8px;
    color: var(--text-main);
    font-family: inherit;
    font-size: 1rem;
    transition: all 0.2s ease;
}

input:focus, select:focus, textarea:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 2px rgba(79, 70, 229, 0.2);
}

/* Fix for select dropdown background */
select option {
    background: var(--bg-color);
    color: var(--text-main);
}

/* Firefox specifically */
@-moz-document url-prefix() {
    select {
        background-color: var(--bg-color);
    }
}

.btn-primary {
    background: var(--primary);
    color: white;
    border: none;
    padding: 0.75rem 1.5rem;
    font-size: 1rem;
    font-weight: 600;
    border-radius: 8px;
    cursor: pointer;
    width: 100%;
    transition: background 0.2s ease, transform 0.1s ease;
}

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

.btn-primary:active {
    transform: scale(0.98);
}

/* Tables */
.table-container {
    padding: 1.5rem;
    overflow-x: auto;
}

.table-container h2 {
    margin-bottom: 1.5rem;
}

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

.data-table th, .data-table td {
    padding: 1rem;
    text-align: left;
    border-bottom: 1px solid var(--glass-border);
}

.data-table th {
    color: var(--text-muted);
    font-weight: 500;
}

.status-badge {
    padding: 0.25rem 0.75rem;
    border-radius: 99px;
    font-size: 0.85rem;
    font-weight: 500;
}

.status-Pending {
    background: rgba(245, 158, 11, 0.2);
    color: var(--warning);
}

.status-Approved {
    background: rgba(16, 185, 129, 0.2);
    color: var(--success);
}

.status-Rejected {
    background: rgba(239, 68, 68, 0.2);
    color: var(--danger);
}

/* Toast */
.toast {
    position: fixed;
    bottom: 2rem;
    right: 2rem;
    background: var(--success);
    color: white;
    padding: 1rem 1.5rem;
    border-radius: 8px;
    box-shadow: 0 4px 12px rgba(0,0,0,0.1);
    transition: all 0.3s ease;
    transform: translateY(0);
    opacity: 1;
    z-index: 1000;
}

.toast.hidden {
    transform: translateY(100px);
    opacity: 0;
    pointer-events: none;
}

/* Scrollbar Customization */
::-webkit-scrollbar {
    width: 8px;
}

::-webkit-scrollbar-track {
    background: rgba(0, 0, 0, 0.1);
}

::-webkit-scrollbar-thumb {
    background: rgba(255, 255, 255, 0.2);
    border-radius: 4px;
}

::-webkit-scrollbar-thumb:hover {
    background: rgba(255, 255, 255, 0.3);
}

/* Responsive */
@media (max-width: 768px) {
    .app-container {
        flex-direction: column;
        padding: 0.5rem;
    }
    
    .sidebar {
        width: 100%;
        padding: 1rem;
        flex-direction: column;
        align-items: center;
        gap: 1rem;
        border-radius: 12px;
    }
    
    .brand {
        margin-bottom: 0;
        width: 100%;
        justify-content: center;
    }
    
    .nav-menu {
        flex-direction: row;
        width: 100%;
        overflow-x: auto;
        padding-bottom: 0.5rem;
        /* Hide scrollbar for a cleaner look */
        scrollbar-width: none;
        -ms-overflow-style: none;
    }
    
    .nav-menu::-webkit-scrollbar {
        display: none;
    }
    
    .nav-item {
        padding: 0.75rem;
        white-space: nowrap;
        font-size: 0.85rem;
    }
    
    .nav-item svg {
        width: 18px;
        height: 18px;
    }
    
    .user-profile {
        display: none; /* Hide user profile on mobile to save space */
    }
    
    .main-content {
        padding: 0.5rem;
    }
    
    .topbar {
        flex-direction: column;
        align-items: flex-start;
        gap: 0.5rem;
        margin-bottom: 1rem;
    }
    
    .topbar h1 {
        font-size: 1.5rem;
    }
    
    .stats-grid {
        grid-template-columns: 1fr;
    }
    
    .form-row {
        flex-direction: column;
    }
}

.search-input {
    width: 200px;
    padding: 0.5rem 1rem;
    background: rgba(15, 23, 42, 0.6);
    border: 1px solid var(--glass-border);
    border-radius: 8px;
    color: var(--text-main);
    font-size: 0.9rem;
}

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

.btn-action {
    background: transparent;
    border: 1px solid var(--glass-border);
    color: var(--text-main);
    padding: 4px 8px;
    border-radius: 4px;
    cursor: pointer;
    font-size: 0.8rem;
    margin-right: 4px;
    transition: all 0.2s ease;
}

.btn-action:hover {
    background: rgba(255, 255, 255, 0.1);
}

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

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

.btn-action.update {
    color: var(--success);
    border-color: var(--success);
}
.btn-action.update:hover {
    background: var(--success);
    color: white;
}

@media print {
    body.printing-form .app-container {
        display: none !important;
    }
    @page {
        margin: 0;
    }
    body {
        margin: 1.5cm;
        background: white !important;
        color: black !important;
    }
    .sidebar, .top-header, .no-print {
        display: none !important;
    }
    .main-content {
        margin-left: 0 !important;
        padding: 0 !important;
        width: 100% !important;
    }
    .view-section.active {
        display: block !important;
    }
    .glass-panel {
        background: none !important;
        backdrop-filter: none !important;
        border: none !important;
        box-shadow: none !important;
    }
    .print-only-header {
        display: block !important;
    }
    .data-table {
        width: 100% !important;
        border-collapse: collapse !important;
    }
    .data-table th, .data-table td {
        border: 1px solid #ccc !important;
        padding: 8px !important;
        color: black !important;
    }
    .data-table th {
        background-color: #f5f5f5 !important;
    }
    }
}

/* --- Tree Chart CSS --- */
.tree-chart {
    display: flex;
    justify-content: center;
    padding: 1rem;
    overflow-x: auto;
}
.tree-chart ul {
    padding-top: 20px;
    position: relative;
    transition: all 0.5s;
    display: flex;
    justify-content: center;
    padding-left: 0;
    margin: 0;
}
.tree-chart li {
    float: left;
    text-align: center;
    list-style-type: none;
    position: relative;
    padding: 20px 5px 0 5px;
    transition: all 0.5s;
}
/* Connectors */
.tree-chart li::before, .tree-chart li::after {
    content: '';
    position: absolute;
    top: 0;
    right: 50%;
    border-top: 2px solid rgba(255,255,255,0.2);
    width: 50%;
    height: 20px;
}
.tree-chart li::after {
    right: auto;
    left: 50%;
    border-left: 2px solid rgba(255,255,255,0.2);
}
.tree-chart li:only-child::after, .tree-chart li:only-child::before {
    display: none;
}
.tree-chart li:only-child {
    padding-top: 0;
}
.tree-chart li:first-child::before, .tree-chart li:last-child::after {
    border: 0 none;
}
.tree-chart li:last-child::before {
    border-right: 2px solid rgba(255,255,255,0.2);
    border-radius: 0 5px 0 0;
}
.tree-chart li:first-child::after {
    border-radius: 5px 0 0 0;
}
.tree-chart ul ul::before {
    content: '';
    position: absolute;
    top: 0;
    left: 50%;
    border-left: 2px solid rgba(255,255,255,0.2);
    width: 0;
    height: 20px;
}
.tree-chart .node-card {
    background: rgba(255,255,255,0.05);
    border: 1px solid rgba(255,255,255,0.1);
    backdrop-filter: blur(10px);
    border-radius: 8px;
    padding: 10px 15px;
    display: inline-block;
    min-width: 140px;
    max-width: 200px;
    color: white;
    box-shadow: 0 4px 6px rgba(0,0,0,0.1);
    transition: transform 0.2s, border-color 0.2s;
    text-align: center;
}
.tree-chart .node-card:hover {
    transform: translateY(-5px);
    border-color: var(--primary);
}
.tree-chart .node-name {
    font-weight: 600;
    font-size: 0.95rem;
    margin-bottom: 2px;
}
.tree-chart .node-role {
    font-size: 0.8rem;
    color: var(--secondary-color);
}
