/* === Global Reset & Theme === */
* { box-sizing: border-box; margin: 0; padding: 0; }

:root {
    --bg-dark:     #0c0a09;
    --bg-panel:    #131110;
    --bg-elevated: #1c1916;
    --bg-input:    #100e0d;
    --border:      #221e1c;
    --border-hover:#302a27;
    --accent:        #e8621a;
    --accent-hover:  #f0743a;
    --accent-glow:   rgba(232, 98, 26, 0.22);
    --accent-subtle: rgba(232, 98, 26, 0.07);
    --accent-wash:   rgba(232, 98, 26, 0.03);
    --text: #ddd9d3;
    --text-muted: #5e5a55;
    --text-light: #9a9187;
    --danger: #e06056;
    --danger-hover: #cc4f45;
    --success: #5cb87a;
    --warning: #e8621a;
    --radius: 14px;
    --radius-sm: 10px;
    --shadow-sm: 0 1px 4px rgba(0,0,0,0.2);
    --shadow-md: 0 4px 24px rgba(0,0,0,0.3);
    --shadow-lg: 0 12px 48px rgba(0,0,0,0.4);
    --transition: 0.25s cubic-bezier(0.4, 0, 0.2, 1);
}

body {
    font-family: 'Figtree', system-ui, sans-serif;
    background: var(--bg-dark);
    color: var(--text);
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    position: relative;
}

/* Subtle ambient background glow */
body::before {
    content: '';
    position: fixed;
    top: -40%;
    left: 50%;
    transform: translateX(-50%);
    width: 120%;
    height: 70%;
    background: radial-gradient(ellipse 60% 50%, rgba(232, 98, 26, 0.04) 0%, transparent 70%);
    pointer-events: none;
    z-index: 0;
}

/* Noise texture overlay for depth */
body::after {
    content: '';
    position: fixed;
    inset: 0;
    background: url("data:image/svg+xml,%3Csvg viewBox='0 0 256 256' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.9' numOctaves='4' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)' opacity='0.025'/%3E%3C/svg%3E");
    pointer-events: none;
    z-index: 0;
}

a { color: var(--accent); text-decoration: none; transition: color var(--transition); }
a:hover { color: var(--accent-hover); }

h1, h2, h3 {
    font-family: 'Instrument Serif', Georgia, serif;
    font-weight: 400;
}

/* === Page-load animation === */
@keyframes fadeIn {
    from { opacity: 0; transform: translateY(18px); }
    to { opacity: 1; transform: translateY(0); }
}

@keyframes fadeInScale {
    from { opacity: 0; transform: scale(0.97) translateY(10px); }
    to { opacity: 1; transform: scale(1) translateY(0); }
}

@keyframes shimmer {
    0% { background-position: -200% 0; }
    100% { background-position: 200% 0; }
}

@keyframes flicker {
    0%, 100% { transform: scaleY(1) rotate(-1deg);    opacity: 1; }
    25%       { transform: scaleY(0.96) rotate(1.2deg); opacity: 0.88; }
    50%       { transform: scaleY(1.04) rotate(-0.6deg); opacity: 0.96; }
    75%       { transform: scaleY(0.98) rotate(0.8deg);  opacity: 0.92; }
}

@keyframes glowPulse {
    0%, 100% { opacity: 0.7; }
    50%       { opacity: 1; }
}

[data-animate] {
    opacity: 0;
    animation: fadeInScale 0.6s cubic-bezier(0.16, 1, 0.3, 1) forwards;
}
[data-animate="1"] { animation-delay: 0.05s; }
[data-animate="2"] { animation-delay: 0.12s; }
[data-animate="3"] { animation-delay: 0.20s; }
[data-animate="4"] { animation-delay: 0.28s; }
[data-animate="5"] { animation-delay: 0.36s; }

/* === Navigation === */
nav {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 32px;
    height: 60px;
    background: rgba(18, 18, 20, 0.7);
    border-bottom: 1px solid var(--border);
    backdrop-filter: blur(20px) saturate(1.2);
    -webkit-backdrop-filter: blur(20px) saturate(1.2);
    position: sticky;
    top: 0;
    z-index: 100;
}

nav .logo {
    font-family: 'Instrument Serif', Georgia, serif;
    font-size: 1.4rem;
    font-weight: 400;
    display: inline-flex;
    align-items: center;
    gap: 7px;
    color: var(--accent);
    letter-spacing: 0.3px;
    transition: opacity var(--transition);
}

nav .logo:hover { opacity: 0.85; }

.logo-img {
    height: 26px;
    width: auto;
    flex-shrink: 0;
    animation: flicker 2.8s ease-in-out infinite;
    transform-origin: center bottom;
}

