/*
 * DevTrack - Main Stylesheet
 * Premium Dashboard UI
 */

/* ============================================================
   DESIGN TOKENS
   ============================================================ */
:root {
  --font-main: 'Plus Jakarta Sans', sans-serif;
  --font-mono: 'JetBrains Mono', monospace;

  /* Brand — Speed Track burnt orange + charcoal from logo */
  --brand:        #C84B11;
  --brand-dark:   #A33C0D;
  --brand-light:  #FBE9E2;

  /* Sidebar — dark charcoal matching logo icon */
  --sidebar-bg:        #1B1B22;
  --sidebar-bg-header: #13131A;
  --sidebar-w:         240px;
  --sidebar-text:      #C4C4D0;
  --sidebar-hover:     #2A2A36;
  --sidebar-active:    #C84B11;

  /* Layout */
  --navbar-h:     60px;
  --bg-page:      #F4F5FA;
  --bg-card:      #ffffff;
  --border:       #E8ECF2;

  /* Text */
  --text-primary:  #1B1B22;
  --text-secondary:#6B7280;
  --text-muted:    #9CA3AF;

  /* Shadows */
  --shadow-sm:  0 1px 3px rgba(0,0,0,.06), 0 1px 2px rgba(0,0,0,.04);
  --shadow-md:  0 4px 12px rgba(0,0,0,.09);
  --shadow-lg:  0 10px 30px rgba(0,0,0,.14);

  /* Status Colors */
  --status-new:     #C84B11;
  --status-prog:    #F59E0B;
  --status-test:    #06B6D4;
  --status-done:    #10B981;
  --status-hold:    #6B7280;

  /* Priority */
  --p-critical: #EF4444;
  --p-high:     #F59E0B;
  --p-medium:   #06B6D4;
  --p-low:      #6B7280;

  --radius-sm: 6px;
  --radius-md: 10px;
  --radius-lg: 14px;
  --transition: all .2s ease;
}

/* ============================================================
   BASE
   ============================================================ */
*, *::before, *::after { box-sizing: border-box; }

body {
  font-family: var(--font-main);
  font-size: 14px;
  color: var(--text-primary);
  background: var(--bg-page);
  margin: 0;
  overflow-x: hidden;
}

a { text-decoration: none; color: var(--brand); }
a:hover { color: var(--brand-dark); }

/* ============================================================
   SIDEBAR
   ============================================================ */
.sidebar {
  position: fixed;
  top: 0; left: 0;
  width: var(--sidebar-w);
  height: 100vh;
  background: var(--sidebar-bg);
  display: flex;
  flex-direction: column;
  z-index: 1000;
  transition: transform .3s ease;
  overflow: hidden;
}

.sidebar-header {
  padding: 12px 16px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  border-bottom: 1px solid rgba(255,255,255,.06);
  background: #ffffff;
  min-height: var(--navbar-h);
}

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
}

.brand-icon {
  width: 32px; height: 32px;
  background: var(--brand);
  border-radius: var(--radius-sm);
  display: flex;
  align-items: center;
  justify-content: center;
  color: #fff;
  font-size: 16px;
}

.brand-name {
  font-size: 16px;
  font-weight: 700;
  color: #fff;
  letter-spacing: -.3px;
}

.sidebar-toggle-btn {
  background: none;
  border: none;
  color: var(--sidebar-text);
  font-size: 16px;
  cursor: pointer;
  padding: 4px;
}

/* Nav */
.sidebar-nav {
  flex: 1;
  padding: 12px 12px 0;
  overflow-y: auto;
  overflow-x: hidden;
}

.sidebar-nav::-webkit-scrollbar { width: 4px; }
.sidebar-nav::-webkit-scrollbar-track { background: transparent; }
.sidebar-nav::-webkit-scrollbar-thumb { background: rgba(255,255,255,.1); border-radius: 2px; }

