/* ============================================================
   SiteMaster — Construction Site Management
   ============================================================ */

:root {
    --bg: #f8f9fa;
    --bg-card: #ffffff;
    --bg-sidebar: #1a1d23;
    --bg-sidebar-hover: #2a2d35;
    --text: #1e293b;
    --text-secondary: #64748b;
    --text-muted: #94a3b8;
    --border: #e2e8f0;
    --primary: #0d9488;
    --primary-light: #ccfbf1;
    --primary-dark: #0f766e;
    --danger: #ef4444;
    --danger-light: #fef2f2;
    --warning: #f59e0b;
    --warning-light: #fffbeb;
    --success: #22c55e;
    --success-light: #f0fdf4;
    --info: #3b82f6;
    --info-light: #eff6ff;
    --radius: 8px;
    --radius-lg: 12px;
    --shadow: 0 1px 3px rgba(0,0,0,0.06);
    --sidebar-w: 240px;
}

* { margin: 0; padding: 0; box-sizing: border-box; }
body { font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif; background: var(--bg); color: var(--text); font-size: 14px; line-height: 1.5; }
a { color: var(--primary); text-decoration: none; }
a:hover { color: var(--primary-dark); }

/* ── Layout ── */
.app { display: flex; min-height: 100vh; }
.sidebar { width: var(--sidebar-w); background: var(--bg-sidebar); color: #e2e8f0; display: flex; flex-direction: column; position: fixed; top: 0; left: 0; bottom: 0; z-index: 100; }
.sidebar-logo { padding: 20px; font-size: 18px; font-weight: 600; display: flex; align-items: center; gap: 10px; color: #fff; border-bottom: 1px solid rgba(255,255,255,0.08); }
.sidebar-logo i { font-size: 24px; color: var(--primary); }
.sidebar-nav { flex: 1; padding: 12px 8px; }
.nav-item { display: flex; align-items: center; gap: 10px; padding: 10px 14px; border-radius: 6px; color: #94a3b8; font-size: 14px; margin-bottom: 2px; transition: all .15s; }
.nav-item:hover { background: var(--bg-sidebar-hover); color: #e2e8f0; }
.nav-item.active { background: var(--primary); color: #fff; }
.nav-item i { font-size: 20px; }
.nav-divider { height: 1px; background: rgba(255,255,255,0.08); margin: 12px 14px; }
.sidebar-footer { padding: 16px; border-top: 1px solid rgba(255,255,255,0.08); }
.sidebar-user { display: flex; align-items: center; gap: 10px; font-size: 13px; }

.main { flex: 1; margin-left: var(--sidebar-w); }
.topbar { padding: 16px 24px; background: var(--bg-card); border-bottom: 1px solid var(--border); display: flex; align-items: center; justify-content: space-between; position: sticky; top: 0; z-index: 50; }
.topbar-title { font-size: 18px; font-weight: 600; }
.topbar-actions { display: flex; align-items: center; gap: 12px; font-size: 13px; color: var(--text-secondary); }
.content { padding: 24px; }

/* ── Cards ── */
.card { background: var(--bg-card); border: 1px solid var(--border); border-radius: var(--radius-lg); padding: 20px; box-shadow: var(--shadow); }
.card-header { display: flex; align-items: center; justify-content: space-between; margin-bottom: 16px; }
.card-title { font-size: 15px; font-weight: 600; }

/* ── Stat Cards ── */
.stats-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 16px; margin-bottom: 24px; }
.stat-card { background: var(--bg-card); border: 1px solid var(--border); border-radius: var(--radius-lg); padding: 16px 20px; box-shadow: var(--shadow); }
.stat-label { font-size: 13px; color: var(--text-secondary); margin-bottom: 4px; }
.stat-value { font-size: 28px; font-weight: 700; line-height: 1.2; }
.stat-value.primary { color: var(--primary); }
.stat-value.danger { color: var(--danger); }
.stat-value.warning { color: var(--warning); }
.stat-value.success { color: var(--success); }
.stat-sub { font-size: 12px; color: var(--text-muted); margin-top: 4px; }

/* ── Kanban ── */
.kanban-board { display: grid; grid-template-columns: repeat(5, 1fr); gap: 12px; min-height: 70vh; }
.kanban-col { background: var(--bg); border-radius: var(--radius); padding: 12px; min-height: 200px; }
.kanban-col-header { font-size: 13px; font-weight: 600; text-transform: uppercase; letter-spacing: 0.5px; padding: 8px 4px; margin-bottom: 8px; display: flex; align-items: center; justify-content: space-between; color: var(--text-secondary); }
.kanban-col-count { background: var(--border); border-radius: 10px; padding: 2px 8px; font-size: 12px; font-weight: 500; }
.kanban-card { background: var(--bg-card); border: 1px solid var(--border); border-radius: var(--radius); padding: 12px; margin-bottom: 8px; cursor: grab; transition: box-shadow .15s, transform .1s; }
.kanban-card:hover { box-shadow: 0 4px 12px rgba(0,0,0,0.08); }
.kanban-card:active { cursor: grabbing; transform: rotate(2deg); }
.kanban-card.sortable-ghost { opacity: 0.4; }
.kanban-card-title { font-size: 14px; font-weight: 500; margin-bottom: 6px; }
.kanban-card-meta { display: flex; align-items: center; gap: 8px; font-size: 12px; color: var(--text-muted); flex-wrap: wrap; }
.kanban-card-meta i { font-size: 14px; }
.kanban-add-btn { width: 100%; padding: 8px; border: 1px dashed var(--border); border-radius: var(--radius); background: none; color: var(--text-muted); cursor: pointer; font-size: 13px; display: flex; align-items: center; justify-content: center; gap: 4px; }
.kanban-add-btn:hover { border-color: var(--primary); color: var(--primary); }

/* Priority badges */
.priority { display: inline-block; font-size: 11px; padding: 2px 8px; border-radius: 4px; font-weight: 500; }
.priority-urgent { background: var(--danger-light); color: var(--danger); }
.priority-high { background: var(--warning-light); color: #92400e; }
.priority-medium { background: var(--info-light); color: var(--info); }
.priority-low { background: #f1f5f9; color: var(--text-muted); }

/* Category badges */
.cat-badge { display: inline-block; font-size: 11px; padding: 2px 8px; border-radius: 4px; background: var(--primary-light); color: var(--primary-dark); font-weight: 500; }

/* Status badges */
.status { display: inline-block; font-size: 12px; padding: 3px 10px; border-radius: 4px; font-weight: 500; }
.status-open { background: var(--danger-light); color: var(--danger); }
.status-assigned, .status-in_progress { background: var(--warning-light); color: #92400e; }
.status-fixed { background: var(--info-light); color: var(--info); }
.status-verified, .status-completed, .status-done { background: var(--success-light); color: #166534; }

/* Severity */
.severity { display: inline-block; font-size: 12px; padding: 3px 10px; border-radius: 4px; font-weight: 600; }
.severity-safety { background: #7f1d1d; color: #fff; }
.severity-critical { background: var(--danger); color: #fff; }
.severity-major { background: var(--warning); color: #fff; }
.severity-minor { background: #e2e8f0; color: var(--text-secondary); }

/* ── Units Grid ── */
.units-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 12px; }
.unit-card { background: var(--bg-card); border: 1px solid var(--border); border-radius: var(--radius); padding: 14px; cursor: pointer; transition: all .15s; position: relative; }
.unit-card:hover { border-color: var(--primary); box-shadow: 0 4px 12px rgba(0,0,0,0.08); }
.unit-card-code { font-weight: 600; font-size: 14px; margin-bottom: 4px; }
.unit-card-type { font-size: 12px; color: var(--text-muted); margin-bottom: 8px; }
.unit-card-bar { height: 4px; border-radius: 2px; background: #e2e8f0; overflow: hidden; margin-bottom: 8px; }
.unit-card-bar-fill { height: 100%; border-radius: 2px; transition: width .3s; }
.unit-card-stats { display: flex; justify-content: space-between; font-size: 12px; color: var(--text-muted); }

/* ── Table ── */
.table { width: 100%; border-collapse: collapse; }
.table th, .table td { padding: 10px 14px; text-align: left; border-bottom: 1px solid var(--border); }
.table th { font-size: 12px; font-weight: 600; color: var(--text-secondary); text-transform: uppercase; letter-spacing: 0.5px; }
.table tr:hover td { background: #f8fafc; }

/* ── Forms ── */
.form-group { margin-bottom: 16px; }
.form-label { display: block; font-size: 13px; font-weight: 500; margin-bottom: 6px; color: var(--text); }
.form-control { width: 100%; padding: 8px 12px; border: 1px solid var(--border); border-radius: var(--radius); font-size: 14px; background: var(--bg-card); color: var(--text); transition: border-color .15s; }
.form-control:focus { outline: none; border-color: var(--primary); box-shadow: 0 0 0 3px rgba(13,148,136,0.1); }
textarea.form-control { resize: vertical; min-height: 80px; }
select.form-control { appearance: none; background-image: url("data:image/svg+xml;charset=utf-8,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' fill='%2364748b'%3E%3Cpath d='M4.427 6.427l3.396 3.396a.25.25 0 00.354 0l3.396-3.396A.25.25 0 0011.396 6H4.604a.25.25 0 00-.177.427z'/%3E%3C/svg%3E"); background-repeat: no-repeat; background-position: right 10px center; padding-right: 32px; }

/* ── Buttons ── */
.btn { display: inline-flex; align-items: center; gap: 6px; padding: 8px 16px; border-radius: var(--radius); font-size: 14px; font-weight: 500; border: none; cursor: pointer; transition: all .15s; }
.btn-primary { background: var(--primary); color: #fff; }
.btn-primary:hover { background: var(--primary-dark); color: #fff; }
.btn-outline { background: transparent; border: 1px solid var(--border); color: var(--text); }
.btn-outline:hover { background: #f8fafc; }
.btn-danger { background: var(--danger); color: #fff; }
.btn-sm { padding: 5px 10px; font-size: 12px; }
.btn-icon { padding: 6px; width: 32px; height: 32px; display: inline-flex; align-items: center; justify-content: center; border-radius: 6px; border: 1px solid var(--border); background: transparent; cursor: pointer; color: var(--text-muted); }
.btn-icon:hover { background: #f1f5f9; color: var(--text); }

/* ── Photo Gallery ── */
.photo-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(120px, 1fr)); gap: 8px; }
.photo-thumb { aspect-ratio: 1; border-radius: var(--radius); overflow: hidden; cursor: pointer; border: 1px solid var(--border); }
.photo-thumb img { width: 100%; height: 100%; object-fit: cover; }
.photo-upload-zone { border: 2px dashed var(--border); border-radius: var(--radius); padding: 20px; text-align: center; color: var(--text-muted); cursor: pointer; transition: all .15s; }
.photo-upload-zone:hover, .photo-upload-zone.dragover { border-color: var(--primary); background: var(--primary-light); color: var(--primary); }

/* ── Filters ── */
.filters { display: flex; gap: 10px; margin-bottom: 20px; flex-wrap: wrap; align-items: center; }
.filters select, .filters input { padding: 6px 12px; font-size: 13px; }

/* ── Progress Bar ── */
.progress { height: 6px; background: #e2e8f0; border-radius: 3px; overflow: hidden; }
.progress-fill { height: 100%; border-radius: 3px; background: var(--primary); transition: width .3s; }
.progress-fill.danger { background: var(--danger); }
.progress-fill.warning { background: var(--warning); }

/* ── Avatar ── */
.avatar-sm { width: 32px; height: 32px; border-radius: 50%; background: var(--primary); color: #fff; display: flex; align-items: center; justify-content: center; font-size: 13px; font-weight: 500; flex-shrink: 0; }

/* ── Modal ── */
.modal-overlay { position: fixed; inset: 0; background: rgba(0,0,0,0.4); z-index: 200; display: none; align-items: center; justify-content: center; }
.modal-overlay.show { display: flex; }
.modal { background: var(--bg-card); border-radius: var(--radius-lg); width: 90%; max-width: 500px; max-height: 90vh; overflow-y: auto; box-shadow: 0 20px 60px rgba(0,0,0,0.15); }
.modal-header { padding: 16px 20px; border-bottom: 1px solid var(--border); display: flex; align-items: center; justify-content: space-between; }
.modal-header h3 { font-size: 16px; font-weight: 600; }
.modal-body { padding: 20px; }
.modal-footer { padding: 12px 20px; border-top: 1px solid var(--border); display: flex; justify-content: flex-end; gap: 8px; }

/* ── Responsive ── */
@media (max-width: 1024px) {
    .kanban-board { grid-template-columns: repeat(3, 1fr); }
}
@media (max-width: 768px) {
    .sidebar { display: none; }
    .main { margin-left: 0; }
    .kanban-board { grid-template-columns: 1fr; }
    .stats-grid { grid-template-columns: repeat(2, 1fr); }
}
