:root {
    --primary-color: #8B4513; /* SaddleBrown */
    --secondary-color: #A0522D;
    --bg-color: #FDF5E6; /* OldLace */
    --text-color: #3e2723;
    --accent-color: #d84315;
    --border-color: #D2691E;
    --sidebar-width: 260px;
    --header-height: 60px;
}

body {
    margin: 0;
    font-family: 'Times New Roman', serif;
    background-color: var(--bg-color);
    color: var(--text-color);
    display: flex;
    height: 100vh;
    overflow: hidden;
}

/* SPA Views Logic */
.view-section {
    display: none;
    width: 100%;
    height: 100%;
}
.view-section.active {
    display: flex; /* or block depending on content */
    animation: fadeIn 0.5s;
}

/* Landing Page Specifics */
#view-landing.active, #view-login.active {
    display: flex;
    justify-content: center;
    align-items: center;
    background: url('../images/pattern-bg.png'), radial-gradient(circle, #fff3e0 0%, #3e2723 100%);
    background-blend-mode: overlay;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 1000;
}

.landing-content {
    background: rgba(255, 255, 255, 0.95);
    padding: 60px;
    border-radius: 15px;
    box-shadow: 0 15px 40px rgba(0,0,0,0.5);
    max-width: 700px;
    width: 90%;
    border: 2px solid #8B4513;
    text-align: center;
}
.hoanh-phi-landing {
    background: #8B0000;
    color: #FFD700;
    padding: 15px 50px;
    border-radius: 40px;
    font-size: 40px;
    font-weight: bold;
    display: inline-block;
    border: 4px solid #FFD700;
    box-shadow: 0 5px 15px rgba(0,0,0,0.3);
    margin-bottom: 40px;
    text-transform: uppercase;
    letter-spacing: 2px;
}
.verse {
    font-style: italic;
    font-size: 20px;
    line-height: 1.8;
    margin-bottom: 40px;
    color: #5d4037;
    border-top: 1px solid #d7ccc8;
    border-bottom: 1px solid #d7ccc8;
    padding: 20px 0;
}
.btn-enter {
    display: inline-block;
    background: #8B4513;
    color: white;
    padding: 18px 50px;
    font-size: 22px;
    text-decoration: none;
    border-radius: 8px;
    transition: all 0.3s ease;
    border: 1px solid #5d4037;
    font-weight: bold;
    box-shadow: 0 4px 6px rgba(0,0,0,0.2);
    cursor: pointer;
}
.btn-enter:hover {
    background: #A0522D;
    transform: translateY(-3px);
    box-shadow: 0 6px 12px rgba(0,0,0,0.3);
}

/* Auth/Login Specifics */
.login-container {
    background: rgba(255,255,255,0.95);
    padding: 40px;
    width: 350px;
    border-radius: 10px;
    box-shadow: 0 15px 35px rgba(0,0,0,0.6);
    text-align: center;
    border: 1px solid var(--primary-color);
}
.login-container h1 {
    font-size: 24px;
    margin-bottom: 30px;
    color: var(--primary-color);
}
.input-group {
    position: relative;
    margin-bottom: 20px;
}
.input-group i {
    position: absolute;
    left: 10px;
    top: 50%;
    transform: translateY(-50%);
    color: #888;
}
.input-group input {
    width: 100%;
    padding: 12px 10px 12px 35px;
    border: 1px solid #ccc;
    border-radius: 5px;
    box-sizing: border-box;
    font-size: 16px;
}
.login-container button {
    width: 100%;
    padding: 12px;
    background: var(--primary-color);
    color: white;
    border: none;
    border-radius: 5px;
    font-size: 16px;
    cursor: pointer;
    transition: 0.3s;
}
.login-container button:hover {
    background: var(--secondary-color);
}
.hoanh-phi-mini {
    background: #8B0000;
    color: #FFD700;
    display: inline-block;
    padding: 5px 20px;
    border-radius: 20px;
    font-weight: bold;
    margin-bottom: 10px;
    border: 2px solid #FFD700;
    box-shadow: 0 2px 5px rgba(0,0,0,0.3);
}
.error-msg {
    color: #d32f2f;
    margin-top: 15px;
    font-size: 14px;
    display: none;
}
.footer-note {
    margin-top: 20px;
    font-size: 12px;
    color: #666;
    border-top: 1px solid #eee;
    padding-top: 10px;
}

/* Sidebar & Dashboard */
.sidebar {
    width: var(--sidebar-width);
    background: #3e2723;
    color: #fff;
    display: flex;
    flex-direction: column;
    z-index: 100;
    box-shadow: 2px 0 10px rgba(0,0,0,0.3);
}
.logo {
    padding: 20px;
    font-size: 24px;
    font-weight: bold;
    text-align: center;
    border-bottom: 1px solid rgba(255,255,255,0.1);
    background: rgba(0,0,0,0.1);
}
.user-info {
    padding: 15px 20px;
    font-size: 14px;
    background: rgba(0,0,0,0.2);
    color: #ccc;
    border-bottom: 1px solid rgba(255,255,255,0.1);
}
.sidebar nav {
    flex: 1;
    overflow-y: auto;
}
.nav-btn, .nav-link {
    display: block;
    width: 100%;
    background: none;
    border: none;
    color: #ccc;
    padding: 15px 20px;
    text-align: left;
    cursor: pointer;
    transition: 0.2s;
    font-size: 15px;
    text-decoration: none;
    box-sizing: border-box;
}
.nav-btn:hover, .nav-link:hover, .nav-btn.active {
    background: rgba(255,255,255,0.1);
    color: #fff;
    border-left: 4px solid var(--accent-color);
}
.nav-btn i, .nav-link i {
    width: 25px;
    text-align: center;
    margin-right: 10px;
}
.logout-btn {
    border-top: 1px solid rgba(255,255,255,0.1);
    color: #ffccbc;
}
.logout-btn:hover {
    background: #b71c1c;
    color: white;
}