.nav-section-label {
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 1.2px;
  text-transform: uppercase;
  color: rgba(255,255,255,.32);
  padding: 14px 10px 6px;
}

.sidebar-nav .nav-link {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 12px;
  border-radius: var(--radius-sm);
  color: var(--sidebar-text);
  font-size: 13.5px;
  font-weight: 500;
  transition: var(--transition);
  margin-bottom: 2px;
  position: relative;
}

.sidebar-nav .nav-link i {
  font-size: 16px;
  width: 18px;
  text-align: center;
  flex-shrink: 0;
}

.sidebar-nav .nav-link:hover {
  background: var(--sidebar-hover);
  color: #ffffff;
}

.sidebar-nav .nav-link.active {
  background: var(--brand);
  color: #ffffff;
}

.nav-badge {
  margin-left: auto;
  background: rgba(200,75,17,.25);
  color: #F97316;
  font-size: 10px;
  font-weight: 700;
  padding: 2px 7px;
  border-radius: 20px;
}

.nav-link.active .nav-badge { background: rgba(255,255,255,.25); color: #fff; }

/* Sidebar User */
.sidebar-user {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 14px 16px;
  border-top: 1px solid rgba(255,255,255,.08);
  background: rgba(0,0,0,.18);
}

.user-avatar {
  width: 32px; height: 32px;
  border-radius: 50%;
  background: var(--brand);
  color: #fff;
  font-size: 13px;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.user-info { flex: 1; overflow: hidden; }
.user-name { font-size: 13px; font-weight: 600; color: #fff; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.user-role { font-size: 11px; color: var(--sidebar-text); }

.user-logout {
  color: var(--sidebar-text);
  font-size: 16px;
  transition: var(--transition);
  padding: 4px;
}
.user-logout:hover { color: #ef4444; }

.sidebar-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,.5);
  z-index: 999;
}
.sidebar-overlay.show { display: block; }

/* ============================================================
   MAIN WRAPPER & NAVBAR
   ============================================================ */
.main-wrapper {
  margin-left: var(--sidebar-w);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  transition: margin-left .3s ease;
}

.top-navbar {
  position: sticky;
  top: 0;
  height: var(--navbar-h);
  background: var(--bg-card);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 24px;
  z-index: 900;
  box-shadow: var(--shadow-sm);
}

.navbar-left {
  display: flex;
  align-items: center;
  gap: 16px;
}

.navbar-toggler {
  background: none;
  border: none;
  font-size: 20px;
  color: var(--text-secondary);
  cursor: pointer;
  padding: 4px;
  line-height: 1;
  display: none;
}

.breadcrumb {
  font-size: 13px;
  margin: 0;
}

.breadcrumb-item a { color: var(--text-secondary); }
.breadcrumb-item.active { color: var(--text-primary); font-weight: 500; }
.breadcrumb-item + .breadcrumb-item::before { color: var(--text-muted); }

.navbar-right {
  display: flex;
  align-items: center;
  gap: 10px;
}

.navbar-icon-btn {
  position: relative;
  width: 36px; height: 36px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: var(--radius-sm);
  color: var(--text-secondary);
  background: var(--bg-page);
  font-size: 18px;
  transition: var(--transition);
}
.navbar-icon-btn:hover { background: var(--border); color: var(--text-primary); }

.icon-badge {
  position: absolute;
  top: 2px; right: 2px;
  background: #ef4444;
  color: #fff;
  font-size: 9px;
  font-weight: 700;
  width: 16px; height: 16px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
}

.navbar-create-btn {
  border-radius: var(--radius-sm);
  font-size: 13px;
  font-weight: 600;
  padding: 7px 14px;
}

.navbar-user-btn {
  display: flex;
  align-items: center;
  gap: 8px;
  background: none;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 5px 10px;
  font-size: 13px;
  font-weight: 500;
  color: var(--text-primary);
  cursor: pointer;
  transition: var(--transition);
}
.navbar-user-btn:hover { background: var(--bg-page); }
.navbar-user-btn::after { display: none; }

.navbar-avatar {
  width: 26px; height: 26px;
  background: var(--brand);
  color: #fff;
  border-radius: 50%;
  font-size: 11px;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
}

/* ============================================================
   PAGE CONTENT
   ============================================================ */
.page-content {
  flex: 1;
  padding: 24px;
}

.page-header {
  margin-bottom: 24px;
}

.page-title {
  font-size: 22px;
  font-weight: 700;
  color: var(--text-primary);
  margin: 0 0 4px;
}

.page-subtitle {
  font-size: 13px;
  color: var(--text-secondary);
  margin: 0;
}

/* ============================================================
   CARDS
   ============================================================ */
.card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-sm);
}

