/* EVE Online Cookbook Style Recipe Viewer */

.recipe-search-container {
    position: relative;
    margin-bottom: 1.5rem;
}

.recipe-filters {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 1rem;
    margin-top: 1rem;
}

.filter-group {
    display: flex;
    flex-direction: column;
}

.filter-group label {
    margin-bottom: 0.5rem;
    font-size: 0.9rem;
}

/* Recipe Card */
.recipe-card {
    background: var(--bg-secondary);
    border: 2px solid var(--border-color);
    border-radius: 8px;
    padding: 2rem;
    margin-bottom: 2rem;
    position: relative; /* Ensure overlay positioning works */
    overflow: visible; /* Allow spinner to extend beyond card if needed */
}

/* Recipe Content Container - ensure it doesn't clip the loading overlay */
#recipeContent {
    position: relative;
    overflow: visible; /* Allow loading overlay spinner to be visible */
    min-height: 200px; /* Ensure minimum height for loading overlay */
}

.recipe-header {
    border-bottom: 2px solid var(--primary-color);
    padding-bottom: 1rem;
    margin-bottom: 1.5rem;
}

.recipe-title {
    font-size: 2rem;
    font-weight: 700;
    color: var(--primary-color);
    margin-bottom: 0.5rem;
    font-family: 'Orbitron', sans-serif;
}

.recipe-meta {
    display: flex;
    gap: 2rem;
    flex-wrap: wrap;
    color: var(--text-secondary);
    font-size: 0.9rem;
}

.recipe-meta-item {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

/* Materials Tree */
.materials-tree {
    margin-top: 1.5rem;
}

.material-node {
    margin-bottom: 0.5rem;
    padding: 0.75rem;
    background: transparent;
    border: none;
    border-left: 2px solid var(--border-color);
    border-radius: 0;
    box-shadow: none;
    transition: none;
}

.material-node:hover {
    background: rgba(0, 100, 200, 0.05);
}

.material-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 0.25rem;
}

.material-name {
    font-weight: 500;
    color: var(--text-primary);
    font-size: 1rem;
}