nav .nav-links {
    display: flex;
    gap: 4px;
    list-style: none;
}

nav .nav-links a {
    color: var(--text-muted);
    font-size: 0.85rem;
    font-weight: 500;
    padding: 7px 18px;
    border-radius: 8px;
    transition: all var(--transition);
    position: relative;
}

nav .nav-links a:hover {
    color: var(--text);
    background: rgba(255, 255, 255, 0.04);
}

nav .nav-links a.active {
    color: var(--accent);
    background: var(--accent-subtle);
}

nav .nav-links a.active::after {
    content: '';
    position: absolute;
    bottom: -1px;
    left: 50%;
    transform: translateX(-50%);
    width: 16px;
    height: 2px;
    background: var(--accent);
    border-radius: 1px;
}

.nav-user {
    display: flex;
    align-items: center;
    gap: 14px;
}

.nav-username {
    color: var(--text);
    font-size: 0.83rem;
    font-weight: 500;
}

.nav-username-link {
    text-decoration: none;
    border-radius: 6px;
    padding: 4px 8px;
    margin: -4px -8px;
    display: inline-flex;
    align-items: center;
    gap: 5px;
    transition: color var(--transition), background var(--transition);
}
.nav-username-link:hover {
    color: var(--text);
    background: rgba(255,255,255,0.06);
}

/* === Toast Notifications === */
#toast-container {
    position: fixed;
    bottom: 28px;
    right: 28px;
    display: flex;
    flex-direction: column;
    gap: 10px;
    z-index: 9999;
    pointer-events: none;
}

.toast {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 14px 18px;
    border-radius: var(--radius-sm);
    border: 1px solid var(--border);
    background: var(--bg-elevated);
    color: var(--text);
    font-size: 0.86rem;
    font-weight: 500;
    box-shadow: 0 8px 32px rgba(0,0,0,0.4);
    pointer-events: all;
    max-width: 340px;
    backdrop-filter: blur(12px);
    animation: toastIn 0.3s cubic-bezier(0.16, 1, 0.3, 1) forwards;
}

.toast.toast-out {
    animation: toastOut 0.25s ease forwards;
}

.toast-icon {
    font-size: 0.9rem;
    flex-shrink: 0;
}

.toast-success {
    border-color: rgba(92, 184, 122, 0.25);
    background: rgba(92, 184, 122, 0.06);
}
.toast-success .toast-icon { color: var(--success); }

.toast-error {
    border-color: rgba(224, 96, 86, 0.25);
    background: rgba(224, 96, 86, 0.06);
}
.toast-error .toast-icon { color: var(--danger); }

.toast-info {
    border-color: rgba(232, 98, 26, 0.2);
    background: rgba(232, 98, 26, 0.05);
}
.toast-info .toast-icon { color: var(--accent); }

@keyframes toastIn {
    from { opacity: 0; transform: translateY(12px) scale(0.97); }
    to   { opacity: 1; transform: translateY(0) scale(1); }
}
@keyframes toastOut {
    from { opacity: 1; transform: translateY(0) scale(1); }
    to   { opacity: 0; transform: translateY(6px) scale(0.97); }
}

/* === Main Content === */
main {
    flex: 1;
    padding: 32px;
    max-width: 1100px;
    width: 100%;
    margin: 0 auto;
    position: relative;
    z-index: 1;
}

/* === Dashboard Sub-Navigation === */
.dash-subnav {
    display: flex;
    gap: 2px;
    padding: 6px;
    background: var(--bg-panel);
    border: 1px solid var(--border);
    border-radius: 12px;
    margin-bottom: 32px;
    width: fit-content;
}

.dash-tab {
    padding: 9px 22px;
    border-radius: 9px;
    font-size: 0.85rem;
    font-weight: 600;
    color: var(--text-muted);
    text-decoration: none;
    transition: all var(--transition);
    position: relative;
}

.dash-tab:hover {
    color: var(--text);
    background: rgba(255, 255, 255, 0.04);
}

.dash-tab.active {
    color: var(--bg-dark);
    background: var(--accent);
    box-shadow: 0 2px 8px rgba(232, 98, 26, 0.2);
}

.dash-tab.active:hover {
    color: var(--bg-dark);
}

/* === Buttons === */
.btn {
    padding: 10px 22px;
    border-radius: var(--radius-sm);
    border: none;
    font-weight: 600;
    font-size: 0.86rem;
    font-family: inherit;
    cursor: pointer;
    transition: all var(--transition);
    position: relative;
    letter-spacing: 0.01em;
}

