/* SFV Project Manager v2 - Styles using theme variables */
@import url('https://fonts.googleapis.com/css2?family=DM+Sans:ital,opsz,wght@0,9..40,300;0,9..40,400;0,9..40,500;0,9..40,600;0,9..40,700;1,9..40,400&display=swap');

/* Non-color constants only — colors come from theme-variables.css */
:root {
    --success: #22c55e;
    --warning: #f59e0b;
    --danger: #ef4444;
    --info: #3b82f6;
    --c1: #22c55e;
    --c2: #3b82f6;
    --c3: #f97316;
    --c4: #a855f7;
    --accent: #f59e0b;
}

* { box-sizing: border-box; margin: 0; padding: 0; }
body {
    font-family: 'DM Sans', sans-serif;
    background: var(--bg-main);
    color: var(--text-primary);
    min-height: 100vh;
    transition: background-color 0.3s ease, color 0.3s ease;
}

/* Sidebar */
.sidebar {
    position: fixed; left: 0; top: 0; bottom: 0;
    width: 260px; background: var(--sidebar-bg, var(--bg-card));
    border-right: 1px solid var(--border);
    z-index: 50; display: flex; flex-direction: column;
    transition: transform 0.3s ease;
}
.sidebar.collapsed { transform: translateX(-260px); }
.sidebar-logo {
    padding: 1.5rem; display: flex; align-items: center; gap: 0.75rem;
    border-bottom: 1px solid var(--border);
    color: var(--sidebar-text, var(--text-primary));
}
.sidebar-logo .icon {
    width: 40px; height: 40px; background: var(--primary);
    border-radius: 10px; display: flex; align-items: center;
    justify-content: center; font-size: 1.25rem;
}
.sidebar-nav { flex: 1; padding: 1rem 0; overflow-y: auto; }
.nav-item {
    display: flex; align-items: center; gap: 0.75rem;
    padding: 0.75rem 1.5rem; color: var(--sidebar-text, var(--text-secondary));
    text-decoration: none; transition: all 0.2s; cursor: pointer;
    border-left: 3px solid transparent;
}
.nav-item:hover, .nav-item.active {
    color: #ffffff;
    background: rgba(14, 165, 233, 0.1);
    border-left-color: var(--primary-light);
}
.nav-item.active { background: rgba(14, 165, 233, 0.15); }

.sidebar-footer {
    padding: 1rem 1.5rem;
    border-top: 1px solid var(--border);
    font-size: 0.8rem; color: var(--sidebar-text, var(--text-secondary));
}

/* Main Content */
.main-content {
    margin-left: 260px; min-height: 100vh;
    transition: margin-left 0.3s ease;
    background: var(--bg-main);
}
.main-content.expanded { margin-left: 0; }

/* Top Bar */
.top-bar {
    background: var(--bg-card); border-bottom: 1px solid var(--border);
    padding: 1rem 2rem; display: flex; align-items: center;
    justify-content: space-between; position: sticky; top: 0; z-index: 40;
    transition: background-color 0.3s ease;
}

/* Cards */
.card {
    background: var(--bg-card); border: 1px solid var(--border);
    border-radius: 12px; overflow: hidden;
    transition: background-color 0.3s ease, border-color 0.3s ease;
}
.card-header {
    padding: 1rem 1.5rem; border-bottom: 1px solid var(--border);
    display: flex; align-items: center; justify-content: space-between;
}
.card-body { padding: 1.5rem; }

/* Stat Cards */
.stat-card {
    background: var(--bg-card); border: 1px solid var(--border);
    border-radius: 12px; padding: 1.5rem;
    display: flex; flex-direction: column; gap: 0.5rem;
    transition: background-color 0.3s ease;
}
.stat-card .stat-icon {
    width: 48px; height: 48px; border-radius: 12px;
    display: flex; align-items: center; justify-content: center;
    font-size: 1.5rem;
}
.stat-card .stat-value {
    font-size: 2rem; font-weight: 700; line-height: 1;
    color: var(--text-primary);
}
.stat-card .stat-label {
    font-size: 0.85rem; color: var(--text-secondary);
}

