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

:root {
  --primary: #10b981;
  --primary-dark: #059669;
  --primary-light: #d1fae5;
  --bg: #f0fdf4;
  --card: #ffffff;
  --text: #1f2937;
  --text-light: #6b7280;
  --border: #e5e7eb;
  --danger: #ef4444;
  --shadow: 0 1px 3px rgba(0,0,0,0.1);
  --shadow-lg: 0 4px 12px rgba(0,0,0,0.1);
}

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
}

.hidden { display: none !important; }

/* Login */
.login-container {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  padding: 1rem;
}

.login-card {
  background: var(--card);
  border-radius: 1rem;
  padding: 2.5rem;
  width: 100%;
  max-width: 400px;
  box-shadow: var(--shadow-lg);
}

.login-card h1 {
  text-align: center;
  font-size: 1.8rem;
  margin-bottom: 0.25rem;
  color: var(--primary-dark);
}

.login-card .subtitle {
  text-align: center;
  color: var(--text-light);
  margin-bottom: 2rem;
  font-size: 0.9rem;
}

.form-group {
  margin-bottom: 1.25rem;
}

.form-group label {
  display: block;
  font-weight: 600;
  margin-bottom: 0.4rem;
  font-size: 0.9rem;
}

.form-group input,
.form-group select,
.form-group textarea {
  width: 100%;
  padding: 0.75rem;
  border: 2px solid var(--border);
  border-radius: 0.5rem;
  font-size: 1rem;
  transition: border-color 0.2s;
  background: #fff;
}

.form-group input:focus,
.form-group select:focus,
.form-group textarea:focus {
  outline: none;
  border-color: var(--primary);
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  padding: 0.75rem 1.5rem;
  border: none;
  border-radius: 0.5rem;
  font-size: 1rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s;
  text-decoration: none;
}

.btn-primary {
  background: var(--primary);
  color: white;
  width: 100%;
}

.btn-primary:hover {
  background: var(--primary-dark);
}

.btn-danger {
  background: var(--danger);
  color: white;
  padding: 0.4rem 0.75rem;
  font-size: 0.8rem;
}

.btn-outline {
  background: transparent;
  border: 2px solid var(--primary);
  color: var(--primary);
}

.btn-outline:hover {
  background: var(--primary-light);
}

.error-msg {
  color: var(--danger);
  text-align: center;
  margin-top: 0.75rem;
  font-size: 0.9rem;
}

/* Header */
.header {
  background: white;
  padding: 1rem 1.5rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  box-shadow: var(--shadow);
  position: sticky;
  top: 0;
  z-index: 100;
}

.header .logo {
  font-weight: 700;
  font-size: 1.3rem;
  color: var(--primary-dark);
}

.header .user-info {
  display: flex;
  align-items: center;
  gap: 1rem;
  font-size: 0.9rem;
  color: var(--text-light);
}

.header .user-info .role-badge {
  background: var(--primary-light);
  color: var(--primary-dark);
  padding: 0.2rem 0.6rem;
  border-radius: 1rem;
  font-size: 0.75rem;
  font-weight: 600;
  text-transform: uppercase;
}

.btn-logout {
  background: none;
  border: 1px solid var(--border);
  padding: 0.4rem 0.75rem;
  border-radius: 0.375rem;
  font-size: 0.85rem;
  cursor: pointer;
  color: var(--text-light);
}

.btn-logout:hover {
  background: #fee2e2;
  border-color: var(--danger);
  color: var(--danger);
}

/* Main content */
.main {
  max-width: 800px;
  margin: 0 auto;
  padding: 1.5rem;
}

/* Add meal form */
.add-meal-card {
  background: var(--card);
  border-radius: 1rem;
  padding: 1.5rem;
  margin-bottom: 1.5rem;
  box-shadow: var(--shadow);
}

.add-meal-card h2 {
  margin-bottom: 1rem;
  font-size: 1.2rem;
}

.photo-upload {
  margin-bottom: 1rem;
}

.photo-area {
  border: 2px dashed var(--border);
  border-radius: 0.75rem;
  padding: 1.5rem;
  text-align: center;
  cursor: pointer;
  transition: all 0.2s;
  position: relative;
  overflow: hidden;
  min-height: 120px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
}

.photo-area:hover {
  border-color: var(--primary);
  background: var(--primary-light);
}

