/* Base styles — reset, custom properties, typography, buttons, forms, cards, utilities */

:root {
    --color-primary: #2563eb;
    --color-primary-hover: #1d4ed8;
    --color-primary-light: #dbeafe;
    --color-primary-dark: #1e40af;
    --color-danger: #dc2626;
    --color-danger-hover: #b91c1c;
    --color-danger-bg: #fee2e2;
    --color-danger-text: #991b1b;
    --color-success: #22c55e;
    --color-success-bg: #d1fae5;
    --color-success-text: #065f46;
    --color-warning-bg: #fef3c7;
    --color-warning-text: #92400e;
    --color-warning-border: #f59e0b;
    --color-info-bg: #dbeafe;
    --color-info-text: #1e40af;
    --color-text: #1f2937;
    --color-text-secondary: #374151;
    --color-text-tertiary: #4b5563;
    --color-muted: #6b7280;
    --color-muted-light: #9ca3af;
    --color-bg: #f3f4f6;
    --color-bg-white: white;
    --color-border: #d1d5db;
    --color-border-light: #e5e7eb;
    --radius: 0.5rem;
    --shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
    --shadow-lg: 0 25px 50px rgba(0, 0, 0, 0.25);
}

@media (prefers-color-scheme: dark) {
    :root {
        --color-primary: #3b82f6;
        --color-primary-hover: #60a5fa;
        --color-primary-light: #1e3a8a;
        --color-primary-dark: #93c5fd;
        --color-danger: #ef4444;
        --color-danger-hover: #f87171;
        --color-danger-bg: #7f1d1d;
        --color-danger-text: #fca5a5;
        --color-success: #22c55e;
        --color-success-bg: #14532d;
        --color-success-text: #86efac;
        --color-warning-bg: #78350f;
        --color-warning-text: #fcd34d;
        --color-warning-border: #f59e0b;
        --color-info-bg: #1e3a8a;
        --color-info-text: #93c5fd;
        --color-text: #f9fafb;
        --color-text-secondary: #e5e7eb;
        --color-text-tertiary: #d1d5db;
        --color-muted: #9ca3af;
        --color-muted-light: #6b7280;
        --color-bg: #111827;
        --color-bg-white: #1f2937;
        --color-border: #374151;
        --color-border-light: #4b5563;
        --shadow: 0 1px 3px rgba(0, 0, 0, 0.3);
        --shadow-lg: 0 25px 50px rgba(0, 0, 0, 0.5);
    }
}

*:not(dialog) {
    margin: 0;
    padding: 0;
}

* {
    box-sizing: border-box;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, sans-serif;
    background-color: var(--color-bg);
    min-height: 100vh;
    line-height: 1.5;
    color: var(--color-text);
}

.container {
    max-width: 56rem;
    margin: 0 auto;
    padding: 2rem 1rem;
}

/* Header */
header {
    margin-bottom: 1.5rem;
}

.header-content {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 1rem;
}

header h1 {
    font-size: 1.875rem;
    font-weight: 700;
    color: var(--color-text);
    margin-bottom: 0.5rem;
}

header p {
    color: var(--color-muted);
}

/* Cards */
.card {
    background: var(--color-bg-white);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    padding: 1.5rem;
    margin-bottom: 1.5rem;
}

.card h2 {
    font-size: 1.25rem;
    font-weight: 600;
    color: var(--color-text-secondary);
    margin-bottom: 1rem;
}

/* Form Elements */
.form-group {
    margin-bottom: 1rem;
}

.form-group label {
    display: block;
    font-size: 0.875rem;
    font-weight: 500;
    color: var(--color-text-secondary);
    margin-bottom: 0.25rem;
}

.form-row {
    display: flex;
    gap: 0.5rem;
}

input[type="text"],
input[type="url"],
textarea,
select {
    width: 100%;
    padding: 0.5rem 1rem;
    border: 1px solid var(--color-border);
    border-radius: var(--radius);
    font-size: 1rem;
    font-family: inherit;
    transition: border-color 0.2s, box-shadow 0.2s;
}

input:focus-visible,
textarea:focus-visible,
select:focus-visible {
    outline: 2px solid var(--color-primary);
    outline-offset: 1px;
    border-color: var(--color-primary);
    box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.2);
}

input:focus:not(:focus-visible),
textarea:focus:not(:focus-visible),
select:focus:not(:focus-visible) {
    border-color: var(--color-primary);
    box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.2);
}

textarea {
    resize: vertical;
    min-height: 4rem;
}

/* Buttons */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 0.5rem 1.5rem;
    border: none;
    border-radius: var(--radius);
    font-size: 1rem;
    font-weight: 500;
    cursor: pointer;
    transition: background-color 0.2s, transform 0.1s;
}

