/**
 * Mobile-optimized CSS for Sandcastle Builder
 * Provides responsive design and mobile-friendly UI components
 */

/* Mobile Store Styles */
.mobile-store-container {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.8);
    z-index: 1000;
    display: none;
    font-family: 'xkcd-Regular', sans-serif;
}

.mobile-store-container.show {
    display: block;
}

.store-header {
    background: #2c3e50;
    color: white;
    padding: 15px 20px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-bottom: 2px solid #34495e;
}

.store-header h2 {
    margin: 0;
    font-size: 1.5em;
}

.close-store {
    background: none;
    border: none;
    color: white;
    font-size: 2em;
    cursor: pointer;
    padding: 0;
    width: 40px;
    height: 40px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.store-tabs {
    display: flex;
    background: #34495e;
    border-bottom: 1px solid #2c3e50;
}

.tab-btn {
    flex: 1;
    background: none;
    border: none;
    color: #bdc3c7;
    padding: 15px 10px;
    cursor: pointer;
    font-size: 0.9em;
    transition: all 0.3s ease;
    border-bottom: 3px solid transparent;
}

.tab-btn.active {
    color: white;
    background: #2c3e50;
    border-bottom-color: #3498db;
}

.tab-btn:hover {
    background: #2c3e50;
    color: white;
}

.store-content {
    height: calc(100vh - 200px);
    overflow-y: auto;
    background: #ecf0f1;
}

.tab-content {
    display: none;
    padding: 20px;
}

.tab-content.active {
    display: block;
}

/* Items Grid */
.items-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
    gap: 20px;
    padding: 10px 0;
}

.item-card {
    background: white;
    border-radius: 10px;
    padding: 20px;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
    transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.item-card:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.15);
}

.item-header {
    display: flex;
    align-items: center;
    margin-bottom: 15px;
}

.item-icon {
    width: 50px;
    height: 50px;
    margin-right: 15px;
    border-radius: 5px;
}

.item-info {
    flex: 1;
}

.item-name {
    margin: 0 0 5px 0;
    font-size: 1.2em;
    color: #2c3e50;
}

.item-desc {
    margin: 0;
    color: #7f8c8d;
    font-size: 0.9em;
    line-height: 1.4;
}

.item-stats {
    margin-bottom: 15px;
    padding: 10px;
    background: #f8f9fa;
    border-radius: 5px;
}

.stat {
    margin: 5px 0;
    font-size: 0.9em;
    color: #2c3e50;
}

.item-cost {
    margin-bottom: 15px;
}

.cost {
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
}

.cost-sand {
    background: #f39c12;
    color: white;
    padding: 5px 10px;
    border-radius: 15px;
    font-size: 0.9em;
}

.cost-castles {
    background: #e74c3c;
    color: white;
    padding: 5px 10px;
    border-radius: 15px;
    font-size: 0.9em;
}

.item-actions {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 10px;
}

.btn-buy {
    background: #27ae60;
    color: white;
    border: none;
    padding: 10px 20px;
    border-radius: 5px;
    cursor: pointer;
    font-size: 1em;
    transition: background 0.3s ease;
}

.btn-buy:hover:not(.disabled) {
    background: #229954;
}

.btn-buy.disabled {
    background: #95a5a6;
    cursor: not-allowed;
}

.owned-count {
    color: #7f8c8d;
    font-size: 0.9em;
}

/* Quick Buy Buttons */
.quick-buy-buttons {
    display: flex;
    gap: 5px;
    margin-top: 10px;
}

.btn-quick-buy {
    background: #3498db;
    color: white;
    border: none;
    padding: 8px 12px;
    border-radius: 5px;
    cursor: pointer;
    font-size: 0.9em;
    transition: background 0.3s ease;
}

.btn-quick-buy:hover {
    background: #2980b9;
}

/* Loadouts */
.loadouts-content {
    padding: 20px 0;
}

.loadout-presets h3,
.custom-loadouts h3 {
    color: #2c3e50;
    margin-bottom: 15px;
}