.material-quantity-container {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.material-quantity {
    color: var(--text-secondary);
    font-weight: 500;
    font-size: 0.95rem;
}

.material-copy-btn {
    background: transparent;
    border: 1px solid var(--border-color);
    border-radius: 4px;
    color: var(--text-secondary);
    cursor: pointer;
    padding: 0.25rem 0.5rem;
    font-size: 0.85rem;
    transition: all 0.2s;
    display: flex;
    align-items: center;
    justify-content: center;
    min-width: 28px;
    height: 24px;
    opacity: 0.6;
}

.material-copy-btn:hover {
    background: var(--bg-card);
    border-color: var(--primary-color);
    color: var(--primary-color);
    opacity: 1;
    transform: scale(1.05);
}

.material-copy-btn:active {
    transform: scale(0.95);
}

.material-details {
    display: inline-flex;
    gap: 1rem;
    margin-top: 0.25rem;
    padding-top: 0;
    border-top: none;
    font-size: 0.85rem;
    color: var(--text-secondary);
}

.material-details strong {
    color: var(--text-secondary);
    font-weight: 500;
}

.material-submaterials {
    margin-top: 0.75rem;
    margin-bottom: 0.5rem;
    padding: 0;
    padding-left: 1rem;
    border-left: 1px solid var(--border-color);
    background: transparent;
    border-radius: 0;
    margin-left: 0.5rem;
}

.material-submaterials-header {
    color: var(--text-secondary);
    font-weight: 500;
    margin-bottom: 0.5rem;
    font-size: 0.85rem;
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding-bottom: 0;
    border-bottom: none;
    transition: color 0.2s;
}

.material-submaterials-header:hover {
    color: var(--text-primary);
}

.submaterial-arrow {
    display: inline-block;
    transition: transform 0.2s;
    font-size: 0.7rem;
}

.material-submaterials.submaterial-collapsed .submaterial-arrow {
    transform: rotate(0deg);
}

.material-submaterials:not(.submaterial-collapsed) .submaterial-arrow {
    transform: rotate(90deg);
}

.material-submaterials-content {
    max-height: 10000px;
    overflow: hidden;
    transition: max-height 0.3s ease-out, opacity 0.2s;
    opacity: 1;
}

.material-submaterials.submaterial-collapsed .material-submaterials-content {
    max-height: 0;
    opacity: 0;
    overflow: hidden;
}

.submaterial-category-group {
    margin-top: 0.5rem;
    margin-bottom: 0.5rem;
}

.submaterial-category-label {
    font-weight: 500;
    font-size: 0.8rem;
    color: var(--text-secondary);
    margin-bottom: 0.25rem;
    padding: 0;
    background: transparent;
    border-radius: 0;
    display: block;
}

.submaterial-category-items {
    margin-left: 0.5rem;
    margin-top: 0.25rem;
}

.material-node[data-depth="1"] {
    border-left-color: var(--primary-color);
}

.material-node[data-depth="2"] {
    border-left-color: var(--secondary-color);
}

.material-node[data-depth="3"] {
    border-left-color: var(--success-color);
}

.material-tier-badge {
    display: inline-block;
    padding: 0.1rem 0.3rem;
    border-radius: 2px;
    font-size: 0.65rem;
    font-weight: 500;
    margin-left: 0.5rem;
    font-family: 'Orbitron', sans-serif;
    opacity: 0.7;
}

.material-tier-badge.tier-direct {
    background: var(--primary-color);
    color: var(--bg-primary);
}

.material-tier-badge.tier-t1 {
    background: var(--success-color);
    color: var(--bg-primary);
}

.material-tier-badge.tier-t2 {
    background: var(--warning-color);
    color: var(--bg-primary);
}

.material-tier-badge.tier-t3 {
    background: var(--secondary-color);
    color: white;
}

.material-node[data-depth="0"] {
    border-left: 2px solid var(--border-color);
    margin-left: 0;
}

.material-node[data-depth="1"] {
    border-left: 2px solid var(--border-color);
    margin-left: 1rem;
}

.material-node[data-depth="2"] {
    border-left: 2px solid var(--border-color);
    margin-left: 2rem;
}

.material-node[data-depth="3"] {
    border-left: 2px solid var(--border-color);
    margin-left: 3rem;
}

.material-node[data-depth] {
    opacity: 1;
}

.material-node[data-depth] {
    opacity: 1;
    transition: opacity 0.2s;
}

.material-submaterial {
    padding: 0.75rem;
    background: var(--bg-primary);
    margin-bottom: 0.5rem;
    border-radius: 4px;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.material-submaterial-name {
    color: var(--text-primary);
}

.material-submaterial-qty {
    color: var(--secondary-color);
    font-weight: 600;
}

.btn-small {
    padding: 0.25rem 0.75rem;
    font-size: 0.85rem;
    background: var(--primary-color);
    color: var(--bg-primary);
    border: none;
    border-radius: 4px;
    cursor: pointer;
    transition: var(--transition);
    font-weight: 600;
}

.btn-small:hover {
    background: var(--primary-hover);
    transform: translateY(-1px);
}

/* Recipe Stats */
.recipe-stats {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
    gap: 1rem;
    margin-top: 1.5rem;
    padding: 1rem;
    background: var(--bg-card);
    border-radius: 8px;
}

.stat-item {
    text-align: center;
}

.stat-label {
    color: var(--text-secondary);
    font-size: 0.85rem;
    text-transform: uppercase;
    margin-bottom: 0.25rem;
}

.stat-value {
    color: var(--primary-color);
    font-size: 1.5rem;
    font-weight: 700;
}

/* Recipe List */
.recipe-list {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(250px, 1fr));
    gap: 1rem;
}

.recipe-list-item {
    background: var(--bg-secondary);
    border: 2px solid var(--border-color);
    border-radius: 8px;
    padding: 1rem;
    cursor: pointer;
    transition: var(--transition);
}

.recipe-list-item:hover {
    border-color: var(--primary-color);
    background: var(--bg-card-hover);
    transform: translateY(-2px);
    box-shadow: var(--shadow-md);
}

.recipe-list-item-name {
    font-weight: 600;
    color: var(--primary-color);
    margin-bottom: 0.5rem;
}

.recipe-list-item-meta {
    font-size: 0.85rem;
    color: var(--text-secondary);
}

.recipe-list-item-materials {
    margin-top: 0.5rem;
    color: var(--text-muted);
    font-size: 0.8rem;
}

/* PI Recipe Badge */
.pi-badge {
    display: inline-block;
    padding: 0.25rem 0.5rem;
    background: var(--warning-color);
    color: var(--bg-primary);
    border-radius: 4px;
    font-size: 0.75rem;
    font-weight: 600;
    margin-left: 0.5rem;
}

.reaction-badge {
    display: inline-block;
    padding: 0.25rem 0.5rem;
    background: var(--success-color);
    color: var(--bg-primary);
    border-radius: 4px;
    font-size: 0.75rem;
    font-weight: 600;
    margin-left: 0.5rem;
}

/* Material Icons */
.material-icon {
    display: inline-block;
    width: 24px;
    height: 24px;
    margin-right: 0.5rem;
    vertical-align: middle;
}

/* Recipe Actions */
.recipe-actions {
    display: flex;
    gap: 1rem;
    margin-top: 1.5rem;
    padding-top: 1.5rem;
    border-top: 2px solid var(--border-color);
    flex-wrap: wrap;
}

.btn-pi {
    padding: 0.75rem 1.5rem;
    background: linear-gradient(135deg, #8B4513, #A0522D);
    color: white;
    border: none;
    border-radius: 6px;
    cursor: pointer;
    font-weight: 600;
    font-size: 0.95rem;
    transition: var(--transition);
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    font-family: 'Rajdhani', sans-serif;
}

.btn-pi:hover {
    background: linear-gradient(135deg, #A0522D, #CD853F);
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(139, 69, 19, 0.4);
}

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

.btn-pi .btn-icon {
    font-size: 1.1rem;
}

/* Component Breakdown Toggle (for all recipes) */
.pi-breakdown-toggle-container {
    margin-top: 1.5rem;
    padding-top: 1.5rem;
    border-top: 2px solid var(--border-color);
    display: block;
}

.pi-toggle-label {
    display: flex;
    align-items: center;
    gap: 1rem;
    cursor: pointer;
    user-select: none;
    padding: 0.75rem;
    background: var(--bg-card);
    border-radius: 8px;
    transition: var(--transition);
}

.pi-toggle-label:hover {
    background: var(--bg-card-hover);
}

.pi-toggle-checkbox {
    display: none;
}

.pi-toggle-slider {
    position: relative;
    width: 50px;
    height: 26px;
    background: var(--bg-secondary);
    border: 2px solid var(--border-color);
    border-radius: 26px;
    transition: var(--transition);
    flex-shrink: 0;
}

.pi-toggle-slider::before {
    content: '';
    position: absolute;
    width: 18px;
    height: 18px;
    left: 3px;
    top: 3px;
    background: var(--text-secondary);
    border-radius: 50%;
    transition: var(--transition);
}

.pi-toggle-checkbox:checked + .pi-toggle-slider {
    background: var(--warning-color);
    border-color: var(--warning-color);
}

.pi-toggle-checkbox:checked + .pi-toggle-slider::before {
    transform: translateX(24px);
    background: white;
}

.pi-toggle-text {
    color: var(--text-primary);
    font-weight: 500;
    font-size: 1rem;
}

/* Material Category Sections */
.material-category-section {
    margin-bottom: 1.5rem;
    padding: 0;
    background: transparent;
    border-radius: 0;
    border: none;
    border-bottom: 1px solid var(--border-color);
    padding-bottom: 1rem;
}

.material-category-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 0.75rem;
    padding: 0.75rem;
    padding-bottom: 0.5rem;
    border-bottom: 1px solid var(--border-color);
    cursor: pointer;
    user-select: none;
    transition: background-color 0.2s;
    border-radius: 4px;
}

.material-category-header:hover {
    background: rgba(0, 100, 200, 0.05);
}

.category-arrow {
    display: inline-block;
    transition: transform 0.2s;
    color: var(--text-secondary);
    font-size: 0.8rem;
}

.material-category-section.category-collapsed .category-arrow {
    transform: rotate(0deg);
}

.material-category-section:not(.category-collapsed) .category-arrow {
    transform: rotate(90deg);
}

/* Start all categories collapsed by default */
.material-category-section {
    /* Already has category-collapsed class by default */
}

.material-count {
    color: var(--text-secondary);
    font-size: 0.85rem;
    font-weight: 400;
}

.material-category-title {
    font-size: 1rem;
    font-weight: 600;
    color: var(--text-primary);
    margin: 0;
}

.material-category-content {
    margin-top: 0.5rem;
    max-height: 10000px;
    overflow: hidden;
    transition: max-height 0.3s ease-out, opacity 0.2s;
    opacity: 1;
}

.material-category-section.category-collapsed .material-category-content {
    max-height: 0;
    margin-top: 0;
    opacity: 0;
    overflow: hidden;
}

/* Category Toggle */
.category-toggle-label {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    cursor: pointer;
    user-select: none;
}

.category-toggle-checkbox {
    display: none;
}

.category-toggle-slider {
    position: relative;
    width: 40px;
    height: 22px;
    background: var(--bg-secondary);
    border: 2px solid var(--border-color);
    border-radius: 22px;
    transition: var(--transition);
    flex-shrink: 0;
}

.category-toggle-slider::before {
    content: '';
    position: absolute;
    width: 14px;
    height: 14px;
    left: 3px;
    top: 3px;
    background: var(--text-secondary);
    border-radius: 50%;
    transition: var(--transition);
}

.category-toggle-checkbox:checked + .category-toggle-slider {
    background: var(--success-color);
    border-color: var(--success-color);
}

.category-toggle-checkbox:checked + .category-toggle-slider::before {
    transform: translateX(18px);
    background: white;
}

.category-toggle-text {
    color: var(--text-primary);
    font-weight: 500;
    font-size: 0.9rem;
}

/* PI Breakdown Section */
.pi-breakdown-section {
    margin-top: 1.5rem;
    padding: 1.5rem;
    background: var(--bg-secondary);
    border: 2px solid var(--warning-color);
    border-radius: 8px;
    animation: fadeIn 0.3s ease-out;
}

.pi-breakdown-content {
    color: var(--text-primary);
}

.pi-breakdown-title {
    color: var(--warning-color);
    font-size: 1.3rem;
    font-weight: 700;
    margin-bottom: 1rem;
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-family: 'Orbitron', sans-serif;
}

.pi-materials-breakdown {
    margin-top: 1rem;
}

.pi-materials-breakdown h5 {
    color: var(--primary-color);
    font-size: 1.1rem;
    margin-bottom: 1rem;
}

.pi-material-breakdown-item {
    background: var(--bg-card);
    padding: 1rem;
    margin-bottom: 1rem;
    border-radius: 6px;
    border-left: 4px solid var(--warning-color);
}

.pi-material-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    margin-bottom: 0.75rem;
    flex-wrap: wrap;
}

.pi-material-name {
    font-weight: 600;
    color: var(--text-primary);
    font-size: 1.1rem;
    flex: 1;
}

.pi-material-qty {
    color: var(--primary-color);
    font-weight: 600;
    font-size: 1.1rem;
}

.pi-material-price {
    color: var(--success-color);
    font-size: 0.9rem;
}

.pi-subrecipe {
    margin-top: 0.75rem;
    padding-top: 0.75rem;
    border-top: 1px solid var(--border-color);
}

.pi-subrecipe-header {
    margin-bottom: 0.5rem;
}

.pi-subrecipe-label {
    color: var(--primary-color);
    font-weight: 600;
    font-size: 0.9rem;
}

.pi-subrecipe-materials {
    margin-top: 0.5rem;
    margin-left: 1rem;
}

.pi-submaterial {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0.5rem;
    background: var(--bg-primary);
    margin-bottom: 0.25rem;
    border-radius: 4px;
}

.pi-submaterial-name {
    color: var(--text-secondary);
    font-size: 0.9rem;
}

.pi-submaterial-qty-container {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.pi-submaterial-qty {
    color: var(--secondary-color);
    font-weight: 600;
    font-size: 0.9rem;
}

.pi-submaterial-note {
    padding: 0.5rem;
    background: var(--bg-primary);
    border-radius: 4px;
    text-align: center;
    color: var(--text-secondary);
    font-size: 0.85rem;
    font-style: italic;
}

.pi-subrecipe-actions {
    margin-top: 0.5rem;
}

.pi-material-note {
    margin-top: 0.5rem;
    padding: 0.5rem;
    background: var(--bg-primary);
    border-radius: 4px;
}

.pi-note-text {
    color: var(--text-secondary);
    font-size: 0.85rem;
    font-style: italic;
}

.pi-summary {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 1rem;
    margin-top: 1.5rem;
    padding: 1rem;
    background: var(--bg-card);
    border-radius: 6px;
}

.pi-summary-item {
    text-align: center;
    color: var(--text-primary);
}

.pi-summary-item strong {
    color: var(--primary-color);
    display: block;
    margin-bottom: 0.25rem;
}

.pi-production-note {
    margin-top: 1.5rem;
    padding: 1rem;
    background: var(--bg-card);
    border-radius: 6px;
    border-left: 4px solid var(--primary-color);
    font-size: 0.9rem;
    color: var(--text-secondary);
}

.pi-production-note ul {
    margin-top: 0.5rem;
    margin-left: 1.5rem;
}

.pi-production-note li {
    margin-bottom: 0.25rem;
}

/* Loading Animation */
@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

@keyframes pulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.5; }
}

