/* Global styles and responsive mobile layout */

:root {
  --bg: #fafafa;
  --text: #111;
  --muted: #777;
  --border: #e5e5e5;
  --primary: #1677ff;
  --success-bg: #e6ffed;
  --success-border: #b7eb8f;
  --error-bg: #fff1f0;
  --error-border: #ffa39e;
}

* {
  box-sizing: border-box;
}
html,
body,
#root {
  height: 100%;
}
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
}
a {
  color: var(--primary);
  text-decoration: none;
}

input,
select,
button {
  font: 16px system-ui, -apple-system, Segoe UI, Roboto, Helvetica, Arial,
    sans-serif;
  padding: 10px 12px;
  border: 1px solid #ddd;
  border-radius: 10px;
}

button {
  background: var(--primary);
  color: #fff;
  border: none;
  cursor: pointer;
}
button:disabled {
  opacity: 0.6;
  cursor: not-allowed;
}
button.ghost {
  background: #f1f3f5;
  color: var(--text);
}

.container {
  font-family: system-ui, -apple-system, Segoe UI, Roboto, Helvetica, Arial,
    sans-serif;
  max-width: 1000px;
  margin: 0 auto;
  padding: 12px 16px;
}

.app-header {
  display: flex;
  gap: 8px;
  align-items: center;
}
.app-header .user {
  margin-left: auto;
  color: var(--muted);
  display: flex;
  align-items: center;
  gap: 8px;
}

.layout {
  display: grid;
  grid-template-columns: 260px 1fr;
  gap: 16px;
  margin-top: 12px;
}
.panel {
  background: #fff;
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 12px;
}

.list {
  list-style: none;
  padding: 0;
  margin: 0;
}
.list > li {
  padding: 10px 0;
  border-bottom: 1px solid #eee;
}
.list > li.clickable:hover {
  background: #fafafa;
}
.list > li.active {
  background: #f6faff;
  border-left: 3px solid #91caff;
}

.grid-2 {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 8px;
}
.row {
  display: flex;
  gap: 8px;
  align-items: center;
}

.alert {
  padding: 8px;
  border-radius: 10px;
}
.alert.success {
  background: var(--success-bg);
  border: 1px solid var(--success-border);
}
.alert.error {
  background: var(--error-bg);
  border: 1px solid var(--error-border);
}

/* Mobile adjustments */
@media (max-width: 800px) {
  .layout {
    grid-template-columns: 1fr !important;
  }
  .app-header {
    flex-wrap: wrap;
  }
  .app-header .user {
    width: 100%;
    justify-content: flex-end;
  }
  .grid-2 {
    grid-template-columns: 1fr !important;
  }
  .row.stack-sm {
    flex-direction: column;
    align-items: stretch;
  }
  .row.stack-sm > * {
    width: 100%;
  }
  input,
  select,
  button {
    border-radius: 12px;
  }
  .panel {
    padding: 12px;
  }

  /* Off-canvas sidebar for mobile */
  .mobile-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.4);
    z-index: 50;
  }
  .mobile-drawer {
    position: fixed;
    left: 0;
    top: 0;
    bottom: 0;
    width: 86vw;
    max-width: 360px;
    background: #fff;
    border-right: 1px solid var(--border);
    padding: 12px;
    z-index: 60;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.15);
    transform: translateX(-100%);
    transition: transform 0.2s ease;
  }
  .mobile-drawer.open {
    transform: translateX(0);
  }
}

/* Kanban board styles */
.kanban {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 12px;
  margin-top: 12px;
}
.kanban-col {
  background: #fafafa;
  border: 1px dashed var(--border);
  border-radius: 12px;
  padding: 8px;
  min-height: 200px;
}
.kanban-col.dragging {
  border-color: #91caff;
  background: #f0f7ff;
}
.kanban-col-title {
  font-weight: 600;
  margin-bottom: 8px;
}
.kanban-col-body {
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.kanban-card {
  background: #fff;
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 8px;
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.04);
}
.kanban-card.drag-over {
  outline: 2px dashed #91caff;
}
.kanban-title {
  font-weight: 600;
  margin-bottom: 4px;
}
.kanban-meta {
  color: var(--muted);
  font-size: 12px;
  margin-bottom: 8px;
}

@media (max-width: 800px) {
  .kanban {
    grid-template-columns: 1fr;
  }
}

