/* CCSPC SMA - Smart Maintenance Assistant Styles */

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

body {
  font-family: 'Roboto', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  background: #f5f5f5;
  color: #333;
  min-height: 100vh;
  overflow-x: hidden;
}

#app {
  min-height: 100vh;
}

/* Screen Management */
.screen {
  display: none;
  min-height: 100vh;
}

.screen.active {
  display: block;
}

/* Login Screen */
.login-container {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  padding: 20px;
  background: linear-gradient(135deg, #1a73e8 0%, #4285f4 100%);
}

.logo-section {
  text-align: center;
  margin-bottom: 40px;
}

.logo {
  width: 100px;
  height: 100px;
  margin-bottom: 10px;
}

.logo-section h1 {
  color: white;
  font-size: 28px;
  font-weight: 500;
  margin-bottom: 5px;
}

.logo-section p {
  color: rgba(255, 255, 255, 0.8);
  font-size: 14px;
}

.form-container {
  width: 100%;
  max-width: 300px;
  background: white;
  padding: 30px;
  border-radius: 12px;
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.15);
}

/* Input Fields */
.input-field {
  width: 100%;
  padding: 12px 16px;
  border: 1px solid #ddd;
  border-radius: 8px;
  font-size: 16px;
  margin-bottom: 12px;
  transition: border-color 0.3s;
}

.input-field:focus {
  outline: none;
  border-color: #1a73e8;
}

textarea.input-field {
  min-height: 80px;
  resize: vertical;
}

/* Buttons */
.btn {
  padding: 12px 24px;
  border: none;
  border-radius: 8px;
  font-size: 16px;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.3s;
}

.btn-primary {
  background: #1a73e8;
  color: white;
}

.btn-primary:hover {
  background: #1557b0;
}

.btn-secondary {
  background: #f1f3f4;
  color: #333;
}

.btn-secondary:hover {
  background: #e8eaed;
}

.btn-danger {
  background: #ea4335;
  color: white;
}

.btn-danger:hover {
  background: #c5221f;
}

.btn-back {
  background: transparent;
  color: white;
  padding: 8px 12px;
  font-size: 14px;
}

.btn-large {
  width: 100%;
  padding: 16px;
  font-size: 18px;
}

.btn-group {
  display: flex;
  gap: 6px;
  margin-top: 12px;
  flex-wrap: wrap;
}

.btn-group .btn {
  flex: 1;
  min-width: 0;
  padding: 10px 6px;
  font-size: 13px;
  white-space: nowrap;
}

/* Header */
.header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px;
  background: #1a73e8;
  color: white;
  position: sticky;
  top: 0;
  z-index: 100;
}

.header h1 {
  font-size: 18px;
  font-weight: 500;
}

.header .spacer {
  width: 60px;
}

/* Navigation Grid */
.nav-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 16px;
  padding: 20px;
}

.nav-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 24px 16px;
  background: white;
  border-radius: 12px;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
  cursor: pointer;
  transition: all 0.3s;
}

.nav-item:hover {
  transform: translateY(-2px);
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
}

.nav-icon {
  font-size: 32px;
  margin-bottom: 8px;
}

.nav-label {
  font-size: 14px;
  font-weight: 500;
  color: #333;
  text-align: center;
}

/* Content Area */
.content {
  padding: 16px;
}

/* Form Groups */
.form-group {
  margin-bottom: 16px;
}

.form-group label {
  display: block;
  font-size: 14px;
  font-weight: 500;
  color: #555;
  margin-bottom: 6px;
}

/* Suggestions */
.suggestions {
  background: white;
  border-radius: 8px;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
  max-height: 200px;
  overflow-y: auto;
  margin-top: 4px;
}

.suggestion-item {
  padding: 12px 16px;
  cursor: pointer;
  border-bottom: 1px solid #eee;
}

.suggestion-item:hover {
  background: #f5f5f5;
}

/* Info Box */
.info-box {
  padding: 12px 16px;
  background: #e8f5e9;
  border-radius: 8px;
  font-size: 14px;
  color: #2e7d32;
}

/* Camera Section */
.camera-preview {
  width: 100%;
  height: 300px;
  background: #f5f5f5;
  border-radius: 12px;
  margin-bottom: 16px;
  overflow: hidden;
}

.camera-preview img {
  width: 100%;
  height: 100%;
  object-fit: contain;
}

/* Result Card */
.result-card {
  background: white;
  padding: 20px;
  border-radius: 12px;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
  margin-bottom: 16px;
}