@keyframes dotPulse {
    0%, 100% { opacity: 0.3; transform: scale(1); }
    50% { opacity: 1; transform: scale(1.2); }
}

.breakdown-loading-overlay {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(10, 14, 26, 0.95);
    backdrop-filter: blur(4px);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    z-index: 1000;
    border-radius: 8px;
    animation: fadeIn 0.2s ease-in;
    overflow: visible; /* Ensure spinner isn't clipped */
    min-height: 200px; /* Ensure enough space for spinner */
    padding: 2rem; /* Add padding to prevent edge clipping */
}

.breakdown-spinner-container {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 1rem;
    overflow: visible; /* Ensure spinner isn't clipped */
    position: relative;
    padding: 1rem; /* Add padding around spinner */
}

.breakdown-spinner {
    width: 60px;
    height: 60px;
    border: 5px solid var(--border-color);
    border-top: 5px solid var(--primary-color);
    border-right: 5px solid var(--primary-color);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
    box-shadow: 0 0 20px rgba(0, 212, 255, 0.3);
    flex-shrink: 0; /* Prevent spinner from shrinking */
    box-sizing: border-box; /* Include border in size calculation */
    overflow: visible; /* Ensure border isn't clipped */
}

.breakdown-loading-text {
    color: var(--primary-color);
    font-size: 1.2rem;
    font-weight: 600;
    text-align: center;
    font-family: 'Orbitron', sans-serif;
    animation: pulse 2s ease-in-out infinite;
}

