/* Bill Splitter Styles */

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Arial, sans-serif;
}

.bill-splitter-container {
  max-width: 900px;
  margin: 20px auto;
  padding: 0 15px;
}

h2 {
  color: #333;
  margin-bottom: 20px;
}

.controls {
  margin: 15px 0;
}

button {
  background: #0066cc;
  color: white;
  border: none;
  padding: 10px 18px;
  border-radius: 6px;
  cursor: pointer;
  font-size: 14px;
  margin: 5px 5px 5px 0;
  transition: background 0.2s, transform 0.1s;
}

button:hover {
  background: #0052a3;
}

button:active {
  transform: scale(0.98);
}

button:disabled {
  background: #ccc;
  cursor: not-allowed;
}

#clearBtn {
  background: #dc3545;
}

#clearBtn:hover {
  background: #c82333;
}

#closeBillBtn {
  background: #ff9800;
}

#closeBillBtn:hover {
  background: #f57c00;
}

#addRowBtn {
  background: #28a745;
}

#addRowBtn:hover {
  background: #218838;
}

input[type="file"] {
  display: block;
  margin: 10px 0;
  padding: 8px;
  border: 2px dashed #ccc;
  border-radius: 6px;
  width: 100%;
  max-width: 400px;
  cursor: pointer;
}

input[type="file"]:hover {
  border-color: #0066cc;
}

select {
  padding: 8px 12px;
  border: 1px solid #ddd;
  border-radius: 6px;
  font-size: 14px;
  margin: 10px 5px 10px 0;
}

#status {
  padding: 10px;
  margin: 10px 0;
  border-radius: 6px;
  background: #f0f0f0;
  min-height: 20px;
}

.bill-table-wrapper {
  width: 100%;
  overflow-x: auto;
  margin: 20px 0;
  box-shadow: 0 2px 8px rgba(0,0,0,0.1);
  border-radius: 8px;
}

.bill-table {
  width: 100%;
  border-collapse: collapse;
  background: white;
  position: relative;
}

.bill-table th:first-child,
.bill-table td:first-child {
  position: sticky;
  left: 0;
  background: white;
  z-index: 10;
  box-shadow: 2px 0 4px rgba(0,0,0,0.1);
}

.bill-table thead th:first-child {
  background: #f8f9fa;
  z-index: 11;
}

.bill-table tfoot td:first-child {
  background: white;
  z-index: 10;
  font-weight: bold;
}

.bill-table th,
.bill-table td {
  border: 1px solid #ddd;
  padding: 10px;
  text-align: left;
}

.bill-table th {
  background: #f8f9fa;
  font-weight: 600;
  position: relative;
}

.bill-table th small {
  display: block;
  font-weight: normal;
  margin-top: 4px;
}

.item-name {
  min-width: 150px;
  max-width: 200px;
  cursor: text;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.item-name:focus {
  outline: 2px solid #0066cc;
  background: #f0f8ff;
}

.item-name[contenteditable="false"] {
  cursor: not-allowed;
  background: #f5f5f5;
}

.item-price {
  width: 80px;
  padding: 6px;
  border: 1px solid #ddd;
  border-radius: 4px;
}

.item-price:focus {
  outline: 2px solid #0066cc;
  border-color: #0066cc;
}

input[type="number"].item-quantity {
  width: 60px;
  padding: 6px;
  border: 1px solid #ddd;
  border-radius: 4px;
  text-align: center;
}

.item-quantity:focus {
  outline: 2px solid #0066cc;
  border-color: #0066cc;
}

.remove-person,
.remove-row {
  background: #dc3545;
  color: white;
  border: none;
  border-radius: 50%;
  width: 24px;
  height: 24px;
  font-size: 16px;
  line-height: 1;
  cursor: pointer;
  margin-left: 8px;
  padding: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.remove-person *,
.remove-row * {
  pointer-events: none; /* Make emoji non-clickable, clicks go to button */
}

.remove-person:hover,
.remove-row:hover {
  background: #c82333;
}

.remove-row {
  font-size: 14px;
}

textarea {
  width: 100%;
  max-width: 500px;
  padding: 10px;
  border: 1px solid #ddd;
  border-radius: 6px;
  font-family: inherit;
  font-size: 14px;
  resize: vertical;
  background: #f9f9f9;
}

textarea:focus {
  outline: 2px solid #0066cc;
  border-color: #0066cc;
}

input[type="text"] {
  display: block;
  margin: 5px 0 15px 0;
}

input[type="text"]:focus {
  outline: 2px solid #0066cc;
  border-color: #0066cc;
}

label {
  display: block;
  margin: 15px 0 5px 0;
  font-weight: 600;
  color: #333;
}

#result {
  background: #f8f9fa;
  padding: 15px;
  border-radius: 6px;
  border-left: 4px solid #0066cc;
  white-space: pre-wrap;
  margin: 20px 0;
  font-family: monospace;
}

/* Share container styles */
#shareContainer {
  margin: 20px 0;
  padding: 15px;
  background: #e3f2fd;
  border-radius: 8px;
  border-left: 4px solid #2196F3;
}

