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

:root {
  --primary: #4285F4;
  --primary-dark: #3367D6;
  --secondary: #34A853;
  --danger: #EA4335;
  --warning: #FBBC05;
  --bg-main: #f5f7fa;
  --bg-card: #ffffff;
  --text-primary: #202124;
  --text-secondary: #5f6368;
  --border: #dadce0;
  --border-dark: #c0c4c9;
  --hover-bg: #f8f9fa;
  --shadow-sm: 0 1px 3px rgba(0, 0, 0, 0.1);
  --shadow-md: 0 4px 6px rgba(0, 0, 0, 0.1);
  --shadow-lg: 0 10px 20px rgba(0, 0, 0, 0.15);
  --transition: all 0.2s ease;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, sans-serif;
  background: var(--bg-main);
  color: var(--text-primary);
  line-height: 1.6;
  min-height: 100vh;
}

.hidden {
  display: none !important;
}

/* Authentication Screen */
.auth-container {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  padding: 20px;
}

.auth-card {
  background: var(--bg-card);
  border-radius: 12px;
  padding: 48px 40px;
  text-align: center;
  box-shadow: var(--shadow-lg);
  max-width: 400px;
  width: 100%;
}

.auth-card h1 {
  font-size: 2rem;
  margin-bottom: 12px;
  color: var(--text-primary);
}

.auth-card p {
  color: var(--text-secondary);
  margin-bottom: 32px;
  font-size: 1rem;
}

.sign-in-btn {
  display: inline-flex;
  align-items: center;
  gap: 12px;
  background: var(--primary);
  color: white;
  border: none;
  padding: 12px 24px;
  border-radius: 8px;
  font-size: 1rem;
  font-weight: 500;
  cursor: pointer;
  transition: var(--transition);
  box-shadow: var(--shadow-sm);
}

.sign-in-btn:hover {
  background: var(--primary-dark);
  box-shadow: var(--shadow-md);
  transform: translateY(-1px);
}

.sign-in-btn:active {
  transform: translateY(0);
}