.preset-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
    gap: 15px;
    margin-bottom: 30px;
}

.loadout-card {
    background: white;
    border-radius: 10px;
    padding: 20px;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
    cursor: pointer;
    transition: transform 0.2s ease;
}

.loadout-card:hover {
    transform: translateY(-2px);
}

.loadout-card h4 {
    margin: 0 0 10px 0;
    color: #2c3e50;
}

.loadout-card p {
    margin: 0 0 15px 0;
    color: #7f8c8d;
    font-size: 0.9em;
}

.btn-apply {
    background: #9b59b6;
    color: white;
    border: none;
    padding: 8px 16px;
    border-radius: 5px;
    cursor: pointer;
    font-size: 0.9em;
}

.btn-create-loadout {
    background: #27ae60;
    color: white;
    border: none;
    padding: 12px 24px;
    border-radius: 5px;
    cursor: pointer;
    font-size: 1em;
    margin-bottom: 20px;
}

/* Store Footer */
.store-footer {
    background: white;
    border-top: 1px solid #bdc3c7;
    padding: 20px;
}

.quick-actions {
    display: flex;
    gap: 10px;
    margin-bottom: 20px;
}

.quick-buy-toggle,
.auto-rebuy-toggle {
    background: #34495e;
    color: white;
    border: none;
    padding: 10px 15px;
    border-radius: 5px;
    cursor: pointer;
    font-size: 0.9em;
}

.smart-queue h4 {
    margin: 0 0 10px 0;
    color: #2c3e50;
}

.queue-items {
    max-height: 150px;
    overflow-y: auto;
}

.queue-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 8px 12px;
    background: #f8f9fa;
    border-radius: 5px;
    margin-bottom: 5px;
}

.btn-remove {
    background: #e74c3c;
    color: white;
    border: none;
    width: 25px;
    height: 25px;
    border-radius: 50%;
    cursor: pointer;
    font-size: 0.8em;
}

.empty-queue {
    color: #7f8c8d;
    font-style: italic;
    text-align: center;
    padding: 20px;
}

/* Mobile Return Summary */
.mobile-return-summary {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.8);
    z-index: 2000;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
}

.summary-content {
    background: white;
    border-radius: 15px;
    padding: 30px;
    max-width: 500px;
    width: 100%;
    max-height: 80vh;
    overflow-y: auto;
}

.summary-content h3 {
    margin: 0 0 20px 0;
    color: #2c3e50;
    text-align: center;
}

.summary-stats {
    margin-bottom: 20px;
}

.stat {
    display: flex;
    justify-content: space-between;
    padding: 10px 0;
    border-bottom: 1px solid #ecf0f1;
}

.stat:last-child {
    border-bottom: none;
}

.stat .label {
    color: #7f8c8d;
}

.stat .value {
    color: #2c3e50;
    font-weight: bold;
}

.events,
.purchases {
    margin-bottom: 20px;
}

.events h4,
.purchases h4 {
    margin: 0 0 10px 0;
    color: #2c3e50;
}

.event {
    padding: 8px 12px;
    border-radius: 5px;
    margin-bottom: 5px;
    font-size: 0.9em;
}

.event.high {
    background: #e74c3c;
    color: white;
}

.event.medium {
    background: #f39c12;
    color: white;
}

.event.low {
    background: #3498db;
    color: white;
}

.purchase {
    padding: 5px 0;
    color: #2c3e50;
    font-size: 0.9em;
}

.summary-actions {
    display: flex;
    gap: 10px;
    margin-top: 20px;
}

.btn-primary {
    background: #27ae60;
    color: white;
    border: none;
    padding: 12px 24px;
    border-radius: 5px;
    cursor: pointer;
    font-size: 1em;
    flex: 1;
}

.btn-secondary {
    background: #95a5a6;
    color: white;
    border: none;
    padding: 12px 24px;
    border-radius: 5px;
    cursor: pointer;
    font-size: 1em;
    flex: 1;
}

/* Mobile Home Screen */
.mobile-home {
    display: none;
}

