/* ============================================================
   Akuahidroponik - Sistem Manajemen
   Design: Simpel, Elegan, Mobile-First
   ============================================================ */

@import url('https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600;700&display=swap');

/* --- CSS Variables (Design Tokens) --- */
:root {
  --color-primary: #0d9488;
  --color-primary-dark: #0f766e;
  --color-primary-light: #ccfbf1;
  --color-secondary: #0ea5e9;
  --color-secondary-light: #e0f2fe;
  --color-accent: #f59e0b;
  --color-accent-light: #fef3c7;
  --color-danger: #ef4444;
  --color-danger-light: #fee2e2;
  --color-success: #22c55e;
  --color-success-light: #dcfce7;
  --color-bg: #f0fdf4;
  --color-bg-card: #ffffff;
  --color-bg-dark: #064e3b;
  --color-text: #1e293b;
  --color-text-muted: #64748b;
  --color-text-light: #94a3b8;
  --color-border: #e2e8f0;
  --color-border-light: #f1f5f9;
  --radius-sm: 8px;
  --radius-md: 12px;
  --radius-lg: 16px;
  --radius-xl: 24px;
  --shadow-sm: 0 1px 3px rgba(0,0,0,0.06), 0 1px 2px rgba(0,0,0,0.04);
  --shadow-md: 0 4px 12px rgba(0,0,0,0.07);
  --shadow-lg: 0 10px 30px rgba(0,0,0,0.1);
  --shadow-xl: 0 20px 50px rgba(0,0,0,0.12);
  --transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  --font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
}

/* --- Reset & Base --- */
*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html {
  scroll-behavior: smooth;
}

body {
  font-family: var(--font-family);
  background: var(--color-bg);
  color: var(--color-text);
  line-height: 1.6;
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
}

a {
  text-decoration: none;
  color: inherit;
  transition: var(--transition);
}

img {
  max-width: 100%;
  display: block;
}

/* --- Utility --- */
.container {
  max-width: 1100px;
  margin: 0 auto;
  padding: 0 20px;
}

.text-center { text-align: center; }
.text-muted { color: var(--color-text-muted); }
.mt-1 { margin-top: 8px; }
.mt-2 { margin-top: 16px; }
.mt-3 { margin-top: 24px; }
.mb-2 { margin-bottom: 16px; }
.mb-3 { margin-bottom: 24px; }

/* --- Navbar --- */
.navbar {
  background: rgba(255,255,255,0.85);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  border-bottom: 1px solid var(--color-border);
  padding: 0 20px;
  position: sticky;
  top: 0;
  z-index: 100;
}

.navbar-inner {
  max-width: 1100px;
  margin: 0 auto;
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: 64px;
}

.navbar-brand {
  display: flex;
  align-items: center;
  gap: 10px;
  font-weight: 700;
  font-size: 1.2rem;
  color: var(--color-primary-dark);
}

.navbar-brand .brand-icon {
  width: 36px;
  height: 36px;
  background: linear-gradient(135deg, var(--color-primary), var(--color-secondary));
  border-radius: var(--radius-sm);
  display: flex;
  align-items: center;
  justify-content: center;
  color: white;
  font-size: 1.1rem;
}

.navbar-menu {
  display: flex;
  align-items: center;
  gap: 6px;
  list-style: none;
}

.navbar-menu a {
  padding: 8px 16px;
  border-radius: var(--radius-sm);
  font-size: 0.9rem;
  font-weight: 500;
  color: var(--color-text-muted);
  transition: var(--transition);
}

.navbar-menu a:hover,
.navbar-menu a.active {
  background: var(--color-primary-light);
  color: var(--color-primary-dark);
}

.navbar-menu .btn-logout {
  background: var(--color-danger-light);
  color: var(--color-danger);
}
.navbar-menu .btn-logout:hover {
  background: var(--color-danger);
  color: white;
}

/* Mobile menu toggle */
.navbar-toggle {
  display: none;
  background: none;
  border: none;
  font-size: 1.5rem;
  cursor: pointer;
  color: var(--color-text);
  padding: 4px;
}

