/* ==========================================================================
   ZeroGravity Shared Styles
   Base reset, accessibility, sidebar navigation, and common components
   ========================================================================== */

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

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
    background: #f5f6fa;
    min-height: 100vh;
}

/* --- Accessibility: Reduced Motion --- */
@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
        scroll-behavior: auto !important;
    }
}

/* --- Accessibility: Focus States --- */
a:focus-visible,
button:focus-visible,
input:focus-visible,
select:focus-visible,
textarea:focus-visible,
[tabindex]:focus-visible {
    outline: 2px solid #7c3aed;
    outline-offset: 2px;
}

/* --- App Layout --- */
.container {
    display: flex;
    min-height: 100vh;
}

.main-content {
    flex: 1;
    min-width: 0;
    padding: 24px;
    margin-left: 240px;
}

/* --- Sidebar --- */
.sidebar {
    width: 240px;
    background: white;
    border-right: 1px solid #e5e7eb;
    display: flex;
    flex-direction: column;
    position: fixed;
    top: 0;
    left: 0;
    bottom: 0;
    z-index: 40;
    overflow-y: auto;
    overflow-x: hidden;
}

.sidebar-header {
    padding: 20px 16px 12px;
    border-bottom: 1px solid #f3f4f6;
}

.sidebar-logo {
    display: flex;
    align-items: center;
    text-decoration: none;
}

.sidebar-nav {
    flex: 1;
    padding: 8px 0;
    overflow-y: auto;
}

.sidebar-section-label {
    font-size: 0.68rem;
    font-weight: 700;
    color: #9ca3af;
    text-transform: uppercase;
    letter-spacing: 0.8px;
    padding: 16px 16px 6px;
}

.sidebar-link {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 8px 16px;
    color: #4b5563;
    text-decoration: none;
    font-size: 0.85rem;
    transition: background 0.15s, color 0.15s;
    border-radius: 0;
    margin: 1px 0;
}

.sidebar-link:hover {
    background: #f3f4f6;
    color: #1f2937;
}

.sidebar-link.active {
    background: #f5f3ff;
    color: #7c3aed;
    font-weight: 600;
    border-right: 3px solid #7c3aed;
}

.sidebar-link.lily {
    color: #7c3aed;
}

.sidebar-link.lily:hover {
    background: #f3e8ff;
}

.sidebar-link.lily.active {
    background: #f3e8ff;
    color: #7c3aed;
    border-right-color: #7c3aed;
}

.sidebar-link.logout {
    color: #ef4444;
}

.sidebar-link.logout:hover {
    background: #fef2f2;
    color: #dc2626;
}

.sidebar-icon {
    width: 18px;
    height: 18px;
    flex-shrink: 0;
    stroke: currentColor;
    fill: none;
    stroke-width: 1.5;
    stroke-linecap: round;
    stroke-linejoin: round;
}

.sidebar-footer {
    border-top: 1px solid #f3f4f6;
    padding: 8px 0;
    margin-top: auto;
}

.sidebar-user {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 8px 16px;
    color: #6b7280;
    font-size: 0.8rem;
    font-weight: 500;
}

/* --- Mobile Sidebar Toggle --- */
.sidebar-toggle {
    display: none;
    position: fixed;
    top: 12px;
    left: 12px;
    z-index: 50;
    background: white;
    border: 1px solid #e5e7eb;
    border-radius: 8px;
    padding: 8px;
    cursor: pointer;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.08);
    transition: background 0.2s;
}