.photo-area .icon {
  font-size: 2rem;
}

.photo-area .text {
  font-size: 0.9rem;
  color: var(--text-light);
}

.photo-area img {
  max-width: 100%;
  max-height: 200px;
  border-radius: 0.5rem;
}

.photo-buttons {
  display: flex;
  gap: 0.5rem;
  margin-top: 0.5rem;
}

.photo-buttons .btn {
  flex: 1;
  padding: 0.5rem;
  font-size: 0.85rem;
}

.form-row {
  display: flex;
  gap: 0.75rem;
}

.form-col {
  flex: 1;
}

.time-picker {
  display: flex;
  align-items: center;
  gap: 0.25rem;
}

.time-picker select {
  padding: 0.6rem 0.4rem;
  border: 2px solid var(--border);
  border-radius: 0.5rem;
  font-size: 1rem;
  background: #fff;
  flex: 1;
  text-align: center;
}

.time-picker select:focus {
  outline: none;
  border-color: var(--primary);
}

.time-picker span {
  font-weight: 700;
  font-size: 1.1rem;
}

.meal-type-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(100px, 1fr));
  gap: 0.5rem;
  margin-bottom: 1rem;
}

.meal-type-option {
  text-align: center;
  padding: 0.6rem;
  border: 2px solid var(--border);
  border-radius: 0.5rem;
  cursor: pointer;
  transition: all 0.2s;
  font-size: 0.85rem;
}

.meal-type-option:hover {
  border-color: var(--primary);
}

.meal-type-option.selected {
  border-color: var(--primary);
  background: var(--primary-light);
  color: var(--primary-dark);
  font-weight: 600;
}

.meal-type-option .emoji {
  display: block;
  font-size: 1.5rem;
  margin-bottom: 0.25rem;
}

