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

:root {
  --green-dark: #2d5016;
  --green: #4a7c28;
  --green-light: #6fa03e;
  --green-pale: #e8f5d8;
  --gold: #c8a432;
  --gold-dark: #a8871a;
  --brown: #8b6914;
  --bg: #f5f3ef;
  --bg-card: #ffffff;
  --text: #2c2c2c;
  --text-light: #6b6b6b;
  --border: #e0ddd6;
  --radius: 10px;
  --shadow: 0 2px 8px rgba(0,0,0,0.08);
  --shadow-lg: 0 8px 32px rgba(0,0,0,0.12);
  --sidebar-w: 240px;
  --topbar-h: 56px;
}

body { font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif; background: var(--bg); color: var(--text); line-height: 1.6; min-height: 100vh; }
a { color: var(--green); text-decoration: none; }
a:hover { text-decoration: underline; }
.screen { display: none; }
.screen.active { display: block; }
.hidden { display: none !important; }

/* ============================
   LANDING
   ============================ */
.hero {
  min-height: 90vh;
  background-size: cover;
  background-position: center;
  display: flex;
  flex-direction: column;
}
.landing-nav {
  display: flex; justify-content: space-between; align-items: center;
  padding: 1.25rem 3rem;
  position: relative; z-index: 2;
}
.landing-logo { font-size: 1.6rem; font-weight: 800; color: #fff; }
.landing-logo span { color: var(--gold); }
.nav-actions { display: flex; gap: 0.75rem; }
.hero-spacer { flex: 1; }

/* Animal Showcase */
.animals-showcase {
  padding: 4rem 3rem;
  background: var(--green-dark);
  color: #fff;
  text-align: center;
}
.animals-showcase h2 { font-size: 2rem; margin-bottom: 0.5rem; }
.section-sub { color: rgba(255,255,255,0.75); margin-bottom: 2rem; font-size: 1.05rem; }

.animal-icons-grid {
  display: flex; flex-wrap: wrap; justify-content: center; gap: 1rem;
  max-width: 900px; margin: 0 auto;
}
.animal-icon-card {
  display: flex; flex-direction: column; align-items: center;
  gap: 0.3rem;
  background: rgba(255,255,255,0.1);
  border-radius: var(--radius);
  padding: 1rem 1.25rem;
  min-width: 90px;
  transition: all 0.2s;
  cursor: default;
}
.animal-icon-card:hover { background: rgba(255,255,255,0.2); transform: translateY(-3px); }
.animal-icon-card span { font-size: 2rem; }
.animal-icon-card small { font-size: 0.75rem; opacity: 0.9; }

.animal-icons-grid.small { gap: 0.5rem; }
.animal-icons-grid.small .animal-icon-card {
  padding: 0.5rem 0.75rem; min-width: 70px;
  background: var(--green-pale); cursor: pointer;
}
.animal-icons-grid.small .animal-icon-card:hover { background: var(--green); color: #fff; }
.animal-icons-grid.small .animal-icon-card span { font-size: 1.5rem; }
.animal-icons-grid.small .animal-icon-card small { font-size: 0.65rem; color: var(--text); }
.animal-icons-grid.small .animal-icon-card.added { opacity: 0.4; pointer-events: none; }

/* Features */
.features-section { padding: 5rem 3rem; background: #fff; text-align: center; }
.features-section h2 { font-size: 2rem; color: var(--green-dark); margin-bottom: 3rem; }
.features-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(280px, 1fr)); gap: 2rem; max-width: 1100px; margin: 0 auto; }
.feature-card { padding: 2rem; border-radius: var(--radius); border: 1px solid var(--border); text-align: left; transition: box-shadow 0.2s; }
.feature-card:hover { box-shadow: var(--shadow-lg); }
.feature-icon { font-size: 2rem; margin-bottom: 0.75rem; }
.feature-card h3 { font-size: 1.1rem; color: var(--green-dark); margin-bottom: 0.5rem; }
.feature-card p { color: var(--text-light); font-size: 0.95rem; }

/* How */
.how-section { padding: 5rem 3rem; background: var(--bg); text-align: center; }
.how-section h2 { font-size: 2rem; color: var(--green-dark); margin-bottom: 3rem; }
.steps-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(250px, 1fr)); gap: 2rem; max-width: 900px; margin: 0 auto 2.5rem; }
.step-num { width: 48px; height: 48px; background: var(--green); color: #fff; border-radius: 50%; display: flex; align-items: center; justify-content: center; font-size: 1.3rem; font-weight: 800; margin: 0 auto 1rem; }
.step h3 { color: var(--green-dark); margin-bottom: 0.5rem; }
.step p { color: var(--text-light); font-size: 0.95rem; }
.cta-center { text-align: center; }

.landing-footer { padding: 2rem 3rem; background: var(--green-dark); color: rgba(255,255,255,0.7); text-align: center; font-size: 0.85rem; }

/* ============================
   BUTTONS
   ============================ */
.btn { padding: 0.6rem 1.2rem; border: 2px solid var(--border); border-radius: 6px; background: var(--bg-card); cursor: pointer; font-size: 0.9rem; font-weight: 600; transition: all 0.2s; text-decoration: none; display: inline-block; text-align: center; }
.btn:hover { text-decoration: none; transform: translateY(-1px); }
.btn-primary { background: var(--green); color: #fff; border-color: var(--green); }
.btn-primary:hover { background: var(--green-dark); border-color: var(--green-dark); color: #fff; }
.btn-gold { background: var(--gold); color: #fff; border-color: var(--gold); }
.btn-gold:hover { background: var(--gold-dark); border-color: var(--gold-dark); color: #fff; }
.btn-outline-light { background: transparent; color: #fff; border-color: rgba(255,255,255,0.5); }
.btn-outline-light:hover { border-color: #fff; color: #fff; }
.btn-danger { background: #dc3545; color: #fff; border-color: #dc3545; }
.btn-danger:hover { background: #b02a37; }
.btn-full { width: 100%; }
.btn-lg { padding: 0.85rem 1.8rem; font-size: 1rem; }
.btn-sm { padding: 0.35rem 0.75rem; font-size: 0.8rem; }
.btn-upload { cursor: pointer; }

/* ============================
   AUTH MODAL
   ============================ */
.auth-modal { max-width: 420px; width: 90%; }
.auth-modal-header { text-align: center; padding: 1.5rem 1.5rem 0; }
.logo-sm { font-size: 1.5rem; font-weight: 800; color: var(--green-dark); }
.logo-sm span { color: var(--gold); }
.auth-form { padding: 1.5rem; }
.auth-form h2 { margin-bottom: 1.25rem; color: var(--green-dark); font-size: 1.3rem; }
.auth-switch { text-align: center; margin-top: 1rem; color: var(--text-light); font-size: 0.9rem; }
.slug-input { display: flex; align-items: center; }
.slug-input input { border-radius: 6px 0 0 6px; flex: 1; }
.slug-suffix { background: var(--green-pale); border: 2px solid var(--border); border-left: none; padding: 0.6rem 0.75rem; border-radius: 0 6px 6px 0; font-size: 0.85rem; color: var(--text-light); white-space: nowrap; }
.slug-hint { color: var(--text-light); font-size: 0.8rem; }
.error-msg { background: #fde8e8; color: #c53030; padding: 0.75rem 1rem; border-radius: var(--radius); margin: 0 1.5rem 1rem; text-align: center; font-size: 0.9rem; }

/* ============================
   FORMS
   ============================ */
.form-group { margin-bottom: 1rem; }
.form-group label { display: block; font-weight: 600; margin-bottom: 0.25rem; font-size: 0.9rem; }
.page-desc { color: var(--text-light); margin-bottom: 1.5rem; }
.input, .auth-form input, .auth-form textarea, .auth-form select { width: 100%; padding: 0.6rem 0.75rem; border: 2px solid var(--border); border-radius: 6px; font-size: 1rem; transition: border-color 0.2s; background: #fff; }
.input:focus, .auth-form input:focus { outline: none; border-color: var(--green); }
.input-sm { padding: 0.4rem 0.6rem; border: 2px solid var(--border); border-radius: 6px; font-size: 0.85rem; background: #fff; }
.form-row { display: flex; gap: 0.5rem; align-items: center; margin-top: 0.5rem; }
.form-row-2col { display: grid; grid-template-columns: 1fr 1fr; gap: 1rem; }

/* ============================
   APP LAYOUT
   ============================ */
#main-screen { display: none; }
#main-screen.active { display: grid; grid-template-columns: var(--sidebar-w) 1fr; grid-template-rows: var(--topbar-h) 1fr; min-height: 100vh; }
.top-bar { grid-column: 1 / -1; background: var(--green-dark); color: #fff; display: flex; align-items: center; padding: 0 1.5rem; gap: 1rem; z-index: 10; }
.top-bar h1 { font-size: 1.1rem; flex: 1; }
.top-right { display: flex; align-items: center; gap: 0.75rem; }
#user-name { font-size: 0.85rem; opacity: 0.9; }
.menu-btn { display: none; background: none; border: none; color: #fff; font-size: 1.5rem; cursor: pointer; }
.role-badge { font-size: 0.7rem; padding: 0.2rem 0.5rem; border-radius: 12px; font-weight: 700; text-transform: uppercase; letter-spacing: 0.5px; }
.role-super_admin { background: #e74c3c; color: #fff; }
.role-ranch_manager { background: var(--gold); color: #fff; }
.role-ranch_hand { background: #3498db; color: #fff; }

/* Sidebar */
.sidebar { background: #fff; border-right: 1px solid var(--border); overflow-y: auto; }
.sidebar-header { padding: 1.25rem; border-bottom: 1px solid var(--border); }
.ranch-name { font-weight: 700; color: var(--green-dark); font-size: 1rem; }
.ranch-slug { font-size: 0.8rem; color: var(--text-light); }
.nav-list { list-style: none; padding: 0.5rem 0; }
.nav-link { display: flex; align-items: center; gap: 0.75rem; padding: 0.7rem 1.25rem; color: var(--text); font-weight: 500; transition: all 0.15s; border-left: 3px solid transparent; }
.nav-link:hover { background: var(--green-pale); text-decoration: none; }
.nav-link.active { background: var(--green-pale); color: var(--green-dark); border-left-color: var(--green); font-weight: 700; }
.nav-icon { font-size: 1.1rem; width: 1.5rem; text-align: center; }
.nav-divider { border-top: 1px solid var(--border); margin: 0.5rem 0; }

/* Content */
.content { padding: 1.5rem; overflow-y: auto; max-height: calc(100vh - var(--topbar-h)); }
.page { display: none; }
.page.active { display: block; }
.page-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 1.5rem; }
.page-header h2 { font-size: 1.5rem; color: var(--green-dark); }

/* Stats */
.stats-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 1rem; margin-bottom: 2rem; }
.stat-card { background: var(--bg-card); border-radius: var(--radius); padding: 1.25rem; box-shadow: var(--shadow); text-align: center; }
.stat-card.clickable { cursor: pointer; transition: transform 0.15s, box-shadow 0.15s; }
.stat-card.clickable:hover { transform: translateY(-3px); box-shadow: var(--shadow-lg); border-bottom: 3px solid var(--green); }
.stat-number { font-size: 2rem; font-weight: 800; color: var(--green-dark); }
.stat-label { color: var(--text-light); font-size: 0.85rem; margin-top: 0.25rem; }
.dashboard-sections { display: grid; grid-template-columns: repeat(auto-fit, minmax(300px, 1fr)); gap: 1.5rem; }
.dash-section { background: var(--bg-card); border-radius: var(--radius); padding: 1.25rem; box-shadow: var(--shadow); }
.dash-section h3 { margin-bottom: 1rem; color: var(--green-dark); font-size: 1rem; }
.empty-state { color: var(--text-light); font-style: italic; padding: 1rem 0; }

/* ============================
   ANIMAL CARDS
   ============================ */
.card-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: 1rem; }
.animal-card {
  background: var(--bg-card); border-radius: var(--radius); padding: 0;
  box-shadow: var(--shadow); cursor: pointer;
  transition: transform 0.15s, box-shadow 0.15s;
  overflow: hidden; border: 1px solid var(--border);
}
.animal-card:hover { transform: translateY(-3px); box-shadow: var(--shadow-lg); }
.animal-card-photo { width: 100%; height: 160px; object-fit: cover; background: var(--green-pale); display: flex; align-items: center; justify-content: center; font-size: 3rem; }
.animal-card-photo img { width: 100%; height: 160px; object-fit: cover; }
.animal-card-body { padding: 1rem; }
.animal-card .card-name { font-weight: 700; font-size: 1.1rem; }
.animal-card .card-meta { color: var(--text-light); font-size: 0.85rem; margin-top: 0.2rem; }
.card-tags { display: flex; gap: 0.4rem; margin-top: 0.5rem; flex-wrap: wrap; }
.card-status { display: inline-block; padding: 0.15rem 0.5rem; border-radius: 12px; font-size: 0.7rem; font-weight: 600; }
.card-type-tag { display: inline-block; padding: 0.15rem 0.5rem; border-radius: 12px; font-size: 0.7rem; font-weight: 600; background: #e8edf3; color: #3a5a7c; }
.status-active { background: var(--green-pale); color: var(--green-dark); }
.status-sold { background: #fff3cd; color: #856404; }
.status-deceased { background: #f5f5f5; color: #6b6b6b; }

/* ============================
   ANIMAL DETAIL
   ============================ */
.animal-profile { display: flex; gap: 1.5rem; margin-bottom: 1.5rem; flex-wrap: wrap; }
.animal-photo-area { text-align: center; }
.animal-photo-placeholder {
  width: 220px; height: 220px; border-radius: var(--radius);
  background: var(--green-pale); display: flex; align-items: center; justify-content: center;
  color: var(--text-light); font-size: 0.9rem; overflow: hidden;
  border: 2px dashed var(--border); margin-bottom: 0.5rem;
}
.animal-photo-placeholder img { width: 100%; height: 100%; object-fit: cover; }

/* Image drop zones */
.img-drop-zone {
  cursor: pointer; outline: none;
  transition: border-color 0.2s, background 0.2s;
}
.img-drop-zone:focus, .img-drop-zone.drag-over {
  border-color: var(--green); background: rgba(74,124,40,0.08);
}
.img-drop-zone .drop-hint {
  text-align: center; color: var(--text-light); pointer-events: none;
}
.img-drop-zone .drop-hint small { font-size: 0.75rem; opacity: 0.7; }
.img-drop-zone.has-image .drop-hint { display: none; }
.img-drop-small {
  width: 100%; height: 120px; border: 2px dashed var(--border);
  border-radius: var(--radius); display: flex; align-items: center; justify-content: center;
  background: var(--green-pale); overflow: hidden; position: relative;
}
.img-drop-small img { width: 100%; height: 100%; object-fit: cover; }
.img-drop-small .img-remove {
  position: absolute; top: 4px; right: 4px;
  background: rgba(0,0,0,0.6); color: #fff; border: none;
  border-radius: 50%; width: 22px; height: 22px; cursor: pointer;
  font-size: 0.75rem; display: none; align-items: center; justify-content: center;
}
.img-drop-small.has-image .img-remove { display: flex; }
.animal-info-card {
  flex: 1; min-width: 260px;
  background: var(--bg-card); border-radius: var(--radius); padding: 1.25rem;
  box-shadow: var(--shadow);
}
.info-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 0.75rem; }
.info-item label { font-size: 0.75rem; color: var(--text-light); text-transform: uppercase; letter-spacing: 0.5px; }
.info-item .info-val { font-weight: 600; font-size: 1rem; }

/* Tabs */
.tab-bar { display: flex; gap: 0; border-bottom: 2px solid var(--border); margin-bottom: 1.5rem; }
.tab { padding: 0.7rem 1.25rem; border: none; background: none; cursor: pointer; font-size: 0.9rem; font-weight: 600; color: var(--text-light); border-bottom: 3px solid transparent; margin-bottom: -2px; transition: all 0.15s; }
.tab:hover { color: var(--green); }
.tab.active { color: var(--green-dark); border-bottom-color: var(--green); }
.tab-pane { display: none; }
.tab-pane.active { display: block; }
.tab-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 1rem; }
.tab-header h3 { font-size: 1.1rem; color: var(--green-dark); }

/* Records in tabs */
.record-card { background: var(--bg-card); border-radius: var(--radius); padding: 1rem; margin-bottom: 0.75rem; box-shadow: var(--shadow); display: flex; justify-content: space-between; align-items: flex-start; gap: 1rem; border-left: 4px solid var(--green); }
.record-card .rec-icon { font-size: 1.5rem; }
.record-card .rec-info { flex: 1; }
.record-card .rec-title { font-weight: 700; font-size: 0.95rem; }
.record-card .rec-meta { font-size: 0.8rem; color: var(--text-light); }
.record-card .rec-amount { font-weight: 700; color: var(--green-dark); }

/* ============================
   TASKS
   ============================ */
.task-filters { display: flex; gap: 0.5rem; margin-bottom: 1.5rem; flex-wrap: wrap; }
.task-filter-btn { padding: 0.4rem 1rem; border: 2px solid var(--border); border-radius: 20px; background: #fff; cursor: pointer; font-size: 0.85rem; font-weight: 600; color: var(--text-light); transition: all 0.15s; }
.task-filter-btn.active, .task-filter-btn:hover { background: var(--green); color: #fff; border-color: var(--green); }

.task-card { background: var(--bg-card); border-radius: var(--radius); padding: 1rem; margin-bottom: 0.75rem; box-shadow: var(--shadow); display: flex; align-items: center; gap: 1rem; }
.task-check { width: 22px; height: 22px; border: 2px solid var(--border); border-radius: 50%; cursor: pointer; flex-shrink: 0; display: flex; align-items: center; justify-content: center; transition: all 0.15s; }
.task-check:hover { border-color: var(--green); }
.task-check.done { background: var(--green); border-color: var(--green); color: #fff; font-size: 0.75rem; }
.task-body { flex: 1; }
.task-title { font-weight: 600; }
.task-title.done { text-decoration: line-through; color: var(--text-light); }
.task-meta { font-size: 0.8rem; color: var(--text-light); }
.priority-high { border-left: 4px solid #f39c12; }
.priority-urgent { border-left: 4px solid #e74c3c; }

.task-presets { display: flex; flex-wrap: wrap; gap: 0.4rem; }
.task-preset { padding: 0.3rem 0.7rem; border-radius: 20px; background: var(--green-pale); border: 1px solid var(--border); cursor: pointer; font-size: 0.8rem; transition: all 0.15s; }
.task-preset:hover { background: var(--green); color: #fff; }

/* ============================
   RECORDS LIST / SETTINGS
   ============================ */
.records-list .record-item { background: var(--bg-card); border-radius: var(--radius); padding: 1rem; margin-bottom: 0.75rem; box-shadow: var(--shadow); display: flex; justify-content: space-between; align-items: center; }
.record-item .record-info { flex: 1; }
.record-item .record-name { font-weight: 700; }
.record-item .record-meta { font-size: 0.85rem; color: var(--text-light); }
.record-item .record-actions { display: flex; gap: 0.5rem; }
.settings-section { background: var(--bg-card); border-radius: var(--radius); padding: 1.5rem; box-shadow: var(--shadow); margin-bottom: 1.5rem; }
.settings-section h3 { margin-bottom: 1rem; color: var(--green-dark); }
.type-tag { display: inline-flex; align-items: center; gap: 0.4rem; background: var(--green-pale); padding: 0.4rem 0.75rem; border-radius: 20px; font-size: 0.85rem; margin: 0.25rem; }
.type-picker { margin-top: 1rem; }
.type-picker h4 { font-size: 0.9rem; color: var(--text-light); margin-bottom: 0.5rem; }
.filters { display: flex; gap: 0.75rem; margin-bottom: 1.5rem; flex-wrap: wrap; }

/* ============================
   MODAL
   ============================ */
.modal-overlay { position: fixed; inset: 0; background: rgba(0,0,0,0.5); display: flex; align-items: center; justify-content: center; z-index: 100; }
.modal { background: var(--bg-card); border-radius: var(--radius); width: 90%; max-width: 500px; max-height: 90vh; overflow-y: auto; box-shadow: var(--shadow-lg); position: relative; }
.modal-lg { max-width: 600px; }
.modal-header { display: flex; justify-content: space-between; align-items: center; padding: 1rem 1.5rem; border-bottom: 1px solid var(--border); }
.modal-header h2 { font-size: 1.2rem; }
.modal-close { background: none; border: none; font-size: 1.5rem; cursor: pointer; color: var(--text-light); position: absolute; top: 1rem; right: 1rem; }
.modal-body { padding: 1.5rem; }
.modal-footer { padding: 1rem 1.5rem; border-top: 1px solid var(--border); display: flex; justify-content: flex-end; gap: 0.75rem; }

/* ============================
   MOBILE
   ============================ */
@media (max-width: 768px) {
  .hero { min-height: 60vh; }
  .landing-nav { padding: 1rem 1.5rem; }
  .features-section, .how-section, .animals-showcase { padding: 3rem 1.5rem; }
  .form-row-2col { grid-template-columns: 1fr; }
  #main-screen.active { grid-template-columns: 1fr; }
  .sidebar { position: fixed; top: var(--topbar-h); left: 0; bottom: 0; width: var(--sidebar-w); z-index: 20; transform: translateX(-100%); transition: transform 0.25s ease; }
  .sidebar.open { transform: translateX(0); }
  .menu-btn { display: block; }
  .stats-grid { grid-template-columns: repeat(2, 1fr); }
  .animal-profile { flex-direction: column; align-items: center; }
}

/* Toast */
.toast { position: fixed; bottom: 2rem; right: 2rem; background: var(--green-dark); color: #fff; padding: 0.75rem 1.25rem; border-radius: var(--radius); box-shadow: var(--shadow-lg); z-index: 200; animation: slideUp 0.3s ease; }
@keyframes slideUp { from { opacity: 0; transform: translateY(10px); } }
