:root {
    --primary-color: #009e60;
    --secondary-color: #1a1a1a;
    --accent-color: #f1c40f;
    --text-dark: #333333;
    --text-light: #666666;
    --white: #ffffff;
    --light-bg: #f4f6f9;
    --danger: #e74c3c;
    --success: #2ecc71;
    --warning: #f39c12;
    --sidebar-width: 260px;
    --header-height: 70px;
    --shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
    --transition: all 0.3s ease;
    --font-primary: 'Poppins', sans-serif;
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    font-family: var(--font-primary);
}

body {
    background-color: var(--light-bg);
    color: var(--text-dark);
    overflow-x: hidden; /* Prevent horizontal scroll on body */
}

a {
    text-decoration: none;
    color: inherit;
}

ul {
    list-style: none;
}

/* Auth Pages (Login/Forgot/Reset) */
.auth-container {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    background: linear-gradient(135deg, rgba(0, 158, 96, 0.8), rgba(26, 26, 26, 0.9)), url('../assets/hero-bg.jpg');
    background-size: cover;
    background-position: center;
    padding: 20px;
}

.auth-box {
    background: var(--white);
    width: 100%;
    max-width: 450px;
    padding: 40px;
    border-radius: 10px;
    box-shadow: 0 10px 25px rgba(0,0,0,0.2);
    text-align: center;
    animation: fadeIn 0.5s ease;
}

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

.auth-header img {
    height: 80px;
    margin-bottom: 20px;
}

.auth-header h2 {
    color: var(--secondary-color);
    margin-bottom: 10px;
}

.auth-header p {
    color: var(--text-light);
    margin-bottom: 30px;
}

.form-group {
    margin-bottom: 20px;
    text-align: left;
}

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

.form-control {
    width: 100%;
    padding: 12px 15px;
    border: 1px solid #ddd;
    border-radius: 5px;
    font-size: 1rem;
    transition: var(--transition);
}

.form-control:focus {
    border-color: var(--primary-color);
    outline: none;
    box-shadow: 0 0 0 3px rgba(0, 158, 96, 0.1);
}

.btn-block {
    width: 100%;
    padding: 12px;
    background-color: var(--primary-color);
    color: var(--white);
    border: none;
    border-radius: 5px;
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    transition: var(--transition);
}

.btn-block:hover {
    background-color: #007f4d;
}

/* Dashboard Layout */
.admin-wrapper {
    display: flex;
    min-height: 100vh;
    position: relative; /* For absolute positioning context if needed */
}

/* Sidebar */
.sidebar {
    width: var(--sidebar-width);
    background-color: var(--secondary-color);
    color: var(--white);
    position: fixed;
    height: 100vh;
    left: 0;
    top: 0;
    z-index: 1000;
    transition: var(--transition);
    display: flex;
    flex-direction: column;
    overflow-y: auto; /* Allow scrolling within sidebar if menu is long */
}

.sidebar-header {
    min-height: var(--header-height);
    display: flex;
    align-items: center;
    justify-content: center;
    border-bottom: 1px solid rgba(255,255,255,0.1);
    padding: 0 20px;
}

.sidebar-header h3 {
    color: var(--primary-color);
    font-size: 1.5rem;
    font-weight: 700;
}

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

.sidebar-menu li {
    margin-bottom: 5px;
}

.sidebar-menu a {
    display: flex;
    align-items: center;
    padding: 12px 25px;
    color: #b0b0b0;
    transition: var(--transition);
    font-size: 0.95rem;
    cursor: pointer;
}

.sidebar-menu a:hover, .sidebar-menu a.active {
    background-color: rgba(255,255,255,0.05);
    color: var(--white);
    border-left: 4px solid var(--primary-color);
}

.sidebar-menu i {
    width: 25px;
    margin-right: 10px;
    font-size: 1.1rem;
}

.sidebar-footer {
    padding: 20px;
    border-top: 1px solid rgba(255,255,255,0.1);
}

.sidebar-footer .user-info {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-bottom: 15px;
}

.sidebar-footer img {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    object-fit: cover;
}

.logout-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 10px;
    background-color: rgba(231, 76, 60, 0.2);
    color: var(--danger);
    border-radius: 5px;
    transition: var(--transition);
}

