/* === PRP Field App — Dark Theme === */
:root {
  --prp-green: #2E7D32;
  --prp-green-dark: #1B5E20;
  --prp-green-light: #4CAF50;
  --prp-black: #1A1A1A;
  --prp-black-light: #2A2A2A;
  --prp-black-lighter: #333333;
  --prp-white: #FFFFFF;
  --prp-gray-300: #D0D0D0;
  --prp-gray-500: #9E9E9E;
  --prp-gray-700: #616161;
  --radius: 10px;
  --shadow: 0 2px 8px rgba(0,0,0,0.4);
}

* { margin: 0; padding: 0; box-sizing: border-box; }

html, body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  background: var(--prp-black);
  color: var(--prp-gray-300);
  -webkit-tap-highlight-color: transparent;
  font-size: 16px;
  min-height: 100vh;
  overflow-x: hidden;
}

/* Header */
.app-header {
  background: var(--prp-black-light);
  color: var(--prp-white);
  padding: 12px 16px;
  display: flex;
  align-items: center;
  gap: 12px;
  position: sticky;
  top: 0;
  z-index: 100;
  min-height: 56px;
  border-bottom: 1px solid var(--prp-green);
}
.app-header .logo { height: 32px; width: auto; }
.app-header h1 { font-size: 18px; font-weight: 700; color: var(--prp-green); }
.app-header .back-btn {
  background: none; border: none; color: var(--prp-white);
  font-size: 24px; cursor: pointer; padding: 4px 8px 4px 0;
  min-width: 44px; min-height: 44px;
  display: flex; align-items: center;
}

/* Screens */
.screen { display: none; padding: 16px; padding-bottom: 80px; }
.screen.active { display: block; }
.screen-title { font-size: 22px; font-weight: 700; color: var(--prp-white); margin-bottom: 16px; }

/* Login */
#login-screen {
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  min-height: 100vh; padding: 32px; padding-bottom: 32px;
  background: var(--prp-black);
}
#login-screen .login-logo { width: 140px; height: auto; margin-bottom: 8px; }
#login-screen .app-name { font-size: 28px; font-weight: 800; color: var(--prp-green); margin-bottom: 32px; }
#login-screen input {
  width: 100%; max-width: 340px; padding: 14px 16px;
  border: 2px solid var(--prp-black-lighter); border-radius: var(--radius);
  font-size: 16px; margin-bottom: 12px; outline: none;
  background: var(--prp-black-light); color: var(--prp-white);
  transition: border-color 0.15s;
}
#login-screen input:focus { border-color: var(--prp-green); }

/* Buttons */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  padding: 14px 24px; border-radius: var(--radius); font-size: 16px; font-weight: 600;
  border: none; cursor: pointer; min-height: 48px; text-decoration: none;
  transition: background 0.15s, transform 0.05s;
}
.btn:active { transform: scale(0.97); }
.btn-primary {
  background: var(--prp-green); color: var(--prp-white); width: 100%; max-width: 340px;
}
.btn-primary:hover { background: var(--prp-green-dark); }
.btn-secondary {
  background: transparent; color: var(--prp-green); border: 2px solid var(--prp-green);
}
.btn-secondary:hover { background: rgba(46,125,50,0.15); }
.btn-sm { padding: 10px 16px; font-size: 14px; min-height: 44px; }
.btn-full { width: 100%; }

/* Cards */
.card {
  background: var(--prp-black-light); border-radius: var(--radius);
  padding: 16px; margin-bottom: 12px;
  border: 1px solid var(--prp-black-lighter);
}
.card-title { font-size: 16px; font-weight: 700; color: var(--prp-white); margin-bottom: 4px; }
.card-subtitle { font-size: 14px; color: var(--prp-gray-500); margin-bottom: 2px; }

