/* ==========================================
   SilvestreStock — Stylesheet v2.0
   Nature-Tech Design System
   ========================================== */

:root {
    --primary-emerald: #10b981;
    --primary-emerald-hover: #34d399;
    --primary-dark: #064e3b;
    --secondary-moss: #365314;
    --accent-gold: #f59e0b;
    --accent-red: #ef4444;
    --bg-deep: #0c1220;
    --bg-mid: #111827;
    --bg-card: rgba(22, 33, 52, 0.8);
    --text-main: #f1f5f9;
    --text-muted: #64748b;
    --text-soft: #94a3b8;
    --glass-border: rgba(255, 255, 255, 0.08);
    --glass-bg: rgba(255, 255, 255, 0.04);
    --sidebar-width: 270px;
    --header-height: 80px;
    --font-main: 'Inter', system-ui, -apple-system, sans-serif;
    --radius-sm: 10px;
    --radius-md: 14px;
    --radius-lg: 20px;
    --transition: 0.25s cubic-bezier(0.4, 0, 0.2, 1);
}

/* ===== RESET & BASE ===== */
*, *::before, *::after {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

html { scroll-behavior: smooth; }

body {
    background-color: var(--bg-deep);
    color: var(--text-main);
    font-family: var(--font-main);
    min-height: 100vh;
    background-image:
        radial-gradient(ellipse at 5% 10%, rgba(16, 185, 129, 0.07) 0%, transparent 45%),
        radial-gradient(ellipse at 95% 85%, rgba(54, 83, 20, 0.07) 0%, transparent 45%),
        radial-gradient(ellipse at 50% 50%, rgba(16, 185, 129, 0.02) 0%, transparent 70%);
    overflow-x: hidden;
}

/* ===== LAYOUT ===== */
.app-wrapper {
    display: flex;
    min-height: 100vh;
}

/* ===== SIDEBAR ===== */
.sidebar {
    width: var(--sidebar-width);
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    padding: 1.5rem 1.25rem;
    flex-shrink: 0;
    position: sticky;
    top: 0;
    height: 100vh;
    overflow-y: auto;
    transition: transform var(--transition);
    z-index: 1000;
}

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

.brand-icon {
    width: 44px;
    height: 44px;
    background: linear-gradient(135deg, var(--primary-emerald), var(--primary-dark));
    border-radius: var(--radius-sm);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.3rem;
    color: white;
    flex-shrink: 0;
}

.btn-close-sidebar {
    background: none;
    border: none;
    color: var(--text-soft);
    font-size: 1.2rem;
    cursor: pointer;
    display: none;
}

/* Sidebar Search */
.sidebar-search { position: relative; }
.search-input-wrapper { position: relative; }
.search-icon {
    position: absolute;
    left: 12px;
    top: 50%;
    transform: translateY(-50%);
    color: var(--text-muted);
    font-size: 0.85rem;
}
.sidebar-search-input {
    width: 100%;
    background: var(--glass-bg);
    border: 1px solid var(--glass-border);
    border-radius: var(--radius-sm);
    color: var(--text-main);
    padding: 0.55rem 0.75rem 0.55rem 2.2rem;
    font-size: 0.82rem;
    outline: none;
    transition: border-color var(--transition);
}
.sidebar-search-input:focus {
    border-color: var(--primary-emerald);
    box-shadow: 0 0 0 3px rgba(16, 185, 129, 0.1);
}
.sidebar-search-input::placeholder { color: var(--text-muted); }

/* Nav Links */
#nav-menu { list-style: none; }
.nav-item { position: relative; }

.nav-link {
    color: var(--text-soft) !important;
    text-decoration: none;
    border-radius: var(--radius-sm) !important;
    transition: all var(--transition);
    font-size: 0.88rem;
    font-weight: 500;
}

.nav-link:hover {
    color: var(--text-main) !important;
    background: rgba(16, 185, 129, 0.08) !important;
    transform: translateX(4px);
}

.nav-link.active {
    color: var(--text-main) !important;
    background: rgba(16, 185, 129, 0.15) !important;
    border-color: var(--primary-emerald) !important;
    box-shadow: inset 3px 0 0 var(--primary-emerald);
}

.nav-link.active .nav-arrow { opacity: 1; color: var(--primary-emerald); }
.nav-arrow { opacity: 0; font-size: 0.75rem; transition: opacity var(--transition); }

.nav-badge {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    background: var(--accent-gold);
    color: #000;
    font-size: 0.65rem;
    font-weight: 700;
    width: 20px;
    height: 20px;
    border-radius: 50%;
    margin-left: auto;
    animation: pulse-badge 2s infinite;
}
.alert-badge { background: var(--accent-red); color: white; }

@keyframes pulse-badge {
    0%, 100% { box-shadow: 0 0 0 0 rgba(239, 68, 68, 0.5); }
    50% { box-shadow: 0 0 0 5px rgba(239, 68, 68, 0); }
}

/* Avatar */
.avatar-circle {
    width: 38px;
    height: 38px;
    border-radius: 50%;
    background: linear-gradient(135deg, var(--primary-emerald), var(--primary-dark));
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.75rem;
    font-weight: 700;
    color: white;
    flex-shrink: 0;
}

.user-profile {
    cursor: pointer;
    transition: all var(--transition);
}
.user-profile:hover {
    border-color: var(--primary-emerald) !important;
    background: rgba(16, 185, 129, 0.06) !important;
}

/* ===== MAIN CONTENT ===== */
.main-content {
    flex: 1;
    padding: 1.5rem;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 0;
    min-width: 0;
}

/* ===== HEADER ===== */
.app-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1.75rem;
    padding: 0.5rem 0;
}