/* Calendar */
.calendar {
  margin-top: 12px;
}
.calendar-head {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  margin-bottom: 8px;
}
.calendar-title {
  font-weight: 700;
}
.calendar-grid {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 6px;
}
.calendar-dow {
  text-align: center;
  color: var(--muted);
  font-size: 12px;
}
.calendar-cell {
  background: #fff;
  border: 1px solid var(--border);
  border-radius: 10px;
  min-height: 100px;
  padding: 6px;
  display: flex;
  flex-direction: column;
}
.calendar-cell.out {
  opacity: 0.5;
}
.calendar-date {
  color: #999;
  font-size: 12px;
  margin-bottom: 4px;
}
.calendar-cell-body {
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.calendar-undated {
  margin-bottom: 8px;
}
.calendar-undated-title {
  color: var(--muted);
  font-size: 12px;
  margin-bottom: 4px;
}
.calendar-undated-list {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
}

.pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 6px;
  border-radius: 12px;
  border: 1px solid var(--border);
  background: #fafafa;
  cursor: grab;
}
.pill-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: #bbb;
}
.pill-text {
  font-size: 12px;
}
.pill-done .pill-dot {
  background: #52c41a;
}
.pill-pending .pill-dot {
  background: #1677ff;
}
.pill-failed .pill-dot {
  background: #faad14;
}

/* Simple modal */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.35);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
}
.modal {
  background: #fff;
  border: 1px solid var(--border);
  border-radius: 12px;
  width: min(640px, 94vw);
  max-height: 86vh;
  overflow: auto;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.2);
}
.modal-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 12px;
  border-bottom: 1px solid var(--border);
}
.modal-title {
  font-weight: 700;
}
.modal-body {
  padding: 12px;
}
.modal-footer {
  padding: 10px 12px;
  border-top: 1px solid var(--border);
  display: flex;
  gap: 8px;
  justify-content: flex-end;
}

/* View tabs - compact design */
.view-tabs {
  display: flex;
  gap: 2px;
  margin-bottom: 8px;
  border-radius: 6px;
  background: #f5f5f5;
  padding: 2px;
}

.view-tabs button {
  border: none;
  background: transparent;
  padding: 8px 12px;
  border-radius: 4px;
  cursor: pointer;
  font-size: 14px;
  transition: all 0.2s ease;
  min-width: 40px;
}

.view-tabs button:hover {
  background: rgba(0, 0, 0, 0.05);
}

.view-tabs button.active {
  background: white;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
  font-weight: 500;
}

/* Timeline view styles */
.timeline-view {
  padding: 16px;
}

.timeline-header {
  margin-bottom: 16px;
  padding-bottom: 12px;
  border-bottom: 1px solid #e0e0e0;
}

.timeline-grid {
  margin-bottom: 24px;
}

.timeline-hours {
  display: flex;
  flex-direction: column;
  gap: 1px;
}

.hour-slot {
  display: flex;
  min-height: 60px;
  border-bottom: 1px solid #f0f0f0;
}

.hour-label {
  width: 60px;
  padding: 8px;
  font-size: 12px;
  color: #666;
  background: #fafafa;
  border-right: 1px solid #e0e0e0;
  display: flex;
  align-items: flex-start;
  font-weight: 500;
}

.hour-content {
  flex: 1;
  padding: 4px 8px;
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.time-entry {
  background: #f3e5f5;
  border-radius: 4px;
  padding: 6px 8px;
  margin: 1px 0;
  border-left: 4px solid #9c27b0;
  font-size: 12px;
}

.entry-title {
  font-weight: 500;
  margin-bottom: 2px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.entry-time {
  color: #666;
  font-size: 11px;
}

.entry-duration {
  color: #333;
  font-size: 11px;
  font-weight: 500;
}

.available-tasks {
  border-top: 1px solid #e0e0e0;
  padding-top: 16px;
}

.available-tasks h3 {
  margin: 0 0 12px 0;
  font-size: 16px;
  font-weight: 600;
}

.task-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.task-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 12px;
  background: white;
  border: 1px solid #e0e0e0;
  border-radius: 6px;
}

.task-info {
  flex: 1;
}

.task-title {
  font-weight: 500;
  margin-bottom: 4px;
}

.task-meta {
  display: flex;
  gap: 12px;
  font-size: 12px;
  color: #666;
}

.task-actions button {
  min-width: 80px;
}

.stop-tracking {
  background: #f44336;
  color: white;
  border: none;
  padding: 8px 16px;
  border-radius: 4px;
  cursor: pointer;
  font-weight: 500;
}

.tracking-active {
  background: #4caf50;
  color: white;
  border: none;
  padding: 6px 12px;
  border-radius: 4px;
  font-size: 12px;
}

@media (max-width: 800px) {
  .view-tabs {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
  }

  .view-tabs button {
    flex-shrink: 0;
    padding: 6px 8px;
    font-size: 12px;
  }

  .timeline-hours {
    font-size: 11px;
  }

  .hour-label {
    width: 50px;
    padding: 6px;
  }

  .task-item {
    flex-direction: column;
    align-items: stretch;
    gap: 8px;
  }
}

/* Productivity Analytics styles */
.productivity-analytics {
  padding: 16px;
}

.analytics-tabs {
  display: flex;
  gap: 2px;
  margin-bottom: 16px;
  border-radius: 6px;
  background: #f5f5f5;
  padding: 2px;
  overflow-x: auto;
}

.analytics-tabs button {
  border: none;
  background: transparent;
  padding: 8px 12px;
  border-radius: 4px;
  cursor: pointer;
  font-size: 12px;
  transition: all 0.2s ease;
  white-space: nowrap;
  flex-shrink: 0;
}

.analytics-tabs button:hover {
  background: rgba(0, 0, 0, 0.05);
}

.analytics-tabs button.active {
  background: white;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
  font-weight: 500;
}

.analytics-content {
  margin-top: 16px;
}

.metrics-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  gap: 12px;
  margin-bottom: 24px;
}

