/* Reusable Components */

/* Buttons */
.btn {
    background: var(--surface);
    border: 2px solid #4a4a4a;
    color: var(--text);
    padding: 12px 20px;
    font-size: 14px;
    cursor: pointer;
    font-family: inherit;
    transition: all 0.2s;
    border-radius: 6px;
    font-weight: 600;
}

.btn:hover:not(:disabled) {
    background: #4a4a4a;
    border-color: var(--primary);
    transform: translateY(-2px);
}

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

.btn-primary {
    background: var(--primary);
    border-color: var(--primary);
    color: #1a1a1a;
}

.btn-primary:hover:not(:disabled) {
    background: var(--primary-light);
    border-color: var(--primary-light);
}

.btn-small {
    padding: 6px 12px;
    font-size: 12px;
}

/* Top bar buttons */
.top-btn {
    background: var(--surface);
    border: 2px solid #4a4a4a;
    color: var(--text);
    padding: 8px 12px;
    font-size: 18px;
    cursor: pointer;
    font-family: inherit;
    transition: all 0.2s;
    border-radius: 6px;
}

.top-btn:hover {
    background: #4a4a4a;
    border-color: var(--primary);
}

/* Modals — backdrop covers 100% of screen including stats bar.
   Content is positioned using vh so it never touches top or bottom bar. */
.modal {
    display: none;
    position: fixed;
    z-index: 2000;
    inset: 0;
    background-color: rgba(0, 0, 0, 0.85);
    backdrop-filter: blur(5px);
}

.modal.active {
    display: block;
}

.modal-content {
    background: var(--background);
    border: 3px solid var(--primary);
    padding: 30px;
    max-width: 700px;
    width: 80%;
    position: fixed;
    top: 5vh;
    left: 50%;
    transform: translateX(-50%);
    max-height: var(--modal-max-height, 60vh);
    overflow-y: auto;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.7);
    border-radius: 15px;
    animation: modalSlideIn 0.3s ease;
    z-index: 2001;
}

.modal-content.menu-modal {
    max-width: 600px;
}

@keyframes modalSlideIn {
    from { opacity: 0; transform: translateX(-50%) scale(0.9); }
    to { opacity: 1; transform: translateX(-50%) scale(1); }
}

@keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

@keyframes fadeOut {
    from { opacity: 1; }
    to { opacity: 0; }
}

.modal-close {
    position: absolute;
    top: 15px;
    right: 15px;
    background: #f44336;
    border: 2px solid #d32f2f;
    color: #fff;
    font-size: 24px;
    width: 40px;
    height: 40px;
    border-radius: 50%;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s;
    font-family: inherit;
    z-index: 10;
}

.modal-close:hover {
    background: #d32f2f;
    transform: rotate(90deg);
}

.modal-title {
    color: var(--primary);
    font-size: 26px;
    margin-bottom: 25px;
    text-align: center;
    border-bottom: 2px solid #444;
    padding-bottom: 15px;
}

/* Toast Notifications */
#toastContainer {
    position: fixed;
    top: 80px;
    right: 20px;
    z-index: 3000;
    display: flex;
    flex-direction: column;
    gap: 10px;
    max-width: 350px;
}

.toast {
    background: var(--surface);
    color: var(--text);
    padding: 15px 20px;
    border-radius: 8px;
    border-left: 4px solid var(--primary);
    box-shadow: 0 5px 20px rgba(0, 0, 0, 0.5);
    animation: toastSlideIn 0.3s ease;
    font-size: 14px;
}

.toast-center {
    position: fixed;
    top: 80px;
    left: 50%;
    transform: translateX(-50%);
    background: var(--surface);
    border: 3px solid var(--primary);
    padding: 20px 30px;
    border-radius: 12px;
    font-size: 18px;
    font-weight: bold;
    text-align: center;
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.7);
    animation: centerPop 0.5s ease-out;
    z-index: 10000;
    min-width: 300px;
}

@keyframes centerPop {
    0% {
        transform: translateX(-50%) scale(0.8);
        opacity: 0;
    }
    50% {
        transform: translateX(-50%) scale(1.05);
    }
    100% {
        transform: translateX(-50%) scale(1);
        opacity: 1;
    }
}

