/* ==================== */
/* Reset & Base Styles  */
/* ==================== */

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

:root {
    --primary-color: #2c5f2d;
    --primary-light: #3d7c3e;
    --primary-dark: #1e4620;
    --secondary-color: #8b4513;
    --accent-color: #d4af37;
    --background: #f5f5f0;
    --card-background: #ffffff;
    --text-primary: #333333;
    --text-secondary: #666666;
    --border-color: #dddddd;
    --error-color: #c53030;
    --success-color: #38a169;
    --shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
    --shadow-lg: 0 4px 16px rgba(0, 0, 0, 0.15);
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, sans-serif;
    background-color: var(--background);
    color: var(--text-primary);
    line-height: 1.6;
    min-height: 100vh;
}

.container {
    max-width: 1400px;
    margin: 0 auto;
    padding: 0 20px;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

/* ==================== */
/* Header               */
/* ==================== */

header {
    background-color: var(--primary-color);
    color: white;
    padding: 1.5rem 0;
    margin: 0 -20px;
    padding-left: 20px;
    padding-right: 20px;
    box-shadow: var(--shadow);
}

header h1 {
    font-size: 2rem;
    margin-bottom: 0.25rem;
}

header .subtitle {
    font-size: 1rem;
    opacity: 0.9;
}

.header-content {
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 1rem;
}

nav {
    display: flex;
    gap: 0.5rem;
    flex-wrap: wrap;
}

/* ==================== */
/* Main Content         */
/* ==================== */

main {
    flex: 1;
    padding: 2rem 0;
}

.view {
    display: none;
}

.view.active {
    display: block;
}

/* ==================== */
/* Cards                */
/* ==================== */

.card {
    background: var(--card-background);
    border-radius: 8px;
    padding: 2rem;
    box-shadow: var(--shadow);
    max-width: 500px;
    margin: 2rem auto;
}

.card h2 {
    color: var(--primary-color);
    margin-bottom: 0.5rem;
}

.card h3 {
    color: var(--text-primary);
    margin-bottom: 1rem;
    font-size: 1.25rem;
}

.card > p {
    color: var(--text-secondary);
    margin-bottom: 2rem;
}

/* ==================== */
/* Forms                */
/* ==================== */

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

.form-section.hidden {
    display: none;
}

input[type="text"],
input[type="email"],
input[type="password"] {
    width: 100%;
    padding: 0.75rem;
    border: 1px solid var(--border-color);
    border-radius: 4px;
    font-size: 1rem;
    margin-bottom: 1rem;
    transition: border-color 0.3s;
}

input[type="text"]:focus,
input[type="email"]:focus,
input[type="password"]:focus {
    outline: none;
    border-color: var(--primary-color);
}

.info-text {
    font-size: 0.875rem;
    color: var(--text-secondary);
    margin-top: 0.5rem;
}

/* ==================== */
/* Buttons              */
/* ==================== */

.btn {
    padding: 0.75rem 1.5rem;
    border: none;
    border-radius: 4px;
    font-size: 1rem;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.3s;
    display: inline-block;
    text-align: center;
}

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

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

.btn-secondary {
    background-color: transparent;
    color: white;
    border: 1px solid white;
}

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

.btn-small {
    padding: 0.5rem 1rem;
    font-size: 0.875rem;
}

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

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

button.btn-secondary:not(header .btn-secondary) {
    color: var(--text-primary);
    border: 1px solid var(--border-color);
}

button.btn-secondary:not(header .btn-secondary):hover {
    background-color: var(--background);
}

/* ==================== */
/* Toolbar              */
/* ==================== */

.toolbar {
    background: var(--card-background);
    padding: 1rem;
    border-radius: 8px;
    box-shadow: var(--shadow);
    margin-bottom: 1.5rem;
    display: flex;
    flex-wrap: wrap;
    gap: 1rem;
    align-items: center;
    justify-content: space-between;
}

.search-box {
    display: flex;
    gap: 0.5rem;
    flex: 1;
    min-width: 200px;
}

.search-box input {
    margin-bottom: 0;
}

.view-controls {
    display: flex;
    gap: 0.5rem;
}

.upload-section {
    display: flex;
    gap: 0.5rem;
}

.upload-section label {
    cursor: pointer;
}

/* ==================== */
/* Tree Container       */
/* ==================== */

.tree-container {
    background: var(--card-background);
    border-radius: 8px;
    padding: 2rem;
    box-shadow: var(--shadow);
    min-height: 400px;
    overflow-x: auto;
}

.tree-node {
    background: var(--background);
    border: 2px solid var(--primary-color);
    border-radius: 8px;
    padding: 1rem;
    margin: 1rem;
    display: inline-block;
    cursor: pointer;
    transition: all 0.3s;
    max-width: 200px;
}

.tree-node:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow-lg);
    border-color: var(--primary-dark);
}

.tree-node h4 {
    color: var(--primary-color);
    margin-bottom: 0.5rem;
    font-size: 1rem;
}

.tree-node p {
    font-size: 0.875rem;
    color: var(--text-secondary);
    margin: 0.25rem 0;
}

/* ==================== */
/* Person List          */
/* ==================== */

.person-list {
    background: var(--card-background);
    border-radius: 8px;
    padding: 1.5rem;
    box-shadow: var(--shadow);
}

.person-item {
    border-bottom: 1px solid var(--border-color);
    padding: 1rem 0;
    display: flex;
    justify-content: space-between;
    align-items: center;
    cursor: pointer;
    transition: background-color 0.3s;
}

