:root {
    --sidebar-width: 280px;
    --primary: #2563eb;
    --primary-dark: #1e40af;
    --bg-color: #f3f4f6;
    --card-bg: #ffffff;
    --text-main: #1f2937;
    --text-muted: #6b7280;
    --border: #e5e7eb;
    --header-height: 64px;
    --input-bg: #ffffff;
    --hover-bg: #f9fafb;
    --active-bg: #eff6ff;
    --heading-color: #111827;
}

[data-theme="dark"] {
    --primary: #3b82f6;
    --primary-dark: #60a5fa;
    --bg-color: #111827;
    --card-bg: #1f2937;
    --text-main: #f9fafb;
    --text-muted: #9ca3af;
    --border: #374151;
    --input-bg: #374151;
    --hover-bg: #374151;
    --active-bg: #1e3a8a;
    --heading-color: #f3f4f6;
}

body {
    margin: 0;
    font-family: 'Inter', system-ui, -apple-system, sans-serif;
    background-color: var(--bg-color);
    display: flex;
    min-height: 100vh;
    color: var(--text-main);
    transition: background-color 0.3s, color 0.3s;
}

/* Sidebar Styles */
.sidebar {
    width: var(--sidebar-width);
    background: var(--card-bg);
    border-right: 1px solid var(--border);
    position: fixed;
    height: 100%;
    top: 0;
    left: 0;
    z-index: 10;
    transition: background-color 0.3s, border-color 0.3s;
}

.sidebar-header {
    padding: 1.5rem;
    border-bottom: 1px solid var(--border);
}

.sidebar-header h2 {
    margin: 0;
    font-size: 1.25rem;
    color: var(--heading-color);
}

.sidebar-header p {
    margin: 0.25rem 0 0;
    font-size: 0.875rem;
    color: var(--text-muted);
}

.sidebar-nav {
    margin-top: 1rem;
}

.nav-link {
    display: block;
    padding: 0.75rem 1.5rem;
    color: var(--text-muted);
    text-decoration: none;
    transition: all 0.2s;
    font-weight: 500;
}

.nav-link:hover {
    background-color: var(--hover-bg);
    color: var(--primary);
}

.nav-link.active {
    background-color: var(--active-bg);
    color: var(--primary);
    border-right: 3px solid var(--primary);
}

.nav-link.logout {
    color: #ef4444;
    margin-top: auto;
}

.nav-link.logout:hover {
    background-color: rgba(239, 68, 68, 0.1);
}

/* Main Content Styles */
.main-content,
.main {
    margin-left: var(--sidebar-width);
    flex: 1;
    padding: 2rem;
    padding-top: calc(60px + 2rem);
    width: calc(100% - var(--sidebar-width));
    box-sizing: border-box;
}

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

.header h1 {
    margin: 0;
    font-size: 1.875rem;
    font-weight: 700;
    color: var(--heading-color);
}

/* Components */
.btn {
    display: inline-block;
    padding: 0.5rem 1rem;
    background-color: var(--primary);
    color: white;
    text-decoration: none;
    border-radius: 0.375rem;
    font-weight: 500;
    border: none;
    cursor: pointer;
    transition: background-color 0.2s;
}

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

/* Grid adjustments */
.grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
    gap: 1.25rem;
}

/* Form Group overrides */
.form-group {
    margin-bottom: 1rem;
    min-width: 0;
    /* Prevents overflow in grid items */
}

/* Radio Button Groups */
.radio-group {
    display: flex;
    gap: 1.5rem;
    align-items: center;
    margin-top: 0.5rem;
    flex-wrap: wrap;
    /* Allows wrapping on small screens */
}

.radio-label {
    display: flex;
    align-items: center;
    cursor: pointer;
    white-space: nowrap;
}

.radio-label input {
    margin-right: 0.5rem;
    width: auto;
    /* Reset width for radio buttons */
    margin-bottom: 0;
    /* Reset margin */
}