.breakdown-progress-dots {
    display: flex;
    gap: 0.5rem;
    margin-top: 0.5rem;
}

.breakdown-progress-dots span {
    width: 8px;
    height: 8px;
    background: var(--primary-color);
    border-radius: 50%;
    animation: dotPulse 1.4s ease-in-out infinite;
}

.breakdown-progress-dots span:nth-child(1) {
    animation-delay: 0s;
}

.breakdown-progress-dots span:nth-child(2) {
    animation-delay: 0.2s;
}

.breakdown-progress-dots span:nth-child(3) {
    animation-delay: 0.4s;
}

.pi-loading, .pi-error {
    text-align: center;
    padding: 2rem;
    color: var(--text-secondary);
}

.pi-error {
    color: var(--danger-color);
}

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

/* Time Display */
.recipe-time {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    color: var(--text-secondary);
}

.time-value {
    color: var(--primary-color);
    font-weight: 600;
}

/* Skills Required */
.skills-required {
    margin-top: 1rem;
    padding: 1rem;
    background: var(--bg-card);
    border-radius: 8px;
}

.skill-item {
    display: flex;
    justify-content: space-between;
    padding: 0.5rem 0;
    border-bottom: 1px solid var(--border-color);
}

.skill-item:last-child {
    border-bottom: none;
}

