:root {
    --bg-color: #0d1117;
    --glass-bg: rgba(30, 36, 45, 0.4);
    --glass-border: rgba(255, 255, 255, 0.1);
    --glass-shadow: 0 8px 32px 0 rgba(0, 0, 0, 0.37);
    --text-primary: #f0f6fc;
    --text-secondary: #8b949e;
    --accent-color: #58a6ff;
    --accent-hover: #3182ce;
    --success-color: #238636;
    --danger-color: #da3633;
    --blob-1: rgba(88, 166, 255, 0.2);
    --blob-2: rgba(138, 43, 226, 0.2);
    --blob-3: rgba(43, 226, 138, 0.2);
}

* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

.hidden {
    display: none !important;
}

body {
    font-family: 'Inter', sans-serif;
    background-color: var(--bg-color);
    color: var(--text-primary);
    min-height: 100vh;
    overflow-x: hidden;
    position: relative;
    line-height: 1.6;
}

/* Background Blobs for Glassmorphism effect */
.background-blobs {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: -1;
    overflow: hidden;
}

.blob {
    position: absolute;
    border-radius: 50%;
    filter: blur(80px);
    animation: float 20s infinite ease-in-out alternate;
}

.blob-1 {
    width: 400px;
    height: 400px;
    background: var(--blob-1);
    top: -100px;
    left: -100px;
}

.blob-2 {
    width: 500px;
    height: 500px;
    background: var(--blob-2);
    bottom: -150px;
    right: -100px;
    animation-delay: -5s;
}

.blob-3 {
    width: 300px;
    height: 300px;
    background: var(--blob-3);
    top: 40%;
    left: 40%;
    animation-delay: -10s;
}

@keyframes float {
    0% {
        transform: translate(0, 0) scale(1);
    }

    100% {
        transform: translate(50px, 50px) scale(1.1);
    }
}

/* Glass Panels */
.glass-panel {
    background: var(--glass-bg);
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
    border: 1px solid var(--glass-border);
    border-radius: 16px;
    box-shadow: var(--glass-shadow);
    padding: 24px;
}

/* Layout */
.container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 40px 20px;
}

header {
    text-align: center;
    margin-bottom: 40px;
    padding: 30px !important;
}

header h1 {
    font-size: 2.5rem;
    font-weight: 700;
    margin-bottom: 8px;
    background: linear-gradient(90deg, #58a6ff, #a371f7);
    -webkit-background-clip: text;
    background-clip: text;
    -webkit-text-fill-color: transparent;
}

header p {
    color: var(--text-secondary);
    font-size: 1.1rem;
}

.header-subtitle {
    color: var(--text-secondary);
    font-size: 1.15rem;
    font-weight: 500;
    margin-bottom: 6px;
}

.header-description {
    color: var(--text-secondary);
    font-size: 0.9rem !important;
    max-width: 650px;
    margin: 8px auto 0;
    line-height: 1.5;
    opacity: 0.7;
}

main {
    display: grid;
    grid-template-columns: 1fr 2fr;
    gap: 30px;
}

@media (max-width: 900px) {
    main {
        grid-template-columns: 1fr;
    }
}

/* Inventory Section */
.inventory-section {
    position: relative;
    z-index: 20;
}

.section-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
}

.section-header h2 {
    font-size: 1.5rem;
    font-weight: 600;
}

.item-count {
    background: rgba(255, 255, 255, 0.1);
    padding: 4px 12px;
    border-radius: 20px;
    font-size: 0.9rem;
    color: var(--text-secondary);
}

.add-item-bar {
    display: flex;
    gap: 10px;
    margin-bottom: 24px;
    position: relative;
    z-index: 10;
}

.search-container {
    flex-grow: 1;
    position: relative;
}

input {
    width: 100%;
    padding: 12px 16px;
    background: rgba(0, 0, 0, 0.2);
    border: 1px solid var(--glass-border);
    border-radius: 8px;
    color: var(--text-primary);
    font-size: 1rem;
    font-family: inherit;
    transition: all 0.3s ease;
}

input:focus {
    outline: none;
    border-color: var(--accent-color);
    box-shadow: 0 0 0 2px rgba(88, 166, 255, 0.2);
}