@media (max-width: 768px) {
  .navbar-toggle { display: block; }
  .navbar-menu {
    display: none;
    flex-direction: column;
    position: absolute;
    top: 64px;
    left: 0;
    right: 0;
    background: rgba(255,255,255,0.98);
    backdrop-filter: blur(20px);
    padding: 12px 20px;
    border-bottom: 1px solid var(--color-border);
    gap: 4px;
  }
  .navbar-menu.open { display: flex; }
  .navbar-menu a { padding: 12px 16px; width: 100%; }
}

/* --- Hero Section (Landing Page) --- */
.hero {
  background: linear-gradient(135deg, var(--color-bg-dark) 0%, #065f46 50%, #047857 100%);
  color: white;
  padding: 80px 20px;
  text-align: center;
  position: relative;
  overflow: hidden;
}

.hero::before {
  content: '';
  position: absolute;
  top: -50%;
  left: -50%;
  width: 200%;
  height: 200%;
  background: radial-gradient(circle at 30% 50%, rgba(14,165,233,0.15) 0%, transparent 50%),
              radial-gradient(circle at 70% 80%, rgba(245,158,11,0.1) 0%, transparent 50%);
  animation: heroFloat 20s ease-in-out infinite;
}

@keyframes heroFloat {
  0%, 100% { transform: translate(0, 0) rotate(0deg); }
  33% { transform: translate(2%, -1%) rotate(1deg); }
  66% { transform: translate(-1%, 1%) rotate(-1deg); }
}

.hero-content {
  position: relative;
  z-index: 1;
  max-width: 700px;
  margin: 0 auto;
}

.hero h1 {
  font-size: 2.8rem;
  font-weight: 700;
  margin-bottom: 16px;
  line-height: 1.2;
}

.hero p {
  font-size: 1.15rem;
  opacity: 0.85;
  margin-bottom: 32px;
  line-height: 1.7;
}

.hero-stats {
  display: flex;
  justify-content: center;
  gap: 40px;
  margin-top: 40px;
  flex-wrap: wrap;
}

.hero-stat {
  text-align: center;
}

.hero-stat .stat-number {
  font-size: 2.2rem;
  font-weight: 700;
  color: var(--color-accent);
}

.hero-stat .stat-label {
  font-size: 0.85rem;
  opacity: 0.7;
  margin-top: 4px;
}

/* --- Cards --- */
.card {
  background: var(--color-bg-card);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-sm);
  border: 1px solid var(--color-border);
  padding: 24px;
  transition: var(--transition);
}

.card:hover {
  box-shadow: var(--shadow-md);
  transform: translateY(-2px);
}

.card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 20px;
  padding-bottom: 16px;
  border-bottom: 1px solid var(--color-border-light);
}

.card-header h2 {
  font-size: 1.15rem;
  font-weight: 600;
}

.card-icon {
  width: 42px;
  height: 42px;
  border-radius: var(--radius-sm);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.2rem;
}

.card-icon.green { background: var(--color-primary-light); color: var(--color-primary); }
.card-icon.blue { background: var(--color-secondary-light); color: var(--color-secondary); }
.card-icon.yellow { background: var(--color-accent-light); color: var(--color-accent); }
.card-icon.red { background: var(--color-danger-light); color: var(--color-danger); }

/* --- Stat Cards Grid --- */
.stat-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
  gap: 20px;
  margin-bottom: 28px;
}

.stat-card {
  background: var(--color-bg-card);
  border-radius: var(--radius-md);
  padding: 24px;
  border: 1px solid var(--color-border);
  box-shadow: var(--shadow-sm);
  display: flex;
  align-items: center;
  gap: 16px;
  transition: var(--transition);
}

.stat-card:hover {
  box-shadow: var(--shadow-md);
  transform: translateY(-2px);
}

.stat-card .stat-info h3 {
  font-size: 0.8rem;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--color-text-muted);
  font-weight: 500;
  margin-bottom: 4px;
}

.stat-card .stat-info .stat-value {
  font-size: 1.5rem;
  font-weight: 700;
  color: var(--color-text);
}