/* Adjustments container styles */
#adjustmentsContainer {
  margin: 15px 0;
  padding: 12px;
  background: #f8f9fa;
  border-radius: 6px;
  border-left: 4px solid #6c757d;
}

#adjustmentsInput {
  width: 120px;
  padding: 8px;
  border: 1px solid #ddd;
  border-radius: 4px;
  font-size: 14px;
}

#adjustmentsInput:focus {
  outline: 2px solid #0066cc;
  border-color: #0066cc;
}

#adjustmentsInput[readonly] {
  background: #e9ecef;
  cursor: not-allowed;
}

#shareContainer strong {
  color: #1976D2;
  font-size: 16px;
}

#shareUrl {
  width: 100%;
  max-width: 500px;
  padding: 8px;
  margin: 10px 0;
  border: 1px solid #90CAF9;
  border-radius: 4px;
  background: white;
  font-family: monospace;
  font-size: 13px;
}

#shareContainer button {
  padding: 8px 16px;
  margin: 5px 5px 5px 0;
}

#copyLinkBtn {
  background: #2196F3;
}

#copyLinkBtn:hover {
  background: #1976D2;
}

#whatsappShareBtn {
  background: #25D366;
}

#whatsappShareBtn:hover {
  background: #128C7E;
}

/* Save bar styles */
#saveBar {
  position: fixed;
  bottom: -100px;
  left: 0;
  right: 0;
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  color: white;
  padding: 15px 20px;
  text-align: center;
  box-shadow: 0 -2px 20px rgba(0,0,0,0.3);
  z-index: 9999;
  transition: bottom 0.3s ease;
}

#saveBar.show {
  bottom: 0;
}

#saveBtn {
  padding: 10px 30px;
  background: white;
  color: #667eea;
  border: none;
  border-radius: 4px;
  cursor: pointer;
  font-weight: 600;
  font-size: 15px;
}

#saveBtn:hover {
  background: #f0f0f0;
}

#saveBtn:disabled {
  background: #ccc;
  color: #666;
  cursor: not-allowed;
}

#cancelBtn {
  padding: 10px 20px;
  background: transparent;
  color: white;
  border: 2px solid white;
  border-radius: 4px;
  cursor: pointer;
  font-weight: 600;
}

#cancelBtn:hover {
  background: rgba(255,255,255,0.1);
}

#unsavedMsg {
  font-weight: 600;
  font-size: 15px;
}

/* Responsive styles */
@media (max-width: 768px) {
  .bill-splitter-container {
    padding: 0 10px;
  }
  
  button {
    padding: 8px 14px;
    font-size: 13px;
  }
  
  .bill-table th,
  .bill-table td {
    padding: 8px;
    font-size: 13px;
  }
  
  .item-name {
    min-width: 120px;
    max-width: 150px;
  }
  
  .item-price {
    width: 70px;
  }
  
  .item-quantity {
    width: 50px !important;
  }
  
  #saveBar {
    padding: 12px 10px;
  }
  
  #saveBar > div {
    flex-direction: column;
    gap: 10px !important;
  }
  
  #saveBtn,
  #cancelBtn {
    width: 100%;
    max-width: 300px;
  }
}

/* Loading indicator */
.loading {
  display: inline-block;
  width: 16px;
  height: 16px;
  border: 2px solid rgba(255,255,255,0.3);
  border-top-color: white;
  border-radius: 50%;
  animation: spin 0.6s linear infinite;
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

/* Permission indicators */
.readonly-indicator {
  display: inline-block;
  padding: 2px 6px;
  background: #ffc107;
  color: #000;
  font-size: 11px;
  border-radius: 3px;
  margin-left: 5px;
}

.owner-badge {
  display: inline-block;
  padding: 3px 8px;
  background: #4CAF50;
  color: white;
  font-size: 11px;
  border-radius: 3px;
  margin-left: 5px;
  font-weight: 600;
}