.mobile-home.show {
    display: block;
}

.mobile-resource-bars {
    display: flex;
    justify-content: space-between;
    padding: 15px 20px;
    background: #2c3e50;
    color: white;
    margin-bottom: 20px;
}

.resource-bar {
    text-align: center;
    flex: 1;
}

.resource-bar:not(:last-child) {
    border-right: 1px solid #34495e;
}

.resource-label {
    font-size: 0.8em;
    color: #bdc3c7;
    margin-bottom: 5px;
}

.resource-value {
    font-size: 1.2em;
    font-weight: bold;
}

.mobile-actions {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 15px;
    padding: 0 20px 20px;
}

.action-button {
    background: #3498db;
    color: white;
    border: none;
    padding: 20px;
    border-radius: 10px;
    font-size: 1.1em;
    cursor: pointer;
    transition: background 0.3s ease;
}

.action-button:hover {
    background: #2980b9;
}

.action-button.primary {
    background: #27ae60;
}

.action-button.primary:hover {
    background: #229954;
}

.mobile-nav {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    background: white;
    border-top: 1px solid #bdc3c7;
    display: flex;
    padding: 10px 0;
    z-index: 100;
}

.nav-item {
    flex: 1;
    text-align: center;
    padding: 10px 5px;
    color: #7f8c8d;
    text-decoration: none;
    font-size: 0.8em;
    transition: color 0.3s ease;
}

.nav-item.active {
    color: #3498db;
}

.nav-item:hover {
    color: #2c3e50;
}

.nav-icon {
    display: block;
    font-size: 1.5em;
    margin-bottom: 5px;
}

/* Responsive Design */
@media (max-width: 768px) {
    .items-grid {
        grid-template-columns: 1fr;
        gap: 15px;
    }
    
    .item-card {
        padding: 15px;
    }
    
    .store-content {
        height: calc(100vh - 180px);
    }
    
    .preset-grid {
        grid-template-columns: 1fr;
    }
    
    .quick-actions {
        flex-direction: column;
    }
    
    .summary-content {
        padding: 20px;
        margin: 10px;
    }
    
    .summary-actions {
        flex-direction: column;
    }
}

@media (max-width: 480px) {
    .store-header {
        padding: 10px 15px;
    }
    
    .store-header h2 {
        font-size: 1.2em;
    }
    
    .tab-btn {
        padding: 12px 8px;
        font-size: 0.8em;
    }
    
    .item-header {
        flex-direction: column;
        text-align: center;
    }
    
    .item-icon {
        margin: 0 0 10px 0;
    }
    
    .mobile-resource-bars {
        padding: 10px 15px;
    }
    
    .mobile-actions {
        padding: 0 15px 15px;
        gap: 10px;
    }
    
    .action-button {
        padding: 15px;
        font-size: 1em;
    }
}

/* Touch-friendly improvements */
@media (hover: none) and (pointer: coarse) {
    .item-card:hover {
        transform: none;
        box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
    }
    
    .btn-buy,
    .btn-quick-buy,
    .btn-apply,
    .action-button {
        min-height: 44px;
    }
    
    .tab-btn {
        min-height: 50px;
    }
}

/* Dark mode support */
@media (prefers-color-scheme: dark) {
    .mobile-store-container {
        background: rgba(0, 0, 0, 0.9);
    }
    
    .item-card {
        background: #2c3e50;
        color: white;
    }
    
    .item-name {
        color: white;
    }
    
    .item-desc {
        color: #bdc3c7;
    }
    
    .stat {
        color: white;
    }
    
    .item-stats {
        background: #34495e;
    }
    
    .store-content {
        background: #2c3e50;
    }
    
    .summary-content {
        background: #2c3e50;
        color: white;
    }
    
    .summary-content h3 {
        color: white;
    }
    
    .stat .label {
        color: #bdc3c7;
    }
    
    .stat .value {
        color: white;
    }
    
    .events h4,
    .purchases h4 {
        color: white;
    }
    
    .purchase {
        color: white;
    }
}