.result-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 12px 0;
  border-bottom: 1px solid #eee;
}

.result-item:last-child {
  border-bottom: none;
}

.result-item .label {
  font-weight: 500;
  color: #555;
  flex-shrink: 0;
  margin-right: 16px;
}

.result-item .result-value {
  text-align: right;
  color: #333;
  word-break: break-all;
}

/* Filter Bar */
.filter-bar {
  display: flex;
  gap: 8px;
  margin-bottom: 16px;
}

.filter-bar .input-field {
  flex: 1;
  min-width: 0;
}

/* List Container */
.list-container {
  max-height: 400px;
  overflow-y: auto;
}

.list-item {
  background: white;
  padding: 16px;
  border-radius: 8px;
  margin-bottom: 8px;
  box-shadow: 0 1px 4px rgba(0, 0, 0, 0.1);
}

.list-item-header {
  font-weight: 500;
  color: #1a73e8;
  margin-bottom: 4px;
}

.list-item-content {
  font-size: 14px;
  color: #555;
}

.empty-state {
  text-align: center;
  padding: 40px;
  color: #999;
}

/* Chat Container */
.ai-hint {
  text-align: center;
  padding: 8px;
  background: #e8f5e9;
  color: #2e7d32;
  border-radius: 8px;
  font-size: 12px;
  color: #e65100;
  margin-bottom: 16px;
}

.chat-container {
  background: white;
  border-radius: 12px;
  padding: 16px;
  min-height: 300px;
  max-height: 400px;
  overflow-y: auto;
  margin-bottom: 16px;
}

.chat-message {
  margin-bottom: 12px;
}

.chat-message.user {
  text-align: right;
}

.chat-message.user .message-content {
  background: #1a73e8;
  color: white;
}

.chat-message.bot .message-content {
  background: #f1f3f4;
  color: #333;
}

.message-content {
  display: inline-block;
  padding: 12px 16px;
  border-radius: 12px;
  max-width: 80%;
  word-wrap: break-word;
}

.chat-input {
  display: flex;
  gap: 8px;
}

.chat-input .input-field {
  flex: 1;
}

/* Tab Bar */
.tab-bar {
  display: flex;
  gap: 6px;
  margin-bottom: 16px;
}

.tab {
  flex: 1;
  padding: 12px;
  background: #f1f3f4;
  border-radius: 8px;
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.3s;
}

.tab.active {
  background: #1a73e8;
  color: white;
}

.tab-content {
  display: none;
}

.tab-content.active {
  display: block !important;
}

/* User Section */
.user-section {
  background: white;
  padding: 20px;
  border-radius: 12px;
  margin-bottom: 16px;
}

.user-section h3 {
  font-size: 16px;
  font-weight: 500;
  margin-bottom: 16px;
  color: #333;
}

/* Admin Only */
.admin-only {
  display: none;
}

.is-admin .admin-only {
  display: block;
}

.is-admin .nav-item.admin-only {
  display: flex;
}

/* Superadmin Only */
.superadmin-only {
  display: none !important;
}

.is-superadmin .superadmin-only {
  display: block !important;
}

.is-superadmin .nav-item.superadmin-only {
  display: flex !important;
}

/* Trial users: hide all admin features */

/* Role badges */
.role-badge {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 10px;
  font-size: 11px;
  font-weight: 500;
}
.role-superadmin {
  background: #ffebee;
  color: #c62828;
}
.role-dataadmin {
  background: #e3f2fd;
  color: #1565c0;
}
.role-user {
  background: #e8f5e9;
  color: #2e7d32;
}
.role-trial {
  background: #fff3e0;
  color: #e65100;
}

/* Modal */
.modal {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0, 0, 0, 0.5);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
}

.modal.hidden {
  display: none;
}

.modal-content {
  background: white;
  padding: 30px;
  border-radius: 16px;
  text-align: center;
  max-width: 300px;
}

.modal-content.error {
  background: #fce4ec;
}

.modal-icon {
  font-size: 48px;
  margin-bottom: 16px;
}

.modal-content h2 {
  font-size: 20px;
  margin-bottom: 8px;
}

.modal-content p {
  font-size: 14px;
  color: #555;
  margin-bottom: 20px;
}

/* Hidden Elements */
.hidden {
  display: none !important;
}

/* Error Message */
.error-message {
  color: #ea4335;
  font-size: 14px;
  text-align: center;
  margin-top: 12px;
}

/* Result Count */
.result-count {
  font-size: 14px;
  color: #555;
  margin-bottom: 12px;
}

