/* Dashboard Styles */

:root {
    --primary: #1B3A5C;
    --primary-light: #2563EB;
    --primary-bg: #E8EEF4;
    --success: #38A169;
    --warning: #D69E2E;
    --danger: #E53E3E;
    --bg: #f0f4f8;
    --text: #1A202C;
    --text-secondary: #718096;
    --text-muted: #A0AEC0;
    --border: #CBD5E0;
    --shadow: 0 1px 3px rgba(0,0,0,0.1);
    --shadow-lg: 0 4px 12px rgba(0,0,0,0.12);
}

* { box-sizing: border-box; margin: 0; padding: 0; }

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    background: var(--bg);
    color: var(--text);
    line-height: 1.5;
    font-size: 14px;
}

/* Top Navigation */
.top-nav {
    background: linear-gradient(135deg, #1B3A5C 0%, #0F2440 100%);
    color: white;
    padding: 0.75rem 2rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
    box-shadow: 0 2px 8px rgba(0,0,0,0.2);
}

.top-nav h1 {
    font-size: 1.2rem;
    font-weight: 700;
}

.nav-actions {
    display: flex;
    align-items: center;
    gap: 1rem;
}

.user-info {
    font-size: 0.85rem;
    opacity: 0.9;
}

.btn-nav {
    background: rgba(255,255,255,0.15);
    color: white;
    border: 1px solid rgba(255,255,255,0.3);
    padding: 0.4rem 1rem;
    border-radius: 6px;
    cursor: pointer;
    font-size: 0.8rem;
    transition: background 0.2s;
}

.btn-nav:hover {
    background: rgba(255,255,255,0.25);
}

/* Dashboard Main */
.dashboard-main {
    max-width: 1200px;
    margin: 0 auto;
    padding: 2rem;
}

.dashboard-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 2rem;
}

.dashboard-header h2 {
    font-size: 1.5rem;
    color: var(--primary);
}

.dashboard-header .subtitle {
    color: var(--text-secondary);
    font-size: 0.9rem;
    margin-top: 0.25rem;
}

/* Buttons */
.btn-primary {
    background: var(--primary-light);
    color: white;
    border: none;
    padding: 0.65rem 1.5rem;
    border-radius: 8px;
    font-weight: 600;
    font-size: 0.9rem;
    cursor: pointer;
    transition: all 0.2s;
}

