/* Plant Health — Forest & Earth (Professional AgTech) */
:root {
    --primary: #2D6A4F;
    --secondary: #40916C;
    --accent: #95D5B2;
    --bg: #F8F9FA;
    --card: #FFFFFF;
    --text: #1B4332;
    --text-muted: #6C757D;
    --border: #DEE2E6;
    --accent-soft: #EDF7F1;
    --shadow-sm: 0 1px 3px rgba(27, 67, 50, 0.06);
    --shadow-md: 0 4px 12px rgba(27, 67, 50, 0.08);
    --radius: 8px;
    --radius-lg: 12px;
    --transition: 0.18s ease;
}

* { box-sizing: border-box; }

body {
    font-family: 'Be Vietnam Pro', -apple-system, BlinkMacSystemFont, sans-serif;
    background: var(--bg);
    color: var(--text);
    min-height: 100vh;
    font-size: 0.9375rem;
    line-height: 1.55;
}

a {
    color: var(--primary);
    transition: color var(--transition);
}

a:hover { color: var(--secondary); }

/* ── Navbar ── */
.navbar {
    background: var(--text) !important;
    border-bottom: 1px solid rgba(255, 255, 255, 0.08);
    padding: 0.75rem 0;
}

.navbar-brand {
    font-weight: 600;
    font-size: 1.125rem;
    color: #fff !important;
    letter-spacing: -0.01em;
}

.navbar-brand .brand-mark {
    display: inline-block;
    width: 8px;
    height: 8px;
    background: var(--accent);
    border-radius: 2px;
    margin-right: 10px;
    vertical-align: middle;
}

.navbar-brand span { color: var(--accent); font-weight: 500; }

.nav-link {
    color: rgba(255, 255, 255, 0.78) !important;
    font-weight: 500;
    font-size: 0.875rem;
    padding: 0.4rem 0.75rem !important;
    border-radius: var(--radius);
}