.card-header {
  padding: 16px 20px;
  border-bottom: 1px solid var(--border);
  background: transparent;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.card-title {
  font-size: 14px;
  font-weight: 700;
  color: var(--text-primary);
  margin: 0;
}

.card-body { padding: 20px; }
.card-footer {
  padding: 12px 20px;
  border-top: 1px solid var(--border);
  background: transparent;
}

/* Stat Cards */
.stat-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 20px;
  display: flex;
  align-items: center;
  gap: 16px;
  box-shadow: var(--shadow-sm);
  transition: var(--transition);
  text-decoration: none;
  color: inherit;
}
.stat-card:hover {
  box-shadow: var(--shadow-md);
  transform: translateY(-1px);
  color: inherit;
}

.stat-icon {
  width: 48px; height: 48px;
  border-radius: var(--radius-md);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 22px;
  flex-shrink: 0;
}

.stat-icon.blue   { background: var(--brand-light); color: var(--brand); }
.stat-icon.yellow { background: #fef3c7; color: #d97706; }
.stat-icon.cyan   { background: #cffafe; color: #0891b2; }
.stat-icon.green  { background: #d1fae5; color: #059669; }
.stat-icon.red    { background: #fee2e2; color: #dc2626; }
.stat-icon.gray   { background: #f3f4f6; color: #6b7280; }

.stat-info { flex: 1; }
.stat-value {
  font-size: 26px;
  font-weight: 800;
  color: var(--text-primary);
  line-height: 1;
  font-variant-numeric: tabular-nums;
}
.stat-label {
  font-size: 12px;
  color: var(--text-secondary);
  font-weight: 500;
  margin-top: 4px;
}

/* ============================================================
   TABLES
   ============================================================ */
.table-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  overflow: hidden;
  box-shadow: var(--shadow-sm);
}

.table { margin: 0; font-size: 13.5px; }
.table thead th {
  background: #f9fafb;
  border-bottom: 1px solid var(--border);
  color: var(--text-secondary);
  font-size: 11px;
  font-weight: 700;
  letter-spacing: .6px;
  text-transform: uppercase;
  padding: 11px 16px;
  white-space: nowrap;
}
.table td {
  padding: 12px 16px;
  border-bottom: 1px solid var(--border);
  vertical-align: middle;
  color: var(--text-primary);
}
.table tbody tr:last-child td { border-bottom: none; }
.table tbody tr:hover td { background: #fdf6f3; }

.task-id-badge {
  font-family: var(--font-mono);
  font-size: 12px;
  font-weight: 600;
  background: var(--brand-light);
  color: var(--brand);
  padding: 3px 8px;
  border-radius: 4px;
  white-space: nowrap;
}

.task-title-link {
  font-weight: 600;
  color: var(--text-primary);
  font-size: 13.5px;
}
.task-title-link:hover { color: var(--brand); }

.task-category {
  font-size: 12px;
  color: var(--text-secondary);
  margin-top: 2px;
}

/* ============================================================
   BADGES
   ============================================================ */
.badge {
  font-size: 11px;
  font-weight: 600;
  padding: 4px 8px;
  border-radius: 5px;
  letter-spacing: .2px;
}

/* Priority row highlight */
tr.priority-critical td:first-child {
  border-left: 3px solid var(--p-critical);
}
tr.priority-high td:first-child {
  border-left: 3px solid var(--p-high);
}

/* ============================================================
   FORMS
   ============================================================ */
.form-label {
  font-size: 13px;
  font-weight: 600;
  color: var(--text-primary);
  margin-bottom: 6px;
}

.form-control, .form-select {
  font-size: 13.5px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 9px 12px;
  transition: var(--transition);
  color: var(--text-primary);
}

.form-control:focus, .form-select:focus {
  border-color: var(--brand);
  box-shadow: 0 0 0 3px rgba(200,75,17,.12);
  outline: none;
}

.form-control.is-invalid { border-color: #ef4444; }
.invalid-feedback { font-size: 12px; color: #ef4444; }

textarea.form-control { resize: vertical; min-height: 100px; }

/* ============================================================
   BUTTONS
   ============================================================ */
.btn {
  font-size: 13px;
  font-weight: 600;
  border-radius: var(--radius-sm);
  padding: 8px 16px;
  transition: var(--transition);
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

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

.btn-sm { padding: 5px 10px; font-size: 12px; }
.btn-icon {
  width: 32px; height: 32px;
  padding: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: var(--radius-sm);
}

/* ============================================================
   TASK DETAIL PAGE
   ============================================================ */
.task-meta-row {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
  gap: 16px;
  padding: 16px 20px;
  border-bottom: 1px solid var(--border);
  background: #fdf6f3;
}

.task-meta-item label {
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .6px;
  color: var(--text-muted);
  display: block;
  margin-bottom: 4px;
}

.task-meta-item .value {
  font-size: 13.5px;
  color: var(--text-primary);
  font-weight: 500;
}

.task-description {
  padding: 20px;
  font-size: 14px;
  line-height: 1.7;
  color: var(--text-secondary);
  white-space: pre-line;
}

/* Status stepper */
.status-stepper {
  display: flex;
  align-items: center;
  gap: 0;
  padding: 16px 20px;
  overflow-x: auto;
  background: #fdf6f3;
  border-bottom: 1px solid var(--border);
}

.step {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 12px;
  font-weight: 600;
  color: var(--text-muted);
  white-space: nowrap;
  flex-shrink: 0;
}

.step-dot {
  width: 28px; height: 28px;
  border-radius: 50%;
  border: 2px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 13px;
  background: #fff;
}

.step.done .step-dot { background: var(--brand); border-color: var(--brand); color: #fff; }
.step.done { color: var(--brand); }
.step.current .step-dot { border-color: var(--brand); color: var(--brand); }
.step.current { color: var(--brand); }

.step-line {
  flex: 1;
  min-width: 24px;
  height: 2px;
  background: var(--border);
  margin: 0 4px;
}
.step-line.done { background: var(--brand); }

/* Comments */
.comment-item {
  display: flex;
  gap: 12px;
  padding: 16px 0;
  border-bottom: 1px solid var(--border);
}
.comment-item:last-child { border-bottom: none; }

.comment-avatar {
  width: 32px; height: 32px;
  border-radius: 50%;
  background: var(--brand);
  color: #fff;
  font-size: 12px;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.comment-item.system-comment .comment-avatar {
  background: #f3f4f6;
  color: var(--text-muted);
}

.comment-body { flex: 1; min-width: 0; }
.comment-header {
  display: flex;
  align-items: baseline;
  gap: 8px;
  margin-bottom: 6px;
}
.comment-author { font-size: 13px; font-weight: 700; }
.comment-time { font-size: 12px; color: var(--text-muted); }
.comment-text { font-size: 13.5px; color: var(--text-secondary); line-height: 1.6; }

.comment-item.system-comment .comment-text {
  font-size: 12.5px;
  color: var(--text-muted);
  font-style: italic;
}

/* Attachments */
.attachment-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: #fdf6f3;
  font-size: 13px;
  transition: var(--transition);
}
.attachment-item:hover { border-color: var(--brand); }
.attachment-icon { font-size: 20px; }
.attachment-name { flex: 1; font-weight: 500; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.attachment-size { font-size: 11px; color: var(--text-muted); white-space: nowrap; }

/* ============================================================
   OVERDUE HIGHLIGHT
   ============================================================ */
.overdue-row td { background: #fff8f8 !important; }
.overdue-badge {
  font-size: 11px;
  background: #fee2e2;
  color: #dc2626;
  padding: 2px 7px;
  border-radius: 4px;
  font-weight: 600;
}

/* ============================================================
   FILTER BAR
   ============================================================ */
.filter-bar {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 14px 16px;
  margin-bottom: 20px;
  box-shadow: var(--shadow-sm);
}

/* ============================================================
   EMPTY STATE
   ============================================================ */
.empty-state {
  text-align: center;
  padding: 48px 24px;
  color: var(--text-muted);
}
.empty-state i { font-size: 48px; display: block; margin-bottom: 12px; opacity: .4; }
.empty-state h5 { font-size: 15px; font-weight: 600; color: var(--text-secondary); }
.empty-state p { font-size: 13px; }

/* ============================================================
   MODALS
   ============================================================ */
.modal-content {
  border: none;
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg);
}
.modal-header {
  padding: 18px 24px;
  border-bottom: 1px solid var(--border);
}
.modal-title { font-size: 16px; font-weight: 700; }
.modal-body { padding: 20px 24px; }
.modal-footer { padding: 14px 24px; border-top: 1px solid var(--border); }

/* ============================================================
   ALERTS
   ============================================================ */
.alert {
  border-radius: var(--radius-sm);
  font-size: 13.5px;
  border: none;
  padding: 12px 16px;
}
.alert-success { background: #d1fae5; color: #065f46; }
.alert-danger   { background: #fee2e2; color: #991b1b; }
.alert-warning  { background: #fef3c7; color: #92400e; }
.alert-info     { background: #cffafe; color: #164e63; }

/* ============================================================
   LOGIN PAGE
   ============================================================ */
.login-page {
  min-height: 100vh;
  background: linear-gradient(135deg, #0e0e14 0%, #1B1B22 50%, #0e0e14 100%);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
}

.login-card {
  width: 100%;
  max-width: 420px;
  background: var(--bg-card);
  border-radius: var(--radius-lg);
  padding: 36px;
  box-shadow: var(--shadow-lg);
}

.login-logo {
  text-align: center;
  margin-bottom: 28px;
  padding-bottom: 20px;
  border-bottom: 1px solid var(--border);
}

/* ============================================================
   WHATSAPP LOG
   ============================================================ */
.wa-status-sent    { color: #059669; }
.wa-status-failed  { color: #dc2626; }
.wa-status-pending { color: #d97706; }

/* ============================================================
   RESPONSIVE
   ============================================================ */
@media (max-width: 991px) {
  .sidebar {
    transform: translateX(-100%);
  }
  .sidebar.open {
    transform: translateX(0);
  }
  .main-wrapper {
    margin-left: 0;
  }
  .navbar-toggler { display: block; }
}

@media (max-width: 576px) {
  .page-content { padding: 16px; }
  .stat-card { padding: 14px; }
  .stat-value { font-size: 20px; }
  .top-navbar { padding: 0 16px; }
  .navbar-create-btn .d-none { display: none; }
}

/* ============================================================
   PRINT
   ============================================================ */
@media print {
  .sidebar, .top-navbar, .btn, .filter-bar { display: none !important; }
  .main-wrapper { margin: 0; }
  .card { box-shadow: none; border: 1px solid #ddd; }
}
