@import url('https://fonts.googleapis.com/css2?family=IBM+Plex+Sans:wght@300;400;500;600;700&family=Poppins:wght@300;400;500;600;700&display=swap');

/* ElasticMove Brand Colors & Tailwind Base */
:root {
  /* ElasticMove Brand Colors */
  --em-primary: #2B6CB0;        /* Primary Blue */
  --em-primary-dark: #215387;   /* Darker Blue */
  --em-secondary: #1A202C;      /* Dark Gray */
  --em-text: #2D3748;           /* Text Gray */
  --em-text-light: #4A5568;     /* Light Text */
  --em-text-muted: #718096;     /* Muted Text */
  --em-gray-100: #EDF2F7;       /* Light Gray */
  --em-gray-50: #F7FAFC;        /* Lightest Gray */
  --em-white: #ffffff;          /* White */
  --em-orange: #ff9900;         /* Orange Accent */
  --em-success: #38a169;        /* Success Green */
  --em-warning: #ed8936;        /* Warning Orange */
  --em-error: #e53e3e;          /* Error Red */
  
  /* Spacing */
  --em-content-width: 1290px;
  --em-content-narrow: 842px;
  --em-edge-spacing: 1.5rem;
  --em-boxed-spacing: 2rem;
}

/* Day header alternating colors and vertical lines */
.table-header-day {
    text-align: center;
    font-weight: 600;
    border-bottom: 2px solid #dee2e6;
    border-left: 2px solid #dee2e6;
    padding: 0.75rem 0.5rem;
    min-width: 80px;
}

/* Time cells with vertical lines */
.time-cell {
    border-left: 2px solid #dee2e6;
}

/* Remove project button */
.remove-project-btn {
    background: #ef4444;
    color: white;
    border: none;
    border-radius: 50%;
    width: 18px;
    height: 18px;
    font-size: 12px;
    line-height: 1;
    cursor: pointer;
    margin-left: 8px;
    display: none;
}

.project-cell:hover .remove-project-btn {
    display: inline-block;
}

.remove-project-btn:hover {
    background: #dc2626;
}

/* Non-billable toggle row */
.non-billable-row {
    display: flex;
    align-items: center;
    gap: 1rem;
    margin-top: 0.5rem;
    padding: 0.5rem;
    background: #f9fafb;
    border-radius: 4px;
}

/* Existing entry indicators */
.existing-entry {
    border-left: 3px solid #3b82f6 !important;
    background: rgba(59, 130, 246, 0.05) !important;
}

.existing-icon {
    font-size: 12px;
    margin-left: 4px;
    opacity: 0.7;
}

/* Apply alternating colors using attribute selectors for reliability */
.time-cell[data-day="0"], .time-cell[data-day="2"], .time-cell[data-day="4"], .time-cell[data-day="6"] {
    background-color: rgba(248, 249, 250, 0.8) !important;
}

.time-cell[data-day="1"], .time-cell[data-day="3"], .time-cell[data-day="5"] {
    background-color: rgba(35, 47, 62, 0.15) !important;
}

/* Header alternating colors using specific positioning */
th:nth-child(2), th:nth-child(4), th:nth-child(6), th:nth-child(8) {
    background-color: #f8f9fa !important;
}

th:nth-child(3), th:nth-child(5), th:nth-child(7) {
    background-color: rgba(35, 47, 62, 0.12) !important;
}

/* Reset & Base */
*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html {
  line-height: 1.15;
  -webkit-text-size-adjust: 100%;
}