/* --- Grid Layout for Panen Cards (Public Page) --- */
.panen-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
  gap: 20px;
  margin-top: 24px;
}

.panen-card {
  background: var(--color-bg-card);
  border-radius: var(--radius-md);
  padding: 24px;
  border: 1px solid var(--color-border);
  box-shadow: var(--shadow-sm);
  transition: var(--transition);
}

.panen-card:hover {
  box-shadow: var(--shadow-lg);
  transform: translateY(-3px);
}

.panen-card .panen-header {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 16px;
}

.panen-card .panen-avatar {
  width: 44px;
  height: 44px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--color-primary), var(--color-secondary));
  display: flex;
  align-items: center;
  justify-content: center;
  color: white;
  font-weight: 700;
  font-size: 1.1rem;
}

.panen-card .panen-name {
  font-weight: 600;
  font-size: 1rem;
}

.panen-card .panen-date {
  font-size: 0.8rem;
  color: var(--color-text-muted);
}

.panen-card .panen-detail {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 12px 0;
  border-top: 1px solid var(--color-border-light);
}

.panen-card .panen-komoditas {
  font-size: 0.85rem;
  color: var(--color-text-muted);
}

.panen-card .panen-result {
  font-size: 1.3rem;
  font-weight: 700;
  color: var(--color-primary);
}

/* --- Section --- */
.section {
  padding: 50px 20px;
}

.section-title {
  font-size: 1.6rem;
  font-weight: 700;
  margin-bottom: 8px;
  color: var(--color-text);
}

.section-subtitle {
  color: var(--color-text-muted);
  margin-bottom: 32px;
  font-size: 0.95rem;
}

/* --- Tables --- */
.table-wrapper {
  overflow-x: auto;
  border-radius: var(--radius-md);
}

table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.9rem;
}

thead th {
  background: var(--color-bg);
  padding: 12px 16px;
  text-align: left;
  font-weight: 600;
  font-size: 0.8rem;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--color-text-muted);
  border-bottom: 2px solid var(--color-border);
}

tbody td {
  padding: 14px 16px;
  border-bottom: 1px solid var(--color-border-light);
  vertical-align: middle;
}

tbody tr {
  transition: var(--transition);
}

tbody tr:hover {
  background: var(--color-primary-light);
}

/* --- Badges / Status --- */
.badge {
  display: inline-block;
  padding: 4px 12px;
  border-radius: 50px;
  font-size: 0.75rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.3px;
}