.logout-btn:hover {
    background-color: var(--danger);
    color: var(--white);
}

/* Main Content */
.main-content {
    margin-left: var(--sidebar-width);
    flex: 1;
    transition: var(--transition);
    width: calc(100% - var(--sidebar-width)); /* Explicit width control */
}

/* Top Header */
.top-header {
    height: var(--header-height);
    background-color: var(--white);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 30px;
    box-shadow: 0 2px 5px rgba(0,0,0,0.05);
    position: sticky;
    top: 0;
    z-index: 999;
}

.toggle-btn {
    font-size: 1.5rem;
    cursor: pointer;
    color: var(--text-dark);
    display: none; /* Hidden on desktop by default */
}

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

.notifications {
    position: relative;
    cursor: pointer;
}

.badge {
    position: absolute;
    top: -5px;
    right: -5px;
    background-color: var(--danger);
    color: var(--white);
    font-size: 0.7rem;
    width: 18px;
    height: 18px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
}

/* Page Content */
.page-content {
    padding: 30px;
    min-height: calc(100vh - var(--header-height));
}

/* SPA Sections */
.spa-section {
    display: none; /* Hidden by default */
    animation: fadeIn 0.4s ease;
}

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

.page-title {
    margin-bottom: 30px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap; /* Allow wrapping on small screens */
    gap: 15px;
}

.page-title h2 {
    font-size: 1.8rem;
    font-weight: 600;
}

.btn-primary {
    background-color: var(--primary-color);
    color: var(--white);
    padding: 10px 20px;
    border-radius: 5px;
    border: none;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    gap: 8px;
    transition: var(--transition);
    white-space: nowrap;
}

.btn-primary:hover {
    background-color: #007f4d;
}

/* Cards */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
    gap: 25px;
    margin-bottom: 40px;
}