.btn-primary:hover { background: #1d4ed8; }

.btn-secondary {
    background: #f1f5f9;
    color: var(--text);
    border: 1px solid var(--border);
    padding: 0.65rem 1.5rem;
    border-radius: 8px;
    font-weight: 500;
    font-size: 0.9rem;
    cursor: pointer;
    transition: all 0.2s;
}

.btn-secondary:hover { background: #e2e8f0; }

.btn-danger {
    background: none;
    color: var(--danger);
    border: none;
    padding: 0.4rem 0.6rem;
    border-radius: 4px;
    cursor: pointer;
    font-size: 0.8rem;
    transition: background 0.2s;
}

.btn-danger:hover { background: #FED7D7; }

/* Project Table */
.project-table-wrapper {
    background: white;
    border-radius: 12px;
    box-shadow: var(--shadow);
}

.project-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.85rem;
    overflow: visible;
}

.project-table thead th {
    background: #f8fafc;
    color: var(--text-secondary);
    font-weight: 600;
    font-size: 0.75rem;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    padding: 0.75rem 1rem;
    text-align: left;
    border-bottom: 2px solid var(--border);
    white-space: nowrap;
    user-select: none;
}

.project-table th.sortable {
    cursor: pointer;
    transition: color 0.2s;
}

.project-table th.sortable:hover { color: var(--primary-light); }

.project-table th.sortable .sort-icon::after { content: ' \2195'; opacity: 0.3; }
.project-table th.sort-asc .sort-icon::after { content: ' \2191'; opacity: 1; }
.project-table th.sort-desc .sort-icon::after { content: ' \2193'; opacity: 1; }

.project-table tbody tr {
    border-bottom: 1px solid #f0f4f8;
    cursor: pointer;
    transition: background 0.15s;
}

.project-table tbody tr:hover { background: #f0f7ff; }
.project-table tbody tr:last-child { border-bottom: none; }

.project-table td {
    padding: 0.75rem 1rem;
    vertical-align: middle;
}

.col-number {
    font-family: monospace;
    font-size: 0.8rem;
    color: var(--primary-light);
    font-weight: 600;
    letter-spacing: 0.5px;
}

.col-name strong {
    color: var(--primary);
    font-weight: 600;
}

.col-ref { color: var(--text-secondary); }
.col-devices { text-align: center; }

.status-badge {
    padding: 0.2rem 0.6rem;
    border-radius: 12px;
    font-size: 0.7rem;
    font-weight: 600;
    text-transform: uppercase;
    white-space: nowrap;
}

.status-badge.draft { background: #FEF3C7; color: #92400E; }
.status-badge.complete { background: #C6F6D5; color: #22543D; }
.status-badge.archived { background: #E2E8F0; color: #4A5568; }

.col-updated { color: var(--text-secondary); font-size: 0.8rem; white-space: nowrap; }

.col-actions { position: relative; overflow: visible !important; }

/* 3-dot menu */
.row-menu-wrapper { position: relative; display: inline-block; }

.btn-dots {
    background: none;
    border: none;
    font-size: 1.2rem;
    cursor: pointer;
    padding: 0.25rem 0.5rem;
    border-radius: 6px;
    color: var(--text-secondary);
    line-height: 1;
    transition: background 0.15s;
}
.btn-dots:hover { background: #e2e8f0; color: var(--text); }

.row-dropdown-menu {
    display: none;
    position: absolute;
    right: 0;
    top: 100%;
    background: white;
    border: 1px solid var(--border);
    border-radius: 8px;
    box-shadow: var(--shadow-lg);
    min-width: 140px;
    z-index: 1000;
}
.row-dropdown-menu.show { display: block; }

.dropdown-item {
    padding: 0.5rem 1rem;
    cursor: pointer;
    font-size: 0.85rem;
    transition: background 0.15s;
}
.dropdown-item:hover { background: #f0f4f8; }
.dropdown-item.danger { color: var(--danger); }
.dropdown-item.danger:hover { background: #FED7D7; }

/* Empty State */
.empty-state {
    text-align: center;
    padding: 4rem 2rem;
}

.empty-icon {
    font-size: 3rem;
    margin-bottom: 1rem;
}

.empty-state h3 {
    font-size: 1.25rem;
    margin-bottom: 0.5rem;
    color: var(--text);
}

.empty-state p {
    color: var(--text-secondary);
    margin-bottom: 1.5rem;
}

/* Loading State */
.loading-state {
    text-align: center;
    padding: 3rem;
    color: var(--text-muted);
    font-size: 0.9rem;
}

/* Modal */
.modal-overlay {
    position: fixed;
    top: 0; left: 0; right: 0; bottom: 0;
    background: rgba(0,0,0,0.5);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
}

.modal-content {
    background: white;
    border-radius: 12px;
    box-shadow: 0 20px 60px rgba(0,0,0,0.3);
    width: 90%;
    max-width: 450px;
    animation: modalSlide 0.2s ease-out;
}

@keyframes modalSlide {
    from { transform: translateY(-20px); opacity: 0; }
    to { transform: translateY(0); opacity: 1; }
}

.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 1.25rem 1.5rem;
    border-bottom: 1px solid #e2e8f0;
}

.modal-header h3 { margin: 0; font-size: 1.1rem; }

.modal-close {
    background: none;
    border: none;
    font-size: 1.5rem;
    cursor: pointer;
    color: #64748b;
}

.modal-close:hover { color: #1e293b; }

.modal-body { padding: 1.5rem; }

.modal-body .form-group { margin-bottom: 1rem; }

.modal-body .form-group label {
    display: block;
    margin-bottom: 0.4rem;
    font-weight: 500;
    color: #475569;
    font-size: 0.85rem;
}

.modal-body .form-group input {
    width: 100%;
    padding: 0.6rem 0.8rem;
    border: 1px solid #e2e8f0;
    border-radius: 6px;
    font-size: 0.9rem;
}

.modal-body .form-group input:focus {
    outline: none;
    border-color: var(--primary-light);
    box-shadow: 0 0 0 3px rgba(37,99,235,0.1);
}

.modal-footer {
    display: flex;
    justify-content: flex-end;
    gap: 0.75rem;
    padding: 1rem 1.5rem;
    border-top: 1px solid #e2e8f0;
}

/* Toast */
.toast {
    position: fixed;
    bottom: 2rem;
    right: 2rem;
    padding: 0.75rem 1.25rem;
    color: white;
    border-radius: 8px;
    box-shadow: var(--shadow-lg);
    font-size: 0.85rem;
    z-index: 1000;
    animation: slideIn 0.3s ease;
}

@keyframes slideIn {
    from { transform: translateY(1rem); opacity: 0; }
    to { transform: translateY(0); opacity: 1; }
}

/* Project number badge */
.project-number {
    font-size: 0.7rem;
    font-weight: 600;
    color: var(--primary-light);
    letter-spacing: 1px;
    margin-bottom: 0.15rem;
    font-family: monospace;
}

/* Header actions */
.header-actions {
    display: flex;
    gap: 0.75rem;
    align-items: center;
}

/* Share button in card */
.btn-share {
    background: none;
    color: var(--primary-light);
    border: none;
    padding: 0.4rem 0.6rem;
    border-radius: 4px;
    cursor: pointer;
    font-size: 0.8rem;
    transition: background 0.2s;
}

.btn-share:hover {
    background: var(--primary-bg);
}

/* Share code display */
.share-code-display {
    font-size: 2rem;
    font-weight: 700;
    letter-spacing: 4px;
    padding: 1rem;
    background: #f0f4f8;
    border-radius: 8px;
    font-family: monospace;
    user-select: all;
}

/* Theme Toggle Button */
.btn-theme-toggle {
    background: rgba(255,255,255,0.15);
    border: 1px solid rgba(255,255,255,0.25);
    color: white;
    width: 32px;
    height: 32px;
    border-radius: 6px;
    cursor: pointer;
    font-size: 1rem;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    transition: background 0.2s;
    padding: 0;
    line-height: 1;
}
.btn-theme-toggle:hover { background: rgba(255,255,255,0.25); }

/* ============================================================================
   DARK MODE
   ============================================================================ */

[data-theme="dark"] {
    --bg: #0f172a;
    --text: #e2e8f0;
    --text-secondary: #94a3b8;
    --text-muted: #64748b;
    --border: #334155;
    --shadow: 0 1px 3px rgba(0,0,0,0.3);
    --shadow-lg: 0 4px 12px rgba(0,0,0,0.4);
}

[data-theme="dark"] body { background: var(--bg); color: var(--text); }

[data-theme="dark"] .dashboard-header h2 { color: var(--text); }
[data-theme="dark"] .dashboard-header .subtitle { color: var(--text-secondary); }

/* Table */
[data-theme="dark"] .project-table-wrapper { background: #1e293b; }

[data-theme="dark"] .project-table thead th {
    background: #253349;
    color: #94a3b8;
    border-bottom-color: var(--border);
}

[data-theme="dark"] .project-table th.sortable:hover { color: #60a5fa; }

[data-theme="dark"] .project-table tbody tr {
    border-bottom-color: #1e293b;
}
[data-theme="dark"] .project-table tbody tr:hover { background: #253349; }

[data-theme="dark"] .project-table td { color: var(--text); }

[data-theme="dark"] .col-number { color: #60a5fa; }
[data-theme="dark"] .col-name strong { color: #93c5fd; }
[data-theme="dark"] .col-ref { color: var(--text-secondary); }
[data-theme="dark"] .col-updated { color: var(--text-secondary); }

/* Status badges */
[data-theme="dark"] .status-badge.draft { background: #78350f; color: #fbbf24; }
[data-theme="dark"] .status-badge.complete { background: #14532d; color: #4ade80; }
[data-theme="dark"] .status-badge.archived { background: #334155; color: #94a3b8; }

/* Buttons */
[data-theme="dark"] .btn-secondary { background: #334155; color: #cbd5e1; border-color: #475569; }
[data-theme="dark"] .btn-secondary:hover { background: #475569; }
[data-theme="dark"] .btn-danger:hover { background: #450a0a; }

[data-theme="dark"] .btn-dots { color: #94a3b8; }
[data-theme="dark"] .btn-dots:hover { background: #334155; color: var(--text); }

/* Dropdown */
[data-theme="dark"] .row-dropdown-menu {
    background: #1e293b;
    border-color: var(--border);
    box-shadow: 0 4px 12px rgba(0,0,0,0.4);
}
[data-theme="dark"] .dropdown-item { color: var(--text); }
[data-theme="dark"] .dropdown-item:hover { background: #334155; }
[data-theme="dark"] .dropdown-item.danger { color: #f87171; }
[data-theme="dark"] .dropdown-item.danger:hover { background: #450a0a; }

/* Modals */
[data-theme="dark"] .modal-content { background: #1e293b; box-shadow: 0 20px 60px rgba(0,0,0,0.6); }
[data-theme="dark"] .modal-header { border-bottom-color: var(--border); }
[data-theme="dark"] .modal-header h3 { color: var(--text); }
[data-theme="dark"] .modal-close { color: #94a3b8; }
[data-theme="dark"] .modal-close:hover { color: var(--text); }
[data-theme="dark"] .modal-body .form-group label { color: #cbd5e1; }
[data-theme="dark"] .modal-body .form-group input {
    background: #0f172a;
    color: var(--text);
    border-color: var(--border);
}
[data-theme="dark"] .modal-body .form-group input:focus {
    border-color: #3b82f6;
    box-shadow: 0 0 0 3px rgba(59,130,246,0.15);
}
[data-theme="dark"] .modal-footer { border-top-color: var(--border); }

/* Empty/Loading states */
[data-theme="dark"] .empty-state h3 { color: var(--text); }
[data-theme="dark"] .empty-state p { color: var(--text-secondary); }
[data-theme="dark"] .loading-state { color: var(--text-muted); }

/* Share code */
[data-theme="dark"] .share-code-display { background: #0f172a; color: #a5b4fc; }

/* Project number */
[data-theme="dark"] .project-number { color: #60a5fa; }

/* Toast */
[data-theme="dark"] .toast { box-shadow: 0 4px 12px rgba(0,0,0,0.5); }

/* Scrollbar */
[data-theme="dark"] ::-webkit-scrollbar { width: 8px; height: 8px; }
[data-theme="dark"] ::-webkit-scrollbar-track { background: #0f172a; }
[data-theme="dark"] ::-webkit-scrollbar-thumb { background: #475569; border-radius: 4px; }
[data-theme="dark"] ::-webkit-scrollbar-thumb:hover { background: #64748b; }

/* Responsive */
@media (max-width: 768px) {
    .dashboard-main { padding: 1rem; }
    .dashboard-header { flex-direction: column; gap: 1rem; align-items: flex-start; }
    .project-table-wrapper { overflow-x: auto; }
    .col-ref, .col-updated { display: none; }
}