.sidebar-toggle:hover { background: #f3f4f6; }

/* --- Legacy nav-link (kept for any remaining inline uses) --- */
.nav-link {
    color: #555;
    text-decoration: none;
    font-size: 0.85rem;
    padding: 6px 12px;
    background: #f3f4f6;
    border-radius: 6px;
    white-space: nowrap;
    transition: background 0.2s, color 0.2s;
    display: inline-flex;
    align-items: center;
    gap: 5px;
}

.nav-link:hover { background: #e5e7eb; }

.nav-link.active {
    color: white;
    background: #7c3aed;
    font-weight: 600;
}

.nav-link.active:hover { background: #6d28d9; }

/* --- Page Header --- */
.page-header { margin-bottom: 20px; }

.page-header h1 {
    font-size: 1.5rem;
    color: #1f2937;
    font-weight: 700;
}

/* --- Cards --- */
.card {
    background: white;
    border-radius: 12px;
    padding: 28px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.06);
    margin-bottom: 20px;
}

.card h2 {
    color: #1f2937;
    font-size: 1.5rem;
    margin-bottom: 20px;
}

/* --- Buttons --- */
.btn {
    padding: 7px 18px;
    border-radius: 6px;
    border: none;
    font-size: 0.85rem;
    font-weight: 600;
    cursor: pointer;
    transition: background 0.2s, box-shadow 0.2s;
    text-decoration: none;
    display: inline-block;
}

.btn-primary { background: #7c3aed; color: white; }
.btn-primary:hover { background: #6d28d9; }

.btn-secondary {
    background: white;
    color: #7c3aed;
    border: 2px solid #7c3aed;
}

.btn-secondary:hover { background: #f5f3ff; }

.btn-success { background: #10b981; color: white; }
.btn-success:hover { background: #059669; }

.btn-muted { background: #e5e7eb; color: #374151; }
.btn-muted:hover { background: #d1d5db; }

/* --- Status Indicators --- */
.status-dot {
    width: 10px;
    height: 10px;
    border-radius: 50%;
    display: inline-block;
    flex-shrink: 0;
}

.status-dot.online { background: #10b981; }
.status-dot.offline { background: #ef4444; }
.status-dot.warning { background: #f59e0b; }

.status-dot.pulse { animation: statusPulse 2s infinite; }

@keyframes statusPulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.4; }
}

/* --- Tables --- */
.data-table { width: 100%; border-collapse: collapse; }

.data-table th {
    background: #f9fafb;
    padding: 10px 12px;
    text-align: left;
    font-size: 0.78rem;
    color: #6b7280;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    border-bottom: 2px solid #e5e7eb;
}

.data-table td {
    padding: 10px 12px;
    font-size: 0.85rem;
    color: #374151;
    border-bottom: 1px solid #f3f4f6;
}

.data-table tr:hover { background: #f9fafb; }

/* --- Badges --- */
.badge {
    display: inline-block;
    padding: 3px 10px;
    border-radius: 12px;
    font-size: 0.72rem;
    font-weight: 700;
    letter-spacing: 0.3px;
}

/* --- Modal --- */
.modal-overlay {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.6);
    z-index: 50;
    justify-content: center;
    align-items: center;
}

.modal-overlay.active { display: flex; }

.modal-content {
    background: white;
    border-radius: 16px;
    max-width: 800px;
    width: 90%;
    max-height: 80vh;
    overflow: hidden;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
    animation: modalIn 0.25s ease;
}

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

.modal-header {
    background: #7c3aed;
    color: white;
    padding: 20px 24px;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.modal-header h3 { margin: 0; font-size: 1.3rem; }

.modal-close {
    background: rgba(255, 255, 255, 0.2);
    border: none;
    color: white;
    font-size: 1.5rem;
    cursor: pointer;
    padding: 4px 12px;
    border-radius: 8px;
    transition: background 0.2s;
    line-height: 1;
}

.modal-close:hover { background: rgba(255, 255, 255, 0.3); }

.modal-body {
    padding: 20px 24px;
    overflow-y: auto;
    max-height: calc(80vh - 80px);
}

/* --- User Info (legacy) --- */
.user-info { color: #333; font-size: 0.9rem; white-space: nowrap; }

.logout-btn {
    background: #7c3aed;
    color: white;
    text-decoration: none;
    padding: 8px 16px;
    border-radius: 6px;
    font-size: 0.9rem;
    transition: background 0.2s;
    white-space: nowrap;
}

.logout-btn:hover { background: #6d28d9; }

/* --- Responsive --- */
@media (max-width: 768px) {
    .sidebar {
        transform: translateX(-100%);
        transition: transform 0.25s ease;
        box-shadow: none;
    }

    .sidebar.open {
        transform: translateX(0);
        box-shadow: 4px 0 20px rgba(0, 0, 0, 0.1);
    }

    .sidebar-toggle { display: flex; }

    .main-content {
        margin-left: 0;
        padding: 16px;
        padding-top: 56px;
    }
}
