/* Panel Layouts & Specific Components */

.panel {
    display: none;
    padding: 20px;
    padding-top: 95px;
    padding-bottom: 120px;
    min-height: calc(100vh - 200px);
}

.panel.active {
    display: block;
    animation: fadeIn 0.3s ease;
}

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

/* Home Locations Grid */
.home-locations-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 20px;
    padding: 10px;
}

.location-card {
    background: var(--surface);
    border: 3px solid #4a4a4a;
    border-radius: 15px;
    padding: 30px 20px;
    text-align: center;
    cursor: pointer;
    transition: all 0.3s ease;
    min-height: 180px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
}

.location-card:hover {
    transform: translateY(-8px) scale(1.02);
    box-shadow: 0 12px 25px color-mix(in srgb, var(--primary) 40%, transparent);
    border-color: var(--primary);
}
.location-card.locked {
    opacity: 0.6;
    border-color: #f44336;
}

.location-card-icon {
    font-size: 64px;
    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: 64px;
}

.location-card-icon img {
    width: 64px;
    height: 64px;
    object-fit: contain;
}

.location-card-name {
    font-size: 18px;
    font-weight: bold;
    color: var(--primary);
}

.location-card-status {
    font-size: 14px;
    color: #f44336;
    font-weight: bold;
    margin-top: 10px;
}

/* Home card ready-indicators */
.location-card {
    position: relative;
}

