/* ==========================================================================
   Stewardship App - Modern UI Styles
   ========================================================================== */

/* =====================================================
   CSS Variables (Theme Colors)
   ===================================================== */
:root {
  --primary-color: #0066cc;
  --primary-dark: #004c99;
  --primary-light: #3399ff;
  --secondary-color: #6c757d;
  --success-color: #28a745;
  --warning-color: #ffc107;
  --danger-color: #dc3545;
  --info-color: #17a2b8;
  
  --bg-light: #f8f9fa;
  --bg-white: #ffffff;
  --bg-dark: #343a40;
  
  --text-primary: #212529;
  --text-secondary: #6c757d;
  --text-muted: #adb5bd;
  
  --border-color: #dee2e6;
  --border-radius: 8px;
  --border-radius-lg: 12px;
  --border-radius-sm: 4px;
  
  --shadow-sm: 0 1px 3px rgba(0,0,0,0.08);
  --shadow-md: 0 4px 12px rgba(0,0,0,0.1);
  --shadow-lg: 0 8px 24px rgba(0,0,0,0.15);
  
  --transition-fast: 0.15s ease;
  --transition-normal: 0.3s ease;
}

/* =====================================================
   Base Styles
   ===================================================== */
* {
  box-sizing: border-box;
}

html {
  scroll-behavior: smooth;
}

body {
  font-family: 'Segoe UI', -apple-system, BlinkMacSystemFont, 'Roboto', 'Helvetica Neue', Arial, sans-serif;
  font-size: 16px;
  line-height: 1.6;
  color: var(--text-primary);
  background-color: var(--bg-light);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

/* =====================================================
   Typography
   ===================================================== */
h1, h2, h3, h4, h5, h6 {
  font-weight: 600;
  line-height: 1.3;
  margin-bottom: 0.5em;
  color: var(--text-primary);
}

h1 { font-size: 2rem; }
h2 { font-size: 1.75rem; }
h3 { font-size: 1.5rem; }
h4 { font-size: 1.25rem; }
h5 { font-size: 1.1rem; }
h6 { font-size: 1rem; }

p {
  margin-bottom: 1rem;
}

a {
  color: var(--primary-color);
  text-decoration: none;
  transition: color var(--transition-fast);
}

a:hover {
  color: var(--primary-dark);
  text-decoration: underline;
}

/* =====================================================
   Navigation Bar
   ===================================================== */
.app-navbar {
  background: linear-gradient(135deg, var(--primary-color) 0%, var(--primary-dark) 100%);
  padding: 12px 20px;
  box-shadow: var(--shadow-md);
  position: sticky;
  top: 0;
  z-index: 1000;
}

.app-navbar .w3-bar-item {
  color: white;
  padding: 10px 16px;
  border-radius: var(--border-radius-sm);
  transition: all var(--transition-fast);
  cursor: pointer;
}

.app-navbar .w3-bar-item:hover {
  background: rgba(255,255,255,0.15);
}

.app-navbar .w3-bar-item i {
  margin-right: 8px;
}

/* =====================================================
   Cards
   ===================================================== */
.app-card {
  background: var(--bg-white);
  border-radius: var(--border-radius-lg);
  box-shadow: var(--shadow-sm);
  padding: 24px;
  margin-bottom: 20px;
  transition: box-shadow var(--transition-normal);
}

.app-card:hover {
  box-shadow: var(--shadow-md);
}

.app-card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 16px;
  padding-bottom: 16px;
  border-bottom: 1px solid var(--border-color);
}

.app-card-title {
  font-size: 1.25rem;
  font-weight: 600;
  color: var(--text-primary);
  margin: 0;
}

.app-card-body {
  padding: 0;
}

/* =====================================================
   Buttons
   ===================================================== */
.app-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 12px 24px;
  font-size: 0.95rem;
  font-weight: 600;
  border: none;
  border-radius: var(--border-radius);
  cursor: pointer;
  transition: all var(--transition-fast);
  text-decoration: none;
}

.app-btn i {
  font-size: 1.1em;
}

.app-btn-primary {
  background: linear-gradient(135deg, var(--primary-color) 0%, var(--primary-dark) 100%);
  color: white;
  box-shadow: 0 2px 8px rgba(0, 102, 204, 0.3);
}