.btn-primary {
    background: linear-gradient(135deg, var(--accent) 0%, #c94e0e 100%);
    color: var(--bg-dark);
    box-shadow: 0 2px 12px rgba(232, 98, 26, 0.15);
}
.btn-primary:hover {
    background: linear-gradient(135deg, var(--accent-hover) 0%, var(--accent) 100%);
    box-shadow: 0 4px 24px rgba(232, 98, 26, 0.3);
    transform: translateY(-1px);
}
.btn-primary:active {
    transform: translateY(0);
    box-shadow: 0 2px 8px rgba(232, 98, 26, 0.2);
}

.btn-danger {
    background: var(--danger);
    color: white;
    box-shadow: 0 2px 8px rgba(224, 96, 86, 0.15);
}
.btn-danger:hover {
    background: var(--danger-hover);
    box-shadow: 0 4px 16px rgba(224, 96, 86, 0.25);
    transform: translateY(-1px);
}

.btn-secondary {
    background: var(--bg-elevated);
    color: var(--text-light);
    border: 1px solid var(--border);
}
.btn-secondary:hover {
    background: var(--border-hover);
    color: var(--text);
    border-color: var(--border-hover);
}

.btn:disabled {
    background: var(--bg-elevated);
    color: var(--text-muted);
    cursor: not-allowed;
    box-shadow: none;
    transform: none;
    border: 1px solid var(--border);
}

.btn-sm {
    padding: 6px 14px;
    font-size: 0.8rem;
    border-radius: 8px;
}

/* === Cards === */
.card {
    background: var(--bg-panel);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 24px;
    box-shadow: var(--shadow-md);
    position: relative;
}

/* Subtle inner glow on cards */
.card::after {
    content: '';
    position: absolute;
    inset: 0;
    border-radius: var(--radius);
    background: linear-gradient(180deg, rgba(255,255,255,0.01) 0%, transparent 40%);
    pointer-events: none;
}

/* === Form Controls === */
.form-input,
.form-select,
.folder-select {
    padding: 10px 14px;
    border-radius: var(--radius-sm);
    border: 1px solid var(--border);
    background: var(--bg-input);
    color: var(--text);
    font-size: 0.86rem;
    font-family: inherit;
    outline: none;
    transition: all var(--transition);
}

.form-input { cursor: text; }
.form-select, .folder-select { cursor: pointer; }

.form-input:focus,
.form-select:focus,
.folder-select:focus {
    border-color: var(--accent);
    box-shadow: 0 0 0 3px var(--accent-subtle), 0 0 20px rgba(232, 98, 26, 0.06);
}

.folder-select {
    min-width: 180px;
}

/* === Status Badges === */
.badge {
    display: inline-block;
    padding: 3px 10px;
    border-radius: 20px;
    font-size: 0.7rem;
    font-weight: 600;
    letter-spacing: 0.03em;
}

.badge-ready {
    background: rgba(92, 184, 122, 0.1);
    color: var(--success);
    border: 1px solid rgba(92, 184, 122, 0.25);
}

.badge-stale {
    background: rgba(232, 98, 26, 0.1);
    color: var(--warning);
    border: 1px solid rgba(232, 98, 26, 0.25);
}

.badge-error {
    background: rgba(224, 96, 86, 0.1);
    color: var(--danger);
    border: 1px solid rgba(224, 96, 86, 0.25);
}

/* === Spinner === */
.spinner {
    display: inline-block;
    width: 18px;
    height: 18px;
    border: 2px solid var(--border);
    border-top-color: var(--accent);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}

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

/* === Banner === */
.banner {
    padding: 12px 16px;
    border-radius: var(--radius-sm);
    margin-bottom: 16px;
    font-size: 0.86rem;
    line-height: 1.5;
}

.banner-warning {
    background: rgba(232, 98, 26, 0.06);
    border: 1px solid rgba(232, 98, 26, 0.18);
    color: var(--warning);
}

.banner-info {
    background: var(--accent-subtle);
    border: 1px solid rgba(232, 98, 26, 0.15);
    color: var(--accent);
}

/* === Empty state === */
.empty-state {
    text-align: center;
    color: var(--text-muted);
    padding: 28px 20px;
    font-size: 0.9rem;
}

/* === Scrollbar === */
::-webkit-scrollbar {
    width: 6px;
}
::-webkit-scrollbar-track {
    background: transparent;
}
::-webkit-scrollbar-thumb {
    background: var(--border);
    border-radius: 3px;
}
::-webkit-scrollbar-thumb:hover {
    background: var(--border-hover);
}

/* === Selection === */
::selection {
    background: rgba(232, 98, 26, 0.25);
    color: var(--text);
}