.person-item:hover {
    background-color: var(--background);
    padding-left: 0.5rem;
    padding-right: 0.5rem;
    border-radius: 4px;
}

.person-item:last-child {
    border-bottom: none;
}

.person-info h4 {
    color: var(--primary-color);
    margin-bottom: 0.25rem;
}

.person-info p {
    font-size: 0.875rem;
    color: var(--text-secondary);
}

/* ==================== */
/* Modal                */
/* ==================== */

.modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.5);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 1000;
}

.modal.hidden {
    display: none;
}

.modal-content {
    background: var(--card-background);
    border-radius: 8px;
    padding: 2rem;
    max-width: 600px;
    max-height: 80vh;
    overflow-y: auto;
    position: relative;
    box-shadow: var(--shadow-lg);
    margin: 1rem;
}

.modal-close {
    position: absolute;
    top: 1rem;
    right: 1rem;
    background: none;
    border: none;
    font-size: 2rem;
    cursor: pointer;
    color: var(--text-secondary);
    padding: 0;
    width: 2rem;
    height: 2rem;
    line-height: 1;
}

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

/* ==================== */
/* Admin Panel          */
/* ==================== */

.admin-panel {
    max-width: 1000px;
    margin: 0 auto;
}

.admin-section {
    background: var(--card-background);
    border-radius: 8px;
    padding: 1.5rem;
    box-shadow: var(--shadow);
    margin-bottom: 1.5rem;
}

.admin-section h2 {
    color: var(--primary-color);
    margin-bottom: 1rem;
    font-size: 1.5rem;
}

.request-list,
.user-list {
    margin-top: 1rem;
}

.request-item,
.user-item {
    background: var(--background);
    border: 1px solid var(--border-color);
    border-radius: 4px;
    padding: 1rem;
    margin-bottom: 0.75rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 0.5rem;
}

.request-info,
.user-info {
    flex: 1;
}

.request-info strong,
.user-info strong {
    color: var(--primary-color);
    display: block;
    margin-bottom: 0.25rem;
}

.request-info small,
.user-info small {
    color: var(--text-secondary);
    font-size: 0.875rem;
}

.request-actions,
.user-actions {
    display: flex;
    gap: 0.5rem;
}

.btn-approve {
    background-color: var(--success-color);
    color: white;
    padding: 0.5rem 1rem;
    font-size: 0.875rem;
}

.btn-approve:hover {
    opacity: 0.9;
}

.btn-deny,
.btn-revoke {
    background-color: var(--error-color);
    color: white;
    padding: 0.5rem 1rem;
    font-size: 0.875rem;
}

.btn-deny:hover,
.btn-revoke:hover {
    opacity: 0.9;
}

.activity-log {
    max-height: 400px;
    overflow-y: auto;
}

.log-item {
    padding: 0.75rem;
    border-bottom: 1px solid var(--border-color);
    font-size: 0.875rem;
}

.log-item:last-child {
    border-bottom: none;
}

.log-item .timestamp {
    color: var(--text-secondary);
    font-size: 0.75rem;
}

/* ==================== */
/* Utility Classes      */
/* ==================== */

.hidden {
    display: none !important;
}

.placeholder {
    color: var(--text-secondary);
    text-align: center;
    padding: 2rem;
    font-style: italic;
}

.loading-spinner {
    border: 4px solid var(--border-color);
    border-top: 4px solid var(--primary-color);
    border-radius: 50%;
    width: 50px;
    height: 50px;
    animation: spin 1s linear infinite;
    margin: 2rem auto;
}

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

.error-message {
    background-color: #fee;
    color: var(--error-color);
    padding: 0.75rem;
    border-radius: 4px;
    margin: 1rem 0;
    border-left: 4px solid var(--error-color);
}

.success-message {
    background-color: #efe;
    color: var(--success-color);
    padding: 0.75rem;
    border-radius: 4px;
    margin: 1rem 0;
    border-left: 4px solid var(--success-color);
}

.badge {
    display: inline-block;
    padding: 0.25rem 0.5rem;
    border-radius: 4px;
    font-size: 0.75rem;
    font-weight: 600;
    text-transform: uppercase;
}

.badge-admin {
    background-color: var(--accent-color);
    color: white;
}

.badge-pending {
    background-color: #ffa500;
    color: white;
}

/* ==================== */
/* Footer               */
/* ==================== */

footer {
    text-align: center;
    padding: 2rem 0;
    color: var(--text-secondary);
    border-top: 1px solid var(--border-color);
    margin-top: auto;
}

/* ==================== */
/* Responsive Design    */
/* ==================== */

@media (max-width: 768px) {
    header h1 {
        font-size: 1.5rem;
    }

    .header-content {
        flex-direction: column;
        align-items: flex-start;
    }

    .toolbar {
        flex-direction: column;
        align-items: stretch;
    }

    .search-box {
        width: 100%;
    }

    .view-controls {
        justify-content: center;
    }

    .card {
        padding: 1.5rem;
        margin: 1rem auto;
    }

    .modal-content {
        width: 90%;
        padding: 1.5rem;
    }

    .request-item,
    .user-item {
        flex-direction: column;
        align-items: flex-start;
    }

    .request-actions,
    .user-actions {
        width: 100%;
        justify-content: flex-end;
    }
}

@media (max-width: 480px) {
    .container {
        padding: 0 10px;
    }

    header {
        margin: 0 -10px;
        padding-left: 10px;
        padding-right: 10px;
    }

    .btn {
        padding: 0.6rem 1rem;
        font-size: 0.9rem;
    }

    nav {
        width: 100%;
    }

    nav .btn {
        flex: 1;
    }
}