.nav-link:hover { color: #fff !important; background: rgba(255, 255, 255, 0.06); }

.nav-link.active {
    color: #fff !important;
    background: rgba(149, 213, 178, 0.15);
}

.navbar .btn-outline-light {
    border-color: rgba(255, 255, 255, 0.35);
    font-size: 0.875rem;
    font-weight: 500;
}

.navbar .btn-accent {
    background: var(--secondary);
    border: none;
    color: #fff;
    font-size: 0.875rem;
    font-weight: 500;
}

.navbar .btn-accent:hover { background: var(--primary); color: #fff; }

/* ── Sidebar ── */
.sidebar {
    background: var(--card);
    border-right: 1px solid var(--border);
    min-height: calc(100vh - 57px);
    padding: 1.5rem 0;
}

.sidebar-label {
    font-size: 0.6875rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: var(--text-muted);
    padding: 0 1.25rem 0.5rem;
}

.sidebar .nav-link {
    color: var(--text-muted) !important;
    padding: 0.55rem 1.25rem !important;
    font-size: 0.875rem;
    font-weight: 500;
    border-left: 3px solid transparent;
    border-radius: 0;
}

.sidebar .nav-link:hover {
    color: var(--text) !important;
    background: var(--bg);
}

.sidebar .nav-link.active {
    color: var(--primary) !important;
    background: var(--accent-soft);
    border-left-color: var(--primary);
    font-weight: 600;
}

/* ── Layout ── */
.main-content {
    padding: 1.75rem 1.5rem 2.5rem;
    max-width: 1320px;
    margin-left: auto;
    margin-right: auto;
}

.page-header { margin-bottom: 1.5rem; }

.page-title {
    font-size: 1.5rem;
    font-weight: 600;
    letter-spacing: -0.02em;
    color: var(--text);
    margin-bottom: 0.25rem;
}

.page-subtitle {
    color: var(--text-muted);
    font-size: 0.875rem;
    margin: 0;
}

.section-title {
    font-size: 0.8125rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    color: var(--text-muted);
    margin-bottom: 1rem;
}

/* ── Cards ── */
.card {
    background: var(--card);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-sm);
}

.card-header {
    background: var(--card);
    color: var(--text);
    border-bottom: 1px solid var(--border);
    padding: 0.875rem 1.25rem;
    font-weight: 600;
    font-size: 0.9375rem;
}

.card-body { padding: 1.25rem; }

.card-footer {
    background: var(--bg);
    border-top: 1px solid var(--border);
}

/* ── Buttons ── */
.btn {
    border-radius: var(--radius);
    font-weight: 500;
    font-size: 0.875rem;
    padding: 0.5rem 1rem;
    transition: all var(--transition);
}

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

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

.btn-outline-primary {
    color: var(--primary);
    border-color: var(--border);
}

.btn-outline-primary:hover {
    background: var(--accent-soft);
    border-color: var(--primary);
    color: var(--primary);
}

.btn-secondary-outline {
    color: var(--text-muted);
    border: 1px solid var(--border);
    background: var(--card);
}

.btn-secondary-outline:hover {
    background: var(--bg);
    color: var(--text);
    border-color: var(--border);
}

/* ── KPI / Stat cards ── */
.stat-card {
    background: var(--card);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: 1.25rem;
    height: 100%;
}

.stat-card .stat-label {
    font-size: 0.75rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    color: var(--text-muted);
    margin-bottom: 0.5rem;
}

.stat-card .stat-value {
    font-size: 1.75rem;
    font-weight: 600;
    color: var(--text);
    line-height: 1.2;
}

.stat-card.stat-alert .stat-value { color: var(--secondary); }
.stat-card.stat-warning .stat-value { color: #B08968; }

.stat-card::before {
    content: '';
    display: block;
    width: 3px;
    height: 100%;
    position: absolute;
    left: 0;
    top: 0;
    background: var(--primary);
    border-radius: var(--radius-lg) 0 0 var(--radius-lg);
}

.stat-card { position: relative; padding-left: 1.35rem; overflow: hidden; }

/* ── Plant / species cards ── */
.plant-card {
    transition: box-shadow var(--transition);
    cursor: pointer;
}

.plant-card:hover {
    box-shadow: var(--shadow-md);
}

/* Toolbar thư viện — gọn 1 hàng */
.library-toolbar {
    display: grid;
    grid-template-columns: 1fr minmax(140px, 180px) auto;
    gap: 0.5rem;
    align-items: center;
    max-width: 640px;
    margin: 0 auto;
}

@media (max-width: 576px) {
    .library-toolbar {
        grid-template-columns: 1fr 1fr;
    }
    .library-toolbar .btn {
        grid-column: 1 / -1;
    }
}

/* Thư viện loài */
.library-grid {
    display: grid;
    gap: 0.875rem;
    grid-template-columns: repeat(2, minmax(0, 1fr));
}

@media (min-width: 576px) {
    .library-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); }
}

@media (min-width: 992px) {
    .library-grid { grid-template-columns: repeat(5, minmax(0, 1fr)); }
}

.library-card-link {
    display: block;
    height: 100%;
    text-decoration: none;
    color: inherit;
}

.species-card {
    height: 100%;
    overflow: hidden;
    display: flex;
    flex-direction: column;
    border: 1px solid var(--border);
    transition: box-shadow var(--transition);
}

.species-card:hover {
    box-shadow: var(--shadow-md);
}

.library-img-wrap,
.library-img-placeholder {
    width: 100%;
    aspect-ratio: 1 / 1;
    flex-shrink: 0;
    background: var(--bg);
    border-bottom: 1px solid var(--border);
    overflow: hidden;
}

.library-img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    object-position: center;
    display: block;
}

.library-img-placeholder {
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--text-muted);
    font-size: 0.65rem;
    font-weight: 500;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.library-card-body {
    padding: 0.625rem 0.75rem 0.75rem;
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    text-align: center;
    min-height: 0;
}

.library-card-title {
    font-size: 0.8125rem;
    font-weight: 600;
    color: var(--text);
    margin-bottom: 0.15rem;
    line-height: 1.35;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
    width: 100%;
}