/* Status badges */
.badge {
    display: inline-flex; align-items: center; gap: 0.25rem;
    padding: 0.25rem 0.75rem; border-radius: 20px;
    font-size: 0.75rem; font-weight: 600;
}
.badge-pending { background: rgba(245,158,11,0.15); color: #fbbf24; }
.badge-installing { background: rgba(59,130,246,0.15); color: #60a5fa; }
.badge-installed { background: rgba(34,197,94,0.15); color: #4ade80; }
.badge-energized { background: rgba(168,85,247,0.15); color: #c084fc; }

/* Tables */
.data-table {
    width: 100%; border-collapse: collapse; font-size: 0.85rem;
}
.data-table th {
    padding: 0.75rem 1rem; text-align: left;
    background: var(--bg-surface); color: var(--text-secondary);
    font-weight: 600; font-size: 0.75rem;
    text-transform: uppercase; letter-spacing: 0.05em;
    border-bottom: 1px solid var(--border);
    position: sticky; top: 0; z-index: 10;
}
.data-table td {
    padding: 0.75rem 1rem;
    border-bottom: 1px solid var(--border);
    color: var(--text-primary);
}
.data-table tr:hover td {
    background: rgba(255,255,255,0.02);
}

/* Buttons */
.btn {
    display: inline-flex; align-items: center; gap: 0.5rem;
    padding: 0.5rem 1rem; border-radius: 8px;
    font-size: 0.85rem; font-weight: 500;
    border: none; cursor: pointer; transition: all 0.2s;
    text-decoration: none; font-family: inherit;
}
.btn-primary { background: var(--primary); color: white; }
.btn-primary:hover { background: var(--primary-dark, #0d5d56); }
.btn-accent { background: var(--accent); color: #1a1a1a; }
.btn-accent:hover { opacity: 0.9; }
.btn-danger { background: var(--danger); color: white; }
.btn-warning { background: var(--warning); color: #1a1a1a; }
.btn-outline {
    background: transparent; color: var(--text-primary);
    border: 1px solid var(--border);
}
.btn-outline:hover { border-color: var(--primary-light); }
.btn-sm { padding: 0.35rem 0.75rem; font-size: 0.75rem; }
.btn-lg { padding: 0.75rem 1.5rem; font-size: 1rem; }

/* Forms */
.form-group { margin-bottom: 1rem; }
.form-label {
    display: block; margin-bottom: 0.25rem;
    font-size: 0.85rem; color: var(--text-secondary); font-weight: 500;
}
.form-input, .form-select, .form-textarea {
    width: 100%; padding: 0.625rem 0.875rem;
    background: var(--bg-surface); border: 1px solid var(--border);
    border-radius: 8px; color: var(--text-primary);
    font-family: inherit; font-size: 0.9rem;
    transition: border-color 0.2s;
}
.form-input:focus, .form-select:focus, .form-textarea:focus {
    outline: none; border-color: var(--primary-light);
}

/* Modal */
.modal-overlay {
    position: fixed; inset: 0; background: rgba(0,0,0,0.7);
    display: none; align-items: center; justify-content: center;
    z-index: 100; backdrop-filter: blur(4px);
}
.modal-overlay.active { display: flex; }
.modal {
    background: var(--bg-card); border: 1px solid var(--border);
    border-radius: 16px; max-width: 600px; width: 90%;
    max-height: 85vh; overflow-y: auto;
    transition: background-color 0.3s ease;
}
.modal-lg { max-width: 900px; }
.modal-header {
    padding: 1.25rem 1.5rem; border-bottom: 1px solid var(--border);
    display: flex; align-items: center; justify-content: space-between;
}
.modal-body { padding: 1.5rem; }
.modal-footer {
    padding: 1rem 1.5rem; border-top: 1px solid var(--border);
    display: flex; justify-content: flex-end; gap: 0.5rem;
}

/* Notifications toast */
.toast-container {
    position: fixed; top: 1rem; right: 1rem;
    z-index: 200; display: flex; flex-direction: column; gap: 0.5rem;
}
.toast {
    padding: 1rem 1.25rem; border-radius: 10px;
    background: var(--bg-card); border: 1px solid var(--border);
    box-shadow: 0 10px 40px rgba(0,0,0,0.3);
    animation: slideIn 0.3s ease; min-width: 300px;
    color: var(--text-primary);
}
.toast-info { border-left: 4px solid var(--info); }
.toast-warning { border-left: 4px solid var(--warning); }
.toast-urgent { border-left: 4px solid var(--danger); }
.toast-success { border-left: 4px solid var(--success); }

@keyframes slideIn {
    from { transform: translateX(100%); opacity: 0; }
    to { transform: translateX(0); opacity: 1; }
}

/* Photo grid */
.photo-grid {
    display: grid; grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
    gap: 0.75rem;
}
.photo-slot {
    aspect-ratio: 1; border: 2px dashed var(--border);
    border-radius: 10px; display: flex; flex-direction: column;
    align-items: center; justify-content: center; gap: 0.25rem;
    cursor: pointer; transition: all 0.2s; position: relative;
    overflow: hidden; font-size: 0.7rem; text-align: center;
    padding: 0.5rem; color: var(--text-secondary);
}
.photo-slot:hover { border-color: var(--primary-light); }
.photo-slot.uploaded {
    border-style: solid; border-color: var(--success);
}
.photo-slot img {
    position: absolute; inset: 0; width: 100%; height: 100%;
    object-fit: cover;
}

/* Gantt chart */
.gantt-bar {
    height: 28px; border-radius: 6px;
    display: flex; align-items: center;
    padding: 0 0.5rem; font-size: 0.7rem;
    font-weight: 600; color: white;
    min-width: 20px;
}

/* Progress bar */
.progress-bar {
    height: 8px; background: var(--bg-surface);
    border-radius: 4px; overflow: hidden;
}
.progress-fill {
    height: 100%; border-radius: 4px;
    transition: width 0.5s ease;
}

/* Offline pending badge */
.offline-badge {
    display: inline-flex; align-items: center; justify-content: center;
    min-width: 20px; height: 20px; padding: 0 5px;
    border-radius: 10px; font-size: 0.7rem; font-weight: 700;
    background: var(--danger); color: white;
    position: absolute; top: -4px; right: -4px;
}

/* Responsive */
@media (max-width: 1024px) {
    .sidebar { transform: translateX(-260px); }
    .sidebar.open { transform: translateX(0); }
    .main-content { margin-left: 0; }
}

/* Login page */
.login-page {
    min-height: 100vh;
    display: flex; align-items: center; justify-content: center;
    background: linear-gradient(135deg, #0c1222 0%, #1a2332 50%, #0d3d2e 100%);
}
.login-card {
    background: var(--bg-card); border: 1px solid var(--border);
    border-radius: 20px; padding: 3rem; width: 100%;
    max-width: 420px; box-shadow: 0 20px 60px rgba(0,0,0,0.5);
}

/* Loading spinner */
.spinner {
    width: 40px; height: 40px;
    border: 3px solid var(--border);
    border-top-color: var(--primary-light);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* Scrollbar */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb {
    background: var(--border); border-radius: 3px;
}
::-webkit-scrollbar-thumb:hover { background: #475569; }

/* Leaflet popup customization */
.leaflet-popup-content-wrapper {
    background: var(--bg-card) !important;
    color: var(--text-primary) !important;
    border: 1px solid var(--border) !important;
    border-radius: 10px !important;
}
.leaflet-popup-tip { background: var(--bg-card) !important; }

/* Login background overlay fix */
.login-bg {
    position: absolute !important;
    inset: 0;
    z-index: 0 !important;
}
.login-page { position: relative; z-index: 1; }
.login-card { position: relative; z-index: 2; }

/* Signature canvas */
.signature-canvas-wrapper {
    border: 2px solid var(--border);
    border-radius: 8px;
    overflow: hidden;
    background: #ffffff;
    touch-action: none;
}