.badge-pembibitan { background: #fef3c7; color: #92400e; }
.badge-peremajaan { background: #e0f2fe; color: #0369a1; }
.badge-pendewasaan { background: #ede9fe; color: #6d28d9; }
.badge-panen { background: #dcfce7; color: #166534; }
.badge-masuk { background: #dcfce7; color: #166534; }
.badge-keluar { background: #fee2e2; color: #991b1b; }

/* --- Forms --- */
.form-group {
  margin-bottom: 20px;
}

.form-group label {
  display: block;
  font-weight: 500;
  font-size: 0.88rem;
  margin-bottom: 6px;
  color: var(--color-text);
}

.form-control {
  width: 100%;
  padding: 12px 16px;
  border: 1.5px solid var(--color-border);
  border-radius: var(--radius-sm);
  font-family: var(--font-family);
  font-size: 0.95rem;
  color: var(--color-text);
  background: var(--color-bg-card);
  transition: var(--transition);
  outline: none;
}

.form-control:focus {
  border-color: var(--color-primary);
  box-shadow: 0 0 0 3px rgba(13,148,136,0.12);
}

select.form-control {
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' fill='%2364748b' viewBox='0 0 16 16'%3E%3Cpath d='M8 11L3 6h10z'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 14px center;
  padding-right: 40px;
}

textarea.form-control {
  resize: vertical;
  min-height: 80px;
}

.form-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
}

@media (max-width: 600px) {
  .form-row { grid-template-columns: 1fr; }
}

/* --- Buttons --- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 11px 24px;
  border: none;
  border-radius: var(--radius-sm);
  font-family: var(--font-family);
  font-size: 0.9rem;
  font-weight: 600;
  cursor: pointer;
  transition: var(--transition);
  text-decoration: none;
}

.btn:active {
  transform: scale(0.97);
}

.btn-primary {
  background: linear-gradient(135deg, var(--color-primary), var(--color-primary-dark));
  color: white;
  box-shadow: 0 2px 8px rgba(13,148,136,0.3);
}
.btn-primary:hover {
  box-shadow: 0 4px 16px rgba(13,148,136,0.4);
  transform: translateY(-1px);
}

.btn-secondary {
  background: var(--color-bg);
  color: var(--color-text);
  border: 1.5px solid var(--color-border);
}
.btn-secondary:hover {
  background: var(--color-border-light);
}

.btn-danger {
  background: var(--color-danger);
  color: white;
}
.btn-danger:hover {
  background: #dc2626;
}

.btn-sm {
  padding: 7px 14px;
  font-size: 0.8rem;
}

.btn-block {
  width: 100%;
}

.btn-group {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

/* --- Auth Pages (Login / Register) --- */
.auth-wrapper {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  padding: 20px;
  background: linear-gradient(135deg, #ecfdf5 0%, #e0f2fe 100%);
}

.auth-card {
  background: var(--color-bg-card);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-xl);
  padding: 48px 40px;
  width: 100%;
  max-width: 420px;
  text-align: center;
}

.auth-card .auth-logo {
  width: 60px;
  height: 60px;
  background: linear-gradient(135deg, var(--color-primary), var(--color-secondary));
  border-radius: var(--radius-md);
  display: flex;
  align-items: center;
  justify-content: center;
  margin: 0 auto 24px;
  font-size: 1.6rem;
  color: white;
}

.auth-card h1 {
  font-size: 1.5rem;
  font-weight: 700;
  margin-bottom: 6px;
}

.auth-card .auth-subtitle {
  color: var(--color-text-muted);
  font-size: 0.9rem;
  margin-bottom: 32px;
}

.auth-card .form-group {
  text-align: left;
}

.auth-footer {
  margin-top: 24px;
  font-size: 0.85rem;
  color: var(--color-text-muted);
}

.auth-footer a {
  color: var(--color-primary);
  font-weight: 600;
}
.auth-footer a:hover {
  text-decoration: underline;
}

/* --- Flash / Alert Messages --- */
.flash {
  padding: 14px 20px;
  border-radius: var(--radius-sm);
  font-size: 0.9rem;
  font-weight: 500;
  margin-bottom: 20px;
  display: flex;
  align-items: center;
  gap: 10px;
  animation: flashIn 0.4s ease;
}

@keyframes flashIn {
  from { opacity: 0; transform: translateY(-10px); }
  to { opacity: 1; transform: translateY(0); }
}

.flash-success {
  background: var(--color-success-light);
  color: #166534;
  border: 1px solid #bbf7d0;
}

.flash-error {
  background: var(--color-danger-light);
  color: #991b1b;
  border: 1px solid #fecaca;
}

.flash-info {
  background: var(--color-secondary-light);
  color: #0369a1;
  border: 1px solid #bae6fd;
}

/* --- AI Chat Box --- */
.ai-box {
  background: linear-gradient(135deg, #f0fdf4, #ecfdf5);
  border: 2px dashed var(--color-primary);
  border-radius: var(--radius-md);
  padding: 24px;
  margin-bottom: 28px;
}

.ai-box-header {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 14px;
}

.ai-box-header .ai-icon {
  width: 36px;
  height: 36px;
  background: linear-gradient(135deg, var(--color-primary), var(--color-secondary));
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  color: white;
  font-size: 1rem;
}

.ai-box-header h3 {
  font-size: 1rem;
  font-weight: 600;
  color: var(--color-primary-dark);
}

.ai-box-header span {
  font-size: 0.8rem;
  color: var(--color-text-muted);
}

.ai-box .ai-input-row {
  display: flex;
  gap: 10px;
}

.ai-box .ai-input-row textarea {
  flex: 1;
  min-height: 48px;
  resize: none;
}

.ai-box .ai-examples {
  margin-top: 12px;
  font-size: 0.8rem;
  color: var(--color-text-muted);
}

.ai-box .ai-examples code {
  background: rgba(13,148,136,0.08);
  padding: 2px 6px;
  border-radius: 4px;
  font-size: 0.78rem;
}

.ai-response {
  margin-top: 14px;
  padding: 14px;
  background: white;
  border-radius: var(--radius-sm);
  border: 1px solid var(--color-border);
  font-size: 0.88rem;
  display: none;
}

.ai-response.show {
  display: block;
  animation: flashIn 0.4s ease;
}

.ai-loading {
  display: none;
  align-items: center;
  gap: 8px;
  margin-top: 12px;
  font-size: 0.85rem;
  color: var(--color-text-muted);
}

.ai-loading.show {
  display: flex;
}

.spinner {
  width: 18px;
  height: 18px;
  border: 2.5px solid var(--color-border);
  border-top-color: var(--color-primary);
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

/* --- Tabs (Manual / AI Toggle) --- */
.tabs {
  display: flex;
  gap: 4px;
  margin-bottom: 24px;
  background: var(--color-bg);
  padding: 4px;
  border-radius: var(--radius-sm);
  width: fit-content;
}

.tab-btn {
  padding: 10px 22px;
  border: none;
  background: transparent;
  border-radius: 6px;
  font-family: var(--font-family);
  font-size: 0.88rem;
  font-weight: 500;
  cursor: pointer;
  color: var(--color-text-muted);
  transition: var(--transition);
}

.tab-btn.active {
  background: white;
  color: var(--color-primary-dark);
  box-shadow: var(--shadow-sm);
}

.tab-content {
  display: none;
}

.tab-content.active {
  display: block;
  animation: flashIn 0.3s ease;
}

/* --- Page Content Wrapper --- */
.page-wrapper {
  padding: 28px 20px 60px;
}

.page-wrapper .container {
  max-width: 1100px;
}

.page-header {
  margin-bottom: 28px;
}

.page-header h1 {
  font-size: 1.5rem;
  font-weight: 700;
}

.page-header p {
  color: var(--color-text-muted);
  font-size: 0.9rem;
  margin-top: 4px;
}

/* --- Modal --- */
.modal-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.4);
  backdrop-filter: blur(4px);
  z-index: 200;
  align-items: center;
  justify-content: center;
  padding: 20px;
}

.modal-overlay.show {
  display: flex;
  animation: flashIn 0.3s ease;
}

.modal {
  background: var(--color-bg-card);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-xl);
  padding: 32px;
  width: 100%;
  max-width: 540px;
  max-height: 90vh;
  overflow-y: auto;
}

.modal h2 {
  font-size: 1.2rem;
  margin-bottom: 20px;
}

.modal-close {
  float: right;
  background: none;
  border: none;
  font-size: 1.3rem;
  cursor: pointer;
  color: var(--color-text-muted);
  padding: 4px;
}
.modal-close:hover {
  color: var(--color-danger);
}

/* --- Footer --- */
.footer {
  text-align: center;
  padding: 24px 20px;
  font-size: 0.8rem;
  color: var(--color-text-light);
  border-top: 1px solid var(--color-border);
  margin-top: 40px;
}

/* --- Empty State --- */
.empty-state {
  text-align: center;
  padding: 60px 20px;
  color: var(--color-text-muted);
}

.empty-state .empty-icon {
  font-size: 3rem;
  margin-bottom: 16px;
  opacity: 0.4;
}

.empty-state h3 {
  font-size: 1.1rem;
  font-weight: 600;
  color: var(--color-text);
  margin-bottom: 6px;
}

.empty-state p {
  font-size: 0.9rem;
}

/* --- Animations --- */
.fade-in {
  animation: fadeIn 0.5s ease;
}

@keyframes fadeIn {
  from { opacity: 0; transform: translateY(12px); }
  to { opacity: 1; transform: translateY(0); }
}

/* --- Scrollbar Custom --- */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--color-border); border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: var(--color-text-light); }