.library-card-scientific {
    font-size: 0.6875rem;
    color: var(--text-muted);
    font-style: italic;
    margin-bottom: 0.35rem;
    width: 100%;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.library-card-body .tag {
    align-self: center;
    margin-bottom: 0.35rem;
    font-size: 0.625rem;
    padding: 0.15rem 0.4rem;
}

.library-card-body .care-meta {
    margin-top: auto;
    font-size: 0.6875rem;
    color: var(--text-muted);
    line-height: 1.4;
    width: 100%;
}

.library-card-body .care-meta div {
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.plant-img {
    width: 100%;
    height: 168px;
    object-fit: cover;
    border-bottom: 1px solid var(--border);
}

.plant-img-placeholder {
    width: 100%;
    height: 168px;
    background: var(--bg);
    border-bottom: 1px solid var(--border);
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--text-muted);
    font-size: 0.75rem;
    font-weight: 500;
    text-transform: uppercase;
    letter-spacing: 0.06em;
}

.plant-img {
.badge-health {
    font-size: 0.6875rem;
    font-weight: 600;
    padding: 0.25rem 0.6rem;
    border-radius: 4px;
    text-transform: uppercase;
    letter-spacing: 0.03em;
}

.badge.bg-success { background: var(--accent-soft) !important; color: var(--primary) !important; }
.badge.bg-info { background: #E7F1FF !important; color: #0D6EFD !important; }
.badge.bg-warning { background: #FFF3E0 !important; color: #8D6E63 !important; }
.badge.bg-danger { background: #FDEDED !important; color: #C62828 !important; }
.badge.bg-secondary { background: var(--bg) !important; color: var(--text-muted) !important; border: 1px solid var(--border); }

.tag {
    display: inline-block;
    font-size: 0.6875rem;
    font-weight: 600;
    padding: 0.2rem 0.5rem;
    border-radius: 4px;
    background: var(--accent-soft);
    color: var(--primary);
    border: 1px solid rgba(45, 106, 79, 0.15);
}

/* ── Lists & alerts ── */
.alert-item {
    border-left: 3px solid var(--secondary);
    background: var(--card);
}

.care-log-item {
    border-left: 2px solid var(--border);
    padding: 0.875rem 0 0.875rem 1rem;
    margin-bottom: 0;
    border-bottom: 1px solid var(--border);
}

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

.list-group-item {
    border-color: var(--border);
    font-size: 0.875rem;
}

.list-group-item:hover { background: var(--bg); }

/* Weather page styles: templates/garden/weather.html (inline) */

/* ── Forms ── */
.form-control, .form-select {
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 0.55rem 0.875rem;
    font-size: 0.875rem;
    color: var(--text);
    background: var(--card);
}

.form-control:focus, .form-select:focus {
    border-color: var(--secondary);
    box-shadow: 0 0 0 3px rgba(64, 145, 108, 0.15);
}

.form-label {
    font-weight: 500;
    color: var(--text);
    font-size: 0.8125rem;
    margin-bottom: 0.35rem;
}

/* ── Upload zone ── */
.upload-zone {
    border: 1px dashed var(--border);
    border-radius: var(--radius-lg);
    padding: 2rem 1.5rem;
    text-align: center;
    background: var(--bg);
    transition: border-color var(--transition), background var(--transition);
    cursor: pointer;
}

.upload-zone:hover, .upload-zone.dragover {
    border-color: var(--secondary);
    background: var(--accent-soft);
}

.upload-zone-title {
    font-weight: 600;
    color: var(--text);
    font-size: 0.9375rem;
    margin-bottom: 0.25rem;
}

.upload-zone-desc {
    font-size: 0.8125rem;
    color: var(--text-muted);
    margin: 0;
}

.upload-zone input[type="file"] {
    position: absolute;
    opacity: 0;
    width: 100%;
    height: 100%;
    top: 0;
    left: 0;
    cursor: pointer;
}

/* ── Auth ── */
body.auth-page .main-content { padding-top: 2rem; }

.auth-wrapper {
    min-height: calc(100vh - 160px);
    display: flex;
    align-items: center;
    justify-content: center;
}

.auth-card {
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-md);
    background: var(--card);
    width: 100%;
}

.auth-card-header {
    padding: 2rem 2rem 0;
    text-align: center;
}

.auth-card-header h4 {
    font-weight: 600;
    color: var(--text);
    margin-bottom: 0.25rem;
}

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

.auth-card-body { padding: 1.75rem 2rem 2rem; }

.auth-divider {
    border: none;
    border-top: 1px solid var(--border);
    margin: 1.5rem 0;
}

/* ── Empty state ── */
.empty-state {
    text-align: center;
    padding: 3rem 1.5rem;
    background: var(--card);
    border-radius: var(--radius-lg);
    border: 1px solid var(--border);
}

.empty-state h5 {
    color: var(--text);
    font-weight: 600;
    font-size: 1rem;
}

.empty-state p { color: var(--text-muted); font-size: 0.875rem; }

/* ── Breadcrumb ── */
.breadcrumb {
    background: transparent;
    padding: 0;
    margin-bottom: 1.25rem;
    font-size: 0.8125rem;
}

.breadcrumb-item a {
    color: var(--text-muted);
    text-decoration: none;
}

.breadcrumb-item a:hover { color: var(--primary); }
.breadcrumb-item.active { color: var(--text); font-weight: 500; }

/* ── Info blocks ── */
.info-pill {
    background: var(--bg);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 0.875rem 1rem;
    height: 100%;
}

.info-pill .info-label {
    font-size: 0.6875rem;
    font-weight: 600;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.04em;
    margin-bottom: 0.35rem;
}

.info-pill strong {
    color: var(--text);
    font-weight: 500;
    font-size: 0.875rem;
}

/* ── Filter bar ── */
.filter-bar {
    background: var(--card);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: 0.75rem 1rem;
}

.filter-bar .btn-sm {
    border-radius: var(--radius);
    font-weight: 500;
    font-size: 0.8125rem;
}

/* ── Search panel (library) ── */
.search-panel {
    background: var(--card);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: 1.5rem;
    margin-bottom: 1.5rem;
    text-align: center;
}

.search-panel h2 {
    font-size: 1.25rem;
    font-weight: 600;
    color: var(--text);
    margin-bottom: 0.25rem;
}

.search-panel p {
    color: var(--text-muted);
    font-size: 0.875rem;
    margin-bottom: 1rem;
}

.search-panel form {
    text-align: left;
    max-width: 720px;
    margin: 0 auto;
}

/* ── Footer ── */
footer {
    background: var(--card);
    border-top: 1px solid var(--border);
    color: var(--text-muted);
    padding: 1.25rem 0;
    margin-top: 2rem;
    font-size: 0.8125rem;
}

footer .footer-brand {
    font-weight: 600;
    color: var(--text);
    font-size: 0.9375rem;
}

footer .footer-brand span { color: var(--secondary); }
footer a { color: var(--text-muted); text-decoration: none; }
footer a:hover { color: var(--primary); }

/* ── Diagnosis ── */
.result-panel {
    background: var(--bg);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: 1.25rem;
}

.ratio-bar {
    height: 6px;
    border-radius: 3px;
    background: var(--border);
    overflow: hidden;
    margin-top: 6px;
}

.ratio-bar-fill { height: 100%; border-radius: 3px; transition: width 0.5s ease; }
.ratio-bar-fill.green { background: var(--secondary); }
.ratio-bar-fill.yellow { background: #C4A035; }
.ratio-bar-fill.brown { background: #8D6E63; }

.ratio-label {
    display: flex;
    justify-content: space-between;
    font-size: 0.8125rem;
    color: var(--text-muted);
}

.ratio-label strong { color: var(--text); font-weight: 500; }

.meta-note {
    font-size: 0.8125rem;
    color: var(--text-muted);
    padding: 0.75rem 1rem;
    background: var(--bg);
    border-radius: var(--radius);
    border: 1px solid var(--border);
}

/* ── Alerts (bootstrap override) ── */
.alert {
    border-radius: var(--radius);
    font-size: 0.875rem;
    border: 1px solid var(--border);
}

.alert-info { background: #EEF6FF; color: #1B4332; border-color: #B6D4FE; }
.alert-success { background: var(--accent-soft); color: var(--text); border-color: rgba(45,106,79,0.2); }
.alert-warning { background: #FFFBF0; color: var(--text); border-color: #FFE082; }

/* ── Table ── */
.table { font-size: 0.875rem; }
.table td { vertical-align: middle; }

/* ── Responsive ── */
@media (max-width: 991px) {
    .main-content { padding: 1.25rem 1rem 2rem; }
    .page-title { font-size: 1.25rem; }
}

@media (max-width: 768px) {
    .sidebar { display: none; }
}

/* ── Chatbot widget ── */
.chatbot-root {
    position: fixed;
    right: 1.25rem;
    bottom: 1.25rem;
    z-index: 9999;
    pointer-events: none;
}

.chatbot-fab,
.chatbot-panel {
    pointer-events: auto;
}

.chatbot-fab {
    width: 3.5rem;
    height: 3.5rem;
    border-radius: 50%;
    border: none;
    background: var(--primary);
    color: #fff;
    box-shadow: 0 4px 16px rgba(27, 67, 50, 0.35);
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.chatbot-fab:hover {
    transform: scale(1.05);
    box-shadow: 0 6px 20px rgba(27, 67, 50, 0.45);
}

.chatbot-fab-hidden {
    opacity: 0;
    pointer-events: none;
    transform: scale(0.8);
}

.chatbot-fab-icon {
    width: 1.75rem;
    height: 1.75rem;
}

.chatbot-panel {
    position: absolute;
    right: 0;
    bottom: 4.25rem;
    width: min(22rem, calc(100vw - 2rem));
    height: 28rem;
    background: var(--card);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.12);
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.chatbot-header {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    padding: 0.875rem 1rem;
    background: var(--primary);
    color: #fff;
}

.chatbot-header-title {
    font-weight: 600;
    font-size: 0.9375rem;
}

.chatbot-header-sub {
    font-size: 0.75rem;
    opacity: 0.85;
    margin-top: 0.125rem;
}

.chatbot-close {
    background: none;
    border: none;
    color: #fff;
    font-size: 1.5rem;
    line-height: 1;
    padding: 0;
    cursor: pointer;
    opacity: 0.85;
}

.chatbot-close:hover { opacity: 1; }

.chatbot-messages {
    flex: 1;
    overflow-y: auto;
    padding: 1rem;
    display: flex;
    flex-direction: column;
    gap: 0.625rem;
    background: var(--bg);
}

.chatbot-msg {
    max-width: 88%;
    padding: 0.625rem 0.875rem;
    border-radius: var(--radius);
    font-size: 0.875rem;
    line-height: 1.45;
    white-space: pre-wrap;
    word-break: break-word;
}

.chatbot-msg-user {
    align-self: flex-end;
    background: var(--primary);
    color: #fff;
    border-bottom-right-radius: 0.25rem;
}

.chatbot-msg-bot {
    align-self: flex-start;
    background: var(--card);
    color: var(--text);
    border: 1px solid var(--border);
    border-bottom-left-radius: 0.25rem;
}

.chatbot-msg-loading {
    opacity: 0.7;
    font-style: italic;
}

.chatbot-form {
    display: flex;
    gap: 0.5rem;
    padding: 0.75rem;
    border-top: 1px solid var(--border);
    background: var(--card);
}

.chatbot-input {
    flex: 1;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 0.5rem 0.75rem;
    font-size: 0.875rem;
    background: var(--bg);
    color: var(--text);
}

.chatbot-input:focus {
    outline: none;
    border-color: var(--primary);
}

.chatbot-send {
    font-size: 0.8125rem;
    padding: 0.5rem 0.875rem;
    white-space: nowrap;
}

@media (max-width: 480px) {
    .chatbot-root {
        right: 0.75rem;
        bottom: 0.75rem;
    }

    .chatbot-panel {
        width: calc(100vw - 1.5rem);
        height: min(28rem, calc(100vh - 6rem));
    }
}