/* Responsive Design */
@media (max-width: 768px) {

    /* Navbar fixes */
    .top-navbar {
        left: 0 !important;
        padding: 0 1rem !important;
    }

    .hamburger-btn {
        display: block !important;
    }

    .logout-text {
        display: none;
    }

    /* Sidebar - Hidden by default */
    .sidebar {
        left: -280px;
        transition: left 0.3s ease;
        box-shadow: 2px 0 5px rgba(0, 0, 0, 0.1);
    }

    /* Sidebar Active State */
    .sidebar.active {
        left: 0;
    }

    /* Main Content - Full width */
    .main-content,
    .main {
        margin-left: 0 !important;
        width: 100% !important;
        padding: 1rem !important;
        padding-top: calc(64px + 1rem) !important;
    }

    /* Hide User Info text on very small screens */
    .user-info {
        display: none;
    }

    /* Form specific overrides */
    .grid {
        grid-template-columns: 1fr !important;
        /* Force stack on mobile */
        gap: 1rem;
    }

    .container {
        padding: 1rem !important;
    }

    .chequeBtn {
        width: 100%;
        /* Full width button on mobile */
    }
}

/* Card & Table Styles */
.card,
table {
    background: var(--card-bg);
    color: var(--text-main);
    border-bottom: 1px solid var(--border);
    transition: background-color 0.3s, border-color 0.3s, color 0.3s;
}

.card {
    padding: 1.5rem;
    border-radius: 0.75rem;
    border: 1px solid var(--border);
    /* Added border to card */
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
}

/* Table Styles */
table {
    width: 100%;
    border-collapse: collapse;
    border-radius: 0.5rem;
    overflow: hidden;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
}

th,
td {
    padding: 1rem;
    text-align: left;
    border-bottom: 1px solid var(--border);
    color: var(--text-main);
}

th {
    background: var(--hover-bg);
    font-weight: 600;
    color: var(--text-muted);
}

tr:last-child td {
    border-bottom: none;
}

.badge {
    padding: 0.25rem 0.75rem;
    border-radius: 9999px;
    font-size: 0.75rem;
    font-weight: 500;
    background: var(--border);
    color: var(--text-main);
}

/* Forms */
input,
select,
textarea,
.form-input {
    width: 100%;
    padding: 0.5rem;
    background-color: var(--input-bg);
    color: var(--text-main);
    border: 1px solid var(--border);
    border-radius: 0.375rem;
    margin-bottom: 1rem;
    box-sizing: border-box;
}

/* Label fix */
label {
    color: var(--text-main);
}

/* Responsive Design */
@media (max-width: 768px) {

    /* Navbar fixes */
    .top-navbar {
        left: 0 !important;
        padding: 0 1rem !important;
    }

    .hamburger-btn {
        display: block !important;
    }

    .logout-text {
        display: none;
    }

    /* Sidebar - Hidden by default */
    .sidebar {
        left: -280px;
        transition: left 0.3s ease;
        box-shadow: 2px 0 5px rgba(0, 0, 0, 0.1);
    }

    /* Sidebar Active State */
    .sidebar.active {
        left: 0;
    }

    /* Main Content - Full width */
    .main-content,
    .main {
        margin-left: 0 !important;
        width: 100% !important;
        padding: 1rem !important;
        padding-top: calc(64px + 1rem) !important;
    }

    /* Responsive Table (Card View) */
    table.responsive-table,
    .responsive-table thead,
    .responsive-table tbody,
    .responsive-table th,
    .responsive-table td,
    .responsive-table tr {
        display: block;
    }

    /* Hide headers */
    .responsive-table thead tr {
        position: absolute;
        top: -9999px;
        left: -9999px;
    }

    .responsive-table tr {
        background: var(--card-bg);
        border: 2px solid var(--primary);
        border-radius: 0.5rem;
        margin-bottom: 1rem;
        padding: 0.5rem;
    }

    .responsive-table td {
        border: none;
        position: relative;
        padding-left: 50% !important;
        /* Make room for label */
        padding-top: 0.5rem;
        padding-bottom: 0.5rem;
        min-height: 24px;
        display: flex;
        align-items: center;
        color: var(--text-main);
    }

    .responsive-table td:before {
        position: absolute;
        top: 50%;
        left: 0.75rem;
        transform: translateY(-50%);
        width: 45%;
        padding-right: 10px;
        white-space: nowrap;
        font-weight: 600;
        color: #4b5563;
        content: attr(data-label);
        /* Show label */
    }
}

