/* ==========================================================================
   Tvarka Brand System
   Inspired by Emerald deep-teal palette, adapted for Lithuanian legal SaaS
   ========================================================================== */

/* --- Custom Properties (Design Tokens) --- */
:root {
    /* Primary: Deep Teal */
    --color-primary-900: #0a2e33;
    --color-primary-800: #0E4751;
    --color-primary-700: #145a66;
    --color-primary-600: #1c696a;
    --color-primary-500: #027377;
    --color-primary-400: #00A291;
    --color-primary-300: #3dbdad;
    --color-primary-200: #a3ddd4;
    --color-primary-100: #d1eeea;
    --color-primary-50:  #ebf3f3;

    /* Accent: Warm Amber (for CTAs) */
    --color-accent-600: #c77820;
    --color-accent-500: #e8952e;
    --color-accent-400: #f0ad4e;
    --color-accent-300: #f5c882;

    /* Neutrals */
    --color-neutral-900: #1a1a2e;
    --color-neutral-800: #2a2a3d;
    --color-neutral-700: #3d3d56;
    --color-neutral-600: #555570;
    --color-neutral-500: #71718a;
    --color-neutral-400: #9494a8;
    --color-neutral-300: #b8b8c8;
    --color-neutral-200: #dddde8;
    --color-neutral-100: #f0f0f5;
    --color-neutral-50:  #f8f8fb;

    /* Status */
    --color-success: #16a34a;
    --color-warning: #eab308;
    --color-danger:  #dc2626;
    --color-info:    #027377;

    /* Shadows */
    --shadow-sm: 0 1px 2px 0 rgba(10, 46, 51, 0.05);
    --shadow-md: 0 4px 6px -1px rgba(10, 46, 51, 0.08), 0 2px 4px -2px rgba(10, 46, 51, 0.05);
    --shadow-lg: 0 10px 15px -3px rgba(10, 46, 51, 0.08), 0 4px 6px -4px rgba(10, 46, 51, 0.05);
    --shadow-xl: 0 20px 25px -5px rgba(10, 46, 51, 0.10), 0 8px 10px -6px rgba(10, 46, 51, 0.05);
    --shadow-brand: 0 0 2rem rgba(0, 0, 0, 0.08), 1rem 1rem 0 -0.4rem var(--color-primary-100);

    /* Typography */
    --font-heading: 'Inter', system-ui, -apple-system, sans-serif;
    --font-body: 'Inter', system-ui, -apple-system, sans-serif;

    /* Transitions */
    --transition-fast: 150ms cubic-bezier(0.4, 0, 0.2, 1);
    --transition-base: 250ms cubic-bezier(0.4, 0, 0.2, 1);
    --transition-slow: 350ms cubic-bezier(0.4, 0, 0.2, 1);
}

/* --- Typography --- */
@import url('https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600;700;800&display=swap');

body {
    font-family: var(--font-body);
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    color: var(--color-neutral-800);
}

/* --- Animated Gradient (landing hero) --- */
@keyframes gradient-shift {
    0%   { background-position: 0% 50%; }
    50%  { background-position: 100% 50%; }
    100% { background-position: 0% 50%; }
}

.hero-gradient {
    background: linear-gradient(135deg,
        var(--color-primary-900) 0%,
        var(--color-primary-800) 25%,
        var(--color-primary-700) 50%,
        var(--color-primary-800) 75%,
        var(--color-primary-900) 100%);
    background-size: 200% 200%;
    animation: gradient-shift 12s ease infinite;
}

/* --- Geometric pattern overlay (hero) --- */
.hero-pattern {
    background-image:
        radial-gradient(circle at 20% 80%, rgba(0, 162, 145, 0.12) 0%, transparent 50%),
        radial-gradient(circle at 80% 20%, rgba(0, 162, 145, 0.08) 0%, transparent 50%),
        radial-gradient(circle at 50% 50%, rgba(255, 255, 255, 0.02) 0%, transparent 70%);
}

/* --- Brand Card Style (Emerald offset shadow) --- */
.brand-card {
    background: #fff;
    border-radius: 0.75rem;
    border: 1px solid var(--color-primary-100);
    box-shadow: var(--shadow-md);
    transition: all var(--transition-base);
}

.brand-card:hover {
    box-shadow: var(--shadow-brand);
    transform: translateY(-2px);
    border-color: var(--color-primary-200);
}

/* Action / triage cards — pure-black shadow, amber left accent */
.action-card {
    background: #fff;
    border-radius: 0.75rem;
    border: 1px solid var(--color-primary-100);
    border-left: 4px solid var(--color-amber-500, #f59e0b);
    box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.07), 0 2px 4px -2px rgba(0, 0, 0, 0.05);
    transition: all var(--transition-base);
}

