/**
 * Compound Crafting CSS
 * สไตล์สำหรับหน้าสูตรการผสมไอเทม
 */

/* === Container === */
.compound-container {
    max-width: 1400px;
    margin: 0 auto;
    padding: 2rem 1rem;
}

/* === Header === */
.compound-header {
    background: linear-gradient(135deg, #1a1f3a 0%, #2d1f47 50%, #1a2940 100%);
    border-radius: 20px;
    padding: 2.5rem;
    margin-bottom: 2rem;
    text-align: center;
    position: relative;
    overflow: hidden;
}

.compound-header::before {
    content: '';
    position: absolute;
    top: -50%;
    left: -50%;
    width: 200%;
    height: 200%;
    background: radial-gradient(circle, rgba(240, 125, 26, 0.08) 0%, transparent 60%);
    animation: compoundShimmer 10s infinite linear;
}

@keyframes compoundShimmer {
    from { transform: rotate(0deg); }
    to { transform: rotate(360deg); }
}

.compound-header::after {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: 
        radial-gradient(circle at 20% 50%, rgba(139, 92, 246, 0.1) 0%, transparent 50%),
        radial-gradient(circle at 80% 50%, rgba(59, 130, 246, 0.1) 0%, transparent 50%);
    pointer-events: none;
}

.compound-header h1 {
    color: #F07D1A;
    font-size: 2.5rem;
    font-weight: 700;
    margin-bottom: 0.5rem;
    text-shadow: 0 2px 20px rgba(240, 125, 26, 0.3);
    position: relative;
    z-index: 1;
}

.compound-header p {
    color: #a0aec0;
    font-size: 1.1rem;
    position: relative;
    z-index: 1;
}

/* === Search & Filter === */
.compound-search-section {
    background: white;
    border-radius: 16px;
    padding: 1.5rem;
    margin-bottom: 2rem;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.08);
}

.compound-search-row {
    display: flex;
    gap: 1rem;
    flex-wrap: wrap;
    align-items: center;
}

.compound-search-wrapper {
    flex: 1;
    min-width: 280px;
    position: relative;
}

.compound-search-wrapper input {
    width: 100%;
    padding: 1rem 1rem 1rem 3rem;
    border: 2px solid #e2e8f0;
    border-radius: 12px;
    font-size: 1rem;
    transition: all 0.3s ease;
    background: #f8fafc;
    box-sizing: border-box;
}

.compound-search-wrapper input:focus {
    outline: none;
    border-color: #F07D1A;
    background: white;
    box-shadow: 0 0 0 4px rgba(240, 125, 26, 0.1);
}

.compound-search-wrapper .search-icon {
    position: absolute;
    left: 1rem;
    top: 50%;
    transform: translateY(-50%);
    font-size: 1.2rem;
    color: #a0aec0;
}

.compound-reset-btn {
    padding: 0.75rem 1.5rem;
    background: #f1f5f9;
    color: #64748b;
    border: 2px solid #e2e8f0;
    border-radius: 10px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.3s ease;
    white-space: nowrap;
    font-size: 1rem;
}

.compound-reset-btn:hover {
    background: #e2e8f0;
    color: #475569;
}

/* === Stats Bar === */
.compound-stats-bar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 1rem 1.5rem;
    background: linear-gradient(135deg, #fff7ed, #ffedd5);
    border-radius: 12px;
    margin-bottom: 1.5rem;
    border: 1px solid #fed7aa;
}

.compound-stats-info {
    display: flex;
    gap: 2rem;
    flex-wrap: wrap;
}

.compound-stats-item {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.compound-stats-item .icon {
    font-size: 1.3rem;
}

.compound-stats-item .label {
    color: #78350f;
    font-size: 0.9rem;
}

.compound-stats-item .value {
    color: #92400e;
    font-weight: 700;
    font-size: 1.1rem;
}

/* === Compound Cards Grid === */
.compound-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(480px, 1fr));
    gap: 1.5rem;
}

/* === Compound Card === */
.compound-card {
    background: white;
    border-radius: 16px;
    overflow: hidden;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.08);
    transition: all 0.3s ease;
    border: 2px solid transparent;
}

.compound-card:hover {
    transform: translateY(-4px);
    box-shadow: 0 12px 30px rgba(0, 0, 0, 0.12);
    border-color: #F07D1A;
}

