/* 
 * 760I Project Timesheet & Project Management Platform
 * Frontend Styling (Vanilla CSS)
 * Author: Antigravity AI
 */

/* Import Google Fonts */
@import url('https://fonts.googleapis.com/css2?family=IBM+Plex+Sans+Thai:wght@300;400;500;600;700&family=Kanit:wght@300;400;500;600;700&family=Prompt:wght@300;400;500;600;700&display=swap');

/* Color variables & Design Tokens */
:root {
  --primary: #0284c7;
  --primary-hover: #0369a1;
  --primary-light: #e0f2fe;
  --primary-dark: #0c4a6e;
  --bg-gradient: linear-gradient(135deg, #f8fafc 0%, #f1f5f9 50%, #e2e8f0 100%);
  --sidebar-gradient: linear-gradient(180deg, #0f172a 0%, #1e293b 100%);
  
  --surface: #ffffff;
  --surface-light: #f8fafc;
  --surface-hover: #f1f5f9;
  
  --text-main: #0f172a;
  --text-secondary: #334155;
  --text-muted: #64748b;
  --text-light: #f8fafc;
  
  --border-color: #e2e8f0;
  --border-hover: #cbd5e1;
  
  --success: #10b981;
  --success-light: #d1fae5;
  --warning: #f59e0b;
  --warning-light: #fef3c7;
  --danger: #ef4444;
  --danger-light: #fee2e2;
  
  --shadow-sm: 0 1px 3px 0 rgba(0, 0, 0, 0.05);
  --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.08), 0 2px 4px -2px rgba(0, 0, 0, 0.08);
  --shadow-lg: 0 10px 15px -3px rgba(15, 23, 42, 0.08), 0 4px 6px -4px rgba(15, 23, 42, 0.08);
  --shadow-premium: 0 20px 25px -5px rgba(15, 23, 42, 0.12), 0 8px 10px -6px rgba(15, 23, 42, 0.12);
  
  --radius-sm: 8px;
  --radius-md: 12px;
  --radius-lg: 16px;
  
  --font-title: 'Prompt', 'Kanit', sans-serif;
  --font-body: 'IBM Plex Sans Thai', 'Prompt', sans-serif;
  
  --transition-fast: 0.15s ease;
  --transition-normal: 0.25s cubic-bezier(0.4, 0, 0.2, 1);
  
  --sidebar-width: 260px;
  --header-height: 70px;
}

/* Base resets & styles */
* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

body {
  font-family: var(--font-body);
  background: var(--bg-gradient);
  color: var(--text-main);
  min-height: 100vh;
  overflow-x: hidden;
  line-height: 1.5;
}

button, input, select, textarea {
  font-family: inherit;
}

h1, h2, h3, h4, h5, h6 {
  font-family: var(--font-title);
  font-weight: 600;
  color: var(--text-main);
}

/* Scrollbar customization */
::-webkit-scrollbar {
  width: 6px;
  height: 6px;
}
::-webkit-scrollbar-track {
  background: transparent;
}
::-webkit-scrollbar-thumb {
  background: #cbd5e1;
  border-radius: 4px;
}
::-webkit-scrollbar-thumb:hover {
  background: #94a3b8;
}

/* Global utility classes */
.card-premium {
  background: var(--surface);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-premium);
  border: 1px solid var(--border-color);
  padding: 1.5rem;
  transition: transform var(--transition-normal), box-shadow var(--transition-normal);
}
.card-premium:hover {
  transform: translateY(-4px);
  box-shadow: 0 25px 30px -5px rgba(15, 23, 42, 0.15);
}