.action-card:hover {
    box-shadow: 0 10px 15px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -4px rgba(0, 0, 0, 0.05);
    transform: translateY(-2px);
    border-color: var(--color-primary-200);
    border-left-color: var(--color-amber-600, #d97706);
}

/* --- Buttons --- */
.btn-primary {
    background-color: var(--color-primary-600);
    color: #fff;
    padding: 0.75rem 1.75rem;
    border-radius: 0.5rem;
    font-weight: 600;
    font-size: 0.9375rem;
    letter-spacing: 0.01em;
    transition: all var(--transition-fast);
    border: 2px solid transparent;
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    cursor: pointer;
}

.btn-primary:hover {
    background-color: var(--color-primary-700);
    box-shadow: 0 4px 12px rgba(28, 105, 106, 0.3);
    transform: translateY(-1px);
}

.btn-primary:active {
    transform: translateY(0);
}

.btn-accent {
    background-color: var(--color-accent-500);
    color: #fff;
    padding: 0.75rem 1.75rem;
    border-radius: 0.5rem;
    font-weight: 600;
    font-size: 0.9375rem;
    letter-spacing: 0.01em;
    transition: all var(--transition-fast);
    border: 2px solid transparent;
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    cursor: pointer;
}

.btn-accent:hover {
    background-color: var(--color-accent-600);
    box-shadow: 0 4px 12px rgba(232, 149, 46, 0.3);
    transform: translateY(-1px);
}

.btn-outline {
    background: transparent;
    color: #fff;
    padding: 0.75rem 1.75rem;
    border-radius: 0.5rem;
    font-weight: 600;
    font-size: 0.9375rem;
    border: 2px solid rgba(255, 255, 255, 0.4);
    transition: all var(--transition-fast);
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    cursor: pointer;
}

.btn-outline:hover {
    border-color: #fff;
    background: rgba(255, 255, 255, 0.1);
}

.btn-outline-dark {
    background: transparent;
    color: var(--color-primary-600);
    padding: 0.75rem 1.75rem;
    border-radius: 0.5rem;
    font-weight: 600;
    font-size: 0.9375rem;
    border: 2px solid var(--color-primary-200);
    transition: all var(--transition-fast);
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    cursor: pointer;
}

.btn-outline-dark:hover {
    border-color: var(--color-primary-400);
    background: var(--color-primary-50);
}

/* --- Feature Icon Circles --- */
.feature-icon {
    width: 3.5rem;
    height: 3.5rem;
    border-radius: 0.75rem;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.feature-icon svg {
    width: 1.5rem;
    height: 1.5rem;
}

.feature-icon-teal {
    background: var(--color-primary-100);
    color: var(--color-primary-600);
}

.feature-icon-amber {
    background: #fef3cd;
    color: var(--color-accent-600);
}

.feature-icon-emerald {
    background: #d1fae5;
    color: #059669;
}

/* --- Navigation (app shell) --- */
.nav-brand {
    background: #fff;
    border-bottom: 1px solid var(--color-primary-100);
    box-shadow: var(--shadow-sm);
}

.nav-link {
    color: var(--color-neutral-600);
    font-weight: 500;
    font-size: 0.875rem;
    padding: 0.5rem 0.75rem;
    border-radius: 0.375rem;
    transition: all var(--transition-fast);
}

.nav-link:hover {
    color: var(--color-primary-600);
    background: var(--color-primary-50);
}

.nav-link-active {
    color: var(--color-primary-700);
    background: var(--color-primary-50);
}

/* Nav icon buttons (right group) */
.nav-icon-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 2.25rem;
    height: 2.25rem;
    border-radius: 0.5rem;
    color: var(--color-neutral-500);
    transition: all var(--transition-fast);
    cursor: pointer;
    border: none;
    background: transparent;
}
.nav-icon-btn:hover {
    color: var(--color-primary-600);
    background: var(--color-primary-50);
}

/* Avatar initials circle */
.avatar-initials {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 2rem;
    height: 2rem;
    border-radius: 9999px;
    background: var(--color-primary-600);
    color: #fff;
    font-size: 0.8125rem;
    font-weight: 600;
    cursor: pointer;
    border: 2px solid transparent;
    transition: all var(--transition-fast);
    line-height: 1;
}
.avatar-initials:hover {
    border-color: var(--color-primary-300);
    box-shadow: 0 0 0 2px var(--color-primary-100);
}

/* Profile dropdown */
.profile-dropdown {
    position: absolute;
    right: 0;
    top: calc(100% + 0.5rem);
    width: 16rem;
    background: #fff;
    border-radius: 0.75rem;
    border: 1px solid var(--color-neutral-200);
    box-shadow: var(--shadow-lg);
    z-index: 50;
    overflow: hidden;
}
.profile-dropdown-item {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.5rem 1rem;
    font-size: 0.875rem;
    color: var(--color-neutral-700);
    transition: background-color var(--transition-fast);
}
.profile-dropdown-item:hover {
    background-color: var(--color-neutral-50);
}

/* Help drawer (slides in from right) */
.help-drawer {
    position: fixed;
    top: 0;
    right: 0;
    bottom: 0;
    width: 22rem;
    max-width: 90vw;
    background: #fff;
    border-left: 1px solid var(--color-neutral-200);
    box-shadow: var(--shadow-xl);
    z-index: 51;
    display: flex;
    flex-direction: column;
    transform: translateX(100%);
    transition: transform var(--transition-base);
}
.help-drawer.help-drawer-open {
    transform: translateX(0);
}

/* --- Login Split Layout --- */
.login-split-brand {
    background: linear-gradient(135deg, var(--color-primary-800) 0%, var(--color-primary-900) 100%);
    position: relative;
    overflow: hidden;
}

.login-split-brand::before {
    content: '';
    position: absolute;
    top: -50%;
    left: -50%;
    width: 200%;
    height: 200%;
    background: radial-gradient(circle at 30% 70%, rgba(0, 162, 145, 0.15) 0%, transparent 50%),
                radial-gradient(circle at 70% 30%, rgba(0, 162, 145, 0.10) 0%, transparent 50%);
}

/* --- Section backgrounds --- */
.section-light {
    background-color: var(--color-primary-50);
}

/* --- Inputs (brand-styled) --- */
.input-brand {
    width: 100%;
    padding: 0.75rem 1rem;
    border: 1.5px solid var(--color-neutral-400);
    border-radius: 0.5rem;
    font-size: 0.9375rem;
    color: var(--color-neutral-800);
    background: #fff;
    transition: all var(--transition-fast);
    font-family: var(--font-body);
}

.input-brand:focus {
    outline: none;
    border-color: var(--color-primary-400);
    box-shadow: 0 0 0 3px rgba(0, 162, 145, 0.12);
}

.input-brand::placeholder {
    color: var(--color-neutral-400);
}

/* --- Subtle animations --- */
@keyframes fade-in-up {
    from {
        opacity: 0;
        transform: translateY(1.5rem);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.animate-fade-in-up {
    animation: fade-in-up 0.6s ease-out forwards;
}

.animate-delay-100 { animation-delay: 100ms; }
.animate-delay-200 { animation-delay: 200ms; }
.animate-delay-300 { animation-delay: 300ms; }
.animate-delay-400 { animation-delay: 400ms; }

/* --- Footer --- */
.footer-brand {
    background: var(--color-neutral-900);
    color: var(--color-neutral-400);
}

.footer-brand a {
    color: var(--color-neutral-300);
    transition: color var(--transition-fast);
}

.footer-brand a:hover {
    color: var(--color-primary-300);
}

/* --- Misc utility overrides for app shell --- */
.app-body {
    background: var(--color-neutral-50);
}

/* Override Tailwind's default blue with our brand teal for common elements */
.text-brand { color: var(--color-primary-600); }
.text-brand-light { color: var(--color-primary-400); }
.bg-brand { background-color: var(--color-primary-600); }
.bg-brand-dark { background-color: var(--color-primary-800); }
.bg-brand-light { background-color: var(--color-primary-50); }
.border-brand { border-color: var(--color-primary-200); }

/* --- Form field styling: visible border, hover contrast --- */
input[type="text"],
input[type="email"],
input[type="password"],
input[type="number"],
input[type="date"],
input[type="url"],
input[type="tel"],
input[type="search"],
select,
textarea {
    border: 1px solid var(--color-neutral-300);
    min-height: 2.75rem;
    padding-top: 0.625rem;
    padding-bottom: 0.625rem;
    transition: border-color var(--transition-fast), background-color var(--transition-fast), box-shadow var(--transition-fast);
}

input[type="text"]:hover,
input[type="email"]:hover,
input[type="password"]:hover,
input[type="number"]:hover,
input[type="date"]:hover,
input[type="url"]:hover,
input[type="tel"]:hover,
input[type="search"]:hover,
select:hover,
textarea:hover {
    border-color: var(--color-neutral-500);
    background-color: var(--color-neutral-50);
}

input[type="text"]:focus,
input[type="email"]:focus,
input[type="password"]:focus,
input[type="number"]:focus,
input[type="date"]:focus,
input[type="url"]:focus,
input[type="tel"]:focus,
input[type="search"]:focus,
select:focus,
textarea:focus {
    border-color: var(--color-primary-500);
    box-shadow: 0 0 0 3px rgba(2, 115, 119, 0.15);
    background-color: #fff;
}

/* Borderless input variant (for embedded search inputs, command palette, etc.) */
.input-borderless,
.input-borderless:hover,
.input-borderless:focus {
    border: none;
    outline: none;
    box-shadow: none;
    min-height: auto;
    background: transparent;
}

/* --- HTMX loading spinner animation --- */
@keyframes htmx-spin {
    from { transform: rotate(0deg); }
    to { transform: rotate(360deg); }
}

.htmx-spinner {
    animation: htmx-spin 1s linear infinite;
}

/* --- Entity layout utility --- */
.entity-layout {
    min-height: calc(100vh - 4rem);
}

/* --- HTMX indicator toast --- */
.htmx-indicator-toast {
    opacity: 0;
    transition: opacity 200ms ease;
}

/* Scrollbar styling */
::-webkit-scrollbar { width: 8px; }
::-webkit-scrollbar-track { background: var(--color-neutral-100); }
::-webkit-scrollbar-thumb { background: var(--color-neutral-300); border-radius: 4px; }
::-webkit-scrollbar-thumb:hover { background: var(--color-neutral-400); }

/* ==========================================================================
   Sidebar (entity_base layout)
   ========================================================================== */

.sidebar-link {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.375rem 0.625rem;
    font-size: 0.8125rem;
    color: #374151;
    border-radius: 0.375rem;
    transition: background-color 150ms, color 150ms;
}
.sidebar-link:hover { background-color: #ebf3f3; color: #145a66; }
.sidebar-link-active {
    background-color: #d1eeea !important;
    color: #145a66 !important;
    font-weight: 500;
}

/* Grey (Internal management) — filled icons: color via fill */
.sidebar-icon {
    width: 1rem;
    height: 1rem;
    flex-shrink: 0;
    fill: #9ca3af;
    stroke: none;
}
.sidebar-link-active .sidebar-icon,
.sidebar-link:hover .sidebar-icon { fill: #1c696a; }
.sidebar-section-btn:hover .sidebar-icon { fill: #6b7280; }

/* Blue (External push/pull) — outline icons: color via stroke */
.sidebar-icon-blue { fill: none; stroke: #6b8db5; }
.sidebar-link-active .sidebar-icon-blue,
.sidebar-link:hover .sidebar-icon-blue { fill: none; stroke: #3b6ea0; }
.sidebar-section-btn:hover .sidebar-icon-blue { fill: none; stroke: #3b6ea0; }

/* Teal (Action) — outline icons: color via stroke */
.sidebar-icon-teal { fill: none; stroke: #2ba3a3; }
.sidebar-link-active .sidebar-icon-teal,
.sidebar-link:hover .sidebar-icon-teal { fill: none; stroke: #1c696a; }
.sidebar-section-btn:hover .sidebar-icon-teal { fill: none; stroke: #1c696a; }

/* Section button */
.sidebar-section-btn {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    width: 100%;
    padding: 0.5rem 0.75rem;
    margin: 0 0.5rem;
    width: calc(100% - 1rem);
    font-size: 0.8125rem;
    font-weight: 500;
    color: #374151;
    border-radius: 0.375rem;
    transition: background-color 150ms;
}
.sidebar-section-btn:hover { background-color: #f9fafb; }

/* Submenu */
.sidebar-submenu { padding: 0.25rem 0.75rem 0.25rem 1.75rem; }
.sidebar-sublink {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0.3rem 0.5rem;
    font-size: 0.8125rem;
    color: #4b5563;
    border-radius: 0.25rem;
    transition: background-color 150ms, color 150ms;
}
.sidebar-sublink:hover { background-color: #f3f4f6; color: #111827; }

/* Disabled / coming soon */
.sidebar-sublink-disabled {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0.3rem 0.5rem;
    font-size: 0.8125rem;
    color: #9ca3af;
    cursor: default;
}
.sidebar-soon-badge {
    font-size: 0.625rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.025em;
    padding: 0.125rem 0.375rem;
    border-radius: 9999px;
    background-color: #fef3c7;
    color: #92400e;
    opacity: 0;
    transition: opacity 150ms;
}
.group:hover .sidebar-soon-badge { opacity: 1; }

/* Badge (counts) */
.sidebar-badge {
    font-size: 0.625rem;
    font-weight: 600;
    padding: 0.0625rem 0.375rem;
    border-radius: 9999px;
}

/* Chevron rotation when open */
.sidebar-section-btn[aria-expanded="true"] .chevron-icon {
    transform: rotate(180deg);
}

/* Mobile sidebar: fixed overlay mode */
@media (max-width: 1023px) {
    #entity-sidebar.sidebar-mobile-open {
        display: flex !important;
        position: fixed;
        top: 4rem;
        left: 0;
        bottom: 0;
        z-index: 30;
        box-shadow: 0 25px 50px -12px rgb(0 0 0 / 0.25);
    }
}