.home-card-badge {
    position: absolute;
    top: 10px;
    right: 10px;
    background: var(--danger, #f44336);
    color: #fff;
    border-radius: 12px;
    padding: 2px 8px;
    font-size: 12px;
    font-weight: 700;
    pointer-events: none;
    min-width: 22px;
    text-align: center;
}

/* Home Grid Size Variants */
.home-locations-grid.home-grid-medium {
    grid-template-columns: repeat(auto-fill, minmax(120px, 1fr));
    gap: 12px;
}
.home-locations-grid.home-grid-medium .location-card {
    min-height: 0;
    aspect-ratio: 1 / 1;
    padding: 12px 8px;
}
.home-locations-grid.home-grid-medium .location-card-icon {
    font-size: 40px;
    min-height: 40px;
    margin-bottom: 8px;
}
.home-locations-grid.home-grid-medium .location-card-icon img {
    width: 40px;
    height: 40px;
}
.home-locations-grid.home-grid-medium .location-card-name {
    font-size: 14px;
}

.home-locations-grid.home-grid-small {
    grid-template-columns: 1fr;
    gap: 6px;
}
.home-locations-grid.home-grid-small .location-card {
    flex-direction: row;
    min-height: 0;
    padding: 12px 16px;
    gap: 14px;
    text-align: left;
    justify-content: flex-start;
    align-items: center;
    border-radius: 10px;
}
.home-locations-grid.home-grid-small .location-card:hover {
    transform: translateX(4px) scale(1.01);
}
.home-locations-grid.home-grid-small .location-card-icon {
    font-size: 28px;
    min-height: 28px;
    margin-bottom: 0;
    flex-shrink: 0;
}
.home-locations-grid.home-grid-small .location-card-icon img {
    width: 28px;
    height: 28px;
}
.home-locations-grid.home-grid-small .location-card-name {
    font-size: 16px;
}
.home-locations-grid.home-grid-small .home-card-badge {
    top: 50%;
    right: 12px;
    transform: translateY(-50%);
}

/* Body-level grid size: affects zone-grid, action-grid, location-grid globally */

/* MEDIUM */
body.grid-size-medium .zone-grid,
body.grid-size-medium .action-grid,
body.grid-size-medium .location-grid {
    grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
    gap: 10px;
}
body.grid-size-medium .zone-card,
body.grid-size-medium .action-card,
body.grid-size-medium .location-grid .location-card {
    padding: 14px 12px;
}
body.grid-size-medium .zone-card h3,
body.grid-size-medium .action-card h3,
body.grid-size-medium .location-grid .location-card h3 {
    font-size: 15px;
    margin-bottom: 6px;
}
body.grid-size-medium .zone-card p,
body.grid-size-medium .action-card p,
body.grid-size-medium .location-grid .location-card p {
    font-size: 12px;
}

/* SMALL (list) */
body.grid-size-small .zone-grid,
body.grid-size-small .action-grid,
body.grid-size-small .location-grid {
    grid-template-columns: 1fr;
    gap: 6px;
}
body.grid-size-small .zone-card,
body.grid-size-small .action-card,
body.grid-size-small .location-grid .location-card {
    display: flex;
    flex-direction: row;
    align-items: center;
    gap: 14px;
    padding: 10px 16px;
    text-align: left;
    border-radius: 10px;
}
body.grid-size-small .zone-card:hover,
body.grid-size-small .action-card:hover,
body.grid-size-small .location-grid .location-card:hover {
    transform: translateX(4px) translateY(0);
}
body.grid-size-small .zone-card h3,
body.grid-size-small .action-card h3,
body.grid-size-small .location-grid .location-card h3 {
    font-size: 15px;
    margin-bottom: 4px;
}
body.grid-size-small .zone-card p,
body.grid-size-small .action-card p,
body.grid-size-small .location-grid .location-card p {
    font-size: 12px;
    margin: 0;
}
body.grid-size-small .zone-card .zone-icon,
body.grid-size-small .action-card .action-icon {
    flex-shrink: 0;
    font-size: 28px;
}

/* Quick Actions Row (home screen) */
.quick-actions-row {
    display: flex;
    gap: 10px;
    justify-content: center;
    margin-top: 16px;
    padding: 0 10px;
}

.quick-action-btn {
    position: relative;
    width: 52px;
    height: 52px;
    border-radius: 12px;
    border: 2px solid #4a4a4a;
    background: var(--surface);
    font-size: 24px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s ease;
}

.quick-action-btn:hover {
    border-color: var(--primary);
    box-shadow: 0 4px 12px color-mix(in srgb, var(--primary) 30%, transparent);
    transform: translateY(-2px);
}

/* Inbox bell animation */
@keyframes inboxPulse {
    0%   { box-shadow: 0 0 0 0 color-mix(in srgb, var(--primary) 60%, transparent); }
    50%  { box-shadow: 0 0 10px 6px color-mix(in srgb, var(--primary) 25%, transparent); }
    100% { box-shadow: 0 0 0 0 color-mix(in srgb, var(--primary) 0%, transparent); }
}
@keyframes inboxRing {
    0%,100% { transform: rotate(0deg); }
    15%     { transform: rotate(12deg); }
    30%     { transform: rotate(-10deg); }
    45%     { transform: rotate(8deg); }
    60%     { transform: rotate(-6deg); }
    75%     { transform: rotate(4deg); }
}
#quickbtn-inbox.has-unread {
    border-color: var(--primary);
    animation: inboxPulse 2s ease-in-out infinite;
}
#quickbtn-inbox.has-unread .inbox-bell-icon {
    display: inline-block;
    animation: inboxRing 2.5s ease-in-out infinite;
    transform-origin: top center;
}

/* Inventory Slide Panel */
.slide-panel {
    position: fixed;
    top: 0;
    right: 0;
    width: 450px;
    height: 100vh;
    background: var(--background);
    border-left: 3px solid var(--primary);
    z-index: 1500;
    transition: transform 0.3s ease;
    overflow-y: auto;
    box-shadow: -5px 0 20px rgba(0, 0, 0, 0.5);
    transform: translateX(100%);
}

.slide-panel.open {
    transform: translateX(0);
}

.slide-panel-header {
    background: var(--surface);
    padding: 20px;
    border-bottom: 2px solid #4a4a4a;
    display: flex;
    justify-content: space-between;
    align-items: center;
    position: sticky;
    top: 0;
    z-index: 10;
}

.slide-panel-header h3 {
    color: var(--primary);
    font-size: 20px;
    margin: 0;
}

