/* ProjectPilot - Main Stylesheet */

* { box-sizing: border-box; margin: 0; padding: 0; }

:root {
    --primary: #8CC63F;
    --primary-dark: #6FAE2B;
    --primary-light: #EAF6D7;
    --brand-navy: #14396D;
    --brand-blue: #1F5F97;
    --brand-green: #8CC63F;
    --brand-green-dark: #6FAE2B;
    --success: #10b981;
    --warning: #f59e0b;
    --danger: #ef4444;
    --info: #3b82f6;
    --purple: #8b5cf6;
    --grey-50: #f9fafb;
    --grey-100: #f3f4f6;
    --grey-200: #e5e7eb;
    --grey-300: #d1d5db;
    --grey-400: #9ca3af;
    --grey-500: #6b7280;
    --grey-600: #4b5563;
    --grey-700: #374151;
    --grey-800: #1f2937;
    --grey-900: #111827;
    --shadow-sm: 0 1px 2px rgba(0,0,0,0.05);
    --shadow: 0 1px 3px rgba(0,0,0,0.1), 0 1px 2px rgba(0,0,0,0.06);
    --shadow-lg: 0 10px 15px -3px rgba(0,0,0,0.1), 0 4px 6px -2px rgba(0,0,0,0.05);
    --radius: 8px;
    --radius-sm: 6px;
    --radius-lg: 12px;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, sans-serif;
    background: var(--grey-50);
    color: var(--grey-800);
    font-size: 14px;
    line-height: 1.5;
    min-height: 100vh;
}

/* Layout */
.app-shell {
    display: flex;
    min-height: 100vh;
}

.sidebar {
    width: 240px;
    background: linear-gradient(180deg, var(--brand-navy) 0%, #0b2344 100%);
    color: #fff;
    display: flex;
    flex-direction: column;
    position: fixed;
    top: 0;
    bottom: 0;
    left: 0;
    z-index: 100;
}

.sidebar-brand {
    padding: 18px 20px;
    border-bottom: 1px solid rgba(255,255,255,0.1);
    display: flex;
    align-items: center;
    gap: 10px;
}
.sidebar-brand .logo {
    width: 32px; height: 32px;
    background: var(--primary);
    border-radius: var(--radius-sm);
    display: flex; align-items: center; justify-content: center;
    font-weight: 700; color: #fff;
}
.sidebar-logo-img {
    width: 42px;
    height: 42px;
    object-fit: contain;
    border-radius: 10px;
    background: rgba(255,255,255,0.95);
    padding: 3px;
}
.sidebar-brand .name {
    font-size: 16px;
    font-weight: 700;
}
.sidebar-brand .name span {
    color: var(--primary);
}

.sidebar-nav {
    flex: 1;
    overflow-y: auto;
    padding: 12px 0;
}
.sidebar-nav .nav-section {
    padding: 8px 20px 4px;
    font-size: 11px;
    text-transform: uppercase;
    color: var(--grey-400);
    letter-spacing: 0.5px;
}
.sidebar-nav a {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 9px 20px;
    color: rgba(255,255,255,0.8);
    text-decoration: none;
    transition: background 0.15s;
    font-size: 14px;
}
.sidebar-nav a:hover {
    background: rgba(255,255,255,0.05);
    color: #fff;
}
.sidebar-nav a.active {
    background: var(--primary);
    color: #fff;
    border-left: 3px solid #fff;
    padding-left: 17px;
}
.sidebar-nav a .icon {
    width: 18px; height: 18px;
    display: inline-flex; align-items: center; justify-content: center;
}

.sidebar-footer {
    padding: 12px 20px;
    border-top: 1px solid rgba(255,255,255,0.1);
    font-size: 11px;
    color: var(--grey-400);
}

.main-content {
    flex: 1;
    margin-left: 240px;
    display: flex;
    flex-direction: column;
}

.topbar {
    background: #fff;
    border-bottom: 1px solid var(--grey-200);
    padding: 12px 24px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    position: sticky;
    top: 0;
    z-index: 50;
}
.topbar .search {
    flex: 1;
    max-width: 480px;
    position: relative;
}
.topbar .search input {
    width: 100%;
    padding: 8px 12px 8px 36px;
    border: 1px solid var(--grey-200);
    border-radius: var(--radius);
    background: var(--grey-50);
    font-size: 13px;
}
.topbar .search input:focus {
    outline: none;
    border-color: var(--primary);
    background: #fff;
}
.topbar .search::before {
    content: "🔍";
    position: absolute;
    left: 12px; top: 50%;
    transform: translateY(-50%);
    font-size: 12px;
}
.topbar .user-menu {
    display: flex;
    align-items: center;
    gap: 12px;
}
.topbar .user-menu .avatar {
    width: 36px; height: 36px;
    background: var(--primary);
    color: #fff;
    border-radius: 50%;
    display: flex; align-items: center; justify-content: center;
    font-weight: 600;
    font-size: 13px;
}
.topbar .notification-bell {
    position: relative;
    cursor: pointer;
    padding: 6px 10px;
    border-radius: var(--radius);
    color: var(--grey-600);
}
.topbar .notification-bell:hover { background: var(--grey-100); }
.topbar .notification-bell .badge {
    position: absolute;
    top: 0; right: 0;
    background: var(--danger);
    color: #fff;
    font-size: 10px;
    border-radius: 10px;
    padding: 1px 5px;
    font-weight: 600;
}

.page {
    padding: 24px;
    flex: 1;
}

.page-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 20px;
    flex-wrap: wrap;
    gap: 12px;
}
.page-header h1 {
    font-size: 22px;
    font-weight: 700;
    color: var(--brand-navy);
}
.page-header .breadcrumb {
    font-size: 12px;
    color: var(--grey-500);
    margin-bottom: 4px;
}
.page-header .breadcrumb a {
    color: var(--grey-500);
    text-decoration: none;
}
.page-header .breadcrumb a:hover { color: var(--primary); }