.app-btn-primary:hover {
  transform: translateY(-2px);
  box-shadow: 0 4px 16px rgba(0, 102, 204, 0.4);
}

.app-btn-success {
  background: linear-gradient(135deg, var(--success-color) 0%, #20c997 100%);
  color: white;
  box-shadow: 0 2px 8px rgba(40, 167, 69, 0.3);
}

.app-btn-success:hover {
  transform: translateY(-2px);
  box-shadow: 0 4px 16px rgba(40, 167, 69, 0.4);
}

.app-btn-secondary {
  background: var(--bg-light);
  color: var(--text-primary);
  border: 1px solid var(--border-color);
}

.app-btn-secondary:hover {
  background: #e9ecef;
}

.app-btn-danger {
  background: linear-gradient(135deg, var(--danger-color) 0%, #c82333 100%);
  color: white;
}

.app-btn-danger:hover {
  transform: translateY(-2px);
  box-shadow: 0 4px 16px rgba(220, 53, 69, 0.4);
}

.app-btn-sm {
  padding: 8px 16px;
  font-size: 0.85rem;
}

.app-btn-lg {
  padding: 16px 32px;
  font-size: 1.1rem;
}

.app-btn:active {
  transform: translateY(0);
}

.app-btn:disabled {
  opacity: 0.6;
  cursor: not-allowed;
  transform: none;
}

/* =====================================================
   Form Elements
   ===================================================== */
.app-form-group {
  margin-bottom: 20px;
}

.app-form-label {
  display: block;
  font-weight: 600;
  color: var(--text-primary);
  margin-bottom: 8px;
  font-size: 0.9rem;
}

.app-form-label.required::after {
  content: " *";
  color: var(--danger-color);
}

.app-input,
.app-select,
.app-textarea {
  width: 100%;
  padding: 12px 16px;
  font-size: 1rem;
  border: 2px solid var(--border-color);
  border-radius: var(--border-radius);
  background: var(--bg-white);
  color: var(--text-primary);
  transition: all var(--transition-fast);
}

.app-input:focus,
.app-select:focus,
.app-textarea:focus {
  outline: none;
  border-color: var(--primary-color);
  box-shadow: 0 0 0 3px rgba(0, 102, 204, 0.15);
}

.app-input::placeholder {
  color: var(--text-muted);
}

.app-textarea {
  min-height: 120px;
  resize: vertical;
}

.app-select {
  cursor: pointer;
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'%3E%3Cpath fill='%236c757d' d='M6 8L1 3h10z'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 16px center;
  padding-right: 40px;
}

/* Checkbox & Radio Styles */
.app-checkbox,
.app-radio {
  display: flex;
  align-items: center;
  gap: 10px;
  cursor: pointer;
  padding: 8px 0;
}

.app-checkbox input,
.app-radio input {
  width: 20px;
  height: 20px;
  accent-color: var(--primary-color);
  cursor: pointer;
}

/* =====================================================
   Tables
   ===================================================== */
.app-table {
  width: 100%;
  border-collapse: collapse;
  background: var(--bg-white);
  border-radius: var(--border-radius);
  overflow: hidden;
  box-shadow: var(--shadow-sm);
}

.app-table thead {
  background: linear-gradient(135deg, var(--primary-color) 0%, var(--primary-dark) 100%);
  color: white;
}

.app-table th {
  padding: 16px;
  text-align: left;
  font-weight: 600;
  font-size: 0.9rem;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.app-table td {
  padding: 14px 16px;
  border-bottom: 1px solid var(--border-color);
}

.app-table tbody tr:hover {
  background: var(--bg-light);
}

.app-table tbody tr:last-child td {
  border-bottom: none;
}

/* =====================================================
   Badges & Tags
   ===================================================== */
.app-badge {
  display: inline-flex;
  align-items: center;
  padding: 4px 12px;
  font-size: 0.8rem;
  font-weight: 600;
  border-radius: 20px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.app-badge-primary {
  background: rgba(0, 102, 204, 0.15);
  color: var(--primary-color);
}

.app-badge-success {
  background: rgba(40, 167, 69, 0.15);
  color: var(--success-color);
}

.app-badge-warning {
  background: rgba(255, 193, 7, 0.15);
  color: #d39e00;
}

.app-badge-danger {
  background: rgba(220, 53, 69, 0.15);
  color: var(--danger-color);
}

.app-badge-info {
  background: rgba(23, 162, 184, 0.15);
  color: var(--info-color);
}

/* =====================================================
   Alerts
   ===================================================== */
.app-alert {
  padding: 16px 20px;
  border-radius: var(--border-radius);
  margin-bottom: 20px;
  display: flex;
  align-items: flex-start;
  gap: 12px;
}

.app-alert i {
  font-size: 1.2rem;
  margin-top: 2px;
}

.app-alert-success {
  background: rgba(40, 167, 69, 0.1);
  border-left: 4px solid var(--success-color);
  color: #155724;
}

.app-alert-warning {
  background: rgba(255, 193, 7, 0.1);
  border-left: 4px solid var(--warning-color);
  color: #856404;
}

.app-alert-danger {
  background: rgba(220, 53, 69, 0.1);
  border-left: 4px solid var(--danger-color);
  color: #721c24;
}

.app-alert-info {
  background: rgba(23, 162, 184, 0.1);
  border-left: 4px solid var(--info-color);
  color: #0c5460;
}

/* =====================================================
   Modal Enhancements
   ===================================================== */
.app-modal-overlay {
  background-color: rgba(0, 0, 0, 0.5);
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
}

.app-modal {
  background: var(--bg-white);
  border-radius: var(--border-radius-lg);
  box-shadow: var(--shadow-lg);
  animation: modalFadeIn 0.3s ease-out;
  overflow: hidden;
}

@keyframes modalFadeIn {
  from {
    opacity: 0;
    transform: translateY(-20px) scale(0.95);
  }
  to {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}

.app-modal-header {
  background: linear-gradient(135deg, var(--primary-color) 0%, var(--primary-dark) 100%);
  color: white;
  padding: 20px 24px;
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.app-modal-header h4 {
  margin: 0;
  color: white;
  font-size: 1.25rem;
}

.app-modal-close {
  background: rgba(255,255,255,0.2);
  border: none;
  color: white;
  width: 36px;
  height: 36px;
  border-radius: 50%;
  cursor: pointer;
  font-size: 1.3rem;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all var(--transition-fast);
}

.app-modal-close:hover {
  background: rgba(255,255,255,0.3);
  transform: scale(1.1);
}

.app-modal-body {
  padding: 24px;
}

.app-modal-footer {
  padding: 16px 24px;
  background: var(--bg-light);
  display: flex;
  justify-content: flex-end;
  gap: 12px;
  border-top: 1px solid var(--border-color);
}

/* =====================================================
   Loading Spinner
   ===================================================== */
.app-spinner {
  display: inline-block;
  width: 24px;
  height: 24px;
  border: 3px solid rgba(0, 102, 204, 0.2);
  border-radius: 50%;
  border-top-color: var(--primary-color);
  animation: spin 0.8s linear infinite;
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

.app-spinner-lg {
  width: 48px;
  height: 48px;
  border-width: 4px;
}

/* =====================================================
   Content Sections
   ===================================================== */
.app-section {
  padding: 24px;
  margin-bottom: 24px;
}

.app-section-title {
  font-size: 1.5rem;
  font-weight: 700;
  color: var(--text-primary);
  margin-bottom: 24px;
  padding-bottom: 12px;
  border-bottom: 3px solid var(--primary-color);
  display: inline-block;
}

/* =====================================================
   List Styles
   ===================================================== */
.app-list {
  list-style: none;
  padding: 0;
  margin: 0;
}

.app-list-item {
  padding: 16px;
  border-bottom: 1px solid var(--border-color);
  display: flex;
  align-items: center;
  gap: 16px;
  transition: background var(--transition-fast);
}

.app-list-item:hover {
  background: var(--bg-light);
}

.app-list-item:last-child {
  border-bottom: none;
}

/* =====================================================
   Tooltips
   ===================================================== */
[data-tooltip] {
  position: relative;
  cursor: help;
}

[data-tooltip]::after {
  content: attr(data-tooltip);
  position: absolute;
  bottom: 100%;
  left: 50%;
  transform: translateX(-50%);
  padding: 8px 12px;
  background: var(--bg-dark);
  color: white;
  font-size: 0.85rem;
  border-radius: var(--border-radius-sm);
  white-space: nowrap;
  opacity: 0;
  visibility: hidden;
  transition: all var(--transition-fast);
  z-index: 1000;
}

[data-tooltip]:hover::after {
  opacity: 1;
  visibility: visible;
  bottom: calc(100% + 8px);
}

/* =====================================================
   Utility Classes
   ===================================================== */
.app-text-center { text-align: center; }
.app-text-left { text-align: left; }
.app-text-right { text-align: right; }

.app-text-muted { color: var(--text-muted); }
.app-text-primary { color: var(--primary-color); }
.app-text-success { color: var(--success-color); }
.app-text-danger { color: var(--danger-color); }
.app-text-warning { color: var(--warning-color); }

.app-mt-1 { margin-top: 8px; }
.app-mt-2 { margin-top: 16px; }
.app-mt-3 { margin-top: 24px; }
.app-mb-1 { margin-bottom: 8px; }
.app-mb-2 { margin-bottom: 16px; }
.app-mb-3 { margin-bottom: 24px; }

.app-p-1 { padding: 8px; }
.app-p-2 { padding: 16px; }
.app-p-3 { padding: 24px; }

.app-flex { display: flex; }
.app-flex-center { display: flex; align-items: center; justify-content: center; }
.app-flex-between { display: flex; align-items: center; justify-content: space-between; }
.app-gap-1 { gap: 8px; }
.app-gap-2 { gap: 16px; }
.app-gap-3 { gap: 24px; }

.app-hidden { display: none !important; }
.app-visible { display: block !important; }

/* =====================================================
   PWA Install Banner (Enhanced)
   ===================================================== */
#pwa-install-banner {
  display: none;
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  background: linear-gradient(135deg, var(--primary-color) 0%, var(--primary-dark) 100%);
  color: white;
  padding: 20px;
  text-align: center;
  z-index: 9999;
  box-shadow: 0 -4px 20px rgba(0,0,0,0.2);
  animation: slideUp 0.3s ease-out;
}

@keyframes slideUp {
  from {
    transform: translateY(100%);
  }
  to {
    transform: translateY(0);
  }
}

#pwa-install-banner p {
  margin: 0 0 12px 0;
}

#pwa-install-banner button {
  background: white;
  color: var(--primary-color);
  border: none;
  padding: 12px 24px;
  margin: 5px;
  border-radius: var(--border-radius);
  cursor: pointer;
  font-weight: 600;
  font-size: 0.95rem;
  transition: all var(--transition-fast);
}

#pwa-install-banner button:hover {
  transform: translateY(-2px);
  box-shadow: 0 4px 12px rgba(0,0,0,0.2);
}

#pwa-install-banner .close-btn {
  background: transparent;
  color: white;
  border: 2px solid white;
}

#pwa-install-banner .close-btn:hover {
  background: rgba(255,255,255,0.15);
}

/* =====================================================
   Mobile Responsive
   ===================================================== */
@media (max-width: 768px) {
  body {
    font-size: 14px;
  }
  
  .app-card {
    padding: 16px;
    border-radius: var(--border-radius);
  }
  
  .app-btn {
    padding: 10px 20px;
    width: 100%;
    justify-content: center;
  }
  
  .app-modal {
    margin: 10px;
    max-width: calc(100% - 20px) !important;
  }
  
  .app-table {
    font-size: 0.85rem;
  }
  
  .app-table th,
  .app-table td {
    padding: 10px 12px;
  }
  
  .app-section {
    padding: 16px;
  }
  
  .app-flex-between {
    flex-direction: column;
    gap: 12px;
  }
}

/* =====================================================
   Dark Mode Support (Optional)
   ===================================================== */
@media (prefers-color-scheme: dark) {
  .app-dark-mode {
    --bg-light: #1a1a2e;
    --bg-white: #16213e;
    --bg-dark: #0f0f1a;
    --text-primary: #e9ecef;
    --text-secondary: #adb5bd;
    --border-color: #343a40;
  }
}

/* =====================================================
   Print Styles
   ===================================================== */
@media print {
  .app-navbar,
  #pwa-install-banner,
  .app-btn {
    display: none !important;
  }
  
  .app-card {
    box-shadow: none;
    border: 1px solid #ddd;
  }
}