/* Card Header - Result Item */
.compound-card-header {
    background: linear-gradient(135deg, #1e293b, #334155);
    padding: 1.25rem;
    display: flex;
    align-items: center;
    gap: 1rem;
    position: relative;
}

.compound-card-header .result-icon-wrap {
    width: 56px;
    height: 56px;
    background: rgba(255, 255, 255, 0.1);
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    border: 2px solid rgba(240, 125, 26, 0.4);
    backdrop-filter: blur(10px);
}

.compound-card-header .result-icon-wrap .item-icon-img {
    transform: scale(1.2);
    image-rendering: pixelated;
}

.compound-card-header .result-info {
    flex: 1;
    min-width: 0;
}

.compound-card-header .result-name {
    font-size: 1.1rem;
    font-weight: 700;
    color: #F07D1A;
    margin-bottom: 0.2rem;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.compound-card-header .result-name a {
    color: #F07D1A;
    text-decoration: none;
    transition: color 0.2s;
}

.compound-card-header .result-name a:hover {
    color: #fbbf24;
}

.compound-card-header .result-id {
    font-size: 0.75rem;
    color: rgba(255, 255, 255, 0.5);
    background: rgba(255, 255, 255, 0.08);
    padding: 0.15rem 0.5rem;
    border-radius: 4px;
    display: inline-block;
}

.compound-card-header .result-arrow {
    font-size: 1.5rem;
    position: absolute;
    right: 1rem;
    top: 50%;
    transform: translateY(-50%);
    filter: drop-shadow(0 0 4px rgba(240, 125, 26, 0.4));
}

/* Card Body - Materials + Stats */
.compound-card-body {
    padding: 1.25rem;
}

/* Materials Row */
.materials-label {
    font-size: 0.8rem;
    color: #94a3b8;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-bottom: 0.75rem;
}

.materials-row {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    margin-bottom: 1rem;
    flex-wrap: wrap;
}

.material-item {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.5rem 0.75rem;
    background: #f8fafc;
    border: 1px solid #e2e8f0;
    border-radius: 10px;
    transition: all 0.2s ease;
    text-decoration: none;
    min-width: 0;
    flex: 1;
}

.material-item:hover {
    background: #f0f4ff;
    border-color: #c7d2fe;
    transform: translateY(-1px);
}

.material-item .mat-icon-wrap {
    width: 38px;
    height: 38px;
    background: white;
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    border: 1px solid #e2e8f0;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.06);
}

.material-item .mat-icon-wrap .item-icon-img {
    image-rendering: pixelated;
}

.material-item .mat-info {
    flex: 1;
    min-width: 0;
}

.material-item .mat-name {
    font-size: 0.8rem;
    font-weight: 600;
    color: #334155;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    display: block;
}

.material-item .mat-id {
    font-size: 0.65rem;
    color: #94a3b8;
}

.material-plus {
    font-size: 1.2rem;
    color: #94a3b8;
    font-weight: 700;
    flex-shrink: 0;
}

.material-item.empty {
    opacity: 0.4;
    pointer-events: none;
}

.material-item.empty .mat-name {
    color: #94a3b8;
    font-style: italic;
}

/* Card Footer - Stats */
.compound-card-footer {
    display: flex;
    gap: 0.5rem;
    flex-wrap: wrap;
    padding-top: 0.75rem;
    border-top: 1px solid #f1f5f9;
}

.compound-stat {
    display: inline-flex;
    align-items: center;
    gap: 0.35rem;
    padding: 0.35rem 0.7rem;
    border-radius: 8px;
    font-size: 0.8rem;
    font-weight: 600;
}

.compound-stat.success {
    background: #dcfce7;
    color: #15803d;
}

.compound-stat.success.high {
    background: linear-gradient(135deg, #bbf7d0, #86efac);
    color: #166534;
}

.compound-stat.success.medium {
    background: #fef9c3;
    color: #a16207;
}

.compound-stat.success.low {
    background: #fee2e2;
    color: #dc2626;
}

.compound-stat.cost {
    background: #fff7ed;
    color: #c2410c;
}

.compound-stat.lose-yes {
    background: #fee2e2;
    color: #dc2626;
}

.compound-stat.lose-no {
    background: #dcfce7;
    color: #15803d;
}

/* === Compound Table (List View) === */
.compound-list {
    display: none;
}

.compound-table-wrapper {
    overflow-x: auto;
    border-radius: 12px;
    border: 1px solid #e2e8f0;
}

.compound-table {
    width: 100%;
    border-collapse: collapse;
    min-width: 900px;
}

.compound-table thead {
    background: linear-gradient(135deg, #F07D1A, #D54A1D);
    color: white;
}

.compound-table th {
    padding: 1rem 0.75rem;
    font-weight: 600;
    font-size: 0.85rem;
    text-align: center;
    white-space: nowrap;
}

.compound-table tbody tr {
    border-bottom: 1px solid #e2e8f0;
    transition: all 0.2s ease;
}

.compound-table tbody tr:hover {
    background: #fef6ee;
}

.compound-table td {
    padding: 0.75rem;
    font-size: 0.9rem;
    color: #1e293b;
    vertical-align: middle;
}

.compound-table .td-result {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.compound-table .td-result a {
    color: #F07D1A;
    text-decoration: none;
    font-weight: 600;
}

.compound-table .td-result a:hover {
    color: #D54A1D;
    text-decoration: underline;
}

.compound-table .td-materials {
    font-size: 0.85rem;
}

.compound-table .td-materials .mat-inline {
    display: inline-flex;
    align-items: center;
    gap: 0.25rem;
    padding: 0.2rem 0.5rem;
    background: #f8fafc;
    border-radius: 6px;
    margin: 0.15rem;
    border: 1px solid #e2e8f0;
}

.compound-table .td-materials .mat-inline a {
    color: #475569;
    text-decoration: none;
    font-weight: 500;
    font-size: 0.8rem;
}

.compound-table .td-materials .mat-inline a:hover {
    color: #F07D1A;
}

.compound-table .td-success {
    text-align: center;
    font-weight: 700;
}

.compound-table .td-cost {
    text-align: center;
    color: #c2410c;
    font-weight: 600;
}

.compound-table .td-lose {
    text-align: center;
}

/* === View Toggle === */
.compound-view-toggle {
    display: flex;
    gap: 0.5rem;
}

.compound-view-btn {
    padding: 0.6rem 1rem;
    background: white;
    border: 2px solid #e2e8f0;
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.3s ease;
    font-size: 1.1rem;
}

.compound-view-btn.active {
    background: linear-gradient(135deg, #F07D1A, #D54A1D);
    border-color: #F07D1A;
    color: white;
}

.compound-view-btn:hover:not(.active) {
    border-color: #F07D1A;
    background: #fff7ed;
}

/* === Pagination === */
.compound-pagination {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 1rem;
    margin-top: 2rem;
    padding: 1rem;
}

.compound-pagination .pagination-btn {
    padding: 0.6rem 1.25rem;
    background: white;
    border: 2px solid #e2e8f0;
    border-radius: 10px;
    cursor: pointer;
    transition: all 0.3s ease;
    font-size: 0.9rem;
    font-weight: 500;
    color: #475569;
    text-decoration: none;
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
}

.compound-pagination .pagination-btn:hover {
    border-color: #F07D1A;
    color: #F07D1A;
    background: #fff7ed;
    transform: translateY(-2px);
}

.compound-pagination .page-current {
    font-size: 0.95rem;
    color: #64748b;
    font-weight: 600;
}

/* === Empty State === */
.compound-empty {
    text-align: center;
    padding: 4rem 2rem;
    grid-column: 1 / -1;
}

.compound-empty .empty-icon {
    font-size: 4rem;
    margin-bottom: 1rem;
}

.compound-empty h3 {
    color: #475569;
    margin-bottom: 0.5rem;
    font-size: 1.3rem;
}

.compound-empty p {
    color: #94a3b8;
    font-size: 1rem;
}

/* === Item Icon overrides for in-compound usage === */
.compound-card .item-icon-img,
.compound-table .item-icon-img {
    display: inline-block;
    image-rendering: pixelated;
    background-repeat: no-repeat;
}

.item-icon-emoji-sm {
    font-size: 1.5rem;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 32px;
    height: 32px;
}

/* === Responsive === */
@media (max-width: 1024px) {
    .compound-grid {
        grid-template-columns: 1fr;
    }
}

@media (max-width: 768px) {
    .compound-header h1 {
        font-size: 1.75rem;
    }

    .compound-search-row {
        flex-direction: column;
    }

    .compound-search-wrapper {
        min-width: 100%;
    }

    .compound-stats-bar {
        flex-direction: column;
        gap: 1rem;
    }

    .materials-row {
        flex-direction: column;
    }

    .material-plus {
        display: none;
    }

    .material-item {
        width: 100%;
    }

    .compound-card-footer {
        flex-direction: column;
    }

    .compound-pagination {
        flex-direction: column;
        gap: 0.75rem;
    }
}

@media (max-width: 480px) {
    .compound-container {
        padding: 1rem 0.5rem;
    }

    .compound-header {
        padding: 1.5rem;
    }

    .compound-header h1 {
        font-size: 1.5rem;
    }
}