/* Job cards */
.job-card {
  background: var(--prp-black-light); border-radius: var(--radius);
  padding: 16px; margin-bottom: 12px; border-left: 4px solid var(--prp-green);
  cursor: pointer; transition: background 0.15s;
}
.job-card:active { background: var(--prp-black-lighter); }
.job-card .job-number { font-size: 13px; font-weight: 700; color: var(--prp-green); margin-bottom: 4px; }
.job-card .job-customer { font-size: 16px; font-weight: 600; color: var(--prp-white); margin-bottom: 2px; }
.job-card .job-address { font-size: 14px; color: var(--prp-gray-500); margin-bottom: 6px; }
.job-card .job-meta { display: flex; gap: 8px; align-items: center; }
.badge { display: inline-block; padding: 4px 10px; border-radius: 20px; font-size: 12px; font-weight: 600; }
.badge-roofing { background: rgba(46,125,50,0.2); color: var(--prp-green-light); }
.badge-solar { background: rgba(255,152,0,0.15); color: #FFB74D; }
.badge-assigned { background: var(--prp-black-lighter); color: var(--prp-gray-500); }
.badge-in-progress { background: rgba(21,101,192,0.2); color: #64B5F6; }
.badge-completed { background: rgba(46,125,50,0.2); color: var(--prp-green-light); }

/* Filter tabs */
.filter-tabs { display: flex; gap: 8px; margin-bottom: 16px; overflow-x: auto; -webkit-overflow-scrolling: touch; }
.filter-tab {
  padding: 8px 16px; border-radius: 20px; font-size: 14px; font-weight: 600;
  border: 2px solid var(--prp-black-lighter); background: var(--prp-black-light);
  color: var(--prp-gray-500); cursor: pointer; white-space: nowrap; min-height: 40px;
}
.filter-tab.active { background: var(--prp-green); color: var(--prp-white); border-color: var(--prp-green); }

/* Section headers */
.section-header {
  background: var(--prp-green); color: var(--prp-white); padding: 12px 16px;
  border-radius: var(--radius); font-size: 16px; font-weight: 700;
  margin-bottom: 12px; margin-top: 20px;
}

/* Material/Labor table */
.material-table { width: 100%; border-collapse: collapse; }
.material-table th {
  text-align: left; padding: 10px 12px; font-size: 13px; font-weight: 700;
  color: var(--prp-gray-500); border-bottom: 2px solid var(--prp-black-lighter);
}
.material-table td {
  padding: 10px 12px; font-size: 14px; color: var(--prp-gray-300);
  border-bottom: 1px solid var(--prp-black-lighter);
}
.material-table tr:last-child td { border-bottom: none; }

/* Quick actions */
.quick-actions { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; margin-top: 16px; }

/* Inventory */
.search-bar {
  width: 100%; padding: 14px 16px; border: 2px solid var(--prp-black-lighter);
  border-radius: var(--radius); font-size: 16px; outline: none; margin-bottom: 12px;
  background: var(--prp-black-light); color: var(--prp-white);
}
.search-bar:focus { border-color: var(--prp-green); }
.search-bar::placeholder { color: var(--prp-gray-700); }
.inventory-item {
  display: flex; justify-content: space-between; align-items: center;
  padding: 14px 16px; background: var(--prp-black-light);
  border: 1px solid var(--prp-black-lighter); border-radius: var(--radius); margin-bottom: 8px;
}
.inventory-item .item-name { font-weight: 600; font-size: 15px; color: var(--prp-white); }
.inventory-item .item-detail { font-size: 13px; color: var(--prp-gray-500); }
.inventory-item .item-qty { text-align: right; }
.inventory-item .item-qty .qty { font-weight: 700; font-size: 16px; color: var(--prp-green); }
.inventory-item .item-qty .location { font-size: 12px; color: var(--prp-gray-500); }

/* Photo capture */
.camera-area {
  width: 100%; height: 240px; background: var(--prp-black-light);
  border: 2px dashed var(--prp-gray-700); border-radius: var(--radius);
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  margin-bottom: 16px; cursor: pointer; position: relative; overflow: hidden;
}
.camera-area .camera-icon { font-size: 48px; margin-bottom: 8px; }
.camera-area .camera-text { font-size: 16px; color: var(--prp-gray-500); }
.camera-area input[type="file"] {
  position: absolute; inset: 0; opacity: 0; cursor: pointer;
}
.camera-area img { width: 100%; height: 100%; object-fit: cover; }
.form-group { margin-bottom: 14px; }
.form-group label { display: block; font-size: 14px; font-weight: 600; color: var(--prp-gray-300); margin-bottom: 6px; }
.form-group input, .form-group select, .form-group textarea {
  width: 100%; padding: 12px 14px; border: 2px solid var(--prp-black-lighter);
  border-radius: var(--radius); font-size: 16px; outline: none;
  background: var(--prp-black-light); color: var(--prp-white);
}
.form-group select { appearance: none; }
.form-group input:focus, .form-group select:focus { border-color: var(--prp-green); }
.sync-note { text-align: center; font-size: 13px; color: var(--prp-gray-500); margin-top: 12px; }
.recent-photos { margin-top: 20px; }
.photo-thumb {
  display: flex; align-items: center; gap: 12px; padding: 10px;
  border: 1px solid var(--prp-black-lighter); border-radius: var(--radius); margin-bottom: 8px;
  background: var(--prp-black-light);
}
.photo-thumb img { width: 56px; height: 56px; border-radius: 6px; object-fit: cover; }
.photo-thumb .photo-info .photo-desc { font-size: 14px; font-weight: 600; color: var(--prp-white); }
.photo-thumb .photo-info .photo-cat { font-size: 12px; color: var(--prp-gray-500); }

/* Profile */
.profile-header { text-align: center; margin-bottom: 24px; }
.avatar {
  width: 80px; height: 80px; border-radius: 50%; background: var(--prp-green);
  color: var(--prp-white); font-size: 28px; font-weight: 700;
  display: inline-flex; align-items: center; justify-content: center; margin-bottom: 12px;
}
.profile-info { text-align: center; margin-bottom: 24px; }
.profile-info .name { font-size: 20px; font-weight: 700; color: var(--prp-white); }
.profile-info .role { font-size: 15px; color: var(--prp-gray-500); }
.profile-info .email { font-size: 14px; color: var(--prp-gray-500); margin-top: 4px; }
.toggle-row {
  display: flex; justify-content: space-between; align-items: center;
  padding: 14px 0; border-bottom: 1px solid var(--prp-black-lighter);
}
.toggle-row:last-child { border-bottom: none; }
.toggle-label { font-size: 15px; color: var(--prp-gray-300); }
.toggle {
  width: 50px; height: 28px; background: var(--prp-gray-700); border-radius: 14px;
  position: relative; cursor: pointer; transition: background 0.2s;
}
.toggle.on { background: var(--prp-green); }
.toggle::after {
  content: ''; position: absolute; width: 22px; height: 22px; border-radius: 50%;
  background: white; top: 3px; left: 3px; transition: transform 0.2s;
  box-shadow: 0 1px 3px rgba(0,0,0,0.2);
}
.toggle.on::after { transform: translateX(22px); }

/* Bottom nav */
.bottom-nav {
  position: fixed; bottom: 0; left: 0; right: 0; background: var(--prp-black-light);
  display: flex; justify-content: space-around; padding: 6px 0;
  padding-bottom: max(6px, env(safe-area-inset-bottom));
  z-index: 200; border-top: 1px solid var(--prp-green);
}
.bottom-nav .nav-item {
  display: flex; flex-direction: column; align-items: center; gap: 2px;
  padding: 6px 12px; color: var(--prp-gray-700); text-decoration: none;
  font-size: 11px; font-weight: 600; cursor: pointer; min-width: 64px; min-height: 48px;
  justify-content: center; border: none; background: none;
}
.bottom-nav .nav-item.active { color: var(--prp-green); }
.bottom-nav .nav-icon { font-size: 22px; }

/* Weather card dark */
#weather-card {
  background: var(--prp-black-light) !important;
  border-color: var(--prp-black-lighter) !important;
}
.hourly-scroll { -webkit-overflow-scrolling: touch; scrollbar-width: none; }
.hourly-scroll::-webkit-scrollbar { display: none; }
.hourly-item { text-align: center; min-width: 52px; flex-shrink: 0; }
.hourly-time { font-size: 11px; color: var(--prp-gray-500); font-weight: 600; }
.hourly-icon { font-size: 20px; margin: 2px 0; }
.hourly-temp { font-size: 15px; font-weight: 700; color: var(--prp-white); }
.hourly-rain { font-size: 11px; color: #64B5F6; font-weight: 600; }

.hidden { display: none !important; }

/* === Time Card === */
.tc-active-badge {
  display: inline-block; background: rgba(46,125,50,0.2); color: var(--prp-green-light);
  padding: 4px 12px; border-radius: 20px; font-size: 12px; font-weight: 700; letter-spacing: 1px;
}
.tc-elapsed {
  font-size: 44px; font-weight: 700; color: var(--prp-white);
  text-align: center; font-variant-numeric: tabular-nums; margin: 10px 0;
}
.tc-meta-row {
  display: flex; justify-content: space-between; align-items: center;
  font-size: 14px; color: var(--prp-gray-500); padding: 5px 0;
  border-bottom: 1px solid var(--prp-black-lighter);
}
.tc-meta-row:last-of-type { border-bottom: none; }
.tc-meta-row span:last-child { color: var(--prp-gray-300); font-weight: 600; text-align: right; }
.tc-clock-out {
  background: #C62828; color: var(--prp-white); width: 100%; margin-top: 14px;
}
.tc-clock-out:hover { background: #B71C1C; }
.tc-delete-btn {
  background: transparent; color: #EF5350; border: 1px solid #EF5350;
  margin-top: 10px; width: 100%;
}
.tc-delete-btn:hover { background: rgba(211,47,47,0.15); }

/* Native date input readable on dark theme */
#tc-date { color-scheme: dark; }