.toast-center.epic {
    border-color: #FFD700;
    background: linear-gradient(135deg, var(--surface) 0%, #2a2410 100%);
    color: #FFD700;
    text-shadow: 0 0 10px rgba(255, 215, 0, 0.5);
}

@keyframes toastSlideIn {
    from { transform: translateX(400px); opacity: 0; }
    to { transform: translateX(0); opacity: 1; }
}

.toast.good {
    border-left-color: var(--primary);
}

.toast.bad {
    border-left-color: #f44336;
    background: #3a2a2a;
}

.toast.info {
    border-left-color: #2196f3;
    background: #2a2a3a;
}

/* Grids */
.action-grid, .zone-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
    gap: 15px;
}

.action-card, .zone-card {
    background: var(--surface);
    border: 2px solid #4a4a4a;
    border-radius: 10px;
    padding: 20px;
    transition: all 0.2s;
}

.action-card:hover, .zone-card:hover {
    border-color: var(--primary);
    transform: translateY(-3px);
}

/* Cookbook recipe cards */
.cookbook-recipe-clickable {
    position: relative;
}

.cookbook-recipe-clickable:hover {
    border-color: var(--success) !important;
    transform: translateY(-5px) scale(1.02) !important;
    box-shadow: 0 8px 20px rgba(76, 175, 80, 0.3);
}

.cookbook-recipe-clickable:active {
    transform: translateY(-2px) scale(0.98) !important;
}

.cookbook-recipe-locked {
    opacity: 0.6;
    cursor: not-allowed !important;
}

.cookbook-recipe-locked:hover {
    border-color: #4a4a4a !important;
    transform: none !important;
}

.action-card h3, .zone-card h3 {
    color: var(--primary);
    margin-bottom: 10px;
    font-size: 18px;
}

.zone-card {
    text-align: center;
    cursor: pointer;
    border: 3px solid #4a4a4a;
    padding: 25px 20px;
}

.zone-card.unlocked {
    border-color: var(--primary);
}

.zone-card.locked {
    opacity: 0.7;
    border-color: #f44336;
}

.action-card.locked {
    opacity: 0.6;
    cursor: not-allowed;
    position: relative;
    /* Ensure it stays in grid flow */
    display: flex;
    flex-direction: column;
}

.zone-icon {
    font-size: 56px;
    margin-bottom: 15px;
    filter: drop-shadow(0 4px 8px rgba(0, 0, 0, 0.3));
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 56px;
}

.zone-icon img {
    width: 56px;
    height: 56px;
    object-fit: contain;
}

/* Item Link */
.item-link {
    color: var(--primary);
    cursor: pointer;
    transition: all 0.2s;
    text-decoration: none;
    border-bottom: 1px dashed var(--primary);
}

.item-link:hover {
    color: var(--primary-light);
    border-bottom-style: solid;
}

.cost-list {
    font-size: 13px;
    color: #aaa;
    margin: 12px 0;
    padding: 12px;
    background: var(--background);
    border-radius: 6px;
    border-left: 3px solid var(--primary);
}

.item-icon {
    width: 32px;
    height: 32px;
    image-rendering: pixelated;
}

.lock-icon {
    position: absolute;
    top: 10px;
    right: 10px;
    font-size: 20px;
    cursor: pointer;
    opacity: 0.6;
    transition: all 0.2s;
    user-select: none;
}

.lock-icon:hover {
    opacity: 1;
    transform: scale(1.2);
}

.lock-icon.locked {
    opacity: 1;
}


/* Tutorial Tooltips */
.tooltip {
    position: absolute;
    background: linear-gradient(135deg, var(--primary) 0%, color-mix(in srgb, var(--primary) 80%, black) 100%);
    color: #000;
    padding: 15px 20px;
    border-radius: 10px;
    font-size: 13px;
    z-index: 10000;
    max-width: 300px;
    box-shadow: 0 8px 20px rgba(0, 0, 0, 0.6);
    animation: tooltipBounce 0.5s ease;
    font-weight: 600;
}

.tooltip::before {
    content: '';
    position: absolute;
    width: 0;
    height: 0;
    border-style: solid;
}

.tooltip.bottom::before {
    top: -10px;
    left: 20px;
    border-width: 0 10px 10px 10px;
    border-color: transparent transparent var(--primary) transparent;
}

.tooltip.top::before {
    bottom: -10px;
    left: 20px;
    border-width: 10px 10px 0 10px;
    border-color: var(--primary) transparent transparent transparent;
}

