/* File: planting-plan.css */

/* --- THEME DEFINITIONS --- */
body.dark-theme {
    --bg-color: #1a1d21;
    --surface-color: #2c2f33;
    --surface-alt-color: #1f2937;
    --primary-text: #e0e0e0;
    --secondary-text: #a9a9a9;
    --border-color: #4f545c;
    --accent-color: #22c55e; /* Green accent */
    --accent-color-text: #166534; /* Dark Green for text */
}
body.light-theme {
    --bg-color: #f8fafc; /* Lighter background */
    --surface-color: #ffffff;
    --surface-alt-color: #f1f5f9;
    --primary-text: #1f2937;
    --secondary-text: #6b7280;
    --border-color: #e5e7eb;
    --accent-color: #16a34a; /* Green accent */
    --accent-color-text: #15803d;
}

/* --- Base Styling --- */
body {
    margin: 0;
    font-family: 'Sarabun', sans-serif;
    background-color: var(--bg-color);
    color: var(--primary-text);
    transition: background-color 0.3s, color 0.3s;
}

/* --- Theme Toggle Button --- */
#theme-toggle {
    position: fixed; top: 20px; right: 20px;
    background: var(--surface-color);
    border: 1px solid var(--border-color);
    color: var(--primary-text);
    width: 40px; height: 40px;
    border-radius: 50%;
    cursor: pointer; font-size: 18px;
    display: flex; justify-content: center; align-items: center;
    z-index: 1000;
    transition: all 0.3s;
}
#theme-toggle:hover {
    transform: scale(1.1);
    box-shadow: 0 4px 15px rgba(0,0,0,0.1);
}

/* --- Layout --- */
.container {
    max-width: 1280px;
    margin: 0 auto;
    padding: 2rem 1rem;
}
.main-layout {
    display: grid;
    grid-template-columns: 1fr;
    gap: 2rem;
}
@media (min-width: 1024px) {
    .main-layout {
        grid-template-columns: 2fr 1fr;
    }
}

/* --- General Components --- */
.card {
    background-color: var(--surface-color);
    border-radius: 0.75rem; /* 12px */
    border: 1px solid var(--border-color);
    padding: 1.5rem;
    box-shadow: 0 1px 3px rgba(0,0,0,0.05);
}
body.dark-theme .card {
     box-shadow: 0 1px 2px rgba(0,0,0,0.15);
}
h1, h2, h3, h4 {
    color: var(--primary-text);
    font-weight: 600;
}
h1 { font-size: 2.25rem; } /* 36px */
h2 { font-size: 1.5rem; } /* 24px */
p.subtitle { color: var(--secondary-text); }
.text-sm { font-size: 0.875rem; }

/* --- Header --- */
.page-header {
    text-align: center;
    margin-bottom: 3rem;
}
.page-header p:first-child {
    color: var(--secondary-text);
}
.page-header h1 {
    color: var(--accent-color-text);
}
body.dark-theme .page-header h1 {
    color: var(--accent-color);
}

/* --- Overview Cards --- */
.overview-cards {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 1.5rem;
    margin-bottom: 3rem;
}
@media (min-width: 768px) {
    .overview-cards {
        grid-template-columns: repeat(4, 1fr);
    }
}
.kpi-card {
    text-align: center;
    padding: 1rem;
}
.kpi-card h3 {
    font-size: 2.25rem;
    font-weight: 700;
    color: var(--accent-color);
}
.kpi-card p {
    color: var(--secondary-text);
}

/* --- Planting Grid --- */
.main-panel h2, .sidebar h2 {
    text-align: center;
    margin-top: 0;
    margin-bottom: 1rem;
}
.tree-grid {
    display: grid;
    grid-template-columns: repeat(7, 1fr);
    gap: 4px;
    border: 1px solid var(--border-color);
    padding: 4px;
    border-radius: 0.5rem;
}
.tree-cell {
    aspect-ratio: 1 / 1;
    transition: transform 0.2s ease, box-shadow 0.2s ease;
    cursor: pointer;
    font-size: 0.7rem;
    line-height: 1.1;
    padding: 2px;
    text-align: center;
    overflow: hidden;
    word-break: break-word;
    display: flex;
    justify-content: center;
    align-items: center;
    border-radius: 4px;
    font-weight: 600;
    color: #1f2937; /* Always dark text for light pastel backgrounds */
}
.tree-cell:hover {
    transform: scale(1.15);
    z-index: 10;
    box-shadow: 0 4px 12px rgba(0,0,0,0.2);
}