/* Main Application */
.app-container {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

/* Header */
.header {
  background: var(--bg-card);
  border-bottom: 1px solid var(--border);
  box-shadow: var(--shadow-sm);
  position: sticky;
  top: 0;
  z-index: 100;
}

.header-content {
  max-width: 100%;
  margin: 0 auto;
  padding: 16px 24px;
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.header h1 {
  font-size: 1.5rem;
  color: var(--text-primary);
}

.user-section {
  display: flex;
  align-items: center;
  gap: 12px;
}

.user-photo {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  border: 2px solid var(--border);
}

.user-name {
  color: var(--text-secondary);
  font-size: 0.9rem;
  max-width: 150px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.sign-out-btn {
  background: transparent;
  color: var(--text-secondary);
  border: 1px solid var(--border);
  padding: 8px 16px;
  border-radius: 6px;
  font-size: 0.9rem;
  cursor: pointer;
  transition: var(--transition);
}

.sign-out-btn:hover {
  background: var(--bg-main);
  color: var(--text-primary);
  border-color: var(--text-secondary);
}

/* Filters */
.filters {
  background: var(--bg-card);
  border-bottom: 1px solid var(--border);
  padding: 16px 24px;
  display: flex;
  flex-wrap: wrap;
  gap: 16px;
  align-items: center;
  width: 100%;
}

.filter-group {
  display: flex;
  align-items: center;
  gap: 8px;
}

.filter-group label {
  font-size: 0.9rem;
  color: var(--text-secondary);
  font-weight: 500;
}

.filter-group select,
.filter-group input[type="text"] {
  padding: 8px 12px;
  border: 1px solid var(--border);
  border-radius: 6px;
  font-size: 0.9rem;
  background: white;
  color: var(--text-primary);
  transition: var(--transition);
  min-width: 120px;
}

.filter-group input[type="text"] {
  min-width: 250px;
}

.filter-group select:focus,
.filter-group input[type="text"]:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(66, 133, 244, 0.1);
}

.bulk-actions {
  display: flex;
  gap: 12px;
  align-items: center;
}

.copy-button-group {
  position: relative;
  display: flex;
  gap: 0;
}

.bulk-action-btn {
  padding: 8px 16px;
  background: var(--primary);
  color: white;
  border: none;
  border-radius: 6px 0 0 6px;
  font-size: 0.9rem;
  font-weight: 500;
  cursor: pointer;
  transition: var(--transition);
  white-space: nowrap;
}

.bulk-action-btn:hover:not(:disabled) {
  background: var(--primary-dark);
}

.bulk-action-btn:disabled {
  background: var(--border);
  color: var(--text-secondary);
  cursor: not-allowed;
}

.bulk-action-btn.copied {
  background: var(--secondary);
}

.bulk-action-dropdown-btn {
  padding: 8px 10px;
  background: var(--primary);
  color: white;
  border: none;
  border-left: 1px solid rgba(255, 255, 255, 0.2);
  border-radius: 0 6px 6px 0;
  font-size: 0.75rem;
  cursor: pointer;
  transition: var(--transition);
}

.bulk-action-dropdown-btn:hover:not(:disabled) {
  background: var(--primary-dark);
}

.bulk-action-dropdown-btn:disabled {
  background: var(--border);
  color: var(--text-secondary);
  cursor: not-allowed;
  border-left-color: rgba(0, 0, 0, 0.1);
}

.copy-dropdown-menu {
  position: absolute;
  top: 100%;
  left: 0;
  margin-top: 4px;
  background: white;
  border: 1px solid var(--border);
  border-radius: 6px;
  box-shadow: var(--shadow-md);
  min-width: 160px;
  z-index: 1000;
  overflow: hidden;
}

.dropdown-item {
  display: flex;
  align-items: center;
  gap: 8px;
  width: 100%;
  padding: 10px 14px;
  background: none;
  border: none;
  text-align: left;
  font-size: 0.9rem;
  color: var(--text-primary);
  cursor: pointer;
  transition: var(--transition);
}

.dropdown-item:hover {
  background: var(--hover-bg);
}

.dropdown-item .checkmark {
  visibility: hidden;
  color: var(--primary);
  font-weight: bold;
  width: 16px;
}

.dropdown-item.active .checkmark {
  visibility: visible;
}

.dropdown-divider {
  margin: 4px 0;
  border: none;
  border-top: 1px solid var(--border);
}

.filter-checkbox {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 0.9rem;
  color: var(--text-secondary);
  cursor: pointer;
  user-select: none;
}

.filter-checkbox input[type="checkbox"] {
  cursor: pointer;
  width: 16px;
  height: 16px;
}

.stats {
  margin-left: auto;
  color: var(--text-secondary);
  font-size: 0.9rem;
  font-weight: 500;
}

/* Main Content */
.main-content {
  flex: 1;
  width: 100%;
  overflow-x: auto;
}

/* Loading */
.loading {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 60px 20px;
  gap: 16px;
}

.spinner {
  width: 40px;
  height: 40px;
  border: 4px solid var(--border);
  border-top-color: var(--primary);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

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

.loading p {
  color: var(--text-secondary);
  font-size: 0.9rem;
}

/* No Data */
.no-data {
  text-align: center;
  padding: 60px 20px;
  color: var(--text-secondary);
}

/* Table Wrapper */
.table-wrapper {
  width: 100%;
  overflow-x: auto;
  background: var(--bg-card);
  border-radius: 8px;
  margin: 0;
  box-shadow: var(--shadow-sm);
}

/* References Table - Excel Style */
.references-table {
  width: 100%;
  border-collapse: separate;
  border-spacing: 0;
  font-size: 0.9rem;
  background: white;
  min-width: 100%;
}

.references-table thead {
  position: sticky;
  top: 0;
  z-index: 10;
  background: #f8f9fa;
}

.references-table thead tr {
  background: linear-gradient(to bottom, #f8f9fa 0%, #e9ecef 100%);
}

.references-table th {
  padding: 14px 16px;
  text-align: left;
  font-weight: 600;
  color: var(--text-primary);
  border-bottom: 2px solid var(--border-dark);
  border-right: 1px solid var(--border);
  background: #f8f9fa;
  white-space: nowrap;
  font-size: 0.85rem;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.references-table th:last-child {
  border-right: none;
}

.references-table tbody tr {
  transition: var(--transition);
  background: white;
}

.references-table tbody tr:nth-child(even) {
  background: #fafbfc;
}

.references-table tbody tr:hover {
  background: #f0f4ff;
  box-shadow: inset 0 0 0 1px var(--primary);
}

.references-table td {
  padding: 12px 16px;
  border-bottom: 1px solid var(--border);
  border-right: 1px solid var(--border);
  vertical-align: top;
  color: var(--text-primary);
  max-width: 400px;
  word-wrap: break-word;
}

.references-table td:last-child {
  border-right: none;
}

/* Column Specific Styling */
.col-checkbox {
  min-width: 40px;
  width: 40px;
  text-align: center;
  padding: 12px 8px !important;
}

.col-checkbox input[type="checkbox"] {
  cursor: pointer;
  width: 16px;
  height: 16px;
}

.col-status {
  min-width: 35px;
  width: 35px;
  text-align: center;
  padding: 12px 8px !important;
  color: var(--secondary);
  font-weight: bold;
  font-size: 1rem;
}

.copy-indicator {
  display: inline-block;
}

.row-copied {
  opacity: 0.7;
}

.row-copied:hover {
  opacity: 1;
}

.col-date {
  min-width: 160px;
  width: 160px;
  font-weight: 500;
  color: var(--text-secondary);
  white-space: nowrap;
}

.col-title {
  min-width: 350px;
  max-width: 500px;
  font-weight: 500;
}

.title-cell {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
}

.col-title a {
  color: var(--primary);
  text-decoration: none;
  transition: var(--transition);
  flex: 1;
}

.col-title a:hover {
  color: var(--primary-dark);
  text-decoration: underline;
}

.copy-link-btn {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 4px 10px;
  background: var(--bg-main);
  border: 1px solid var(--border);
  border-radius: 4px;
  font-size: 0.75rem;
  color: var(--text-secondary);
  cursor: pointer;
  transition: var(--transition);
  white-space: nowrap;
  flex-shrink: 0;
}

.copy-link-btn:hover {
  background: var(--primary);
  color: white;
  border-color: var(--primary);
}

.copy-link-btn.copied {
  background: var(--secondary);
  color: white;
  border-color: var(--secondary);
}

.copy-link-btn svg {
  flex-shrink: 0;
}

.col-platform,
.col-category,
.col-source {
  min-width: 100px;
  width: 120px;
  font-weight: 500;
}

.col-user {
  min-width: 140px;
  width: 160px;
  color: var(--text-secondary);
  font-size: 0.85rem;
}

.col-notes {
  min-width: 200px;
  max-width: 300px;
  color: var(--text-secondary);
  font-size: 0.85rem;
  line-height: 1.5;
}

.col-url {
  min-width: 80px;
  width: 80px;
  text-align: center;
}

.url-link {
  display: inline-block;
  padding: 6px 12px;
  background: var(--primary);
  color: white;
  text-decoration: none;
  border-radius: 4px;
  font-size: 0.8rem;
  font-weight: 500;
  transition: var(--transition);
}

.url-link:hover {
  background: var(--primary-dark);
  transform: translateY(-1px);
  box-shadow: var(--shadow-sm);
}

/* Responsive */
@media (max-width: 768px) {
  .header-content {
    flex-direction: column;
    align-items: flex-start;
    gap: 12px;
  }

  .user-section {
    width: 100%;
    justify-content: space-between;
  }

  .filters {
    flex-direction: column;
    align-items: stretch;
  }

  .filter-group {
    flex-direction: column;
    align-items: stretch;
  }

  .filter-group select,
  .filter-group input[type="text"] {
    width: 100%;
    min-width: auto;
  }

  .stats {
    margin-left: 0;
    text-align: center;
  }

  .references-table {
    font-size: 0.8rem;
  }

  .references-table th,
  .references-table td {
    padding: 10px 12px;
  }

  .col-date {
    min-width: 120px;
  }

  .col-title {
    min-width: 200px;
  }

  .col-notes {
    min-width: 150px;
    max-width: 200px;
  }
}

@media (max-width: 480px) {
  .auth-card {
    padding: 32px 24px;
  }

  .auth-card h1 {
    font-size: 1.5rem;
  }

  .header h1 {
    font-size: 1.25rem;
  }

  .user-name {
    display: none;
  }

  .references-table {
    font-size: 0.75rem;
  }

  .references-table th,
  .references-table td {
    padding: 8px 10px;
  }
}

/* Scrollbar styling for table */
.table-wrapper::-webkit-scrollbar {
  height: 12px;
}

.table-wrapper::-webkit-scrollbar-track {
  background: #f1f1f1;
  border-radius: 6px;
}

.table-wrapper::-webkit-scrollbar-thumb {
  background: #c1c1c1;
  border-radius: 6px;
}

.table-wrapper::-webkit-scrollbar-thumb:hover {
  background: #a8a8a8;
}