.tooltip.right::before {
    left: -10px;
    top: 15px;
    border-width: 10px 10px 10px 0;
    border-color: transparent var(--primary) transparent transparent;
}

.tooltip.left::before {
    right: -10px;
    top: 15px;
    border-width: 10px 0 10px 10px;
    border-color: transparent transparent transparent var(--primary);
}

.tooltip-close {
    position: absolute;
    top: 5px;
    right: 5px;
    background: rgba(0, 0, 0, 0.3);
    border: none;
    color: #fff;
    width: 20px;
    height: 20px;
    border-radius: 50%;
    cursor: pointer;
    font-size: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s;
}

.tooltip-close:hover {
    background: rgba(0, 0, 0, 0.5);
    transform: scale(1.1);
}

@keyframes tooltipBounce {
    0% { transform: scale(0.8); opacity: 0; }
    50% { transform: scale(1.05); }
    100% { transform: scale(1); opacity: 1; }
}


/* Status Effects - Top Bar Icons */
.status-effects {
    display: flex;
    gap: 8px;
    align-items: center;
}

.status-effect {
    background: var(--background);
    border: 2px solid var(--primary);
    border-radius: 8px;
    padding: 8px 12px;
    font-size: 24px;
    cursor: pointer;
    transition: all 0.2s;
    
}

.status-effect.new {
    animation: statusPop 0.3s ease;
}

.status-effect:hover {
    transform: scale(1.1);
    box-shadow: 0 4px 12px color-mix(in srgb, var(--primary) 40%, transparent);
}

.status-effect.fireplace {
    border-color: #ff6b35;
}

.status-effect.bed {
    border-color: #4ecdc4;
}

.status-effect.perk {
    border-color: #ffd700;
}

@keyframes statusPop {
    0% { 
        transform: scale(0);
        opacity: 0;
    }
    50% {
        transform: scale(1.1);
    }
    100% { 
        transform: scale(1);
        opacity: 1;
    }
}
/* Status Effects Collapse Button */
.status-effects-toggle {
    background: var(--background);
    border: 2px solid var(--primary);
    border-radius: 8px;
    padding: 8px 12px;
    font-size: 16px;
    cursor: pointer;
    transition: all 0.2s;
    display: flex;
    align-items: center;
    gap: 5px;
}

.status-effects-toggle:hover {
    transform: scale(1.05);
    box-shadow: 0 4px 12px color-mix(in srgb, var(--primary) 40%, transparent);
}

.status-effects-modal .modal-content {
    max-width: 400px;
}

.status-effect-list {
    display: flex;
    flex-direction: column;
    gap: 15px;
}

.status-effect-detail {
    background: var(--surface);
    border: 2px solid var(--primary);
    border-radius: 10px;
    padding: 15px;
    display: flex;
    align-items: center;
    gap: 15px;
}

.status-effect-detail-icon {
    font-size: 32px;
}

.status-effect-detail-info {
    flex: 1;
}

.status-effect-detail-name {
    font-size: 16px;
    font-weight: bold;
    color: var(--primary);
    margin-bottom: 5px;
}

.status-effect-detail-desc {
    font-size: 13px;
    color: #999;
}


/* Activity Animations */
.activity-icon-pop {
    position: fixed;
    pointer-events: none;
    z-index: 5000;
    font-size: 32px;
    animation: iconPop 1.5s ease-out forwards;
}

@keyframes iconPop {
    0% {
        opacity: 1;
        transform: translateY(0) scale(0.5) rotate(0deg);
    }
    50% {
        opacity: 1;
        transform: translateY(-50px) scale(1.2) rotate(180deg);
    }
    100% {
        opacity: 0;
        transform: translateY(-120px) scale(0.8) rotate(360deg);
    }
}

.activity-icon-pop.left {
    animation: iconPopLeft 1.5s ease-out forwards;
}

.activity-icon-pop.right {
    animation: iconPopRight 1.5s ease-out forwards;
}

@keyframes iconPopLeft {
    0% {
        opacity: 1;
        transform: translate(0, 0) scale(0.5) rotate(0deg);
    }
    50% {
        opacity: 1;
        transform: translate(-30px, -50px) scale(1.2) rotate(180deg);
    }
    100% {
        opacity: 0;
        transform: translate(-60px, -120px) scale(0.8) rotate(360deg);
    }
}