/* Loading Spinner */
.loading {
  display: inline-block;
  width: 20px;
  height: 20px;
  border: 2px solid #f3f3f3;
  border-top: 2px solid #1a73e8;
  border-radius: 50%;
  animation: spin 1s linear infinite;
}

@keyframes spin {
  0% { transform: rotate(0deg); }
  100% { transform: rotate(360deg); }
}

/* Responsive */
@media (max-width: 360px) {
  .nav-grid {
    grid-template-columns: 1fr;
  }
  
  .header h1 {
    font-size: 16px;
  }
  
  .btn {
    padding: 10px 16px;
    font-size: 14px;
  }
}

/* Sub Tab Bar */
.sub-tab-bar {
  display: flex;
  gap: 8px;
  margin-bottom: 20px;
  border-bottom: 2px solid #e0e0e0;
}

.sub-tab {
  padding: 10px 20px;
  border: none;
  background: #e3f2fd;
  color: #1565c0;
  font-size: 14px;
  cursor: pointer;
  border-radius: 8px 8px 0 0;
  font-weight: 500;
  transition: all 0.3s;
}

.sub-tab:hover {
  background: #bbdefb;
}

.sub-tab.active {
  background: #1a73e8;
  color: #fff;
}

.sub-tab-content {
  display: none;
}

.sub-tab-content.active {
  display: block;
}

/* Result Container */
.result-container {
  margin-top: 16px;
}

.data-table {
  width: 100%;
  border-collapse: collapse;
  margin-top: 12px;
  font-size: 14px;
}

.data-table th,
.data-table td {
  padding: 10px 8px;
  text-align: left;
  border-bottom: 1px solid #eee;
}

.data-table th {
  background: #f5f5f5;
  font-weight: 500;
  color: #333;
}

.data-table tr:hover {
  background: #fafafa;
}

.data-table .action-btn {
  padding: 4px 8px;
  margin: 2px;
  font-size: 12px;
}

/* Reading Form */
.reading-form {
  margin-top: 20px;
  padding: 16px;
  background: #f9f9f9;
  border-radius: 8px;
}

.reading-form h4 {
  margin-bottom: 12px;
  color: #333;
}

/* Site Info Display */
.site-info {
  padding: 12px;
  background: #e3f2fd;
  border-radius: 8px;
  margin-bottom: 12px;
}

.site-info-item {
  display: flex;
  justify-content: space-between;
  padding: 6px 0;
}

.site-info-item .label {
  font-weight: 500;
  color: #666;
}

/* Message Box */
.message {
  padding: 12px;
  border-radius: 8px;
  margin-top: 12px;
  font-size: 14px;
}

.message.success {
  background: #e8f5e9;
  color: #2e7d32;
}

.message.error {
  background: #ffebee;
  color: #c62828;
}

/* Site Reading Card (Query & Download) */
.site-reading-card {
  background: white;
  border-radius: 12px;
  box-shadow: 0 2px 8px rgba(0,0,0,0.1);
  margin-bottom: 16px;
  overflow: hidden;
}

.card-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 12px 16px;
  background: #e3f2fd;
  border-bottom: 1px solid #bbdefb;
}

.site-id-badge {
  font-weight: 700;
  font-size: 16px;
  color: #1565c0;
}

.site-coords {
  font-size: 12px;
  color: #666;
}

.site-reading-card .data-table {
  margin: 0;
}

.site-reading-card .data-table th {
  background: #fafafa;
  font-size: 12px;
}

.site-reading-card .data-table td {
  font-size: 13px;
}

/* Add User Section */
.admin-only .user-section.admin-only {
  display: block;
}

/* Photo Preview in off-site */
#offsite-preview img {
  width: 100%;
  height: 100%;
  object-fit: contain;
}

/* Improve modal */
.modal-message {
  font-size: 16px;
  color: #333;
  margin-bottom: 20px;
}

/* Loading state */
#ai-loading-msg .message-content {
  background: #f1f3f4;
}

/* Action buttons in tables */
.action-btn {
  padding: 4px 8px !important;
  margin: 1px;
  font-size: 11px !important;
}

/* Site selection list in onsite flow */
#nearby-sites-list .list-item {
  cursor: pointer;
  transition: background 0.2s;
}
#nearby-sites-list .list-item:hover,
#nearby-sites-list .list-item:active {
  background: #e3f2fd;
}

/* Reading edit inline section */
#reading-edit-section,
#offsite-edit-section {
  padding: 8px 0;
  border-top: 1px solid #eee;
}