/* Cards */
.card {
    background: #fff;
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-sm);
    border: 1px solid var(--grey-200);
    overflow: hidden;
}
.card-header {
    padding: 14px 18px;
    border-bottom: 1px solid var(--grey-200);
    display: flex;
    align-items: center;
    justify-content: space-between;
}
.card-header h3 {
    font-size: 15px;
    font-weight: 600;
    color: var(--grey-800);
}
.card-body { padding: 18px; }

/* Summary cards (KPI cards) */
.kpi-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
    gap: 16px;
    margin-bottom: 24px;
}
.kpi-card {
    background: #fff;
    border-radius: var(--radius-lg);
    padding: 18px;
    box-shadow: var(--shadow-sm);
    border: 1px solid var(--grey-200);
    border-left: 4px solid var(--primary);
}
.kpi-card.success { border-left-color: var(--success); }
.kpi-card.warning { border-left-color: var(--warning); }
.kpi-card.danger { border-left-color: var(--danger); }
.kpi-card.info { border-left-color: var(--info); }
.kpi-card.purple { border-left-color: var(--purple); }

.kpi-card .label {
    font-size: 11px;
    text-transform: uppercase;
    color: var(--grey-500);
    letter-spacing: 0.5px;
    margin-bottom: 6px;
    font-weight: 600;
}
.kpi-card .value {
    font-size: 28px;
    font-weight: 700;
    color: var(--brand-navy);
}
.kpi-card .sub {
    font-size: 12px;
    color: var(--grey-500);
    margin-top: 4px;
}

