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

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  background: #f7fafc;
  color: #2d3748;
}

.admin-container {
  max-width: 1400px;
  margin: 0 auto;
  padding: 20px;
}

header {
  background: white;
  padding: 30px;
  border-radius: 12px;
  box-shadow: 0 2px 4px rgba(0,0,0,0.1);
  margin-bottom: 30px;
  display: flex;
  justify-content: space-between;
  align-items: center;
}

header h1 {
  font-size: 2em;
  color: #2d3748;
}

.back-link {
  padding: 10px 20px;
  background: #667eea;
  color: white;
  text-decoration: none;
  border-radius: 8px;
  transition: background 0.3s;
}

.back-link:hover {
  background: #5568d3;
}

.actions {
  margin-bottom: 30px;
  display: flex;
  gap: 10px;
}

.btn {
  padding: 12px 24px;
  border: none;
  border-radius: 8px;
  cursor: pointer;
  font-size: 1em;
  transition: all 0.3s;
}

.btn-primary {
  background: #667eea;
  color: white;
}

.btn-primary:hover {
  background: #5568d3;
}

.btn-secondary {
  background: #e2e8f0;
  color: #2d3748;
}

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

.btn-small {
  padding: 6px 12px;
  font-size: 0.9em;
  border: none;
  background: #4299e1;
  color: white;
  border-radius: 4px;
  cursor: pointer;
  margin-right: 5px;
}

.btn-small:hover {
  background: #3182ce;
}

.btn-danger {
  background: #f56565;
}

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

.form-container {
  background: white;
  padding: 30px;
  border-radius: 12px;
  box-shadow: 0 2px 4px rgba(0,0,0,0.1);
  margin-bottom: 30px;
}

.form-container h2 {
  margin-bottom: 20px;
  color: #2d3748;
}

.form-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
  gap: 20px;
  margin-bottom: 20px;
}

.form-group {
  display: flex;
  flex-direction: column;
}

.form-group label {
  margin-bottom: 8px;
  font-weight: 500;
  color: #4a5568;
}

.form-group input,
.form-group textarea,
.form-group select {
  padding: 10px;
  border: 1px solid #e2e8f0;
  border-radius: 6px;
  font-size: 1em;
}

.form-group input:focus,
.form-group textarea:focus {
  outline: none;
  border-color: #667eea;
}

.form-actions {
  display: flex;
  gap: 10px;
  margin-top: 20px;
}

.services-table {
  background: white;
  padding: 30px;
  border-radius: 12px;
  box-shadow: 0 2px 4px rgba(0,0,0,0.1);
}

.services-table h2 {
  margin-bottom: 20px;
  color: #2d3748;
}

table {
  width: 100%;
  border-collapse: collapse;
}

thead {
  background: #f7fafc;
}

th {
  padding: 12px;
  text-align: left;
  font-weight: 600;
  color: #4a5568;
  border-bottom: 2px solid #e2e8f0;
}

td {
  padding: 12px;
  border-bottom: 1px solid #e2e8f0;
}

tr:hover {
  background: #f7fafc;
}

tr.inactive {
  opacity: 0.5;
}

.badge {
  display: inline-block;
  padding: 4px 12px;
  background: #e2e8f0;
  border-radius: 12px;
  font-size: 0.85em;
  color: #2d3748;
}

.status-badge {
  display: inline-block;
  padding: 4px 12px;
  border-radius: 12px;
  font-size: 0.85em;
  font-weight: 500;
}

.status-badge.active {
  background: #c6f6d5;
  color: #22543d;
}

.status-badge.inactive {
  background: #fed7d7;
  color: #742a2a;
}

td.actions {
  white-space: nowrap;
}

/* Modal Styles */
.modal {
  display: none;
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0,0,0,0.5);
  z-index: 1000;
  overflow-y: auto;
  padding: 20px;
  justify-content: center;
  align-items: center;
}

.modal.active {
  display: flex;
}

/* Enhanced Modal Styles */
.enhanced-modal .modal-content {
  animation: slideDown 0.3s ease;
}