body {
  font-family: "IBM Plex Sans", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  font-size: 15px;
  line-height: 1.6;
  color: var(--em-text);
  background-color: var(--em-gray-50);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

/* Typography */
h1, h2, h3, h4, h5, h6 {
  font-family: "Poppins", sans-serif;
  font-weight: 600;
  line-height: 1.2;
  color: var(--em-secondary);
  margin-bottom: 0.5em;
}

h1 { font-size: clamp(2.25rem, 1.728rem + 1.63vw, 3rem); }
h2 { font-size: clamp(1.75rem, 1.576rem + 0.543vw, 2rem); }
h3 { font-size: clamp(1.5rem, 1.4rem + 0.3vw, 1.75rem); }
h4 { font-size: clamp(1.25rem, 1.2rem + 0.2vw, 1.5rem); }

/* Modal Styles */
.modal-overlay {
  position: fixed;
  top: 0;
  left: 0;
  width: 100vw;
  height: 100vh;
  background: rgba(0, 0, 0, 0.5);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 9999;
}

.modal-card {
  background: var(--em-white);
  border-radius: 0.75rem;
  padding: 2rem;
  width: 24rem;
  max-width: 90vw;
  box-shadow: 0 20px 25px -5px rgba(0, 0, 0, 0.1), 0 10px 10px -5px rgba(0, 0, 0, 0.04);
}

.modal-header {
  font-size: 1.125rem;
  font-weight: 600;
  color: var(--em-secondary);
  margin-bottom: 1.5rem;
}

.modal-field {
  margin-bottom: 1.5rem;
}

.modal-label {
  display: block;
  font-size: 0.875rem;
  font-weight: 500;
  color: var(--em-text);
  margin-bottom: 0.5rem;
}

.modal-select, .modal-input {
  width: 100%;
  padding: 0.5rem;
  border: 1px solid #d1d5db;
  border-radius: 0.375rem;
  font-size: 0.875rem;
}

.modal-select:focus, .modal-input:focus {
  outline: none;
  border-color: var(--em-primary);
  box-shadow: 0 0 0 3px rgba(43, 108, 176, 0.1);
}

.modal-actions {
  display: flex;
  justify-content: flex-end;
  gap: 0.5rem;
}

.modal-help {
  font-size: 0.75rem;
  color: var(--em-text-muted);
  margin-top: 0.25rem;
}

/* Authentication Styles */
.auth-container {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  background: linear-gradient(135deg, var(--em-primary) 0%, var(--em-primary-dark) 100%);
  padding: 2rem;
}

.auth-card {
  background: var(--em-white);
  border-radius: 0.75rem;
  box-shadow: 0 20px 25px -5px rgba(0, 0, 0, 0.1), 0 10px 10px -5px rgba(0, 0, 0, 0.04);
  padding: 3rem;
  max-width: 400px;
  width: 100%;
  text-align: center;
}

.auth-header h1 {
  color: var(--em-secondary);
  margin-bottom: 0.5rem;
  font-size: 2rem;
}

.auth-header p {
  color: var(--em-text-muted);
  margin-bottom: 2rem;
}

.auth-btn {
  width: 100%;
  padding: 0.875rem 1.5rem;
  font-size: 1rem;
}

.app-container {
  min-height: 100vh;
  background: var(--em-gray-50);
}

/* Layout Components */
.container {
  max-width: var(--em-content-width);
  margin: 0 auto;
  padding: 0 var(--em-edge-spacing);
}

.container-narrow {
  max-width: var(--em-content-narrow);
  margin: 0 auto;
  padding: 0 var(--em-edge-spacing);
}

/* Header */
.header {
  background: var(--em-white);
  border-bottom: 1px solid var(--em-gray-100);
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
  position: sticky;
  top: 0;
  z-index: 50;
}

.header-content {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 1rem 0;
  gap: 1rem;
}

/* Navigation */
.week-nav {
  display: flex;
  align-items: center;
  gap: 1rem;
  flex: 1;
  justify-content: center;
}

.week-nav h2 {
  font-size: 1.125rem;
  font-weight: 600;
  color: var(--em-text);
  margin: 0;
}

/* Buttons */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0.5rem 1rem;
  font-size: 0.875rem;
  font-weight: 500;
  line-height: 1.25;
  border-radius: 0.375rem;
  border: 1px solid transparent;
  cursor: pointer;
  transition: all 0.15s ease-in-out;
  text-decoration: none;
  white-space: nowrap;
}

.btn:focus {
  outline: 2px solid transparent;
  outline-offset: 2px;
  box-shadow: 0 0 0 3px rgba(43, 108, 176, 0.1);
}

.btn-primary {
  background-color: var(--em-primary);
  color: var(--em-white);
  border-color: var(--em-primary);
}

.btn-primary:hover {
  background-color: var(--em-primary-dark);
  border-color: var(--em-primary-dark);
}

.btn-secondary {
  background-color: var(--em-white);
  color: var(--em-text);
  border-color: var(--em-gray-100);
}

.btn-secondary:hover {
  background-color: var(--em-gray-50);
  border-color: var(--em-text-muted);
}

