/* Add these styles to fix the header overlap */

/* Add this to adjust the main content positioning */
.main-content {
    margin-top: 70px; /* Adjust this value based on your header height */
    margin-left: 250px;
    padding: 20px;
    transition: margin-left 0.3s ease;
    min-height: 100vh;
    background: #f5f5f5;
}

/* Make sure the sidebar and header are properly positioned */
.sidebar {
    height: 100vh;
    position: fixed;
    top: 0;
    left: 0;
    z-index: 1002; /* Higher than header */
}

.header {
    position: fixed;
    top: 0;
    left: 250px; /* Same as sidebar width */
    right: 0;
    z-index: 1001;
    background: white;
    box-shadow: 0 2px 10px rgba(0,0,0,0.1);
    height: 70px; /* Fixed height */
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 30px;
}

/* Adjust the content header spacing */
.content-header {
    margin-top: 0;
    margin-bottom: 20px; /* Reduced from 250px */
}

/* Modal z-index fix */
.modal {
    z-index: 1003; /* Higher than header and sidebar */
}

/* Responsive adjustments */
@media (max-width: 768px) {
    .header {
        left: 0;
    }
    
    .main-content {
        margin-left: 0;
        margin-top: 60px; /* Slightly less on mobile */
    }
    
    .sidebar.active ~ .main-content {
        margin-left: 250px; /* When sidebar is active on mobile */
    }
}

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

:root {
    --primary: #2c5530;
    --secondary: #4a7c59;
    --accent: #8fb996;
    --light: #f8f9fa;
    --dark: #343a40;
    --danger: #dc3545;
    --warning: #ffc107;
    --success: #28a745;
    --info: #17a2b8;
}

/* ============================================
   BASE STYLES
   ============================================ */
body {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    background-color: #f5f5f5;
    color: var(--dark);
    line-height: 1.6;
    min-height: 100vh;
}

/* ============================================
   LOGIN PAGE STYLES
   ============================================ */
body.login-body {
    background: linear-gradient(135deg, var(--primary), var(--secondary));
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0;
    margin: 0;
}

/* Hide layout elements on login pages */
body.login-body .header,
body.login-body .sidebar,
body.login-body .main-content {
    display: none !important;
}

/* Show login container on login pages */
body.login-body .login-container {
    display: block !important;
}

.login-container {
    background: white;
    border-radius: 10px;
    box-shadow: 0 10px 30px rgba(0,0,0,0.3);
    overflow: hidden;
    width: 400px;
    max-width: 90%;
}

.login-form {
    padding: 40px;
}

/* ============================================
   DEFAULT SIDEBAR STYLES (when it exists)
   ============================================ */
.sidebar {
    background: var(--primary);
    color: white;
    width: 250px;
    height: 100vh;
    position: fixed;
    left: 0;
    top: 0;
    z-index: 1002;
    transition: all 0.3s ease;
    overflow-y: auto;
}

/* When sidebar exists, body gets left padding */
body.with-sidebar {
    padding-left: 250px;
}

/* ============================================
   DEFAULT HEADER STYLES (when it exists)
   ============================================ */
.header {
    background: white;
    box-shadow: 0 2px 10px rgba(0,0,0,0.1);
    display: flex;
    justify-content: space-between;
    align-items: center;
    position: fixed;
    top: 0;
    right: 0;
    z-index: 1001;
    height: 70px;
    padding: 0 30px;
    transition: all 0.3s ease;
}

/* When header exists, body gets top padding */
body.with-header {
    padding-top: 70px;
}

/* When both sidebar and header exist together */
body.with-sidebar.with-header .header {
    left: 250px;
    right: 0;
}

body.with-sidebar.with-header .main-content {
    margin-left: 250px;
    margin-top: 70px;
}

/* ============================================
   MAIN CONTENT AREA
   ============================================ */
.main-content {
    padding: 20px;
    min-height: calc(100vh - 70px);
    background: #f5f5f5;
    transition: all 0.3s ease;
}

/* Default: no sidebar, no header */
.main-content {
    margin-left: 0;
    margin-top: 0;
    min-height: 100vh;
}

