/* Premium Design System for Caselist - Enhanced Theming */

:root {
    /* --- LIGHT MODE (Default) --- */
    --primary-main: #2563eb;
    /* Blue-600 */
    --primary-hover: #1d4ed8;
    /* Blue-700 */

    --bg-body: #f8fafc;
    /* Slate-50 */
    --bg-surface: rgba(255, 255, 255, 0.7);
    --bg-card: #ffffff;
    --bg-input: rgba(255, 255, 255, 0.9);

    --text-main: #1e293b;
    /* Slate-800 */
    --text-muted: #64748b;
    /* Slate-500 */
    --text-inverted: #ffffff;

    --border-color: rgba(226, 232, 240, 0.8);
    /* Slate-200 */
    --border-glass: rgba(255, 255, 255, 0.5);

    --shadow-soft: 0 10px 40px -10px rgba(0, 0, 0, 0.08);
    --shadow-hover: 0 20px 50px -12px rgba(37, 99, 235, 0.25);

    --modal-overlay: rgba(0, 0, 0, 0.4);
    --modal-bg: rgba(255, 255, 255, 0.95);

    --hero-glow-color: rgba(59, 130, 246, 0.15);

    --gradient-text: linear-gradient(315deg, #1e40af 0%, #3b82f6 50%, #8b5cf6 100%);
}

/* --- DARK MODE --- */
[data-theme="dark"] {
    --bg-body: #020617;
    /* Extra Deep Slate-950 */
    --bg-surface: rgba(15, 23, 42, 0.8);
    /* Slate-900 glass */
    --bg-card: #0f172a;
    /* Slate-900 */
    --bg-input: rgba(2, 6, 23, 0.9);

    --text-main: #f8fafc;
    /* Slate-50 */
    --text-muted: #94a3b8;
    /* Slate-400 */
    --text-inverted: #f8fafc;

    --border-color: rgba(30, 41, 59, 1);
    /* Slate-800 */
    --border-glass: rgba(255, 255, 255, 0.05);

    --shadow-soft: 0 10px 40px -10px rgba(0, 0, 0, 0.8);
    --shadow-hover: 0 20px 50px -12px rgba(0, 0, 0, 0.9);

    --modal-overlay: rgba(0, 0, 0, 0.85);
    --modal-bg: #0f172a;

    --hero-glow-color: rgba(59, 130, 246, 0.08);

    --gradient-text: linear-gradient(315deg, #38bdf8 0%, #818cf8 50%, #c084fc 100%);
    /* More sophisticated gradient */
}

/* Backgrounds */
body {
    background-color: var(--bg-body);
    color: var(--text-main);
    transition: background-color 0.3s ease, color 0.3s ease;
    /* Optional: Subtle Mesh for both modes */
    background-image:
        radial-gradient(at 0% 0%, var(--hero-glow-color) 0px, transparent 50%),
        radial-gradient(at 100% 0%, rgba(139, 92, 246, 0.1) 0px, transparent 50%);
    background-attachment: fixed;
    background-repeat: no-repeat;
    background-size: cover;
}

/* Utilities */
.glass-panel {
    background: var(--bg-surface);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border: 1px solid var(--border-glass);
    box-shadow: var(--shadow-soft);
    color: var(--text-main);
}

.text-gradient {
    background: var(--gradient-text) !important;
    -webkit-background-clip: text !important;
    -webkit-text-fill-color: transparent !important;
    background-clip: text !important;
    color: transparent !important;
}

/* Category Card */
.category-card {
    background: var(--bg-card);
    border-radius: 1.25rem;
    border: 1px solid var(--border-color);
    transition: all 0.3s ease;
    overflow: hidden;
    position: relative;
    color: var(--text-main);
    /* Flex alignment fixes */
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 1.25rem 0.75rem;
    gap: 0.75rem;
}

.category-card:hover {
    border-color: var(--primary-main, #2563eb);
    box-shadow: var(--shadow-hover);
    transform: translateY(-5px);
}

/* Inputs */
.premium-input {
    background: var(--bg-input);
    border: 1px solid var(--border-color);
    color: var(--text-main);
    backdrop-filter: blur(4px);
    transition: all 0.2s ease;
}

.premium-input:focus {
    background: var(--bg-card);
    border-color: var(--primary-main, #2563eb);
    box-shadow: 0 0 0 2px rgba(59, 130, 246, 0.2);
    outline: none;
}

/* Modals */
.modal-background {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: var(--modal-overlay);
    backdrop-filter: blur(8px);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 1000;
}

.modal-content {
    background: var(--modal-bg);
    border: 1px solid var(--border-glass);
    color: var(--text-main);
    box-shadow: var(--shadow-soft);
    padding: 2.5rem;
    border-radius: 1.5rem;
    width: 90%;
    max-width: 550px;
    position: relative;
    animation: modalSlideUp 0.3s cubic-bezier(0.16, 1, 0.3, 1);
}

.modal-background.hidden {
    display: none;
}

@keyframes modalSlideUp {
    from {
        opacity: 0;
        transform: translateY(20px) scale(0.95);
    }

    to {
        opacity: 1;
        transform: translateY(0) scale(1);
    }
}

/* Scrollbar for Dark Mode */
[data-theme="dark"] ::-webkit-scrollbar {
    width: 10px;
}

[data-theme="dark"] ::-webkit-scrollbar-track {
    background: #020617;
}

[data-theme="dark"] ::-webkit-scrollbar-thumb {
    background: #1e293b;
    border-radius: 5px;
    border: 2px solid #020617;
}

[data-theme="dark"] ::-webkit-scrollbar-thumb:hover {
    background: #334155;
}

/* --- HEADER TRANSITIONS --- */
.nav-transparent {
    background-color: transparent !important;
    border-bottom-color: transparent !important;
    box-shadow: none !important;
}

.nav-scrolled {
    background-color: var(--bg-card) !important;
    backdrop-filter: blur(12px) !important;
    -webkit-backdrop-filter: blur(12px) !important;
    border-bottom-color: var(--border-color) !important;
    box-shadow: var(--shadow-soft) !important;
    height: 70px !important;
    /* Slightly more compact when scrolled */
}

/* Transition for the content inside navbar */
.nav-scrolled .nav-container {
    height: 70px !important;
}

/* Ensure navbar logo and links adapt if needed */
.nav-transparent .text-gray-900,
.nav-transparent .text-gray-600 {
    transition: color 0.3s ease;
}

/* --- TAILWIND UTILITY OVERRIDES (Theme Enforcement) --- */

/* Layout Backgrounds */
.bg-white,
.bg-gray-50,
.bg-gray-100 {
    background-color: var(--bg-card) !important;
    color: var(--text-main) !important;
    border-color: var(--border-color) !important;
}

/* Dark Layouts (Navbars) */
.bg-gray-900,
.bg-gray-800 {
    background-color: var(--bg-card) !important;
    color: var(--text-main) !important;
    border-color: var(--border-color) !important;
}

[data-theme="dark"] .bg-gray-900,
[data-theme="dark"] .bg-gray-800 {
    background-color: var(--bg-body) !important;
    color: var(--text-inverted) !important;
}

/* Specific Footer override to keep it dark if desired, or at least fix contrast */
footer.bg-gray-800 {
    background-color: #1e293b !important;
    /* Always dark Slate-800 */
    color: #f8fafc !important;
    /* Always light Slate-50 */
}

footer.bg-gray-800 a {
    color: #94a3b8 !important;
    /* Slate-400 */
}

footer.bg-gray-800 a:hover {
    color: #ffffff !important;
}

/* Text Colors */
.text-gray-900,
.text-gray-800,
.text-gray-700 {
    color: var(--text-main) !important;
}

.text-gray-600,
.text-gray-500,
.text-gray-400 {
    color: var(--text-muted) !important;
}

/* Borders */
.border-gray-100,
.border-gray-200,
.border-gray-300,
.border-gray-800 {
    border-color: var(--border-color) !important;
}

/* Shadows */
.shadow-sm,
.shadow-md,
.shadow-lg,
.shadow-xl {
    box-shadow: var(--shadow-soft) !important;
}

/* Form Elements */
input,
select,
textarea {
    background-color: var(--bg-input) !important;
    color: var(--text-main) !important;
    border-color: var(--border-color) !important;
}

/* --- AI Chat Modal Styles (Moved from home.php) --- */

/* Modified modal-background to match the demo's slightly darker overlay */
.modal-background {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: var(--modal-overlay);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 1000;
    opacity: 0;
    transition: opacity 0.3s ease;
    backdrop-filter: blur(8px);
}

.modal-background.visible {
    opacity: 1;
    display: flex;
}

.modal-background.hidden {
    display: none;
}

/* Close Button Override for Chat */
.modal-close-btn-chat {
    position: absolute;
    top: 0.75rem;
    right: 0.75rem;
    background: none;
    border: none;
    font-size: 1.75rem;
    cursor: pointer;
    line-height: 1;
    color: var(--text-muted);
    transition: all 0.2s ease-in-out;
    z-index: 20;
    width: 2rem;
    height: 2rem;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
}

.modal-close-btn-chat:hover {
    color: #ef4444;
    /* Red-500 */
    background: rgba(239, 68, 68, 0.1);
    transform: rotate(90deg);
}

/* Premium Live Chat Modal Content */
.live-chat-modal-content {
    background: var(--bg-card);
    position: relative;
    border-radius: 1.75rem;
    box-shadow: var(--shadow-hover);
    width: 95%;
    max-width: 800px;
    height: 85vh;
    max-height: 800px;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    border: 1px solid var(--border-glass);
    animation: fadeInScale 0.3s cubic-bezier(0.16, 1, 0.3, 1) forwards;
}

/* Glass gradient overlay */
.live-chat-modal-content::before {
    content: '';
    position: absolute;
    inset: 0;
    pointer-events: none;
    background: linear-gradient(180deg, rgba(255, 255, 255, 0) 0%, rgba(255, 255, 255, 0.02) 100%);
    z-index: 1;
}

@media (min-width: 640px) {
    .live-chat-modal-content {
        width: 90%;
    }
}

@keyframes fadeInScale {
    from {
        opacity: 0;
        transform: scale(0.95) translateY(10px);
    }

    to {
        opacity: 1;
        transform: scale(1) translateY(0);
    }
}

.chat-header {
    text-align: center;
    padding: 1.5rem;
    color: var(--text-main);
    font-weight: 800;
    font-size: 1.5rem;
    border-bottom: 1px solid var(--border-color);
    background: var(--bg-surface);
    backdrop-filter: blur(10px);
    z-index: 10;
}

.chat-messages-container-attractive {
    flex-grow: 1;
    overflow-y: auto;
    padding: 1.5rem;
    background-color: var(--bg-body);
    display: flex;
    flex-direction: column;
    gap: 1.25rem;
    scroll-behavior: smooth;
}

/* Premium Message Bubbles */
.chat-message-bubble {
    padding: 1rem 1.25rem;
    border-radius: 1.25rem;
    max-width: 80%;
    line-height: 1.6;
    font-size: 0.95rem;
    position: relative;
    box-shadow: 0 2px 5px rgba(0, 0, 0, 0.05);
    transition: transform 0.2s;
}

.chat-message-bubble:hover {
    transform: translateY(-1px);
}

.chat-message-bubble.ai {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    color: var(--text-main);
    align-self: flex-start;
    border-bottom-left-radius: 0.25rem;
}

.chat-message-bubble.user {
    background: linear-gradient(135deg, #3b82f6 0%, #2563eb 100%);
    color: white;
    align-self: flex-end;
    border-bottom-right-radius: 0.25rem;
    box-shadow: 0 4px 12px rgba(59, 130, 246, 0.3);
}

[data-theme="dark"] .chat-message-bubble.user {
    background: linear-gradient(135deg, #6366f1 0%, #a855f7 100%);
    box-shadow: 0 4px 15px rgba(168, 85, 247, 0.4);
    border: 1px solid rgba(255, 255, 255, 0.1);
}

.chat-message-bubble .message-time {
    display: block;
    font-size: 0.7rem;
    margin-top: 0.4rem;
    opacity: 0.7;
    text-align: right;
}

/* Input Area */
.chat-input-area {
    display: flex;
    gap: 0.75rem;
    padding: 1.25rem;
    border-top: 1px solid var(--border-color);
    background: var(--bg-surface);
    backdrop-filter: blur(10px);
}

.chat-input-area input {
    flex-grow: 1;
    padding: 0.875rem 1.25rem;
    border-radius: 9999px;
    background: var(--bg-input);
    border: 1px solid var(--border-color);
    color: var(--text-main);
    outline: none;
    transition: all 0.2s;
    box-shadow: inset 0 2px 4px rgba(0, 0, 0, 0.03);
}

.chat-input-area input:focus {
    border-color: #3b82f6;
    box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.15);
    background: var(--bg-card);
}

.chat-input-area button {
    background: linear-gradient(135deg, #3b82f6 0%, #2563eb 100%);
    color: white;
    padding: 0 1.5rem;
    border-radius: 9999px;
    font-weight: 600;
    box-shadow: 0 4px 12px rgba(37, 99, 235, 0.3);
    transition: all 0.2s;
}

.chat-input-area button:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 16px rgba(37, 99, 235, 0.4);
}

.chat-input-area button:disabled {
    background: #9ca3af;
    cursor: not-allowed;
    transform: none;
    box-shadow: none;
}

.chat-footer-message {
    text-align: center;
    font-size: 0.75rem;
    color: var(--text-muted);
    margin-top: 0.5rem;
}

/* --- ACTION DROPDOWNS --- */
.dropdown-container {
    position: relative;
    display: inline-block;
}

.dropdown-menu {
    display: none;
    position: absolute;
    right: 0;
    top: 100%;
    margin-top: 0.5rem;
    min-width: 160px;
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: 0.75rem;
    box-shadow: 0 10px 25px -5px rgba(0, 0, 0, 0.1), 0 8px 10px -6px rgba(0, 0, 0, 0.1);
    z-index: 50;
    overflow: hidden;
    animation: dropdownFadeIn 0.2s ease-out;
}

.dropdown-menu.show {
    display: block;
}

.dropdown-item {
    display: flex;
    align-items: center;
    padding: 0.625rem 1rem;
    font-size: 0.875rem;
    color: var(--text-main);
    transition: all 0.2s;
    width: 100%;
    text-align: left;
    border-bottom: 1px solid var(--border-color);
}

.dropdown-item:last-child {
    border-bottom: none;
}

.dropdown-item:hover {
    background-color: rgba(37, 99, 235, 0.05);
    color: var(--primary-main);
}

[data-theme="dark"] .dropdown-item:hover {
    background-color: rgba(255, 255, 255, 0.05);
}

.dropdown-item i {
    width: 1.25rem;
    margin-right: 0.75rem;
    opacity: 0.7;
}

@keyframes dropdownFadeIn {
    from {
        opacity: 0;
        transform: translateY(-10px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* Ensure buttons in dropdown look like links */
.dropdown-item button {
    background: none;
    border: none;
    padding: 0;
    font: inherit;
    cursor: pointer;
    color: inherit;
    display: flex;
    align-items: center;
    width: 100%;
}

/* --- MOBILE BOTTOM NAVIGATION --- */
.mobile-bottom-nav {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    height: 70px;
    background: var(--bg-card);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border-top: 1px solid var(--border-color);
    display: flex;
    justify-content: space-around;
    align-items: center;
    z-index: 1000;
    padding-bottom: env(safe-area-inset-bottom);
    box-shadow: 0 -4px 12px rgba(0, 0, 0, 0.05);
}

.mobile-bottom-nav a {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    color: var(--text-muted);
    font-size: 0.65rem;
    font-weight: 500;
    text-decoration: none;
    transition: all 0.2s;
    width: 20%;
}

.mobile-bottom-nav a i {
    font-size: 1.25rem;
    margin-bottom: 4px;
}

.mobile-bottom-nav a.active {
    color: var(--primary-main);
}

.mobile-bottom-nav a.active i {
    transform: translateY(-2px);
}

/* Responsive Utilities */
@media (min-width: 768px) {
    .mobile-bottom-nav {
        display: none !important;
    }
}

@media (max-width: 767px) {
    .hide-on-mobile {
        display: none !important;
    }

    body {
        padding-bottom: 80px;
    }

    .container {
        padding-left: 1.25rem;
        padding-right: 1.25rem;
    }

    .tile-grid {
        grid-template-columns: 1fr !important;
        gap: 1rem !important;
    }
}

@media (max-width: 640px) {

    button,
    .btn,
    a.dropdown-item {
        min-height: 44px;
        display: flex;
        align-items: center;
    }
}

/* Category Cards */
.category-card {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: 1.25rem;
    padding: 1.25rem 1rem;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.75rem;
    transition: all 0.3s ease;
    text-decoration: none;
}

.category-card:hover {
    transform: translateY(-5px);
    border-color: var(--primary-main);
    box-shadow: var(--shadow-hover);
}

/* Hero Refinements */
.text-gradient {
    background: linear-gradient(135deg, #3b82f6 0%, #2563eb 100%);
    -webkit-background-clip: text;
    background-clip: text;
    -webkit-text-fill-color: transparent;
}

[data-theme="dark"] .text-gradient {
    background: linear-gradient(135deg, #60a5fa 0%, #a855f7 100%);
}

.premium-input {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    color: var(--text-main);
    transition: all 0.3s ease;
}

.premium-input:focus {
    border-color: var(--primary-main);
    box-shadow: 0 0 0 4px rgba(37, 99, 235, 0.1);
}