.header-left {
    display: flex;
    align-items: center;
    gap: 1rem;
}

.header-actions {
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.btn-hamburger {
    background: none;
    border: none;
    color: var(--text-soft);
    cursor: pointer;
    padding: 0.4rem;
    border-radius: 8px;
    transition: color var(--transition);
}
.btn-hamburger:hover { color: var(--text-main); }

.btn-icon {
    position: relative;
    width: 42px;
    height: 42px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--text-soft);
    border-radius: var(--radius-sm) !important;
    transition: all var(--transition);
}
.btn-icon:hover { color: var(--text-main); }

.notif-dot {
    position: absolute;
    top: 8px;
    right: 8px;
    width: 8px;
    height: 8px;
    background: var(--accent-red);
    border-radius: 50%;
    border: 2px solid var(--bg-deep);
}

/* ===== GLASSMORPHISM ===== */
.glass-panel {
    background: var(--glass-bg);
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
    border: 1px solid var(--glass-border);
    border-radius: var(--radius-lg);
    box-shadow: 0 8px 40px rgba(0, 0, 0, 0.35);
}

.glass-card {
    background: var(--bg-card);
    backdrop-filter: blur(10px);
    border: 1px solid var(--glass-border);
    border-radius: var(--radius-md);
    transition: transform var(--transition), box-shadow var(--transition), border-color var(--transition);
}

.glass-card:hover {
    transform: translateY(-3px);
    box-shadow: 0 12px 40px rgba(16, 185, 129, 0.15);
    border-color: rgba(16, 185, 129, 0.3);
}

/* ===== STAT CARDS ===== */
.stat-card {
    position: relative;
    overflow: hidden;
}
.stat-card::before {
    content: '';
    position: absolute;
    top: 0; right: 0;
    width: 80px; height: 80px;
    background: radial-gradient(circle, rgba(16, 185, 129, 0.08) 0%, transparent 70%);
    border-radius: 50%;
}
.stat-icon { font-size: 1.5rem; }
.stat-card .display-6 { font-size: 2rem !important; }

/* ===== PAGE SECTIONS ===== */
.page-section {
    display: none;
    flex-direction: column;
    gap: 1rem;
    animation: fadeIn 0.4s ease forwards;
}
.page-section.active {
    display: flex;
}