/* Meals list */
.meals-section h2 {
  margin-bottom: 1rem;
  font-size: 1.2rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.date-nav {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  margin-bottom: 1rem;
}

.date-nav button {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 0.375rem;
  padding: 0.4rem 0.75rem;
  cursor: pointer;
  font-size: 1rem;
}

.date-nav input[type="date"] {
  padding: 0.4rem 0.75rem;
  border: 1px solid var(--border);
  border-radius: 0.375rem;
  font-size: 0.9rem;
}

.meal-card {
  background: var(--card);
  border-radius: 0.5rem;
  padding: 0.5rem;
  margin-bottom: 0.5rem;
  box-shadow: var(--shadow);
  display: flex;
  gap: 0.5rem;
  align-items: center;
}

.meal-card .meal-photo {
  width: 52px;
  height: 52px;
  border-radius: 0.375rem;
  object-fit: cover;
  flex-shrink: 0;
  background: var(--border);
  cursor: pointer;
}

.meal-card .meal-info {
  flex: 1;
  min-width: 0;
}

.meal-card .meal-type-tag {
  display: inline-block;
  background: var(--primary-light);
  color: var(--primary-dark);
  padding: 0.1rem 0.4rem;
  border-radius: 0.25rem;
  font-size: 0.65rem;
  font-weight: 600;
  text-transform: uppercase;
}

.meal-card .meal-time {
  font-size: 0.65rem;
  color: var(--text-light);
  margin-left: 0.25rem;
}

.meal-card .meal-desc {
  font-weight: 500;
  font-size: 0.85rem;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.meal-card .meal-notes {
  font-size: 0.75rem;
  color: var(--text-light);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.meal-card .meal-actions {
  flex-shrink: 0;
}

.meal-card .meal-actions .btn-danger {
  padding: 0.25rem 0.5rem;
  font-size: 0.7rem;
}

.no-meals {
  text-align: center;
  padding: 2rem;
  color: var(--text-light);
}

/* Nutritionist - patient list */
.patient-card {
  background: var(--card);
  border-radius: 0.75rem;
  padding: 1.25rem;
  margin-bottom: 0.75rem;
  box-shadow: var(--shadow);
  cursor: pointer;
  transition: all 0.2s;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

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

.patient-card .patient-info h3 {
  font-size: 1.1rem;
  margin-bottom: 0.25rem;
}

.patient-card .patient-info p {
  font-size: 0.85rem;
  color: var(--text-light);
}

.patient-card .arrow {
  font-size: 1.5rem;
  color: var(--text-light);
}

.back-btn {
  display: inline-flex;
  align-items: center;
  gap: 0.25rem;
  background: none;
  border: none;
  color: var(--primary-dark);
  font-size: 0.9rem;
  font-weight: 600;
  cursor: pointer;
  margin-bottom: 1rem;
  padding: 0.25rem 0;
}

/* Photo modal */
.modal-overlay {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0,0,0,0.7);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
  padding: 1rem;
}

.modal-overlay img {
  max-width: 100%;
  max-height: 90vh;
  border-radius: 0.5rem;
}

.modal-overlay .close-modal {
  position: absolute;
  top: 1rem;
  right: 1rem;
  background: white;
  border: none;
  width: 2.5rem;
  height: 2.5rem;
  border-radius: 50%;
  font-size: 1.2rem;
  cursor: pointer;
  box-shadow: var(--shadow-lg);
}

/* Button link */
.btn-link {
  display: block;
  background: none;
  border: none;
  color: var(--primary-dark);
  font-size: 0.85rem;
  cursor: pointer;
  margin-top: 1rem;
  text-align: center;
  width: 100%;
}

.btn-link:hover {
  text-decoration: underline;
}

/* Button small */
.btn-sm {
  padding: 0.4rem 0.75rem;
  font-size: 0.85rem;
}

/* Button profile */
.btn-profile {
  background: none;
  border: none;
  font-size: 0.9rem;
  color: var(--text);
  font-weight: 600;
  cursor: pointer;
}

.btn-profile:hover {
  color: var(--primary-dark);
  text-decoration: underline;
}

/* Info & success messages */
.info-msg {
  color: var(--primary-dark);
  background: var(--primary-light);
  padding: 0.5rem 0.75rem;
  border-radius: 0.375rem;
  font-size: 0.85rem;
  margin-bottom: 0.75rem;
}

.success-msg {
  color: var(--primary-dark);
  text-align: center;
  margin-top: 0.5rem;
  font-size: 0.9rem;
}

/* Profile / Settings */
.profile-card {
  background: var(--card);
  border-radius: 0.75rem;
  box-shadow: var(--shadow);
  overflow: hidden;
}

.setting-row {
  padding: 1rem 1.25rem;
  border-bottom: 1px solid var(--border);
}

.setting-row:last-child {
  border-bottom: none;
}

.setting-label {
  font-size: 0.7rem;
  font-weight: 600;
  color: var(--text-light);
  text-transform: uppercase;
  letter-spacing: 0.03em;
  margin-bottom: 0.3rem;
}

.setting-value {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.setting-value span {
  font-size: 0.95rem;
}

.setting-action {
  background: none;
  border: none;
  color: var(--primary-dark);
  font-size: 0.85rem;
  font-weight: 600;
  cursor: pointer;
  padding: 0.2rem 0;
}

.setting-action:hover {
  text-decoration: underline;
}

.setting-edit {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  margin-top: 0.5rem;
}

.setting-edit input {
  padding: 0.5rem 0.75rem;
  border: 1px solid var(--border);
  border-radius: 0.375rem;
  font-size: 0.9rem;
  width: 100%;
}

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

.setting-edit-actions {
  display: flex;
  gap: 0.5rem;
}

/* Modal blur */
.modal-blur {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0,0,0,0.3);
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
  padding: 1rem;
}

.modal-card {
  background: var(--card);
  border-radius: 1rem;
  padding: 1.5rem;
  width: 100%;
  max-width: 400px;
  box-shadow: var(--shadow-lg);
}

.modal-card h3 {
  font-size: 1.2rem;
  margin-bottom: 1rem;
}

.modal-actions {
  display: flex;
  gap: 0.5rem;
  margin-top: 0.5rem;
}

/* Toast */
.toast {
  position: fixed;
  bottom: 2rem;
  left: 50%;
  transform: translateX(-50%) translateY(20px);
  background: #1f2937;
  color: white;
  padding: 0.6rem 1.25rem;
  border-radius: 0.5rem;
  font-size: 0.9rem;
  z-index: 2000;
  opacity: 0;
  transition: opacity 0.3s, transform 0.3s;
  pointer-events: none;
}

.toast.show {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}

/* Responsive */
@media (max-width: 480px) {
  .login-card { padding: 1.5rem; }
  .main { padding: 0.75rem; }
  .header .user-info span.user-name { display: none; }
}
