/* Base styles and CSS reset */
*, *::before, *::after {
    box-sizing: border-box;
}

html, body {
    margin: 0;
    padding: 0;
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, sans-serif;
    font-size: 16px;
    line-height: 1.5;
}

h1, h2, h3, h4, h5, h6 {
    margin: 0;
}

a {
    color: inherit;
    text-decoration: none;
}

button {
    font-family: inherit;
}

/* Blazor error UI */
#blazor-error-ui {
    background: #cf222e;
    color: white;
    bottom: 0;
    box-shadow: 0 -1px 2px rgba(0, 0, 0, 0.2);
    display: none;
    left: 0;
    padding: 0.6rem 1.25rem 0.7rem 1.25rem;
    position: fixed;
    width: 100%;
    z-index: 1000;
}

#blazor-error-ui .dismiss {
    cursor: pointer;
    position: absolute;
    right: 0.75rem;
    top: 0.5rem;
}

.blazor-error-boundary {
    background: url(data:image/svg+xml;base64,PHN2ZyB3aWR0aD0iNTYiIGhlaWdodD0iNDkiIHhtbG5zPSJodHRwOi8vd3d3LnczLm9yZy8yMDAwL3N2ZyIgeG1sbnM6eGxpbms9Imh0dHA6Ly93d3cudzMub3JnLzE5OTkveGxpbmsiIG92ZXJmbG93PSJoaWRkZW4iPjxkZWZzPjxjbGlwUGF0aCBpZD0iY2xpcDAiPjxyZWN0IHg9IjIzNSIgeT0iNTEiIHdpZHRoPSI1NiIgaGVpZ2h0PSI0OSIvPjwvY2xpcFBhdGg+PC9kZWZzPjxnIGNsaXAtcGF0aD0idXJsKCNjbGlwMCkiIHRyYW5zZm9ybT0idHJhbnNsYXRlKC0yMzUgLTUxKSI+PHBhdGggZD0iTTI2My41MDYgNTFDMjY0LjcxNyA1MSAyNjUuODEzIDUxLjQ4MzcgMjY2LjYwNiA1Mi4yNjU4TDI2Ni42MDYgNTIuMjY1OEwyODkuOTQzIDc0LjU4MzlDMjkwLjc5NiA3NS40MTI4IDI5MS4yODkgNzYuNTQ3NyAyOTEuMjg5IDc3LjcyMzlDMjkxLjI4OSA3OC45MDAyIDI5MC43OTYgOD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4zNTUgODQuODcyMSAyNjMuNTc2IDg0Ljg3MjFaIiBmaWxsPSJ3aGl0ZSIgZmlsbC1ydWxlPSJldmVub2RkIi8+PC9nPjwvc3ZnPg==) no-repeat 1rem 1rem;
    padding: 1rem 1rem 1rem 3.7rem;
    border: 1px solid #cf222e;
    border-radius: 0.5rem;
}

.blazor-error-boundary::after {
    content: "An error has occurred.";
}

/* Custom reconnect modal */
#components-reconnect-modal {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 10000;
    background: rgba(0,0,0,0.5);
    align-items: center;
    justify-content: center;
}
#components-reconnect-modal.components-reconnect-show,
#components-reconnect-modal.components-reconnect-retrying,
#components-reconnect-modal.components-reconnect-failed,
#components-reconnect-modal.components-reconnect-rejected {
    display: flex;
}

#components-reconnect-modal .components-reconnect-dialog {
    background-color: #21262d;
    color: #f0f6fc;
    border: 1px solid #30363d;
    border-radius: 8px;
    padding: 1.5rem 2rem;
    text-align: center;
    box-shadow: 0 4px 12px rgba(0,0,0,0.3);
}
#components-reconnect-modal .components-reconnect-dialog p {
    margin: 1rem 0;
    color: #f0f6fc;
}
#components-reconnect-modal .components-reconnect-dialog button {
    background: #30363d;
    color: #f0f6fc;
    border: 1px solid #484f58;
    padding: 0.5rem 1.25rem;
    border-radius: 6px;
    cursor: pointer;
    font-size: 0.9rem;
    font-weight: 500;
    margin-top: 0.5rem;
}
#components-reconnect-modal .components-reconnect-dialog button:hover {
    background: #484f58;
}

/* Rejoining animation - ripple effect (matches original Blazor) */
.components-rejoining-animation {
    position: relative;
    width: 60px;
    height: 60px;
    margin: 0 auto 1rem;
}
.components-rejoining-animation > div {
    position: absolute;
    width: 100%;
    height: 100%;
    border: 4px solid #58a6ff;
    border-radius: 50%;
    animation: reconnect-ripple 1.5s cubic-bezier(0, 0.2, 0.8, 1) infinite;
    opacity: 0;
}
.components-rejoining-animation > div:nth-child(2) {
    animation-delay: -0.5s;
}
@keyframes reconnect-ripple {
    0% { transform: scale(0.1); opacity: 1; }
    100% { transform: scale(1); opacity: 0; }
}