#item-qty {
    width: 80px;
}

/* Buttons */
.btn {
    padding: 12px 20px;
    border: none;
    border-radius: 8px;
    font-weight: 600;
    font-size: 1rem;
    cursor: pointer;
    transition: all 0.3s ease;
    font-family: inherit;
}

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

.primary-btn {
    background: var(--accent-color);
    color: #fff;
}

.primary-btn:hover:not(:disabled) {
    background: var(--accent-hover);
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(88, 166, 255, 0.3);
}

.action-btn {
    width: 100%;
    background: var(--success-color);
    color: #fff;
    margin-top: 20px;
    font-size: 1.1rem;
    padding: 16px;
}

.action-btn:hover:not(:disabled) {
    background: #2ea043;
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(35, 134, 54, 0.3);
}

.remove-btn {
    background: transparent;
    color: var(--danger-color);
    border: 1px solid var(--danger-color);
    padding: 6px 10px;
    font-size: 0.8rem;
    border-radius: 6px;
}

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

/* Autocomplete Dropdown */
.search-dropdown {
    position: absolute;
    top: 100%;
    left: 0;
    min-width: 100%;
    width: max-content;
    max-width: 450px;
    margin-top: 5px;
    background: #161b22;
    border: 1px solid var(--glass-border);
    border-radius: 8px;
    max-height: 250px;
    overflow-y: auto;
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.5);
    z-index: 1000;
}

.search-dropdown.hidden {
    display: none;
}

.search-item {
    padding: 10px 16px;
    cursor: pointer;
    display: grid;
    grid-template-columns: auto 1fr auto;
    align-items: center;
    gap: 12px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.05);
    min-height: 45px;
}

.search-item:hover {
    background: rgba(88, 166, 255, 0.1);
}

.search-item-info {
    display: flex;
    align-items: center;
    min-width: 0;
    /* Important constraint for ellipsis inside grid child */
}

.search-item-icon {
    width: 28px;
    height: 28px;
    border-radius: 4px;
    object-fit: contain;
    background: rgba(0, 0, 0, 0.3);
    margin-right: 12px;
}

.search-item-name {
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    min-width: 0;
}

.search-item-group {
    font-size: 0.8rem;
    color: var(--text-secondary);
    background: rgba(255, 255, 255, 0.1);
    padding: 2px 6px;
    border-radius: 4px;
    justify-self: end;
}

/* Inventory List */
.inventory-list {
    display: flex;
    flex-direction: column;
    gap: 10px;
    max-height: 500px;
    overflow-y: auto;
    padding-right: 5px;
}

.inventory-list::-webkit-scrollbar {
    width: 6px;
}

.inventory-list::-webkit-scrollbar-thumb {
    background: rgba(255, 255, 255, 0.2);
    border-radius: 10px;
}

.inv-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    background: rgba(0, 0, 0, 0.2);
    padding: 12px 16px;
    border-radius: 8px;
    border: 1px solid rgba(255, 255, 255, 0.05);
    transition: transform 0.2s ease;
}

.inv-item:hover {
    transform: translateX(4px);
    background: rgba(255, 255, 255, 0.05);
}

.inv-info {
    display: flex;
    flex-direction: column;
}

.inv-name {
    font-weight: 600;
}

.inv-qty {
    font-size: 0.9rem;
    color: var(--accent-color);
}

/* Inventory Inline Edit */
.inv-item-editing {
    border-color: var(--accent-color) !important;
    background: rgba(88, 166, 255, 0.08) !important;
    transform: none !important;
}