/* --- Legend --- */
.legend {
    display: flex;
    justify-content: center;
    gap: 1.5rem;
    margin-top: 1.5rem;
    font-size: 0.875rem;
}
.legend-item {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}
.legend-color {
    width: 1rem;
    height: 1rem;
    border-radius: 9999px;
    border: 1px solid var(--border-color);
}

/* --- Sidebar Controls --- */
.sidebar {
    display: flex;
    flex-direction: column;
    gap: 2rem;
}
.chart-container {
    position: relative;
    width: 100%;
    max-width: 300px;
    margin: 0 auto;
    height: 250px;
}
.total-count {
    text-align: center;
    margin-bottom: 1rem;
    font-weight: 600;
}
.total-count-warning {
    color: #ef4444;
}
body.light-theme .total-count-warning {
    color: #dc2626;
}

.species-list {
    list-style: none;
    padding: 0;
    margin: 0;
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}
.species-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding-bottom: 0.5rem;
    border-bottom: 1px solid var(--border-color);
}
.input-group {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}
.count-input {
    width: 45px;
    text-align: center;
    border: 1px solid var(--border-color);
    background-color: var(--bg-color);
    color: var(--primary-text);
    border-radius: 0.25rem;
    -moz-appearance: textfield;
}
.count-input::-webkit-outer-spin-button,
.count-input::-webkit-inner-spin-button {
    -webkit-appearance: none; margin: 0;
}
.adjust-count-btn {
    background-color: var(--surface-alt-color);
    border: 1px solid var(--border-color);
    color: var(--secondary-text);
    border-radius: 4px;
    width: 28px;
    height: 28px;
    cursor: pointer;
    transition: background-color 0.2s;
}
.adjust-count-btn:hover {
    background-color: var(--border-color);
}
.btn {
    width: 100%;
    font-weight: 600;
    padding: 0.75rem 1rem;
    border-radius: 9999px;
    border: none;
    cursor: pointer;
    transition: all 0.2s;
}
.btn-primary {
    background-color: var(--accent-color);
    color: white;
}
.btn-primary:hover {
    opacity: 0.9;
    transform: translateY(-2px);
}
.btn-secondary {
    background-color: var(--secondary-text);
    color: var(--bg-color);
    margin-top: 0.5rem;
}
body.dark-theme .btn-secondary {
    color: var(--primary-text);
}
.btn-secondary:hover {
    opacity: 0.8;
}

/* --- Guidelines Section --- */
.guidelines {
    margin-top: 3rem;
}
.guidelines h2 {
    text-align: center;
    margin-top: 0;
    margin-bottom: 1.5rem;
}
.guidelines ul {
    list-style: none;
    padding: 0;
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 1.5rem;
}
.guidelines li {
    background-color: var(--surface-alt-color);
    padding: 1rem;
    border-radius: 0.5rem;
    text-align: center;
}
.guidelines li .icon {
    font-size: 1.875rem;
    margin-bottom: 0.5rem;
}
.guidelines li h4 {
    font-weight: 600;
    color: var(--primary-text);
}
.guidelines li p {
    font-size: 0.875rem;
    color: var(--secondary-text);
}

/* --- Modal --- */
.modal-overlay {
    position: fixed;
    inset: 0;
    background-color: rgba(0,0,0,0.6);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 50;
    transition: opacity 0.3s;
    opacity: 0;
    pointer-events: none;
}
.modal-overlay.show {
    opacity: 1;
    pointer-events: auto;
}
.modal-content {
    background-color: var(--surface-color);
    border-radius: 1rem;
    box-shadow: 0 10px 25px rgba(0,0,0,0.2);
    padding: 1.5rem;
    width: 90%;
    max-width: 400px;
    text-align: center;
    transform: scale(0.95);
    transition: transform 0.3s;
}
.modal-overlay.show .modal-content {
    transform: scale(1);
}
.modal-content h3 {
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--accent-color-text);
    margin-top: 0;
    margin-bottom: 0.5rem;
}
body.dark-theme .modal-content h3 {
    color: var(--accent-color);
}
.modal-content p {
    color: var(--secondary-text);
    margin-bottom: 1rem;
}
#modalTreeDetails {
    text-align: left;
    background-color: var(--surface-alt-color);
    padding: 1rem;
    border-radius: 0.5rem;
}
#modalTreeDetails p {
    margin: 0.5rem 0;
    color: var(--primary-text);
}
.modal-content .btn {
    margin-top: 1.5rem;
}

.footer-link { text-align: center; }
.footer-link a { color: var(--secondary-text); text-decoration: none; font-size: 0.875rem; }
.footer-link a:hover { text-decoration: underline; }