.stat-card {
    background-color: var(--white);
    padding: 25px;
    border-radius: 10px;
    box-shadow: var(--shadow);
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.stat-info h3 {
    font-size: 2rem;
    font-weight: 700;
    margin-bottom: 5px;
    color: var(--secondary-color);
}

.stat-info p {
    color: var(--text-light);
    font-size: 0.9rem;
}

.stat-icon {
    width: 60px;
    height: 60px;
    border-radius: 50%;
    background-color: rgba(0, 158, 96, 0.1);
    color: var(--primary-color);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.8rem;
}

/* Tables */
.table-container {
    background-color: var(--white);
    border-radius: 10px;
    box-shadow: var(--shadow);
    overflow: hidden;
    margin-bottom: 30px;
}

.table-header {
    padding: 20px;
    border-bottom: 1px solid #eee;
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 15px;
}

.table-responsive {
    width: 100%;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch; /* Smooth scrolling on iOS */
}

table {
    width: 100%;
    border-collapse: collapse;
    min-width: 600px; /* Force scroll on small screens */
}

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

th {
    background-color: #fafafa;
    font-weight: 600;
    color: var(--text-light);
}

tr:hover {
    background-color: #f9f9f9;
}

.status {
    padding: 5px 12px;
    border-radius: 20px;
    font-size: 0.85rem;
    font-weight: 500;
    white-space: nowrap;
}

.status.active {
    background-color: rgba(46, 204, 113, 0.1);
    color: var(--success);
}

.status.pending {
    background-color: rgba(243, 156, 18, 0.1);
    color: var(--warning);
}

.status.critical {
    background-color: rgba(231, 76, 60, 0.1);
    color: var(--danger);
}

.status.inactive {
    background-color: rgba(100, 100, 100, 0.1);
    color: #666;
}

.action-btn {
    padding: 6px 10px;
    border-radius: 4px;
    border: none;
    cursor: pointer;
    margin-right: 5px;
    transition: var(--transition);
}

.btn-edit {
    background-color: rgba(52, 152, 219, 0.1);
    color: #3498db;
}

.btn-delete {
    background-color: rgba(231, 76, 60, 0.1);
    color: var(--danger);
}

.btn-view {
    background-color: rgba(46, 204, 113, 0.1);
    color: var(--success);
}

/* Financial Specifics */
.financial-summary {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
    gap: 25px;
    margin-bottom: 30px;
}

.balance-card {
    background: linear-gradient(135deg, var(--primary-color), #007f4d);
    color: var(--white);
    padding: 30px;
    border-radius: 10px;
    box-shadow: 0 10px 20px rgba(0, 158, 96, 0.2);
}

.balance-card h4 {
    font-size: 1rem;
    opacity: 0.9;
    margin-bottom: 10px;
}

.balance-card h2 {
    font-size: 2.5rem;
    font-weight: 700;
}

/* Modal System */
.modal {
    display: none;
    position: fixed;
    z-index: 2000;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    overflow: auto;
    background-color: rgba(0, 0, 0, 0.5);
    backdrop-filter: blur(4px);
    opacity: 0;
    transition: opacity 0.3s ease;
}

/* Switch Toggle */
.switch {
  position: relative;
  display: inline-block;
  width: 50px;
  height: 24px;
}

.switch input { 
  opacity: 0;
  width: 0;
  height: 0;
}

.slider {
  position: absolute;
  cursor: pointer;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background-color: #ccc;
  -webkit-transition: .4s;
  transition: .4s;
}

.slider:before {
  position: absolute;
  content: "";
  height: 16px;
  width: 16px;
  left: 4px;
  bottom: 4px;
  background-color: white;
  -webkit-transition: .4s;
  transition: .4s;
}

input:checked + .slider {
  background-color: var(--primary-color);
}

input:focus + .slider {
  box-shadow: 0 0 1px var(--primary-color);
}

input:checked + .slider:before {
  -webkit-transform: translateX(26px);
  -ms-transform: translateX(26px);
  transform: translateX(26px);
}

/* Rounded sliders */
.slider.round {
  border-radius: 34px;
}

.slider.round:before {
  border-radius: 50%;
}

.modal.show {
    display: block;
    opacity: 1;
}

.modal-content {
    background-color: #fefefe;
    margin: 10% auto;
    padding: 0;
    border: 1px solid #888;
    width: 90%;
    max-width: 600px;
    border-radius: 10px;
    box-shadow: 0 15px 30px rgba(0,0,0,0.2);
    transform: translateY(-20px);
    transition: transform 0.3s ease;
    animation: slideDown 0.3s forwards;
}

@keyframes slideDown {
    to { transform: translateY(0); }
}

.modal-header {
    padding: 15px 25px;
    border-bottom: 1px solid #eee;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.modal-header h3 {
    margin: 0;
    color: var(--secondary-color);
}

.close-modal {
    color: #aaa;
    font-size: 28px;
    font-weight: bold;
    cursor: pointer;
    transition: color 0.2s;
}

.close-modal:hover {
    color: var(--danger);
}

.modal-body {
    padding: 25px;
}

.modal-footer {
    padding: 15px 25px;
    border-top: 1px solid #eee;
    display: flex;
    justify-content: flex-end;
    gap: 10px;
}

.btn-secondary {
    background-color: #e0e0e0;
    color: #333;
    padding: 10px 20px;
    border-radius: 5px;
    border: none;
    cursor: pointer;
    font-weight: 500;
}

.btn-secondary:hover {
    background-color: #d0d0d0;
}

/* Mobile Responsive */
@media (max-width: 991px) {
    .toggle-btn {
        display: block;
    }

    .sidebar {
        left: -100%;
        width: 280px; /* Slightly wider for better mobile touch */
    }
    
    .sidebar.active {
        left: 0;
        box-shadow: 5px 0 15px rgba(0,0,0,0.2);
    }
    
    .main-content {
        margin-left: 0;
        width: 100%;
    }
    
    .overlay {
        position: fixed;
        top: 0;
        left: 0;
        width: 100%;
        height: 100%;
        background-color: rgba(0,0,0,0.5);
        z-index: 998;
        display: none;
        backdrop-filter: blur(2px);
    }
    
    .overlay.active {
        display: block;
    }
    
    .page-content {
        padding: 15px;
    }
    
    .stats-grid {
        grid-template-columns: 1fr; /* Stack cards on mobile */
    }
    
    .top-header {
        padding: 0 15px;
    }
}

@media (max-width: 480px) {
    .auth-box {
        padding: 25px;
    }
    
    .page-title h2 {
        font-size: 1.5rem;
    }
    
    .financial-summary {
        grid-template-columns: 1fr;
    }
}