.inv-edit-panel {
    width: 100%;
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.inv-edit-header .inv-name {
    font-size: 1.05rem;
    color: var(--accent-color);
}

.inv-edit-body {
    display: flex;
    align-items: center;
    gap: 12px;
}

.inv-edit-label {
    font-size: 0.85rem;
    color: var(--text-secondary);
    white-space: nowrap;
}

.inv-edit-input {
    flex: 1;
    padding: 8px 12px !important;
    font-size: 1.1rem !important;
    font-weight: 600;
    background: rgba(0, 0, 0, 0.3) !important;
    border: 1px solid var(--accent-color) !important;
    text-align: center;
}

.inv-edit-actions {
    display: flex;
    gap: 8px;
}

.inv-edit-save {
    flex: 1;
    background: var(--success-color) !important;
    color: #fff !important;
    padding: 8px 12px !important;
    font-size: 0.85rem !important;
}

.inv-edit-save:hover {
    background: #2ea043 !important;
}

.inv-edit-cancel {
    flex: 1;
    background: rgba(255, 255, 255, 0.1) !important;
    color: var(--text-secondary) !important;
    padding: 8px 12px !important;
    font-size: 0.85rem !important;
}

.inv-edit-cancel:hover {
    background: rgba(255, 255, 255, 0.2) !important;
    color: var(--text-primary) !important;
}

.inv-edit-delete {
    background: transparent !important;
    color: var(--danger-color) !important;
    border: 1px solid var(--danger-color) !important;
    padding: 8px 12px !important;
    font-size: 0.85rem !important;
}

.inv-edit-delete:hover {
    background: var(--danger-color) !important;
    color: #fff !important;
}

.empty-state {
    text-align: center;
    padding: 30px 20px;
    color: var(--text-secondary);
    font-style: italic;
    background: rgba(0, 0, 0, 0.1);
    border-radius: 8px;
}

/* Recipes Grid */
.recipes-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: 20px;
    margin-top: 20px;
}

.results-meta {
    margin-bottom: 15px;
    color: var(--accent-color);
    font-weight: 500;
}

.recipe-card {
    display: flex;
    flex-direction: column;
    gap: 16px;
    padding: 20px;
    background: rgba(22, 27, 34, 0.6);
    transition: transform 0.3s ease, box-shadow 0.3s ease;
}

.recipe-card:hover {
    transform: translateY(-4px);
    box-shadow: 0 12px 28px rgba(0, 0, 0, 0.4);
    border-color: rgba(88, 166, 255, 0.3);
}

.recipe-header {
    display: flex;
    align-items: center;
    gap: 15px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
    padding-bottom: 15px;
}

.recipe-icon {
    width: 48px;
    height: 48px;
    border-radius: 8px;
    background: #000;
    border: 1px solid rgba(255, 255, 255, 0.2);
    object-fit: contain;
}

.recipe-info {
    flex-grow: 1;
}

.recipe-name {
    font-size: 1.1rem;
    font-weight: 700;
    margin-bottom: 4px;
}

.badge {
    display: inline-block;
    padding: 2px 8px;
    border-radius: 12px;
    font-size: 0.75rem;
    font-weight: 600;
    text-transform: uppercase;
}

.recipe-prof {
    background: rgba(138, 43, 226, 0.2);
    color: #cb9eff;
    border: 1px solid rgba(138, 43, 226, 0.4);
}

.recipe-crafts {
    display: flex;
    flex-direction: column;
    align-items: flex-end;
}

.craft-count {
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--success-color);
    line-height: 1.2;
}

.craft-label {
    font-size: 0.7rem;
    color: var(--text-secondary);
    text-transform: uppercase;
}