.metric-card {
  background: white;
  border: 1px solid #e0e0e0;
  border-radius: 8px;
  padding: 16px;
  text-align: center;
}

.metric-value {
  font-size: 24px;
  font-weight: 600;
  color: #333;
  margin-bottom: 4px;
}

.metric-label {
  font-size: 12px;
  color: #666;
}

/* Chart styles */
.chart-container {
  display: flex;
  align-items: end;
  gap: 4px;
  height: 200px;
  padding: 16px;
  background: white;
  border: 1px solid #e0e0e0;
  border-radius: 8px;
  overflow-x: auto;
}

.chart-bar {
  display: flex;
  flex-direction: column;
  align-items: center;
  min-width: 40px;
  height: 100%;
}

.chart-bar-fill {
  width: 100%;
  min-height: 2px;
  border-radius: 2px 2px 0 0;
  transition: height 0.3s ease;
}

.chart-bar-label {
  margin-top: 8px;
  font-size: 10px;
  color: #666;
  transform: rotate(-45deg);
  white-space: nowrap;
}

.productivity-charts {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 24px;
}

.chart-section h4 {
  margin: 0 0 12px 0;
  font-size: 16px;
  font-weight: 600;
}

/* Estimation accuracy styles */
.estimation-tasks {
  margin-top: 24px;
}

.estimation-task {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 12px;
  background: white;
  border: 1px solid #e0e0e0;
  border-radius: 6px;
  margin-bottom: 8px;
}

.task-info {
  flex: 1;
}

.task-title {
  font-weight: 500;
  margin-bottom: 4px;
}

.task-times {
  font-size: 12px;
  color: #666;
}

.accuracy-indicator {
  font-size: 18px;
  padding: 4px;
  border-radius: 50%;
}

.accuracy-indicator.good {
  background: #e8f5e8;
}

.accuracy-indicator.fair {
  background: #fff3e0;
}

.accuracy-indicator.poor {
  background: #ffebee;
}

/* Project progress styles */
.project-list {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.project-card {
  background: white;
  border: 1px solid #e0e0e0;
  border-radius: 8px;
  padding: 16px;
}

.project-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 12px;
}

.project-header h4 {
  margin: 0;
  font-size: 16px;
}

.progress-bar {
  position: relative;
  width: 120px;
  height: 20px;
  background: #f0f0f0;
  border-radius: 10px;
  overflow: hidden;
}

.progress-fill {
  height: 100%;
  background: linear-gradient(90deg, #4caf50, #81c784);
  transition: width 0.3s ease;
}

.progress-text {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  font-size: 11px;
  font-weight: 600;
  color: #333;
}

.project-stats {
  display: flex;
  gap: 16px;
  font-size: 12px;
  color: #666;
}

/* AI Reflection styles */
.reflection-section {
  max-width: 800px;
}

.reflection-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 24px;
}

.reflection-header h3 {
  margin: 0;
}

.daily-summary {
  margin-bottom: 24px;
}

.daily-summary h4 {
  margin: 0 0 16px 0;
}

.ai-reflection {
  background: #f8f9fa;
  border: 1px solid #e9ecef;
  border-radius: 8px;
  padding: 20px;
}

.ai-reflection h4 {
  margin: 0 0 16px 0;
  color: #495057;
}

.reflection-text {
  line-height: 1.6;
  color: #495057;
}

.reflection-text div {
  margin-bottom: 8px;
}

@media (max-width: 800px) {
  .productivity-charts {
    grid-template-columns: 1fr;
  }

  .chart-container {
    height: 150px;
    padding: 12px;
  }

  .metrics-grid {
    grid-template-columns: repeat(2, 1fr);
  }

  .project-header {
    flex-direction: column;
    align-items: stretch;
    gap: 8px;
  }

  .progress-bar {
    width: 100%;
  }

  .reflection-header {
    flex-direction: column;
    gap: 12px;
    align-items: stretch;
  }
}