/* Light theme */
html[data-theme^="light"] #components-reconnect-modal .components-reconnect-dialog {
    background-color: #f6f8fa;
    color: #1f2328;
    border-color: #d0d7de;
}
html[data-theme^="light"] #components-reconnect-modal .components-reconnect-dialog p {
    color: #1f2328;
}
html[data-theme^="light"] #components-reconnect-modal .components-reconnect-dialog button {
    background: #eaeef2;
    color: #1f2328;
    border-color: #d0d7de;
}
html[data-theme^="light"] #components-reconnect-modal .components-reconnect-dialog button:hover {
    background: #d0d7de;
}
html[data-theme^="light"] .components-rejoining-animation > div {
    border-color: #0969da;
}

/* Loading indicator */
.loading-spinner {
    display: inline-block;
    animation: spin 1s linear infinite;
}

@keyframes spin {
    from { transform: rotate(0deg); }
    to { transform: rotate(360deg); }
}

/* Default theme variables (fallback - actual themes in MainLayout.razor.css) */
.app-container {
    /* Fallback variables */
    --bg-primary: #0d1117;
    --bg-secondary: #161b22;
    --bg-card: #21262d;
    --text-primary: #f0f6fc;
    --text-secondary: #8b949e;
    --border-color: #30363d;
    --accent-color: #58a6ff;
    --success-color: #3fb950;
    --warning-color: #d29922;
    --danger-color: #f85149;
    --nav-bg: #161b22;

    /* Layout */
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    background-color: var(--bg-primary);
    color: var(--text-primary);
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, sans-serif;
}

/* Navbar - Horizontal Layout */
.app-navbar {
    display: flex;
    flex-direction: row;
    align-items: center;
    padding: 0.75rem 1.5rem;
    background-color: var(--nav-bg);
    border-bottom: 1px solid var(--border-color);
    gap: 2rem;
}

.navbar-brand {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-weight: 600;
    font-size: 1.25rem;
}

.navbar-icon {
    font-size: 1.5rem;
}

.navbar-nav {
    display: flex;
    flex-direction: row;
    gap: 2.5rem;
    flex: 1;
    margin-left: 2rem;
}

.nav-link {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.75rem 1rem;
    color: var(--text-secondary);
    text-decoration: none;
    transition: all 0.2s;
    border-bottom: 2px solid transparent;
    margin-bottom: -1px;
}

.nav-link:hover {
    color: var(--text-primary);
}

.nav-link.active {
    color: var(--accent-color);
    border-bottom-color: var(--accent-color);
    font-weight: 500;
}

.nav-icon {
    font-size: 1.1rem;
}

.theme-toggle {
    background: none;
    border: 1px solid var(--border-color);
    border-radius: 6px;
    padding: 0.5rem;
    font-size: 1.25rem;
    cursor: pointer;
    transition: all 0.2s;
}

.theme-toggle:hover {
    background-color: var(--bg-card);
}

/* Main content */
.main-content {
    flex: 1;
    padding: 1.5rem;
    max-width: 1400px;
    margin: 0 auto;
    width: 100%;
}

/* Footer */
.footer {
    display: flex;
    justify-content: space-between;
    padding: 1rem 1.5rem;
    background-color: var(--nav-bg);
    border-top: 1px solid var(--border-color);
    color: var(--text-secondary);
    font-size: 0.875rem;
}

/* Form Controls */
.sort-label {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-size: 0.875rem;
    color: var(--text-secondary);
}

.sort-select,
select {
    background-color: var(--bg-card);
    color: var(--text-primary);
    border: 1px solid var(--border-color);
    border-radius: 6px;
    padding: 0.5rem 0.75rem;
    font-size: 0.875rem;
    cursor: pointer;
    transition: border-color 0.2s, box-shadow 0.2s;
}

.sort-select:hover,
select:hover {
    border-color: var(--accent-color);
}

.sort-select:focus,
select:focus {
    outline: none;
    border-color: var(--accent-color);
    box-shadow: 0 0 0 2px rgba(88, 166, 255, 0.2);
}

/* Buttons */
.btn {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.5rem 1rem;
    border-radius: 6px;
    font-size: 0.875rem;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s;
    border: 1px solid transparent;
}

.btn-secondary {
    background-color: var(--bg-card);
    color: var(--text-primary);
    border-color: var(--border-color);
}

.btn-secondary:hover {
    background-color: var(--bg-secondary);
    border-color: var(--accent-color);
}

.btn-secondary:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

/* Page Headers */
.page-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    margin-bottom: 1.5rem;
    flex-wrap: wrap;
    gap: 1rem;
}

.header-content {
    flex: 1;
}

.header-actions {
    display: flex;
    gap: 0.75rem;
    align-items: center;
    flex-wrap: wrap;
}

.page-title {
    font-size: 1.5rem;
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: 0.25rem;
}

.page-subtitle {
    font-size: 0.875rem;
    color: var(--text-secondary);
}

/* Responsive */
@media (max-width: 768px) {
    .app-navbar {
        flex-wrap: wrap;
        padding: 0.5rem 1rem;
    }

    .navbar-nav {
        order: 3;
        width: 100%;
        overflow-x: auto;
        padding-top: 0.5rem;
    }

    .nav-link {
        padding: 0.5rem 0.75rem;
        white-space: nowrap;
    }

    .main-content {
        padding: 1rem;
    }
}