.text-gradient {
  background: linear-gradient(135deg, var(--primary) 0%, var(--primary-dark) 100%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
}

.badge {
  display: inline-flex;
  align-items: center;
  gap: 0.25rem;
  padding: 0.25rem 0.75rem;
  border-radius: 9999px;
  font-size: 0.75rem;
  font-weight: 600;
}
.badge-success { background: var(--success-light); color: var(--success); }
.badge-warning { background: var(--warning-light); color: var(--warning); }
.badge-danger { background: var(--danger-light); color: var(--danger); }
.badge-primary { background: var(--primary-light); color: var(--primary); }

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

/* Sidebar styling */
.sidebar {
  width: var(--sidebar-width);
  background: var(--sidebar-gradient);
  color: var(--text-light);
  display: flex;
  flex-direction: column;
  position: fixed;
  top: 0;
  bottom: 0;
  left: 0;
  z-index: 100;
  box-shadow: var(--shadow-lg);
  transition: transform var(--transition-normal);
}

.sidebar-header {
  padding: 1.5rem;
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
}

.sidebar-logo {
  font-family: var(--font-title);
  font-size: 1.25rem;
  font-weight: 700;
  letter-spacing: 0.5px;
  color: #fff;
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.sidebar-sub {
  font-size: 0.7rem;
  color: #38bdf8;
  text-transform: uppercase;
  letter-spacing: 1px;
}

.sidebar-menu {
  flex: 1;
  padding: 1rem;
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
  overflow-y: auto;
}

.menu-item {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.75rem 1rem;
  border-radius: var(--radius-md);
  color: #94a3b8;
  text-decoration: none;
  font-weight: 500;
  cursor: pointer;
  transition: all var(--transition-fast);
}
.menu-item:hover, .menu-item.active {
  background: rgba(255, 255, 255, 0.08);
  color: #fff;
}
.menu-item.active {
  background: var(--primary);
  box-shadow: 0 4px 12px rgba(2, 132, 199, 0.3);
}

.sidebar-footer {
  padding: 1rem;
  border-top: 1px solid rgba(255, 255, 255, 0.08);
}

.user-profile-badge {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.5rem;
  border-radius: var(--radius-md);
  background: rgba(255, 255, 255, 0.04);
}

.user-avatar {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  background: var(--primary);
  color: white;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: bold;
}

.user-info {
  display: flex;
  flex-direction: column;
}

.user-name {
  font-size: 0.85rem;
  font-weight: 600;
  color: white;
}

.user-role {
  font-size: 0.7rem;
  color: #94a3b8;
}

/* Main panel & Layout structure */
.main-panel {
  flex: 1;
  margin-left: var(--sidebar-width);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

/* Header style */
.main-header {
  height: var(--header-height);
  background: var(--surface);
  border-bottom: 1px solid var(--border-color);
  padding: 0 2rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  position: sticky;
  top: 0;
  z-index: 90;
  box-shadow: var(--shadow-sm);
}

.sheet-status-container {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-size: 0.85rem;
  font-weight: 500;
}

.status-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  position: relative;
}
.status-dot.online { background-color: var(--success); box-shadow: 0 0 8px var(--success); }
.status-dot.loading { background-color: var(--warning); box-shadow: 0 0 8px var(--warning); animation: pulse 1s infinite alternate; }
.status-dot.offline { background-color: var(--danger); box-shadow: 0 0 8px var(--danger); }

@keyframes pulse {
  0% { opacity: 0.4; }
  100% { opacity: 1; }
}

/* Content Container */
.content-wrapper {
  padding: 2rem;
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 2rem;
  max-width: 1600px;
  width: 100%;
  margin: 0 auto;
}

/* View panels switcher */
.view-panel {
  display: none;
  animation: fadeIn var(--transition-normal);
}
.view-panel.active {
  display: block;
}

@keyframes fadeIn {
  from { opacity: 0; transform: translateY(10px); }
  to { opacity: 1; transform: translateY(0); }
}

/* Login Panel overlay & styling */
.login-wrapper {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  background: linear-gradient(135deg, #0f172a 0%, #1e293b 100%);
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 1000;
}

.login-card {
  width: 100%;
  max-width: 440px;
  background: rgba(255, 255, 255, 0.95);
  backdrop-filter: blur(10px);
  border-radius: var(--radius-lg);
  box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.5);
  padding: 3rem 2.5rem;
  border: 1px solid rgba(255, 255, 255, 0.1);
  display: flex;
  flex-direction: column;
  gap: 2rem;
}

.login-header {
  text-align: center;
}

.login-logo {
  font-family: var(--font-title);
  font-size: 1.75rem;
  font-weight: 800;
  color: var(--primary-dark);
  margin-bottom: 0.25rem;
}

.login-sub {
  color: var(--text-muted);
  font-size: 0.9rem;
}

.form-group {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  margin-bottom: 1.25rem;
}

.form-group label {
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--text-secondary);
}

.input-control {
  width: 100%;
  padding: 0.75rem 1rem;
  border-radius: var(--radius-md);
  border: 1px solid var(--border-color);
  background: var(--surface-light);
  font-size: 0.95rem;
  transition: all var(--transition-fast);
}
.input-control:focus {
  outline: none;
  border-color: var(--primary);
  background: #fff;
  box-shadow: 0 0 0 4px var(--primary-light);
}

.btn-primary {
  width: 100%;
  padding: 0.75rem 1.5rem;
  border-radius: var(--radius-md);
  border: none;
  background: var(--primary);
  color: white;
  font-weight: 600;
  font-size: 1rem;
  cursor: pointer;
  box-shadow: 0 4px 10px rgba(2, 132, 199, 0.2);
  transition: all var(--transition-fast);
}
.btn-primary:hover {
  background: var(--primary-hover);
  box-shadow: 0 6px 14px rgba(2, 132, 199, 0.3);
  transform: translateY(-1px);
}

/* Dashboard Grid & Cards */
.kpi-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
  gap: 1.5rem;
}

