/* Main CSS */
:root {
    --primary-color: #2563eb;
    --bg-color: #f8fafc;
    --text-color: #1e293b;
    font-family: system-ui, -apple-system, sans-serif;
}

body {
    margin: 0;
    padding: 0;
    background-color: var(--bg-color);
    color: var(--text-color);
    display: grid;
    grid-template-rows: auto 1fr;
    min-height: 100vh;
}

header {
    background: white;
    padding: 1rem 2rem;
    border-bottom: 1px solid #e2e8f0;
    display: flex;
    justify-content: space-between;
    align-items: center;
    view-transition-name: main-header;
}

main {
    padding: 2rem;
    max-width: 1200px;
    margin: 0 auto;
    width: 100%;
    box-sizing: border-box;
}

h1 {
    margin: 0;
}

nav a {
    margin-left: 1rem;
    text-decoration: none;
    color: var(--text-color);
    font-weight: 500;
}

nav a:hover {
    color: var(--primary-color);
}

nav a[aria-current="page"] {
    color: var(--primary-color);
    border-bottom: 2px solid var(--primary-color);
}

/* View Transitions */
@keyframes fade-in {
    from {
        opacity: 0;
    }
}

@keyframes fade-out {
    to {
        opacity: 0;
    }
}

@keyframes slide-from-right {
    from {
        transform: translateX(30px);
    }
}

@keyframes slide-to-left {
    to {
        transform: translateX(-30px);
    }
}

::view-transition-old(root) {
    animation: 90ms cubic-bezier(0.4, 0, 1, 1) both fade-out,
        300ms cubic-bezier(0.4, 0, 0.2, 1) both slide-to-left;
}

::view-transition-new(root) {
    animation: 210ms cubic-bezier(0, 0, 0.2, 1) 90ms both fade-in,
        300ms cubic-bezier(0.4, 0, 0.2, 1) both slide-from-right;
}

/* Dropdown Styles */
.user-menu {
    position: relative;
    display: inline-block;
}

.user-button {
    background: #f1f5f9;
    border: 1px solid #e2e8f0;
    padding: 0.5rem 1rem;
    border-radius: 0.25rem;
    cursor: pointer;
    font-weight: 500;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.user-button:hover {
    background: #e2e8f0;
}

.dropdown-content {
    display: none;
    position: absolute;
    right: 0;
    background-color: white;
    min-width: 160px;
    box-shadow: 0px 8px 16px 0px rgba(0, 0, 0, 0.2);
    z-index: 1000;
    border-radius: 0.25rem;
    margin-top: 0.25rem;
    border: 1px solid #e2e8f0;
}

.dropdown-content a,
.dropdown-content form {
    color: var(--text-color);
    padding: 0.75rem 1rem;
    text-decoration: none;
    display: block;
    font-size: 0.875rem;
}

.dropdown-content a:hover,
.dropdown-content button:hover {
    background-color: #f1f5f9;
}

.dropdown-content button {
    width: 100%;
    text-align: left;
    background: none;
    border: none;
    padding: 0;
    font-family: inherit;
    font-size: inherit;
    cursor: pointer;
    color: inherit;
}

.dropdown-content.show {
    display: block;
}

.empty-state {
    text-align: center;
    padding: 3rem;
    color: #64748b;
}

.btn {
    display: inline-block;
    background: var(--primary-color);
    color: white;
    padding: 0.5rem 1rem;
    border-radius: 0.375rem;
    text-decoration: none;
    font-weight: 500;
    border: none;
    cursor: pointer;
    transition: background 0.2s;
}

.btn:hover {
    background: #1d4ed8;
}

label:has(+input[required], +select[required], +textarea[required]):after {
    content: "*";
    font-size: .8em;
    vertical-align: super
}

form section {
    margin-top: 2rem;
    padding: 1rem;
    background: white;
    border-radius: 0.5rem;
    box-shadow: 0 1px 3px 0 rgb(0 0 0 / 0.1);
}

/* Dropdown Styles (Popover API) */
.dropdown-panel {
    background: white;
    border-radius: 0.75rem;
    box-shadow: 0 10px 15px -3px rgb(0 0 0 / 0.1), 0 4px 6px -4px rgb(0 0 0 / 0.1);
    border: 1px solid #e2e8f0;
    animation: dropdownSlide 0.2s ease-out;
}

.dropdown-panel:popover-open {
    position-area: bottom;
}

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

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* Relative Date Filters */
.relative-date-filters {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.relative-date-row {
    display: flex;
    flex-direction: row;
    align-items: center;
    gap: 0.5rem;
}

.rel-num-input {
    width: 60px;
    padding: 0.25rem 0.5rem;
    border: 1px solid #d1d5db;
    border-radius: 0.25rem;
    text-align: center;
    font-size: 0.875rem;
}

.rel-unit-select,
.rel-dir-select {
    padding: 0.25rem 0.5rem;
    border: 1px solid #d1d5db;
    border-radius: 0.25rem;
    background: white;
    font-size: 0.875rem;
}