/* AI Smart O&M Platform - 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;
}

/* ===================== Platform Landing ===================== */
.platform-bg {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: #0a0e1a;
  background-image:
    radial-gradient(ellipse at 20% 30%, rgba(26, 115, 232, 0.15) 0%, transparent 50%),
    radial-gradient(ellipse at 80% 70%, rgba(0, 188, 212, 0.12) 0%, transparent 50%),
    linear-gradient(135deg, #0a0e1a 0%, #0d1526 50%, #0a0e1a 100%);
  position: relative;
  overflow: hidden;
}

.platform-bg::before {
  content: '';
  position: absolute;
  top: 0; left: 0; right: 0; bottom: 0;
  background-image:
    linear-gradient(rgba(26, 115, 232, 0.06) 1px, transparent 1px),
    linear-gradient(90deg, rgba(26, 115, 232, 0.06) 1px, transparent 1px);
  background-size: 40px 40px;
  pointer-events: none;
}

.platform-content {
  position: relative;
  z-index: 1;
  width: 100%;
  max-width: 960px;
  padding: 40px 20px;
  text-align: center;
}

.platform-header {
  margin-bottom: 48px;
}

.platform-title {
  font-family: 'Orbitron', 'Roboto', sans-serif;
  font-size: 32px;
  font-weight: 900;
  color: #e8f0fe;
  text-transform: uppercase;
  letter-spacing: 3px;
  text-shadow: 0 0 20px rgba(26, 115, 232, 0.5), 0 0 40px rgba(26, 115, 232, 0.3);
  margin-bottom: 8px;
}

.platform-subtitle {
  font-size: 14px;
  color: rgba(232, 240, 254, 0.5);
  letter-spacing: 1px;
  text-transform: uppercase;
}

.platform-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 20px;
}

.platform-card {
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid rgba(26, 115, 232, 0.2);
  border-radius: 16px;
  padding: 32px 20px;
  cursor: pointer;
  transition: all 0.4s cubic-bezier(0.23, 1, 0.32, 1);
  position: relative;
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  overflow: hidden;
}

.platform-card::after {
  content: '';
  position: absolute;
  top: 0; left: -100%;
  width: 100%; height: 100%;
  background: linear-gradient(90deg, transparent, rgba(26, 115, 232, 0.08), transparent);
  transition: left 0.6s ease;
}

.platform-card:hover::after {
  left: 100%;
}

.platform-card:hover {
  border-color: rgba(26, 115, 232, 0.6);
  background: rgba(26, 115, 232, 0.08);
  transform: translateY(-6px);
  box-shadow: 0 12px 40px rgba(26, 115, 232, 0.2);
}

.platform-card.disabled {
  opacity: 0.45;
  cursor: default;
  pointer-events: none;
}

.platform-card-icon {
  font-size: 44px;
  margin-bottom: 16px;
  filter: drop-shadow(0 0 8px rgba(26, 115, 232, 0.4));
}

.platform-card-name {
  font-size: 16px;
  font-weight: 700;
  color: #e8f0fe;
  margin-bottom: 8px;
}

.platform-card-desc {
  font-size: 12px;
  color: rgba(232, 240, 254, 0.45);
  line-height: 1.5;
  margin-bottom: 16px;
}

.platform-card-badge {
  display: inline-block;
  padding: 3px 12px;
  border-radius: 20px;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 1px;
  background: rgba(26, 115, 232, 0.2);
  color: #8ab4f8;
  border: 1px solid rgba(26, 115, 232, 0.4);
}

.platform-card-badge.coming {
  background: rgba(255, 255, 255, 0.06);
  color: rgba(232, 240, 254, 0.4);
  border-color: rgba(255, 255, 255, 0.15);
}

@media (max-width: 768px) {
  .platform-title { font-size: 22px; letter-spacing: 2px; }
  .platform-subtitle { font-size: 11px; }
  .platform-grid { grid-template-columns: 1fr; gap: 16px; }
  .platform-card { padding: 24px 16px; }
  .platform-card-icon { font-size: 36px; }
}

#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;
}

/* Project Grid (landing screen) */
.project-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
  gap: 12px;
}

.project-card {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 20px 12px;
  background: white;
  border-radius: 12px;
  box-shadow: 0 1px 4px rgba(0, 0, 0, 0.1);
  cursor: pointer;
  transition: all 0.3s;
  text-align: center;
}

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

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

.project-card-name {
  font-size: 15px;
  font-weight: 500;
  color: #333;
  word-break: break-word;
}

/* 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;
}