.kpi-card {
  display: flex;
  align-items: center;
  gap: 1.25rem;
}

.kpi-icon {
  width: 52px;
  height: 52px;
  border-radius: var(--radius-md);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.5rem;
  color: var(--primary);
  background: var(--primary-light);
}

.kpi-info {
  display: flex;
  flex-direction: column;
}

.kpi-value {
  font-size: 1.75rem;
  font-weight: 700;
  color: var(--text-main);
  line-height: 1.2;
}

.kpi-label {
  font-size: 0.85rem;
  color: var(--text-muted);
  font-weight: 500;
}

/* Dashboard Graphs Section */
.charts-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(450px, 1fr));
  gap: 1.5rem;
}

.chart-card {
  min-height: 350px;
  display: flex;
  flex-direction: column;
}

.chart-container {
  flex: 1;
  position: relative;
  width: 100%;
  height: 100%;
}

/* Table Design (Scrollable) */
.table-responsive {
  width: 100%;
  overflow-x: auto;
  border-radius: var(--radius-md);
  border: 1px solid var(--border-color);
  max-height: 500px;
  overflow-y: auto;
}

table {
  width: 100%;
  border-collapse: collapse;
  text-align: left;
}

th {
  background: var(--surface-light);
  padding: 1rem;
  font-weight: 600;
  font-size: 0.85rem;
  color: var(--text-secondary);
  border-bottom: 1px solid var(--border-color);
  position: sticky;
  top: 0;
  z-index: 10;
}

td {
  padding: 1rem;
  border-bottom: 1px solid var(--border-color);
  font-size: 0.9rem;
  color: var(--text-secondary);
  background: white;
}

tr:hover td {
  background: var(--surface-light);
}

/* Calendar Schedule View */
.calendar-wrapper {
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

.calendar-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.calendar-grid {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  overflow: hidden;
  background: white;
}

.calendar-day-header {
  background: var(--surface-light);
  padding: 0.75rem;
  text-align: center;
  font-weight: 600;
  font-size: 0.85rem;
  color: var(--text-secondary);
  border-bottom: 1px solid var(--border-color);
  border-right: 1px solid var(--border-color);
}
.calendar-day-header:last-child {
  border-right: none;
}

.calendar-cell {
  height: 140px;
  max-height: 140px;
  overflow-y: auto;
  padding: 0.5rem;
  border-right: 1px solid var(--border-color);
  border-bottom: 1px solid var(--border-color);
  background: white;
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
}
.calendar-cell::-webkit-scrollbar {
  width: 4px;
}
.calendar-cell::-webkit-scrollbar-track {
  background: transparent;
}
.calendar-cell::-webkit-scrollbar-thumb {
  background: #cbd5e1;
  border-radius: 4px;
}
.calendar-cell::-webkit-scrollbar-thumb:hover {
  background: #94a3b8;
}
.calendar-cell:nth-child(7n) {
  border-right: none;
}
.calendar-cell.other-month {
  background: var(--surface-light);
  color: #94a3b8;
}

.calendar-date-num {
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--text-secondary);
}

.calendar-event {
  font-size: 0.7rem;
  padding: 0.25rem 0.5rem;
  border-radius: 4px;
  color: white;
  font-weight: 500;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* Modals & Popup Styling */
.modal-overlay {
  display: none;
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(15, 23, 42, 0.4);
  backdrop-filter: blur(4px);
  z-index: 500;
  align-items: center;
  justify-content: center;
  animation: fadeIn var(--transition-fast);
}
.modal-overlay.active {
  display: flex;
}

.modal-content {
  background: white;
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-premium);
  max-width: 600px;
  width: 90%;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  animation: slideUp var(--transition-normal);
}