.close-btn {
    background: #f44336;
    border: 2px solid #d32f2f;
    color: #fff;
    font-size: 20px;
    width: 35px;
    height: 35px;
    border-radius: 50%;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s;
}

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

.slide-panel-content {
    padding: 20px;
}

.inventory-tabs {
    display: flex;
    gap: 10px;
    margin-bottom: 20px;
}

.inventory-tab {
    flex: 1;
    padding: 10px;
    background: var(--surface);
    border: 2px solid #4a4a4a;
    color: #999;
    cursor: pointer;
    text-align: center;
    border-radius: 6px;
    transition: all 0.2s;
    font-size: 14px;
}

.inventory-tab.active {
    background: var(--primary);
    border-color: var(--primary);
    color: #1a1a1a;
    font-weight: bold;
}

.inventory-money-display {
    background: linear-gradient(135deg, var(--surface) 0%, #3a4a3a 100%);
    border: 2px solid var(--primary);
    border-radius: 12px;
    padding: 20px;
    margin-bottom: 15px;
    display: flex;
    align-items: center;
    gap: 15px;
}

.inventory-item-card {
    background: var(--surface);
    border: 2px solid #4a4a4a;
    border-radius: 8px;
    padding: 15px;
    margin-bottom: 10px;
    display: flex;
    align-items: center;
    gap: 15px;
}

.inventory-item-card:hover {
    border-color: var(--primary);
}

.inventory-item-icon {
    font-size: 32px;
    flex-shrink: 0;
    cursor: pointer;
}

.inventory-item-details {
    flex: 1;
}

.inventory-item-name {
    color: var(--primary);
    font-weight: bold;
    margin-bottom: 5px;
}

.inventory-item-qty {
    color: #999;
    font-size: 14px;
}

.inventory-item-actions {
    display: flex;
    gap: 5px;
    flex-direction: column;
}

.storage-header {
    background: var(--background);
    padding: 15px;
    border-radius: 8px;
    margin-bottom: 20px;
    border-left: 3px solid var(--primary);
}

/* Location Content */
.location-content {
    padding: 20px 0;
}

.location-feature, .upgrade-offer {
    background: var(--surface);
    border: 2px solid #4a4a4a;
    border-radius: 10px;
    padding: 20px;
    margin-bottom: 15px;
}

.location-feature h3, .upgrade-offer h3 {
    color: var(--primary);
    margin-bottom: 15px;
    font-size: 20px;
}

.upgrade-cost {
    font-size: 14px;
    margin: 15px 0;
    padding: 15px;
    background: var(--background);
    border-radius: 8px;
    border-left: 3px solid var(--primary);
}

.fireplace-status {
    background: var(--background);
    padding: 15px;
    border-radius: 8px;
    margin-bottom: 15px;
    border-left: 3px solid var(--primary);
}

.fireplace-status p {
    color: var(--primary);
    margin: 5px 0;
    font-size: 14px;
}

/* Mobile inventory backdrop */
.inventory-backdrop {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.6);
    z-index: 9998;
}

.inventory-backdrop.active {
    display: block;
}

/* Responsive */
@media (max-width: 768px) {
    .panel {
        padding-top: 80px;
        padding-bottom: 140px;
    }

    .home-locations-grid, .zone-grid, .action-grid {
        grid-template-columns: 1fr;
    }

    .stats-bar {
        bottom: 10px;
        left: 10px;
        right: 10px;
        transform: none;
    }

    .slide-panel {
        width: 100%;
        right: 0;
        top: 0;
        bottom: 0;
        height: 100dvh;
        z-index: 10000;
        transform: translateY(100%);
        border-left: none;
        border-top: 3px solid var(--primary);
        overflow-y: auto;
        -webkit-overflow-scrolling: touch;
    }

    .slide-panel.open {
        transform: translateY(0);
    }

    .slide-panel .slide-panel-content {
        padding-bottom: 100px;
    }

    .modal-content {
        padding: 20px;
    }
}