/* ===== BUTTON STYLES ===== */
.btn-emerald {
    background: linear-gradient(135deg, var(--primary-emerald), #059669);
    color: #fff !important;
    font-weight: 600;
    border: none;
    transition: all var(--transition);
}
.btn-emerald:hover {
    background: linear-gradient(135deg, var(--primary-emerald-hover), var(--primary-emerald));
    transform: translateY(-1px);
    box-shadow: 0 6px 20px rgba(16, 185, 129, 0.35);
}

/* ===== TABLE ===== */
.table-dark {
    --bs-table-bg: transparent;
    --bs-table-hover-bg: rgba(16, 185, 129, 0.06);
    border-color: var(--glass-border);
}
.table thead th {
    color: var(--text-muted);
    font-size: 0.78rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    padding: 0.85rem 1rem;
    border-bottom: 1px solid var(--glass-border);
    background: rgba(16, 185, 129, 0.04);
}
.table tbody td {
    padding: 0.85rem 1rem;
    font-size: 0.875rem;
    border-bottom: 1px solid rgba(255,255,255,0.04);
    vertical-align: middle;
}

.border-glass { border-color: var(--glass-border) !important; }

/* ===== BADGES / STATUS ===== */
.status-badge {
    display: inline-block;
    padding: 0.25em 0.7em;
    border-radius: 50px;
    font-size: 0.72rem;
    font-weight: 600;
}
.status-vulneravel   { background: rgba(245,158,11,0.15); color: #f59e0b; }
.status-perigo       { background: rgba(239,68,68,0.15);  color: #ef4444; }
.status-quase-ameacada { background: rgba(251, 191, 36, 0.15); color: #fbbf24; }
.status-pouco-preocupante { background: rgba(16,185,129,0.15); color: #10b981; }
.status-critico      { background: rgba(239,68,68,0.15);  color: #ef4444; }

.health-badge {
    display: inline-block;
    padding: 0.2em 0.6em;
    border-radius: 50px;
    font-size: 0.72rem;
    font-weight: 500;
}
.health-excelente { background: rgba(16,185,129,0.15); color: #10b981; }
.health-bom       { background: rgba(59,130,246,0.15); color: #60a5fa; }
.health-monitorado{ background: rgba(245,158,11,0.15); color: #f59e0b; }
.health-critico   { background: rgba(239,68,68,0.15);  color: #ef4444; }

/* ===== ACTIVITY FEED ===== */
.activity-feed .icon-circle {
    width: 34px;
    height: 34px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    flex-shrink: 0;
    font-size: 0.9rem;
    background: rgba(255,255,255,0.06);
}

/* ===== CHART SELECT ===== */
.chart-select {
    background: var(--glass-bg) !important;
    color: var(--text-main) !important;
    border: 1px solid var(--glass-border) !important;
    border-radius: var(--radius-sm) !important;
    font-size: 0.82rem;
}
.chart-select option { background: var(--bg-mid); color: var(--text-main); }

/* ===== GEO MAP ===== */
.geo-map-container {
    background: var(--glass-bg);
    border: 1px solid var(--glass-border);
    border-radius: var(--radius-md);
    height: 420px;
    position: relative;
    overflow: hidden;
    display: flex;
    align-items: center;
    justify-content: center;
}

.geo-map-svg {
    width: 100%;
    height: 100%;
    object-fit: contain;
}

.geo-dot {
    cursor: pointer;
    transition: all 0.2s;
}
.geo-dot:hover circle { filter: brightness(1.5); }

.geo-label {
    font-family: var(--font-main);
    font-size: 11px;
    fill: var(--text-soft);
    pointer-events: none;
}

.geo-species-item {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.7rem;
    border-radius: var(--radius-sm);
    border: 1px solid var(--glass-border);
    background: var(--glass-bg);
    transition: all var(--transition);
    cursor: pointer;
}
.geo-species-item:hover {
    border-color: var(--primary-emerald);
    background: rgba(16,185,129,0.06);
}
.geo-species-dot {
    width: 12px;
    height: 12px;
    border-radius: 50%;
    flex-shrink: 0;
}

/* ===== STOCK PROGRESS BAR ===== */
.stock-bar-wrap { display: flex; align-items: center; gap: 0.5rem; }
.stock-bar-bg {
    flex: 1;
    height: 6px;
    background: rgba(255,255,255,0.08);
    border-radius: 3px;
    overflow: hidden;
}
.stock-bar-fill {
    height: 100%;
    border-radius: 3px;
    transition: width 0.6s ease;
}
.stock-ok    { background: var(--primary-emerald); }
.stock-low   { background: var(--accent-gold); }
.stock-crit  { background: var(--accent-red); }

/* ===== ALERT CARDS ===== */
.alert-card {
    display: flex;
    gap: 1rem;
    padding: 1rem;
    border-radius: var(--radius-md);
    border: 1px solid;
    transition: all var(--transition);
}
.alert-card.urgente {
    border-color: rgba(239,68,68,0.3);
    background: rgba(239,68,68,0.06);
}
.alert-card.atencao {
    border-color: rgba(245,158,11,0.3);
    background: rgba(245,158,11,0.06);
}
.alert-card .alert-icon {
    font-size: 1.4rem;
    flex-shrink: 0;
}
.alert-card.urgente .alert-icon { color: var(--accent-red); }
.alert-card.atencao .alert-icon { color: var(--accent-gold); }

.btn-resolve {
    background: none;
    border: 1px solid rgba(16,185,129,0.3);
    color: var(--primary-emerald);
    border-radius: 6px;
    padding: 0.2rem 0.7rem;
    font-size: 0.75rem;
    cursor: pointer;
    transition: all var(--transition);
    flex-shrink: 0;
    align-self: flex-start;
}
.btn-resolve:hover {
    background: var(--primary-emerald);
    color: var(--bg-deep);
}

/* ===== MODAL ===== */
.modal-content {
    color: var(--text-main);
}
.modal-header { border-color: var(--glass-border) !important; }
.modal-footer { border-color: var(--glass-border) !important; }

.glass-input {
    background: rgba(255,255,255,0.05) !important;
    border: 1px solid var(--glass-border) !important;
    color: var(--text-main) !important;
    border-radius: var(--radius-sm) !important;
    transition: border-color var(--transition);
}
.glass-input:focus {
    border-color: var(--primary-emerald) !important;
    box-shadow: 0 0 0 3px rgba(16, 185, 129, 0.12) !important;
    background: rgba(255,255,255,0.07) !important;
}
.glass-input::placeholder { color: var(--text-muted) !important; }
.glass-input option { background: var(--bg-mid); color: var(--text-main); }

/* ===== INVENTORY SEARCH ===== */
.inventory-search-input {
    background: var(--glass-bg) !important;
    border: 1px solid var(--glass-border) !important;
    color: var(--text-main) !important;
    border-radius: var(--radius-sm) !important;
    max-width: 280px;
}
.inventory-search-input:focus {
    border-color: var(--primary-emerald) !important;
    box-shadow: 0 0 0 3px rgba(16,185,129,0.10) !important;
}

/* ===== TOAST ===== */
#app-toast {
    min-width: 280px;
}

/* ===== ANIMATIONS ===== */
@keyframes fadeIn {
    from { opacity: 0; transform: translateY(16px); }
    to   { opacity: 1; transform: translateY(0); }
}

@keyframes slideIn {
    from { opacity: 0; transform: translateX(-20px); }
    to   { opacity: 1; transform: translateX(0); }
}

.animate-fade {
    opacity: 0;
    animation: fadeIn 0.6s cubic-bezier(0.4, 0, 0.2, 1) forwards;
}

/* ===== SIDEBAR OVERLAY (mobile) ===== */
.sidebar-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.6);
    z-index: 999;
    backdrop-filter: blur(4px);
}

/* ===== UTILITY ===== */
.text-emerald  { color: var(--primary-emerald) !important; }
.text-accent   { color: var(--accent-gold) !important; }
.text-danger-c { color: var(--accent-red) !important; }
.bg-emerald    { background-color: var(--primary-emerald) !important; }
.bg-emerald-light { background-color: rgba(16, 185, 129, 0.1) !important; }
.border-accent { border-color: rgba(245, 158, 11, 0.4) !important; }
.smaller       { font-size: 0.72rem; }

.text-gradient {
    background: linear-gradient(135deg, var(--primary-emerald) 0%, #6ee7b7 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

/* ===== SCROLLBAR ===== */
::-webkit-scrollbar { width: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--glass-border); border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: var(--primary-emerald); }

/* ===== RESPONSIVE ===== */
@media (max-width: 991.98px) {
    .sidebar {
        position: fixed;
        left: 0; top: 0;
        height: 100%;
        transform: translateX(-100%);
        z-index: 1000;
    }
    .sidebar.open {
        transform: translateX(0);
    }
    .sidebar-overlay.open { display: block; }
    .btn-close-sidebar { display: block !important; }
    .main-content { padding: 1rem; }
}

@media (max-width: 575.98px) {
    .header-actions .btn-icon { display: none; }
    .stat-card .display-6 { font-size: 1.5rem !important; }
}