@keyframes iconPopRight {
    0% {
        opacity: 1;
        transform: translate(0, 0) scale(0.5) rotate(0deg);
    }
    50% {
        opacity: 1;
        transform: translate(30px, -50px) scale(1.2) rotate(-180deg);
    }
    100% {
        opacity: 0;
        transform: translate(60px, -120px) scale(0.8) rotate(-360deg);
    }
}


/* Achievement Popup */
.achievement-popup {
    position: fixed;
    top: -200px;
    left: 50%;
    transform: translateX(-50%);
    background: linear-gradient(135deg, var(--primary) 0%, var(--primary-light) 100%);
    border: 3px solid #FFD700;
    border-radius: 15px;
    padding: 20px 30px;
    min-width: 350px;
    max-width: 500px;
    box-shadow: 0 10px 40px rgba(0,0,0,0.5);
    z-index: 10000;
    animation: achievementSlideIn 0.5s ease-out forwards, achievementSlideOut 0.5s ease-in 4.5s forwards;
    text-align: center;
}

.achievement-popup-header {
    font-size: 14px;
    color: rgba(255,255,255,0.9);
    font-weight: 600;
    margin-bottom: 10px;
    text-transform: uppercase;
    letter-spacing: 2px;
}

.achievement-popup-icon {
    font-size: 64px;
    margin: 10px 0;
    animation: achievementIconBounce 0.6s ease-out;
}

.achievement-popup-name {
    font-size: 24px;
    color: #fff;
    font-weight: bold;
    margin: 10px 0;
    text-shadow: 2px 2px 4px rgba(0,0,0,0.3);
}

.achievement-popup-desc {
    font-size: 14px;
    color: rgba(255,255,255,0.9);
    margin: 10px 0;
}

.achievement-popup-rewards {
    margin-top: 15px;
    padding-top: 15px;
    border-top: 2px solid rgba(255,255,255,0.3);
    font-size: 16px;
    color: #FFD700;
    font-weight: bold;
}

@keyframes achievementSlideIn {
    0% {
        top: -200px;
        opacity: 0;
    }
    100% {
        top: 20px;
        opacity: 1;
    }
}

@keyframes achievementSlideOut {
    0% {
        top: 20px;
        opacity: 1;
    }
    100% {
        top: -200px;
        opacity: 0;
    }
}

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

/* Ledger Styles */
.ledger-nav-card {
    cursor: pointer;
    background: var(--background);
    border: 2px solid var(--primary);
    border-radius: 8px;
    padding: 20px;
    text-align: center;
    transition: transform 0.2s, box-shadow 0.2s;
}

.ledger-nav-card:hover {
    transform: scale(1.05);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
}

.ledger-guide-btn {
    opacity: 0.8;
    transition: opacity 0.2s, transform 0.2s;
}

.ledger-guide-btn:hover {
    opacity: 1;
    transform: scale(1.05);
}

/* ===================================
   HOMESTEAD LEVEL SYSTEM STYLES
   =================================== */

/* XP Bar in Stats Bar */
.homestead-level-display {
    min-width: 120px !important;
}

.xp-bar-container {
    position: relative;
    width: 100px;
    height: 16px;
    background: rgba(0, 0, 0, 0.5);
    border: 1px solid #4a4a4a;
    border-radius: 8px;
    overflow: hidden;
}