.recipe-materials h4 {
    font-size: 0.9rem;
    color: var(--text-secondary);
    margin-bottom: 8px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.materials-list {
    list-style: none;
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.materials-list li {
    font-size: 0.9rem;
    display: flex;
    justify-content: space-between;
    background: rgba(0, 0, 0, 0.2);
    padding: 4px 8px;
    border-radius: 4px;
}

.mat-qty {
    color: var(--accent-color);
    font-weight: 600;
}

/* Sort Controls */
.results-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1rem;
    flex-wrap: wrap;
    gap: 1rem;
}

.sort-controls {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.sort-controls.hidden {
    display: none;
}

.sort-label {
    font-size: 0.85rem;
    color: var(--text-secondary);
    margin-right: 0.25rem;
}

.sort-btn {
    padding: 6px 12px;
    font-size: 0.85rem;
    background: rgba(0, 0, 0, 0.2);
    border: 1px solid rgba(255, 255, 255, 0.1);
    color: var(--text-primary);
    border-radius: 6px;
    cursor: pointer;
    transition: all 0.2s ease;
}

.sort-btn:hover {
    background: rgba(255, 255, 255, 0.1);
}

.sort-btn.active {
    background: var(--accent-color);
    border-color: var(--accent-hover);
    color: #fff;
    box-shadow: 0 0 8px rgba(88, 166, 255, 0.4);
}

/* Floating Contact / Feedback Button */
.contact-fab {
    position: fixed;
    bottom: 24px;
    right: 24px;
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 12px 20px;
    background: rgba(30, 35, 44, 0.85);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border: 1px solid var(--glass-border);
    border-radius: 50px;
    color: var(--text-secondary);
    text-decoration: none;
    font-size: 0.85rem;
    font-weight: 500;
    font-family: inherit;
    cursor: pointer;
    transition: all 0.3s ease;
    z-index: 100;
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.3);
}

.contact-fab:hover {
    background: rgba(88, 166, 255, 0.15);
    border-color: var(--accent-color);
    color: var(--accent-color);
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(88, 166, 255, 0.2);
}

.contact-fab svg {
    flex-shrink: 0;
}

@media (max-width: 600px) {
    .contact-fab span {
        display: none;
    }

    .contact-fab {
        padding: 12px;
        border-radius: 50%;
    }
}

/* Feedback Modal */
.modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.6);
    backdrop-filter: blur(4px);
    -webkit-backdrop-filter: blur(4px);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 200;
    animation: fadeIn 0.2s ease;
}

.modal-overlay.hidden {
    display: none;
}

@keyframes fadeIn {
    from {
        opacity: 0;
    }

    to {
        opacity: 1;
    }
}

.modal-panel {
    width: 90%;
    max-width: 440px;
    padding: 28px 32px !important;
    animation: slideUp 0.3s ease;
}

@keyframes slideUp {
    from {
        opacity: 0;
        transform: translateY(20px);
    }

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

.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 4px;
}

.modal-header h3 {
    font-size: 1.3rem;
    font-weight: 600;
    background: linear-gradient(90deg, #58a6ff, #a371f7);
    -webkit-background-clip: text;
    background-clip: text;
    -webkit-text-fill-color: transparent;
}

.modal-close {
    background: none;
    border: none;
    color: var(--text-secondary);
    font-size: 1.6rem;
    cursor: pointer;
    padding: 0 4px;
    line-height: 1;
    transition: color 0.2s;
}

.modal-close:hover {
    color: var(--danger-color);
}

.modal-desc {
    color: var(--text-secondary);
    font-size: 0.9rem;
    margin-bottom: 20px;
}

.modal-field {
    margin-bottom: 16px;
}

.modal-field label {
    display: block;
    font-size: 0.85rem;
    color: var(--text-secondary);
    margin-bottom: 6px;
    font-weight: 500;
}

.modal-field textarea {
    width: 100%;
    padding: 12px 16px;
    background: rgba(0, 0, 0, 0.2);
    border: 1px solid var(--glass-border);
    border-radius: 8px;
    color: var(--text-primary);
    font-size: 0.95rem;
    font-family: inherit;
    resize: vertical;
    transition: all 0.3s ease;
}

.modal-field textarea:focus {
    outline: none;
    border-color: var(--accent-color);
    box-shadow: 0 0 0 2px rgba(88, 166, 255, 0.2);
}

.modal-submit {
    width: 100%;
    background: var(--accent-color) !important;
    color: #fff !important;
    padding: 14px !important;
    font-size: 1rem !important;
    margin-top: 4px;
    border-radius: 8px;
}

.modal-submit:hover:not(:disabled) {
    background: var(--accent-hover) !important;
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(88, 166, 255, 0.3);
}

.modal-submit:disabled {
    opacity: 0.7;
    cursor: wait;
}

.modal-success {
    text-align: center;
    padding: 20px 0;
}

.modal-success .success-icon {
    width: 56px;
    height: 56px;
    margin: 0 auto 16px;
    border-radius: 50%;
    background: var(--success-color);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.8rem;
    color: #fff;
    animation: popIn 0.4s ease;
}

@keyframes popIn {
    0% {
        transform: scale(0);
    }

    70% {
        transform: scale(1.15);
    }

    100% {
        transform: scale(1);
    }
}

.modal-success p {
    color: var(--text-primary);
    font-size: 1rem;
    font-weight: 500;
}