/* With sidebar only */
body.with-sidebar:not(.with-header) .main-content {
    margin-left: 250px;
    margin-top: 0;
}

/* With header only */
body.with-header:not(.with-sidebar) .main-content {
    margin-left: 0;
    margin-top: 70px;
}

/* With both sidebar and header */
body.with-sidebar.with-header .main-content {
    margin-left: 250px;
    margin-top: 70px;
}

/* ============================================
   RESPONSIVE DESIGN
   ============================================ */
@media (max-width: 768px) {
    /* Mobile - remove sidebar padding */
    body.with-sidebar {
        padding-left: 0;
    }
    
    /* Hide sidebar by default on mobile */
    .sidebar {
        transform: translateX(-100%);
    }
    
    .sidebar.active {
        transform: translateX(0);
    }
    
    /* Mobile header adjustments */
    body.with-header {
        padding-top: 60px;
    }
    
    .header {
        height: 60px;
        padding: 0 20px;
        left: 0 !important;
        right: 0;
    }
    
    /* Mobile main content */
    .main-content {
        margin-left: 0 !important;
        margin-top: 60px !important;
        padding: 15px;
        min-height: calc(100vh - 60px);
    }
    
    /* When sidebar is active on mobile */
    .sidebar.active ~ .header {
        left: 250px !important;
    }
    
    .sidebar.active ~ .main-content {
        margin-left: 250px !important;
    }
    
    /* Override body classes for mobile */
    body.with-sidebar.with-header .header,
    body.with-sidebar.with-header .main-content {
        margin-left: 0;
        left: 0;
    }
}

/* ============================================
   COMPONENT STYLES
   ============================================ */

/* Logo */
.logo {
    text-align: center;
    margin-bottom: 30px;
}

.logo h2 {
    color: var(--primary);
    margin-bottom: 5px;
}

.logo p {
    color: var(--secondary);
    font-size: 14px;
}

/* Form Styles */
.form-group {
    margin-bottom: 20px;
}

.form-group label {
    display: block;
    margin-bottom: 5px;
    font-weight: 500;
    color: var(--dark);
}

.form-group input,
.form-group select,
.form-group textarea {
    width: 100%;
    padding: 10px 12px;
    border: 1px solid #ddd;
    border-radius: 5px;
    font-size: 14px;
    transition: border-color 0.3s ease;
}

.form-group input:focus,
.form-group select:focus,
.form-group textarea:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 2px rgba(44, 85, 48, 0.1);
}

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

/* Buttons */
.btn {
    padding: 12px 24px;
    border: none;
    border-radius: 5px;
    cursor: pointer;
    font-size: 14px;
    font-weight: 500;
    text-decoration: none;
    display: inline-block;
    text-align: center;
    transition: all 0.3s ease;
}

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

.btn-primary:hover {
    background: var(--secondary);
    transform: translateY(-1px);
}