.btn-success {
  background-color: var(--em-success);
  color: var(--em-white);
  border-color: var(--em-success);
}

.btn-success:hover {
  background-color: #2f855a;
  border-color: #2f855a;
}

.btn-orange {
  background-color: var(--em-orange);
  color: var(--em-white);
  border-color: var(--em-orange);
}

.btn-orange:hover {
  background-color: #e68900;
  border-color: #e68900;
}

/* Cards & Containers */
.card {
  background: var(--em-white);
  border-radius: 0.5rem;
  box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06);
  overflow: hidden;
}

.timesheet-container {
  background: var(--em-white);
  margin: 1.5rem auto;
  max-width: var(--em-content-width);
  border-radius: 0.5rem;
  box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06);
  overflow: hidden;
}

/* Tables */
.table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.875rem;
}

.table th {
  background-color: var(--em-gray-50);
  padding: 0.75rem 0.5rem;
  text-align: center;
  border: 1px solid var(--em-gray-100);
  font-weight: 600;
  color: var(--em-text);
  font-family: "Poppins", sans-serif;
}

.table th:first-child {
  text-align: left;
  min-width: 200px;
}

.table td {
  border: 1px solid var(--em-gray-100);
  padding: 0.5rem;
  vertical-align: top;
  position: relative;
}

.table-header-day {
  min-width: 100px;
}

.table-header-day small {
  display: block;
  font-weight: normal;
  color: var(--em-text-muted);
  font-size: 0.75rem;
}

/* Project Cells */
.project-cell {
  background-color: var(--em-gray-50);
  padding: 0.75rem;
}

.project-name {
  font-weight: 600;
  margin-bottom: 0.25rem;
  color: var(--em-text);
  font-family: "Poppins", sans-serif;
}

.project-meta {
  font-size: 0.75rem;
  color: var(--em-text-muted);
}

/* Badges */
.badge {
  display: inline-block;
  padding: 0.125rem 0.375rem;
  border-radius: 0.25rem;
  font-size: 0.625rem;
  font-weight: 500;
  margin-left: 0.5rem;
}

.badge-billable {
  background-color: var(--em-success);
  color: var(--em-white);
}

.badge-non-billable {
  background-color: var(--em-text-muted);
  color: var(--em-white);
}

.badge-orange {
  background-color: var(--em-orange);
  color: var(--em-white);
}

/* Time Cells */
.time-cell {
  min-height: 60px;
  cursor: pointer;
  transition: background-color 0.15s ease-in-out;
}

.time-cell:hover {
  background-color: var(--em-gray-50);
}

.add-entry-area {
  padding: 0.5rem;
  margin-top: 0.25rem;
  border: 1px dashed #ccc;
  border-radius: 0.25rem;
  text-align: center;
  color: #666;
  cursor: pointer;
  font-size: 0.875rem;
  transition: all 0.2s ease;
}

.add-entry-area:hover {
  background-color: var(--em-gray-50);
  border-color: var(--em-primary);
  color: var(--em-primary);
}

.time-cell.has-multiple .time-entry {
  margin-bottom: 0.125rem;
}

.time-cell.has-multiple .time-entry:last-child {
  margin-bottom: 0;
}

.time-entry {
  margin-bottom: 0.25rem;
  padding: 0.25rem;
  border-radius: 0.25rem;
  background-color: rgba(43, 108, 176, 0.1);
  border-left: 3px solid var(--em-primary);
}

.time-entry-non-billable {
  background-color: rgba(220, 38, 38, 0.1);
  border-left-color: #dc2626;
}

.time-entry-orange {
  background-color: rgba(255, 153, 0, 0.1);
  border-left-color: var(--em-orange);
}

.entry-hours {
  font-weight: 600;
  display: inline-block;
  min-width: 30px;
  color: var(--em-text);
}