.enhanced-header {
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  color: white;
  padding: 25px 30px 15px 30px;
  margin: 0;
  border-radius: 12px 12px 0 0;
}

.enhanced-header h2 {
  color: white;
  margin: 0;
  font-size: 1.4em;
}

.enhanced-header .close-btn {
  color: white;
  background: rgba(255,255,255,0.2);
}

.enhanced-header .close-btn:hover {
  background: rgba(255,255,255,0.3);
  color: white;
}

@keyframes slideDown {
  from {
    opacity: 0;
    transform: translateY(-30px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

/* Service Logo Thumbnail */
.service-logo-thumb {
  width: 32px;
  height: 32px;
  object-fit: contain;
  border-radius: 6px;
  border: 2px solid #e2e8f0;
  background: white;
  padding: 2px;
}

table td {
  vertical-align: middle;
}

table tbody tr {
  cursor: pointer;
  transition: background-color 0.2s;
}

table tbody tr:hover {
  background-color: #f7fafc;
}

table tbody tr.selected {
  background-color: #ebf4ff !important;
  border-left: 4px solid #667eea;
}

table tbody tr.selected .actions {
  display: table-cell !important;
}

.modal-content {
  background: white;
  border-radius: 12px;
  max-width: 800px;
  width: 100%;
  max-height: 90vh;
  position: relative;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.modal-body {
  overflow-y: auto;
  padding: 20px 30px 30px 30px;
  max-height: calc(90vh - 80px);
}

.modal-content form {
  overflow-y: auto;
  padding: 0 30px 30px 30px;
}

.enhanced-modal .modal-header {
  position: sticky;
  top: 0;
  z-index: 10;
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
}

.modal-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 0;
  padding: 25px 30px 15px 30px;
  border-bottom: 2px solid #e2e8f0;
  background: transparent;
}

.modal-header h2 {
  margin: 0;
  color: #2d3748;
}

.close-btn {
  background: rgba(255,255,255,0.2);
  border: none;
  font-size: 2em;
  color: #fff;
  cursor: pointer;
  padding: 0;
  width: 40px;
  height: 40px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  transition: all 0.3s;
  position: relative;
}

.close-btn:hover {
  background: rgba(255,255,255,0.3);
  color: #fff;
}

/* Category Management */
.category-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 15px;
  background: #f7fafc;
  border-radius: 8px;
  margin-bottom: 10px;
}

.category-info {
  display: flex;
  flex-direction: column;
  gap: 5px;
}

.category-info strong {
  font-size: 1.1em;
  color: #2d3748;
}

.category-info span {
  font-size: 0.9em;
  color: #718096;
}

.category-actions {
  display: flex;
  gap: 10px;
}

/* Social Link Items */
.social-link-item {
  padding: 15px;
  background: #f7fafc;
  border-radius: 8px;
  margin-bottom: 15px;
}

.social-link-item .form-grid {
  grid-template-columns: 1fr 2fr 1fr auto;
  align-items: end;
}

.btn-icon-remove {
  background: #e53e3e;
  color: white;
  border: none;
  border-radius: 6px;
  width: 36px;
  height: 36px;
  font-size: 1.8em;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.3s;
  padding: 0;
  line-height: 1;
}

.btn-icon-remove:hover {
  background: #c53030;
  transform: scale(1.1);
}

/* Logo Preview */
.logo-preview {
  margin-top: 10px;
  min-height: 20px;
}

.logo-preview img {
  max-width: 100px;
  max-height: 100px;
  border-radius: 8px;
  border: 2px solid #e2e8f0;
}

/* Custom Modal Styles for Alerts and Confirmations */
.custom-modal {
  display: none;
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0, 0, 0, 0.6);
  z-index: 10000;
  justify-content: center;
  align-items: center;
  animation: fadeIn 0.3s ease;
}

.custom-modal.active {
  display: flex;
}

.custom-modal-content {
  background: white;
  border-radius: 15px;
  max-width: 500px;
  width: 90%;
  box-shadow: 0 10px 40px rgba(0, 0, 0, 0.3);
  animation: slideDown 0.3s ease;
  overflow: hidden;
}

.custom-modal-header {
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  color: white;
  padding: 20px 25px;
}

.custom-modal-header h3 {
  margin: 0;
  font-size: 1.3em;
  font-weight: 600;
}

.custom-modal-body {
  padding: 30px 25px;
  color: #2d3748;
  font-size: 1.05em;
  line-height: 1.6;
}

.custom-modal-body p {
  margin: 0;
}

.custom-modal-footer {
  padding: 20px 25px;
  background: #f7fafc;
  display: flex;
  gap: 10px;
  justify-content: flex-end;
  border-top: 1px solid #e2e8f0;
}

.custom-modal-footer .btn {
  padding: 10px 25px;
  border: none;
  border-radius: 8px;
  cursor: pointer;
  font-size: 1em;
  font-weight: 500;
  transition: all 0.3s;
}

.custom-modal-footer .btn-primary {
  background: #667eea;
  color: white;
}

.custom-modal-footer .btn-primary:hover {
  background: #5568d3;
  transform: translateY(-1px);
}

.custom-modal-footer .btn-danger {
  background: #f56565;
  color: white;
}

.custom-modal-footer .btn-danger:hover {
  background: #e53e3e;
  transform: translateY(-1px);
}

.custom-modal-footer .btn-secondary {
  background: #e2e8f0;
  color: #2d3748;
}

.custom-modal-footer .btn-secondary:hover {
  background: #cbd5e0;
}

@keyframes fadeIn {
  from { opacity: 0; }
  to { opacity: 1; }
}

@keyframes slideDown {
  from {
    opacity: 0;
    transform: translateY(-30px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@media (max-width: 768px) {
  header {
    flex-direction: column;
    gap: 20px;
  }
  
  table {
    font-size: 0.9em;
  }
  
  .form-grid {
    grid-template-columns: 1fr;
  }
  
  .social-link-item .form-grid {
    grid-template-columns: 1fr;
  }
  
  .modal-content {
    padding: 20px;
    margin: 10px;
  }
}

/* Enhanced Modal Redesign Styles */
.modal-redesigned {
  max-width: 900px;
}

/* Wider modal for social media settings */
#socialModal .modal-content {
  max-width: 1100px;
  width: 95%;
}

.modal-redesigned .modal-body {
  padding: 0;
}

.modal-redesigned form {
  padding: 0;
}

.form-section {
  padding: 25px 30px;
  border-bottom: 1px solid #e2e8f0;
}

.form-section:last-of-type {
  border-bottom: none;
}

.section-title {
  font-size: 1.1em;
  font-weight: 600;
  color: #2d3748;
  margin: 0 0 20px 0;
  padding-bottom: 10px;
  border-bottom: 2px solid #667eea;
  display: inline-block;
}

.form-grid-3 {
  grid-template-columns: repeat(3, 1fr);
}

.form-group-checkbox {
  display: flex;
  align-items: flex-end;
  padding-bottom: 10px;
}

.checkbox-label {
  display: flex;
  align-items: center;
  gap: 10px;
  cursor: pointer;
  padding: 12px;
  background: #f7fafc;
  border-radius: 8px;
  transition: all 0.3s;
  width: 100%;
  justify-content: center;
}

.checkbox-label:hover {
  background: #e2e8f0;
}

.checkbox-label input[type="checkbox"] {
  width: 20px;
  height: 20px;
  cursor: pointer;
  margin: 0;
}

.checkbox-text {
  font-weight: 600;
  color: #2d3748;
  font-size: 1.05em;
}

/* Color Picker Styling */
input[type="color"] {
  width: 100%;
  height: 45px;
  border: 2px solid #cbd5e0;
  border-radius: 8px;
  cursor: pointer;
  transition: all 0.3s;
}

input[type="color"]:hover {
  border-color: #667eea;
  box-shadow: 0 2px 8px rgba(102, 126, 234, 0.2);
}

input[type="color"]::-webkit-color-swatch-wrapper {
  padding: 4px;
}

input[type="color"]::-webkit-color-swatch {
  border: none;
  border-radius: 6px;
}

/* Enhanced File Upload */
.file-upload-enhanced {
  display: flex;
  align-items: center;
  gap: 15px;
  padding: 12px;
  background: #f7fafc;
  border-radius: 8px;
  border: 2px dashed #cbd5e0;
  transition: all 0.3s;
}

.file-upload-enhanced:hover {
  border-color: #667eea;
  background: #ebf4ff;
}

.file-input-hidden {
  display: none;
}

.btn-upload {
  padding: 10px 20px;
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  color: white;
  border: none;
  border-radius: 8px;
  cursor: pointer;
  font-weight: 600;
  transition: all 0.3s;
  display: flex;
  align-items: center;
  gap: 8px;
  white-space: nowrap;
}

.btn-upload:hover {
  transform: translateY(-2px);
  box-shadow: 0 4px 12px rgba(102, 126, 234, 0.4);
}

.file-name {
  color: #718096;
  font-size: 0.95em;
  flex: 1;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* Category List Enhanced */
.category-list-enhanced {
  margin-bottom: 25px;
}

.category-item {
  background: linear-gradient(135deg, #f7fafc 0%, #e2e8f0 100%);
  border-left: 4px solid #667eea;
  transition: all 0.3s;
}

.category-item:hover {
  transform: translateX(5px);
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
}

.category-add-section {
  background: #f7fafc;
  border-radius: 12px;
  margin-top: 20px;
}

/* Social Links Enhanced */
.social-links-enhanced .social-link-item {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 15px;
}

.social-links-enhanced .social-link-item .form-grid {
  flex: 1;
  display: flex;
  gap: 10px;
  margin: 0;
}

.social-links-enhanced .social-link-item .form-grid .form-group {
  flex: 1;
  margin: 0;
}

.social-links-enhanced .social-link-item button {
  flex-shrink: 0;
  margin-top: 0;
}

.social-links-enhanced .social-link-item-old {
  background: linear-gradient(135deg, #f7fafc 0%, #e2e8f0 100%);
  border-left: 4px solid #667eea;
  transition: all 0.3s;
}

.social-links-enhanced .social-link-item:hover {
  transform: translateX(5px);
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
}

.btn-add-social {
  width: 100%;
  margin-top: 15px;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 14px;
  font-size: 1.05em;
}

/* Improved Form Actions */
.form-actions {
  display: flex;
  gap: 12px;
  margin-top: 0;
  padding: 25px 30px;
  background: #f7fafc;
  border-top: 1px solid #e2e8f0;
  position: sticky;
  bottom: 0;
}

.modal-redesigned .form-actions {
  margin-top: 0;
}

/* Table row selection persistence fix */
table tbody tr.selected {
  background-color: #ebf4ff !important;
  border-left: 4px solid #667eea;
}

table tbody tr.selected:hover {
  background-color: #dbeafe !important;
}

/* Ensure actions stay visible when row is selected */
table tbody tr.selected td.actions {
  display: table-cell !important;
  opacity: 1;
}

/* Prevent deselection on button clicks */
table tbody tr td.actions button {
  pointer-events: auto;
}

@media (max-width: 768px) {
  .form-grid-3 {
    grid-template-columns: 1fr;
  }
  
  .modal-redesigned {
    max-width: 95%;
  }
  
  .form-section {
    padding: 20px 15px;
  }
  
  .file-upload-enhanced {
    flex-direction: column;
    align-items: stretch;
  }
  
  .btn-upload {
    justify-content: center;
  }
}

/* Google Drive Setup Modal Styles */
.status-display {
  background: linear-gradient(135deg, #f7fafc 0%, #edf2f7 100%);
  border-radius: 12px;
  padding: 20px;
  border: 2px solid #e2e8f0;
}

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

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

.status-label {
  font-weight: 600;
  color: #2d3748;
}

.status-value {
  font-family: 'Courier New', monospace;
  font-size: 14px;
}

.enabled-services-list {
  background: #f7fafc;
  border-radius: 12px;
  padding: 20px;
  max-height: 300px;
  overflow-y: auto;
}

.enabled-services-count {
  background: linear-gradient(135deg, #4285f4, #34a853);
  color: white;
  padding: 10px 15px;
  border-radius: 8px;
  margin-bottom: 15px;
  text-align: center;
}

.enabled-service-item {
  display: flex;
  align-items: center;
  padding: 12px;
  background: white;
  border-radius: 8px;
  margin-bottom: 8px;
  border: 1px solid #e2e8f0;
  transition: all 0.3s ease;
}

.enabled-service-item:hover {
  border-color: #4285f4;
  box-shadow: 0 2px 8px rgba(66, 133, 244, 0.1);
}

.enabled-service-item i {
  margin-right: 10px;
  font-size: 20px;
}

.enabled-service-item .service-name {
  font-weight: 600;
  color: #2d3748;
  flex: 1;
}

.enabled-service-item .service-path {
  font-family: 'Courier New', monospace;
  font-size: 12px;
  color: #718096;
  background: #edf2f7;
  padding: 4px 8px;
  border-radius: 4px;
}

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

.empty-state p {
  margin: 10px 0;
}

.setup-steps {
  background: #f7fafc;
  border-radius: 12px;
  padding: 20px;
}

.step-item {
  display: flex;
  gap: 20px;
  margin-bottom: 25px;
  padding-bottom: 25px;
  border-bottom: 2px dashed #e2e8f0;
}

.step-item:last-child {
  border-bottom: none;
  margin-bottom: 0;
  padding-bottom: 0;
}

.step-number {
  flex-shrink: 0;
  width: 40px;
  height: 40px;
  background: linear-gradient(135deg, #4285f4, #34a853);
  color: white;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: bold;
  font-size: 18px;
}

.step-content {
  flex: 1;
}

.step-content h4 {
  margin: 0 0 10px 0;
  color: #2d3748;
  font-size: 16px;
}

.step-content p {
  margin: 8px 0;
  color: #4a5568;
  line-height: 1.6;
}

.code-block {
  position: relative;
  background: #1a202c;
  color: #48bb78;
  padding: 15px;
  border-radius: 8px;
  font-family: 'Courier New', monospace;
  font-size: 14px;
  margin: 10px 0;
  overflow-x: auto;
}

.code-block code {
  display: block;
  white-space: pre-wrap;
  word-break: break-all;
}

.copy-btn {
  position: absolute;
  top: 10px;
  right: 10px;
  background: rgba(255, 255, 255, 0.1);
  border: 1px solid rgba(255, 255, 255, 0.2);
  color: white;
  padding: 6px 10px;
  border-radius: 6px;
  cursor: pointer;
  font-size: 12px;
  transition: all 0.3s ease;
}

.copy-btn:hover {
  background: rgba(255, 255, 255, 0.2);
  transform: scale(1.05);
}

.setup-list {
  margin: 10px 0;
  padding-left: 20px;
}

.setup-list li {
  margin: 8px 0;
  color: #4a5568;
  line-height: 1.6;
}

.setup-list li strong {
  color: #2d3748;
  font-family: 'Courier New', monospace;
  background: #edf2f7;
  padding: 2px 6px;
  border-radius: 3px;
}

.reference-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 15px;
  background: #f7fafc;
  padding: 20px;
  border-radius: 12px;
}

.reference-item {
  background: white;
  padding: 15px;
  border-radius: 8px;
  border: 1px solid #e2e8f0;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.reference-item strong {
  color: #2d3748;
  font-size: 14px;
}

.reference-item span {
  color: #4a5568;
  font-size: 13px;
}

.hint-text {
  margin-top: 10px;
  padding: 12px;
  background: #fef5e7;
  border-left: 4px solid #f59e0b;
  border-radius: 6px;
  font-size: 14px;
  color: #744210;
  display: flex;
  align-items: center;
  gap: 8px;
}

.hint-text i {
  font-size: 20px;
  color: #f59e0b;
}

@keyframes gdriveGlow {
  0%, 100% {
    box-shadow: 0 0 20px rgba(66, 133, 244, 0.3);
  }
  50% {
    box-shadow: 0 0 30px rgba(66, 133, 244, 0.6);
  }
}