.btn:active {
    transform: scale(0.98);
}

.btn-primary {
    background-color: var(--color-primary);
    color: white;
}

.btn-primary:hover {
    background-color: var(--color-primary-hover);
}

.btn-secondary {
    background-color: var(--color-border-light);
    color: var(--color-text-secondary);
}

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

.btn-danger {
    background-color: var(--color-danger);
    color: white;
}

.btn-danger:hover {
    background-color: var(--color-danger-hover);
}

.btn-icon {
    padding: 0.5rem;
    background: transparent;
    color: var(--color-muted);
}

.btn-icon:hover {
    color: var(--color-primary);
}

.btn-icon:focus-visible {
    outline: 2px solid var(--color-primary);
    outline-offset: 1px;
    border-radius: 0.25rem;
}

.btn-icon.delete:hover {
    color: var(--color-danger);
}

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

.btn-sm {
    padding: 0.375rem 0.75rem;
    font-size: 0.875rem;
    gap: 0.375rem;
}

.btn-sm svg {
    flex-shrink: 0;
}

.btn-group {
    display: flex;
    gap: 0.5rem;
}

.btn-full {
    width: 100%;
    justify-content: center;
}

/* Checkbox */
.checkbox-group {
    margin-bottom: 1rem;
}

.checkbox-label {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    cursor: pointer;
    font-size: 0.875rem;
    color: var(--color-text-secondary);
}

.checkbox-label input[type="checkbox"] {
    width: 1rem;
    height: 1rem;
    cursor: pointer;
}

.checkbox-hint {
    display: block;
    font-size: 0.75rem;
    color: var(--color-muted);
    margin-top: 0.25rem;
    margin-left: 1.5rem;
}

/* Loading Spinner */
.loading-spinner {
    border: 2px solid #f3f3f3;
    border-top: 2px solid #3b82f6;
    border-radius: 50%;
    width: 16px;
    height: 16px;
    animation: spin 1s linear infinite;
    display: inline-block;
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

/* Notification */
.notification {
    position: fixed;
    bottom: 1rem;
    right: 1rem;
    padding: 0.75rem 1rem;
    border-radius: var(--radius);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
    z-index: 100;
    transition: opacity 0.3s;
}

.notification.success {
    background-color: var(--color-success);
    color: white;
}

.notification.error {
    background-color: #ef4444;
    color: white;
}

.notification.info {
    background-color: var(--color-text);
    color: white;
}

/* Offline Banner */
.offline-banner {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    background: linear-gradient(135deg, #fbbf24 0%, #f59e0b 100%);
    color: #78350f;
    padding: 0.75rem 1rem;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    font-size: 0.875rem;
    font-weight: 500;
    z-index: 1000;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
}

.offline-banner svg {
    flex-shrink: 0;
}

.offline-banner.hidden {
    display: none;
}

body.offline .container {
    margin-top: 3rem;
}

/* Pagination */
.pagination {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.75rem;
    padding: 1.5rem 1rem;
    margin-top: 1rem;
    background: var(--color-bg-white);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
}

@media (min-width: 640px) {
    .pagination {
        flex-direction: row;
        justify-content: space-between;
    }
}

.pagination-info {
    font-size: 0.875rem;
    color: var(--color-muted);
}

.pagination-controls {
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.pagination-pages {
    font-size: 0.875rem;
    color: var(--color-text-secondary);
    font-weight: 500;
}

/* Empty State */
.empty-state {
    text-align: center;
    padding: 3rem 1rem;
}

.empty-state svg {
    width: 4rem;
    height: 4rem;
    margin: 0 auto;
    color: var(--color-muted-light);
}

.empty-state h3 {
    margin-top: 1rem;
    font-size: 1.125rem;
    font-weight: 500;
    color: var(--color-text);
}

.empty-state p {
    margin-top: 0.5rem;
    color: var(--color-muted);
}

/* Stats */
.stats {
    margin-top: 2rem;
    text-align: center;
    font-size: 0.875rem;
    color: var(--color-muted);
}

/* Skip link */
.skip-link {
    position: absolute;
    top: -100%;
    left: 1rem;
    padding: 0.5rem 1rem;
    background: var(--color-primary);
    color: white;
    border-radius: var(--radius);
    z-index: 2000;
    text-decoration: none;
    font-weight: 500;
}

.skip-link:focus {
    top: 1rem;
}

/* Utility */
.sr-only {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
}

/* 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;
    }
}

.hidden {
    display: none !important;
}

.flex-1 {
    flex: 1;
}