.modal-header {
  padding: 1.5rem;
  border-bottom: 1px solid var(--border-color);
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.modal-body {
  padding: 1.5rem;
  max-height: 70vh;
  overflow-y: auto;
}

.modal-footer {
  padding: 1.25rem 1.5rem;
  border-top: 1px solid var(--border-color);
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 0.75rem;
}

@keyframes slideUp {
  from { transform: translateY(20px); opacity: 0; }
  to { transform: translateY(0); opacity: 1; }
}

.btn-secondary {
  padding: 0.75rem 1.5rem;
  border-radius: var(--radius-md);
  border: 1px solid var(--border-color);
  background: white;
  color: var(--text-secondary);
  font-weight: 600;
  cursor: pointer;
  transition: all var(--transition-fast);
}
.btn-secondary:hover {
  background: var(--surface-light);
}

.btn-icon {
  background: transparent;
  border: none;
  width: 32px;
  height: 32px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  color: var(--text-muted);
  transition: all var(--transition-fast);
}
.btn-icon:hover {
  background: var(--surface-light);
  color: var(--text-main);
}

/* Modern Loader Styling */
.loader-wrapper {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(255, 255, 255, 0.75);
  backdrop-filter: blur(2px);
  z-index: 2000;
  display: none;
  align-items: center;
  justify-content: center;
  flex-direction: column;
  gap: 1rem;
}
.loader-wrapper.active {
  display: flex;
}

.loader {
  width: 48px;
  height: 48px;
  border: 4px solid var(--primary-light);
  border-bottom-color: var(--primary);
  border-radius: 50%;
  display: inline-block;
  box-sizing: border-box;
  animation: rotation 1s linear infinite;
}

@keyframes rotation {
  0% { transform: rotate(0deg); }
  100% { transform: rotate(360deg); }
}

/* Responsive Overrides (Media Queries) */
@media (max-width: 992px) {
  .sidebar {
    transform: translateX(-100%);
  }
  .sidebar.active {
    transform: translateX(0);
  }
  .main-panel {
    margin-left: 0;
  }
  .charts-grid {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 576px) {
  .content-wrapper {
    padding: 1rem;
  }
  .main-header {
    padding: 0 1rem;
  }
  .login-card {
    padding: 2rem 1.5rem;
  }
  .kpi-grid {
    grid-template-columns: 1fr;
  }
}

/* ========================================== */
/* Gantt Chart & Timeline Styling             */
/* ========================================== */
.gantt-legend-box {
  display: inline-block;
  width: 14px;
  height: 14px;
  border-radius: 3px;
  vertical-align: middle;
}
.gantt-legend-box.kickoff, .gantt-bar-kickoff { background-color: #4CAF50 !important; }
.gantt-legend-box.present, .gantt-bar-present { background-color: #FFEB3B !important; }
.gantt-legend-box.forbid, .gantt-bar-forbid { background-color: #FF9800 !important; }
.gantt-legend-box.forpermiss, .gantt-bar-forpermiss { background-color: #9C27B0 !important; }
.gantt-legend-box.forcons, .gantt-bar-forcons { background-color: #F44336 !important; }
.gantt-legend-box.finish, .gantt-bar-finish { background-color: #2196F3 !important; }

.gantt-day-cell {
  width: 8px;
  min-width: 8px;
  max-width: 8px;
  height: 24px;
  border-right: 1px solid #f1f5f9;
  padding: 0 !important;
  cursor: pointer;
  background-color: transparent;
}
.gantt-day-cell:hover {
  background-color: rgba(2, 132, 199, 0.1) !important;
}

.gantt-month-start {
  border-left: 2px solid #cbd5e1 !important;
}

.gantt-today-line {
  background-color: rgba(239, 68, 68, 0.1) !important;
  border-left: 1px dashed #ef4444 !important;
  border-right: 1px dashed #ef4444 !important;
}

.gantt-status-badge {
  display: inline-block;
  padding: 0.15rem 0.4rem;
  border-radius: 4px;
  font-size: 0.7rem;
  font-weight: 600;
  margin: 1px;
}

.gantt-status-badge.kickoff { background-color: #e8f5e9; color: #2e7d32; }
.gantt-status-badge.present { background-color: #fffde7; color: #f57f17; }
.gantt-status-badge.forbid { background-color: #fff3e0; color: #e65100; }
.gantt-status-badge.forpermiss { background-color: #f3e5f5; color: #6a1b9a; }
.gantt-status-badge.forcons { background-color: #ffebee; color: #c62828; }
.gantt-status-badge.finish { background-color: #e3f2fd; color: #1565c0; }
.gantt-status-badge.none { background-color: #f1f5f9; color: #64748b; }