/* Buttons */
.btn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 8px 14px;
    border-radius: var(--radius);
    border: 1px solid transparent;
    font-size: 13px;
    font-weight: 500;
    text-decoration: none;
    cursor: pointer;
    transition: all 0.15s;
    background: #fff;
    color: var(--grey-700);
    border-color: var(--grey-300);
}
.btn:hover { background: var(--grey-50); }
.btn-primary {
    background: var(--primary);
    color: #fff;
    border-color: var(--primary);
}
.btn-primary:hover { background: var(--primary-dark); border-color: var(--primary-dark); }
.btn-success { background: var(--success); color: #fff; border-color: var(--success); }
.btn-success:hover { background: #059669; }
.btn-danger { background: var(--danger); color: #fff; border-color: var(--danger); }
.btn-danger:hover { background: #dc2626; }
.btn-sm { padding: 5px 10px; font-size: 12px; }
.btn-lg { padding: 11px 20px; font-size: 14px; }

/* Forms */
.form-group { margin-bottom: 14px; }
.form-group label {
    display: block;
    margin-bottom: 5px;
    font-size: 12px;
    font-weight: 600;
    color: var(--grey-700);
    text-transform: uppercase;
    letter-spacing: 0.3px;
}
.form-control {
    width: 100%;
    padding: 9px 12px;
    border: 1px solid var(--grey-300);
    border-radius: var(--radius);
    font-size: 13px;
    font-family: inherit;
    background: #fff;
    color: var(--brand-navy);
}
.form-control:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px var(--primary-light);
}
textarea.form-control { min-height: 80px; resize: vertical; }
.form-row {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    gap: 14px;
}

/* Tables */
.table-wrapper { overflow-x: auto; }
.table {
    width: 100%;
    border-collapse: collapse;
    font-size: 13px;
}
.table th {
    background: var(--grey-50);
    padding: 10px 12px;
    text-align: left;
    border-bottom: 1px solid var(--grey-200);
    font-weight: 600;
    color: var(--grey-700);
    font-size: 12px;
    text-transform: uppercase;
    letter-spacing: 0.3px;
    position: sticky;
    top: 0;
}
.table td {
    padding: 10px 12px;
    border-bottom: 1px solid var(--grey-100);
    vertical-align: middle;
}
.table tr:hover td { background: var(--grey-50); }
.table tr:last-child td { border-bottom: none; }

/* Badges & status pills */
.badge {
    display: inline-flex;
    align-items: center;
    padding: 3px 9px;
    border-radius: 12px;
    font-size: 11px;
    font-weight: 600;
    color: #fff;
    white-space: nowrap;
}
.tag {
    display: inline-block;
    padding: 2px 7px;
    background: var(--grey-100);
    color: var(--grey-700);
    border-radius: 4px;
    font-size: 11px;
    margin-right: 4px;
}

/* RAG indicator */
.rag-dot {
    display: inline-block;
    width: 10px; height: 10px;
    border-radius: 50%;
    margin-right: 6px;
    vertical-align: middle;
}

/* Alerts */
.alert {
    padding: 12px 16px;
    border-radius: var(--radius);
    margin-bottom: 16px;
    font-size: 13px;
    border-left: 4px solid;
}
.alert-success { background: #d1fae5; color: #065f46; border-left-color: var(--success); }
.alert-danger { background: #fee2e2; color: #991b1b; border-left-color: var(--danger); }
.alert-warning { background: #fef3c7; color: #92400e; border-left-color: var(--warning); }
.alert-info { background: var(--primary-light); color: #1e40af; border-left-color: var(--primary); }

/* Modals */
.modal-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(17,24,39,0.5);
    z-index: 1000;
    align-items: flex-start;
    justify-content: center;
    padding-top: 60px;
}
.modal-overlay.active { display: flex; }
.modal {
    background: #fff;
    border-radius: var(--radius-lg);
    width: 92%;
    max-width: 640px;
    max-height: 85vh;
    overflow-y: auto;
    box-shadow: var(--shadow-lg);
}
.modal-header {
    padding: 16px 20px;
    border-bottom: 1px solid var(--grey-200);
    display: flex;
    justify-content: space-between;
    align-items: center;
}
.modal-header h3 { font-size: 16px; }
.modal-close {
    background: none;
    border: none;
    font-size: 24px;
    color: var(--grey-500);
    cursor: pointer;
    line-height: 1;
}
.modal-body { padding: 20px; }
.modal-footer {
    padding: 14px 20px;
    border-top: 1px solid var(--grey-200);
    display: flex;
    justify-content: flex-end;
    gap: 8px;
}

/* Login page */
.login-page {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    background: radial-gradient(circle at 20% 20%, rgba(140,198,63,0.28), transparent 26%),
                linear-gradient(135deg, var(--brand-navy) 0%, var(--brand-blue) 58%, var(--brand-green-dark) 100%);
    padding: 20px;
}
.login-card {
    background: #fff;
    border-radius: var(--radius-lg);
    padding: 36px;
    width: 100%;
    max-width: 400px;
    box-shadow: var(--shadow-lg);
}
.login-card .login-brand {
    text-align: center;
    margin-bottom: 28px;
}
.login-card .login-brand .logo {
    width: 64px; height: 64px;
    background: var(--primary);
    border-radius: var(--radius-lg);
    margin: 0 auto 12px;
    display: flex; align-items: center; justify-content: center;
    font-size: 26px; font-weight: 700;
    color: #fff;
}
.login-logo {
    width: 240px;
    max-width: 100%;
    height: auto;
    display: block;
    margin: 0 auto 14px;
}
.login-card .login-brand h1 {
    font-size: 24px;
    color: var(--brand-navy);
}
.login-card .login-brand h1 span { color: var(--primary); }
.login-card .login-brand p {
    color: var(--grey-500);
    margin-top: 4px;
    font-size: 13px;
}

/* Charts */
.chart-container {
    position: relative;
    height: 280px;
}
.chart-container.tall { height: 360px; }

/* Utility classes */
.text-success { color: var(--success); }
.text-warning { color: var(--warning); }
.text-danger { color: var(--danger); }
.text-muted { color: var(--grey-500); }
.text-bold { font-weight: 600; }
.text-small { font-size: 12px; }
.text-center { text-align: center; }
.text-right { text-align: right; }

.flex { display: flex; }
.flex-between { display: flex; justify-content: space-between; align-items: center; }
.flex-gap-8 { gap: 8px; }
.flex-gap-12 { gap: 12px; }
.flex-wrap { flex-wrap: wrap; }
.flex-1 { flex: 1; }

.mb-0 { margin-bottom: 0; }
.mb-8 { margin-bottom: 8px; }
.mb-16 { margin-bottom: 16px; }
.mb-24 { margin-bottom: 24px; }
.mt-16 { margin-top: 16px; }
.mt-24 { margin-top: 24px; }

.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.grid-3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 16px; }
.grid-2-1 { display: grid; grid-template-columns: 2fr 1fr; gap: 16px; }

@media (max-width: 1024px) {
    .grid-2, .grid-3, .grid-2-1 { grid-template-columns: 1fr; }
}

@media (max-width: 768px) {
    .sidebar { transform: translateX(-100%); transition: transform 0.2s; }
    .sidebar.open { transform: translateX(0); }
    .main-content { margin-left: 0; }
    .topbar { padding: 10px 14px; }
    .page { padding: 14px; }
    .kpi-card .value { font-size: 22px; }
}

/* Item detail drawer */
.drawer-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(17,24,39,0.4);
    z-index: 900;
}
.drawer-overlay.active { display: block; }
.drawer {
    position: fixed;
    top: 0; right: 0; bottom: 0;
    width: 540px;
    max-width: 100%;
    background: #fff;
    box-shadow: var(--shadow-lg);
    z-index: 950;
    transform: translateX(100%);
    transition: transform 0.2s;
    display: flex;
    flex-direction: column;
}
.drawer.active { transform: translateX(0); }
.drawer-header {
    padding: 16px 20px;
    border-bottom: 1px solid var(--grey-200);
    display: flex;
    justify-content: space-between;
    align-items: center;
}
.drawer-body { flex: 1; overflow-y: auto; padding: 20px; }

/* Kanban board */
.kanban-board {
    display: flex;
    gap: 14px;
    overflow-x: auto;
    padding-bottom: 12px;
}
.kanban-column {
    flex: 0 0 280px;
    background: var(--grey-100);
    border-radius: var(--radius);
    padding: 12px;
}
.kanban-column h4 {
    font-size: 13px;
    margin-bottom: 10px;
    color: var(--grey-700);
    display: flex;
    justify-content: space-between;
    align-items: center;
}
.kanban-card {
    background: #fff;
    border-radius: var(--radius-sm);
    padding: 10px 12px;
    margin-bottom: 8px;
    box-shadow: var(--shadow-sm);
    border-left: 3px solid var(--primary);
    cursor: pointer;
    font-size: 13px;
}
.kanban-card:hover { box-shadow: var(--shadow); }
.kanban-card .meta {
    font-size: 11px;
    color: var(--grey-500);
    margin-top: 4px;
}

/* Comment thread */
.comment {
    border-left: 3px solid var(--primary-light);
    padding: 10px 14px;
    margin-bottom: 12px;
    background: var(--grey-50);
    border-radius: 0 var(--radius) var(--radius) 0;
}
.comment .meta {
    font-size: 11px;
    color: var(--grey-500);
    margin-bottom: 4px;
}
.comment .author { font-weight: 600; color: var(--grey-800); }

/* Empty state */
.empty-state {
    text-align: center;
    padding: 40px 20px;
    color: var(--grey-500);
}
.empty-state .icon {
    font-size: 48px;
    margin-bottom: 12px;
}
.empty-state h3 { color: var(--grey-700); margin-bottom: 6px; }

/* Print */
@media print {
    .sidebar, .topbar, .no-print { display: none !important; }
    .main-content { margin-left: 0; }
    .page { padding: 0; }
}