/* Main Content */
.main-content {
    flex: 1;
    position: relative;
    overflow: hidden;
    display: flex;
    flex-direction: column;
}

.tab-content {
    display: none;
    height: 100%;
    padding: 20px;
    box-sizing: border-box;
    overflow-y: auto;
}
.tab-content.active {
    display: block;
    animation: fadeIn 0.3s;
}

@keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

/* Overlay Decoration */
.decoration-overlay {
    position: absolute;
    top: 0;
    left: var(--sidebar-width);
    right: 0;
    height: 100px;
    pointer-events: none;
    z-index: 50;
    display: flex;
    justify-content: space-between;
    padding: 10px 40px;
}
.hoanh-phi {
    background: #8B0000;
    color: #FFD700;
    padding: 5px 40px;
    border-radius: 0 0 30px 30px;
    font-size: 28px;
    font-weight: bold;
    display: flex;
    align-items: center;
    border: 2px solid #FFD700;
    border-top: none;
    box-shadow: 0 4px 10px rgba(0,0,0,0.3);
    height: 50px;
    font-family: 'Pinyon Script', cursive;
}
.cau-doi {
    background: #8B0000;
    color: #FFD700;
    width: 36px;
    padding: 15px 5px;
    text-align: center;
    font-size: 18px;
    font-weight: bold;
    border: 2px solid #FFD700;
    writing-mode: vertical-rl;
    text-orientation: upright;
    border-radius: 0 0 10px 10px;
    border-top: none;
    box-shadow: 0 4px 10px rgba(0,0,0,0.3);
}

/* Tree Canvas */
#canvas-container {
    width: 100%;
    height: 100%;
    cursor: grab;
    overflow: hidden;
    background-color: #f4e1c1;
    background-image: radial-gradient(#d7ccc8 1px, transparent 1px);
    background-size: 20px 20px;
    border-radius: 5px;
    box-shadow: inset 0 0 20px rgba(0,0,0,0.1);
}
#canvas-container:active {
    cursor: grabbing;
}
.toolbar {
    position: absolute;
    bottom: 30px;
    right: 30px;
    display: flex;
    gap: 10px;
    z-index: 10;
}
.toolbar button {
    background: #3e2723;
    color: white;
    border: none;
    width: 40px;
    height: 40px;
    border-radius: 50%;
    cursor: pointer;
    box-shadow: 0 2px 5px rgba(0,0,0,0.3);
    font-size: 16px;
}

/* Table */
.panel-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
    padding-bottom: 15px;
    border-bottom: 2px solid var(--border-color);
}
.table-container {
    background: white;
    border-radius: 8px;
    box-shadow: 0 2px 10px rgba(0,0,0,0.05);
    overflow: hidden;
}
table {
    width: 100%;
    border-collapse: collapse;
}
th, td {
    padding: 15px;
    text-align: left;
    border-bottom: 1px solid #eee;
}
th {
    background-color: var(--primary-color);
    color: white;
    font-weight: normal;
}
tr:hover {
    background-color: #f9f9f9;
}
.avatar-cell {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    object-fit: cover;
    border: 2px solid #eee;
}

/* Modal */
.modal {
    display: none;
    position: fixed;
    z-index: 200;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0,0,0,0.5);
    animation: fadeIn 0.2s;
}
.modal-content {
    background-color: #fff;
    margin: 3% auto;
    width: 650px;
    max-width: 95%;
    border-radius: 10px;
    box-shadow: 0 10px 30px rgba(0,0,0,0.3);
    display: flex;
    flex-direction: column;
    max-height: 90vh;
}
.modal-header {
    padding: 15px 20px;
    background: var(--primary-color);
    color: white;
    border-radius: 10px 10px 0 0;
    display: flex;
    justify-content: space-between;
    align-items: center;
}
.modal-header h2 { margin: 0; font-size: 18px; }
.close {
    color: white;
    font-size: 24px;
    font-weight: bold;
    cursor: pointer;
}
.modal-body {
    padding: 20px;
    overflow-y: auto;
}
.modal-footer {
    padding: 15px 20px;
    border-top: 1px solid #eee;
    text-align: right;
    background: #f9f9f9;
    border-radius: 0 0 10px 10px;
}
.grid-2 {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 15px;
}
.form-group {
    margin-bottom: 15px;
}
.form-group label {
    display: block;
    margin-bottom: 5px;
    font-weight: bold;
    font-size: 14px;
    color: #555;
}
.form-group input, .form-group select, .form-group textarea {
    width: 100%;
    padding: 10px;
    border: 1px solid #ccc;
    border-radius: 5px;
    box-sizing: border-box;
    font-family: inherit;
}
.form-group textarea { resize: vertical; }

.btn-primary {
    background: var(--primary-color);
    color: white;
    padding: 10px 20px;
    border: none;
    border-radius: 5px;
    cursor: pointer;
}
.btn-secondary {
    background: #607d8b;
    color: white;
    padding: 10px 20px;
    border: none;
    border-radius: 5px;
    cursor: pointer;
}
.btn-danger {
    background: #d32f2f;
    color: white;
    padding: 10px 20px;
    border: none;
    border-radius: 5px;
    cursor: pointer;
    margin-right: auto;
}
.btn-ai {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    border: none;
    padding: 8px 15px;
    border-radius: 20px;
    font-size: 13px;
    cursor: pointer;
    margin-top: 5px;
    display: inline-flex;
    align-items: center;
    gap: 5px;
    box-shadow: 0 2px 5px rgba(0,0,0,0.2);
}
.required { color: red; }