.xp-bar-fill {
    position: absolute;
    left: 0;
    top: 0;
    height: 100%;
    background: linear-gradient(90deg, #4ade80 0%, #22c55e 100%);
    transition: width 0.5s ease-out;
    border-radius: 8px;
}

.xp-bar-text {
    position: absolute;
    left: 50%;
    top: 50%;
    transform: translate(-50%, -50%);
    font-size: 10px;
    font-weight: bold;
    color: white;
    text-shadow: 0 1px 2px rgba(0,0,0,0.8);
    pointer-events: none;
    white-space: nowrap;
}

/* Level-Up Notification */
.level-up-notification {
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%) scale(0);
    background: linear-gradient(135deg, #FFD700 0%, #FFA500 100%);
    color: #1a1a1a;
    padding: 30px 50px;
    border-radius: 16px;
    border: 4px solid #FF8C00;
    box-shadow: 0 20px 60px rgba(255, 215, 0, 0.5);
    z-index: 10000;
    text-align: center;
    animation: levelUpPop 0.6s cubic-bezier(0.68, -0.55, 0.265, 1.55) forwards;
}

@keyframes levelUpPop {
    0% {
        transform: translate(-50%, -50%) scale(0) rotate(-180deg);
        opacity: 0;
    }
    50% {
        transform: translate(-50%, -50%) scale(1.2) rotate(10deg);
    }
    100% {
        transform: translate(-50%, -50%) scale(1) rotate(0deg);
        opacity: 1;
    }
}

.level-up-notification h2 {
    font-size: 36px;
    margin: 0 0 10px 0;
    text-shadow: 2px 2px 4px rgba(0,0,0,0.3);
}

.level-up-notification .level-number {
    font-size: 64px;
    font-weight: bold;
    margin: 10px 0;
    text-shadow: 3px 3px 6px rgba(0,0,0,0.4);
}

.level-up-notification .rewards {
    margin-top: 20px;
    font-size: 18px;
    font-weight: 600;
}

.level-up-notification .reward-item {
    margin: 5px 0;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
}

/* XP Gain Feedback */
.xp-gain-popup {
    position: fixed;
    font-size: 20px;
    font-weight: bold;
    color: #4ade80;
    text-shadow: 0 2px 4px rgba(0,0,0,0.8), 0 0 10px rgba(74, 222, 128, 0.5);
    pointer-events: none;
    z-index: 9999;
    animation: xpFloat 1.5s ease-out forwards;
}

@keyframes xpFloat {
    0% {
        opacity: 1;
        transform: translateY(0) scale(1);
    }
    100% {
        opacity: 0;
        transform: translateY(-80px) scale(1.2);
    }
}

/* Locked Content Indicator */
.locked-overlay {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.7);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    border-radius: 8px;
    z-index: 10;
}

.locked-overlay .lock-icon {
    font-size: 40px;
    margin-bottom: 8px;
}

.locked-overlay .unlock-text {
    font-size: 14px;
    font-weight: bold;
    color: #fbbf24;
    text-shadow: 0 1px 2px rgba(0,0,0,0.8);
}

/* Level Requirement Badge */
.level-requirement {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    background: rgba(251, 191, 36, 0.2);
    border: 1px solid #fbbf24;
    color: #fbbf24;
    padding: 2px 8px;
    border-radius: 12px;
    font-size: 11px;
    font-weight: bold;
}

.level-requirement.unlocked {
    background: rgba(74, 222, 128, 0.2);
    border-color: #4ade80;
    color: #4ade80;
}

/* Zone Card Locked State */
.zone-card.locked {
    opacity: 0.6;
    position: relative;
    cursor: not-allowed !important;
}

.zone-card.locked:hover {
    transform: none !important;
    border-color: #4a4a4a !important;
}

/* Market Item Locked */
.market-item.locked {
    opacity: 0.5;
    cursor: not-allowed;
    filter: grayscale(0.5);
}

.market-item.locked:hover {
    border-color: #666 !important;
    transform: none !important;
}

/* ========================================
   SEARCH & FILTER BAR
   ======================================== */

.search-filter-bar {
    display: flex;
    align-items: center;
    background: var(--background);
    border: 2px solid #4a4a4a;
    border-radius: 6px;
    padding: 8px 12px;
    margin-bottom: 15px;
    gap: 8px;
    transition: border-color 0.2s;
}

.search-filter-bar:focus-within {
    border-color: var(--primary);
}

.search-filter-icon {
    font-size: 16px;
    opacity: 0.6;
    flex-shrink: 0;
}

.search-filter-input {
    flex: 1;
    background: none;
    border: none;
    color: var(--text);
    font-size: 14px;
    font-family: inherit;
    outline: none;
    min-width: 0;
}

.search-filter-input::placeholder {
    color: #666;
}

.search-filter-clear {
    display: none;
    align-items: center;
    justify-content: center;
    background: none;
    border: none;
    color: #666;
    font-size: 14px;
    cursor: pointer;
    padding: 2px 6px;
    border-radius: 4px;
    flex-shrink: 0;
    transition: color 0.2s, background 0.2s;
}

.search-filter-clear:hover {
    color: var(--text);
    background: rgba(255,255,255,0.1);
}


