:root {
    /* Using Bootswatch Flatly Theme Colors */
    
    --primary-color: var(--bs-primary);
    --secondary-color: var(--bs-secondary);
    --accent-color: var(--bs-info);
    --background-color: var(--bs-body-bg); 
    --text-color: var(--bs-body-color);
    --border-color: var(--bs-border-color);
    --card-bg: #FFFFFF;
    --success-color: var(--bs-success);
    
    --font-heading: var(--bs-font-sans-serif);
    --font-body: var(--bs-font-sans-serif);
    
    --spacing-sm: 0.5rem;
    --spacing-md: 1rem;
    --spacing-lg: 2rem;
    
    --border-radius: 12px;
    --shadow: 0 4px 12px rgba(0, 0, 0, 0.08);
}

body {
    /* Let Bootstrap handle font */
    position: relative;
    min-height: 100vh;
    background-color: #f8f9fa; /* Fallback light gray */
    overflow-x: hidden; /* Prevent accidental scrollbars from animation */
}

/* Wallpaper Background */
body::before {
    content: "";
    position: fixed;
    top: -1000px; /* Oversize to allow scrolling without gaps if needed, but repeat handles it */
    left: -1000px;
    right: -1000px;
    bottom: -1000px;
    
    /* Wallpaper Image */
    background-image: url('../images/wallpaper.jpg');
    background-repeat: repeat;
    background-size: 1000px; /* Controls tile size */
    
    /* Adjust these for Intensity and Blur */
    filter: blur(2px) grayscale(0.1) contrast(0.9);
    opacity: 0.15; 
    
    z-index: -1;
    pointer-events: none;

    /* Animation */
    animation: scroll-bg 120s linear infinite;
    will-change: transform; /* Better performance than background-position sometimes, but lets use bg-pos for repeat */
}

/* Use background-position for infinite seamless scrolling */
@keyframes scroll-bg {
    0% {
        background-position: 0 0;
    }
    100% {
        background-position: 1000px 1000px; /* Must match background-size */
    }
}

/* Custom Header */
.app-header {
    background-color: var(--bs-primary);
    box-shadow: 0 4px 12px rgba(0,0,0,0.1);
}

/* Footer */
.app-footer {
    background-color: var(--bs-secondary);
    color: white;
}

/* Tableta Board (Custom Grid) */
.board-wrapper {
    position: relative;
    margin: 0 auto;
    max-width: 400px;
    background: white;
    border: 4px solid var(--bs-primary);
    border-radius: 4px;
    padding: 10px;
    box-shadow: 0 10px 20px rgba(0,0,0,0.15);
}

.tabla-header-container {
    padding-bottom: 5px;
}

.tabla-header-container input::placeholder {
    color: #ccc;
    font-weight: normal;
}

.tableta-board {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 10px;
    background: white;
    transition: filter 0.3s;
}

.tableta-board.blur {
    filter: blur(4px) grayscale(0.5);
    pointer-events: none;
}

.grid-cell {
    position: relative;
    cursor: pointer;
    transition: transform 0.2s, box-shadow 0.2s;
    border: 1px solid #ddd;
    overflow: hidden;
    border-radius: 2px;
}

.grid-cell:hover {
    transform: scale(1.05);
    z-index: 1;
    box-shadow: 0 4px 12px rgba(0,0,0,0.2);
    border-color: var(--bs-info);
}

.grid-cell.duplicate {
    border: 3px solid var(--bs-danger);
    box-sizing: border-box;
    animation: pulse 2s infinite;
}

@keyframes pulse {
    0% { box-shadow: 0 0 0 0 rgba(231, 76, 60, 0.4); }
    70% { box-shadow: 0 0 0 10px rgba(231, 76, 60, 0); }
    100% { box-shadow: 0 0 0 0 rgba(231, 76, 60, 0); }
}

.grid-cell img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
}

.generating-overlay {
    position: absolute;
    top: 0; left: 0; right: 0; bottom: 0;
    display: flex;
    flex-direction: column;
    gap: 1rem;
    justify-content: center;
    align-items: center;
    background: rgba(255, 255, 255, 0.85);
    backdrop-filter: blur(2px);
    font-size: 1.5rem;
    font-weight: bold;
    color: var(--bs-primary);
    z-index: 10;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.3s;
    border-radius: 4px;
}

.generating-overlay.active {
    opacity: 1;
    pointer-events: all;
}

/* Modal Customization */
.card-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(90px, 1fr));
    gap: var(--spacing-sm);
}

.select-card-item {
    cursor: pointer;
    border: 2px solid transparent;
    border-radius: 8px;
    padding: 4px;
    position: relative;
    background: white;
    box-shadow: 0 2px 4px rgba(0,0,0,0.05);
    transition: all 0.2s;
}

.select-card-item:hover {
    border-color: var(--bs-primary);
    transform: translateY(-2px);
    box-shadow: 0 4px 8px rgba(0,0,0,0.1);
}

.select-card-item.on-board {
    background-color: rgba(24, 188, 156, 0.1); /* Flatly Success transparent */
    border-color: var(--bs-success);
    opacity: 0.9;
}

.select-card-item.on-board::after {
    content: "✅";
    position: absolute;
    top: -8px;
    right: -8px;
    font-size: 1.2rem;
    background: white;
    border-radius: 50%;
    box-shadow: 0 2px 4px rgba(0,0,0,0.15);
    padding: 2px;
    border: 1px solid var(--bs-success);
}

.select-card-item img {
    width: 100%;
    display: block;
    border-radius: 4px;
}

.select-card-item p {
    font-size: 0.75rem;
    text-align: center;
    margin-top: 4px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    font-weight: 500;
    margin-bottom: 0;
}

/* Code Display */
.code-display code {
    background: var(--bs-light);
    color: var(--bs-primary);
    padding: 0.4rem 0.8rem;
    border-radius: 6px;
    font-family: monospace;
    font-size: 1.3rem;
    font-weight: bold;
    letter-spacing: 1px;
    border: 1px dashed var(--bs-secondary);
}

/* Hover Effects for Feature Cards */
.feature-card, .card {
    transition: transform 0.3s ease, box-shadow 0.3s ease;
}

.feature-card:hover, .card:hover {
    transform: translateY(-5px);
    box-shadow: 0 10px 20px rgba(0,0,0,0.15) !important;
}

/* Mock Ad Styles */
.mock-ad {
    display: none !important; /* Hidden for production/verification. Change to flex to visualize. */
    background-color: #f8f9fa;
    border: 2px dashed #dee2e6;
    color: #adb5bd;
    padding: 20px;
    text-align: center;
    margin: 2rem auto;
    width: 100%;
    /* display: flex; Combined with !important above, this won't show, but let's comment it out to be safe/clear */
    /* align-items: center; */
    /* justify-content: center; */
    min-height: 100px;
}

.mock-ad::before {
    content: "Advertisement";
    font-weight: bold;
    text-transform: uppercase;
    font-size: 0.8rem;
    letter-spacing: 1px;
}

/* Responsive Adjustments */
@media (max-width: 768px) {
    .board-wrapper {
        max-width: 100%;
        border-width: 2px;
        padding: 5px;
    }

    .tableta-board {
        gap: 5px;
    }

    .grid-cell {
        border-radius: 1px;
    }

    .card-grid {
        grid-template-columns: repeat(auto-fill, minmax(70px, 1fr));
    }
}