/* Navbar Dropdown */
.dropdown-container {
    position: relative;
}

.dropdown-menu {
    position: absolute;
    top: 100%;
    right: 0;
    margin-top: 0.5rem;
    background: var(--card-bg);
    border: 1px solid var(--border);
    border-radius: 0.5rem;
    box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06);
    min-width: 180px;
    z-index: 50;
    display: none;
    overflow: hidden;
}

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

.dropdown-item {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.75rem 1rem;
    color: var(--text-main);
    text-decoration: none;
    font-size: 0.875rem;
    transition: background-color 0.2s;
}

.dropdown-item:hover {
    background-color: var(--hover-bg);
}

.dropdown-item.logout {
    color: #ef4444;
}

.dropdown-item.logout:hover {
    background-color: rgba(239, 68, 68, 0.1);
}

.user-profile {
    cursor: pointer;
    -webkit-user-select: none;
    user-select: none;
    color: var(--text-main);
}

/* Sidebar Dropdown (Members) */
.nav-item-dropdown {
    display: flex;
    flex-direction: column;
}

.nav-item-dropdown .dropdown-toggle {
    justify-content: space-between;
    align-items: center;
    cursor: pointer;
}

.nav-item-dropdown .arrow {
    transition: transform 0.3s ease;
    font-size: 0.8rem;
}

.nav-item-dropdown .arrow.rotate {
    transform: rotate(180deg);
}

.sidebar-sub-menu {
    display: none;
    background-color: var(--hover-bg);
    border-radius: 0.5rem;
    margin-top: 0.25rem;
    border: 1px solid var(--border);
    overflow: hidden;
}

.sidebar-sub-menu .nav-link {
    padding-left: 3rem;
    font-size: 0.9rem;
    color: var(--text-muted);
}

.sidebar-sub-menu .nav-link:hover {
    color: var(--text-main);
    background-color: var(--bg-color);
    /* Slightly lighter/darker depending on theme */
}

.sidebar-sub-menu .nav-link.active {
    color: var(--primary);
    background-color: transparent;
    font-weight: 600;
}

/* --- Action Buttons (View, Edit, Delete) --- */
.action-btn {
    display: inline-block;
    padding: 0.25rem 0.75rem;
    font-size: 0.8em;
    font-weight: 500;
    border-radius: 0.375rem;
    text-decoration: none;
    text-align: center;
    transition: background-color 0.2s;
    border: 1px solid transparent;
}

.btn-view {
    background-color: #dbeafe;
    /* Light Blue */
    color: #1e40af;
    /* Dark Blue */
    border-color: #bfdbfe;
}

.btn-view:hover {
    background-color: #bfdbfe;
}

.btn-edit {
    background-color: #fef3c7;
    /* Light Amber */
    color: #92400e;
    /* Dark Amber */
    border-color: #fde68a;
}

.btn-edit:hover {
    background-color: #fde68a;
}

.btn-delete {
    background-color: #fee2e2;
    /* Light Red */
    color: #991b1b;
    /* Dark Red */
    border-color: #fecaca;
    border: none;
    cursor: pointer;
}

.btn-delete:hover {
    background-color: #fecaca;
}

/* Adjust delete FORM button */
form.delete-form {
    display: inline;
}

form.delete-form button {
    font-family: inherit;
}