.btn-success { background: var(--success); color: white; }
.btn-danger { background: var(--danger); color: white; }
.btn-warning { background: var(--warning); color: black; }
.btn-info { background: var(--info); color: white; }
.btn-secondary { background: #6c757d; color: white; }
.btn-sm { padding: 8px 16px; font-size: 12px; }

/* Alerts */
.alert {
    padding: 12px 15px;
    border-radius: 5px;
    margin-bottom: 20px;
    border: 1px solid transparent;
}

.alert-error {
    background: #f8d7da;
    color: #721c24;
    border-color: #f5c6cb;
}

.alert-success {
    background: #d4edda;
    color: #155724;
    border-color: #c3e6cb;
}

.alert-warning {
    background: #fff3cd;
    color: #856404;
    border-color: #ffeaa7;
}

/* Content Header */
.content-header {
    background: white;
    padding: 20px;
    border-radius: 10px;
    margin-bottom: 20px;
    box-shadow: 0 2px 10px rgba(0,0,0,0.1);
}

.content-header h1 {
    color: var(--primary);
    margin-bottom: 5px;
    font-size: 28px;
}

.content-header p {
    color: #666;
    font-size: 14px;
}

/* Dashboard Stats */
.dashboard-stats {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
    gap: 20px;
    margin-bottom: 30px;
}

.stat-card {
    background: white;
    padding: 25px;
    border-radius: 10px;
    box-shadow: 0 2px 10px rgba(0,0,0,0.1);
    display: flex;
    align-items: center;
    gap: 20px;
    transition: transform 0.3s ease, box-shadow 0.3s ease;
}

.stat-card:hover {
    transform: translateY(-5px);
    box-shadow: 0 5px 20px rgba(0,0,0,0.15);
}

/* Cards */
.card {
    background: white;
    border-radius: 10px;
    box-shadow: 0 2px 10px rgba(0,0,0,0.1);
    padding: 25px;
    margin-bottom: 20px;
}

.card-header {
    margin-bottom: 20px;
    padding-bottom: 15px;
    border-bottom: 1px solid #eee;
}

.card-header h2 {
    color: var(--primary);
    font-size: 20px;
}

/* Tables */
.table-container {
    background: white;
    border-radius: 10px;
    box-shadow: 0 2px 10px rgba(0,0,0,0.1);
    overflow: hidden;
    margin-bottom: 20px;
}

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

.table th,
.table td {
    padding: 12px 15px;
    text-align: left;
    border-bottom: 1px solid #eee;
}

.table th {
    background: #f8f9fa;
    font-weight: 600;
    color: var(--primary);
    font-size: 14px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.table tbody tr:hover {
    background: #f8f9fa;
}

/* Modal */
.modal {
    z-index: 1003;
}

/* ============================================
   SIDEBAR SPECIFIC STYLES
   ============================================ */
.sidebar-header {
    padding: 20px;
    text-align: center;
    border-bottom: 1px solid rgba(255,255,255,0.1);
}

.sidebar-header h3 {
    color: white;
    font-size: 20px;
}

.sidebar-menu {
    padding: 20px 0;
}

.menu-section {
    padding: 10px 20px;
    font-size: 12px;
    color: rgba(255,255,255,0.6);
    text-transform: uppercase;
    letter-spacing: 1px;
    margin-top: 10px;
}

.menu-item {
    padding: 12px 20px;
    display: flex;
    align-items: center;
    gap: 10px;
    color: rgba(255,255,255,0.8);
    text-decoration: none;
    transition: all 0.3s ease;
    border-left: 3px solid transparent;
}

.menu-item:hover,
.menu-item.active {
    background: rgba(255,255,255,0.1);
    color: white;
    border-left-color: var(--accent);
}

.menu-item i {
    width: 20px;
    text-align: center;
}

/* ============================================
   HEADER SPECIFIC STYLES
   ============================================ */
.header-left {
    display: flex;
    align-items: center;
    gap: 15px;
}

.header-left h1 {
    color: var(--primary);
    font-size: 24px;
}

.menu-toggle {
    background: none;
    border: none;
    font-size: 20px;
    cursor: pointer;
    padding: 5px;
    color: var(--primary);
}

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

.user-info {
    display: flex;
    align-items: center;
    gap: 10px;
    position: relative;
}

.user-btn {
    background: none;
    border: none;
    font-size: 20px;
    cursor: pointer;
    padding: 5px;
    color: var(--primary);
}

.dropdown-content {
    display: none;
    position: absolute;
    top: 100%;
    right: 0;
    background: white;
    box-shadow: 0 5px 15px rgba(0,0,0,0.1);
    border-radius: 5px;
    min-width: 150px;
    z-index: 1003;
    border: 1px solid #eee;
}

.dropdown-content a {
    display: block;
    padding: 10px 15px;
    text-decoration: none;
    color: var(--dark);
    border-bottom: 1px solid #eee;
    transition: background 0.3s ease;
}

.dropdown-content a:hover {
    background: #f8f9fa;
    color: var(--primary);
}

.user-dropdown:hover .dropdown-content {
    display: block;
}

/* ============================================
   PRINT STYLES
   ============================================ */
@media print {
    .header,
    .sidebar {
        display: none !important;
    }
    
    .main-content {
        margin-left: 0 !important;
        margin-top: 0 !important;
        padding: 0 !important;
    }
    
    .card,
    .table-container {
        box-shadow: none !important;
        border: 1px solid #ddd !important;
    }
}