.skill-name {
    color: var(--text-primary);
}

.skill-level {
    color: var(--primary-color);
    font-weight: 600;
}

/* Search Results */
.search-results {
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    background: var(--bg-secondary);
    border: 2px solid var(--primary-color);
    border-radius: 8px;
    margin-top: 0.5rem;
    max-height: 400px;
    overflow-y: auto;
    z-index: 1000;
    box-shadow: var(--shadow-lg);
}

.search-result-item {
    padding: 1rem;
    cursor: pointer;
    border-bottom: 1px solid var(--border-color);
    transition: var(--transition);
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.search-result-item:hover {
    background: var(--bg-card-hover);
}

.search-result-item:last-child {
    border-bottom: none;
}

.search-result-name {
    font-weight: 600;
    color: var(--primary-color);
}

.search-result-info {
    font-size: 0.85rem;
    color: var(--text-secondary);
}

.no-results {
    padding: 1rem;
    text-align: center;
    color: var(--text-secondary);
}

.hidden {
    display: none !important;
}

/* Responsive */
@media (max-width: 768px) {
    .recipe-filters {
        grid-template-columns: 1fr;
    }
    
    .recipe-list {
        grid-template-columns: 1fr;
    }
    
    .material-submaterials {
        margin-left: 1rem;
    }
}