.entry-comment {
  font-size: 0.75rem;
  color: var(--em-text-muted);
  margin-top: 0.125rem;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* Expand Toggle */
.expand-toggle {
  position: absolute;
  top: 0.25rem;
  right: 0.25rem;
  background-color: var(--em-primary);
  color: var(--em-white);
  border: none;
  border-radius: 50%;
  width: 20px;
  height: 20px;
  font-size: 0.75rem;
  cursor: pointer;
  display: none;
  transition: background-color 0.15s ease-in-out;
}

.expand-toggle:hover {
  background-color: var(--em-primary-dark);
}

.time-cell.has-multiple .expand-toggle {
  display: block;
}

/* Expanded Cell */
.expanded-cell {
  position: absolute;
  top: -0.625rem;
  left: -0.625rem;
  right: -0.625rem;
  min-width: 300px;
  background: var(--em-white);
  border: 2px solid var(--em-primary);
  border-radius: 0.5rem;
  padding: 1.25rem;
  z-index: 10;
  box-shadow: 0 10px 25px rgba(0, 0, 0, 0.15);
}

.expanded-entry {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
  margin-bottom: 1rem;
}

.expanded-entry input,
.expanded-entry textarea {
  border: 1px solid var(--em-gray-100);
  border-radius: 0.25rem;
  padding: 0.5rem 0.75rem;
  font-size: 0.875rem;
  transition: border-color 0.15s ease-in-out;
}

.expanded-entry input:focus,
.expanded-entry textarea:focus {
  outline: none;
  border-color: var(--em-primary);
  box-shadow: 0 0 0 3px rgba(43, 108, 176, 0.1);
}

.hours-input {
  width: 120px;
  text-align: center;
  font-size: 1rem;
  font-weight: 600;
}

.comment-input {
  min-height: 80px;
  resize: vertical;
  font-family: inherit;
  line-height: 1.4;
}

/* Totals */
.row-total {
  text-align: center;
  font-weight: 600;
  background-color: var(--em-gray-50);
  color: var(--em-text);
}

.totals-row {
  background-color: var(--em-gray-100);
  font-weight: 600;
  color: var(--em-text);
}

.totals-row td {
  text-align: center;
  padding: 0.75rem 0.5rem;
}

.weekly-summary {
  text-align: right;
  font-size: 0.75rem;
  color: var(--em-text-muted);
}

/* Empty States */
.empty-cell {
  color: var(--em-text-muted);
  text-align: center;
  font-size: 0.75rem;
  opacity: 0.6;
}

/* Utilities */
.text-orange {
  color: var(--em-orange);
}

.bg-orange {
  background-color: var(--em-orange);
}

.border-orange {
  border-color: var(--em-orange);
}

.text-primary {
  color: var(--em-primary);
}

.bg-primary {
  background-color: var(--em-primary);
}

.border-primary {
  border-color: var(--em-primary);
}

/* Responsive Design */
@media (max-width: 768px) {
  .container {
    padding: 0 1rem;
  }
  
  .timesheet-container {
    margin: 0.75rem;
  }
  
  .header-content {
    padding: 0.5rem 0;
    flex-wrap: wrap;
  }
  
  .week-nav {
    order: 2;
    width: 100%;
    justify-content: center;
  }
  
  .table {
    font-size: 0.75rem;
  }
  
  .table th:first-child {
    min-width: 150px;
  }
  
  .table-header-day {
    min-width: 80px;
  }
  
  .expanded-cell {
    min-width: 280px;
  }
}

/* Fixed table layout to prevent column expansion from long comments */
.table {
  table-layout: fixed !important;
}

.table th:first-child,
.table td:first-child {
  width: 200px !important;
  max-width: 200px !important;
}

.table-header-day,
.table td:not(:first-child):not(:last-child) {
  width: 120px !important;
  min-width: 120px !important;
  max-width: 120px !important;
}

.table th:last-child,
.table td:last-child {
  width: 100px !important;
  min-width: 100px !important;
  max-width: 100px !important;
}

.table td {
  overflow: visible !important;
  word-wrap: break-word !important;
  position: relative !important;
}

@media (max-width: 480px) {
  .container {
    padding: 0 0.75rem;
  }
  
  .btn {
    padding: 0.375rem 0.75rem;
    font-size: 0.75rem;
  }
  
  .table th,
  .table td {
    padding: 0.375rem 0.25rem;
  }
}

/* Highlight animation for existing project */
@keyframes highlightBlink {
  0%, 100% {
    background-color: transparent;
  }
  25%, 75% {
    background-color: rgba(59, 130, 246, 0.3);
  }
  50% {
    background-color: rgba(59, 130, 246, 0.5);
  }
}

.highlight-existing {
  animation: highlightBlink 2s ease-in-out;
}
