/**
 * Main stylesheet for Instagram Poster Generator
 * Modern, clean design with smooth interactions
 */

/* ===== CSS Reset & Base ===== */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

/* ===== Fonts ===== */
@font-face {
    font-family: 'Exo 2';
    src: url('../assets/fonts/Exo2-Regular.ttf') format('truetype');
    font-weight: 400;
    font-style: normal;
}

@font-face {
    font-family: 'Exo 2';
    src: url('../assets/fonts/Exo2-Bold.ttf') format('truetype');
    font-weight: 700;
    font-style: normal;
}

@font-face {
    font-family: 'Exo 2';
    src: url('../assets/fonts/Exo2-ExtraBold.ttf') format('truetype');
    font-weight: 800;
    font-style: normal;
}

@font-face {
    font-family: 'Exo 2';
    src: url('../assets/fonts/Exo2-Black.ttf') format('truetype');
    font-weight: 900;
    font-style: normal;
}

body {
    font-family: 'Exo 2', -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Roboto', 'Oxygen',
        'Ubuntu', 'Cantarell', 'Fira Sans', 'Droid Sans', 'Helvetica Neue',
        sans-serif;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: #333;
    overflow: hidden;
}

/* ===== App Container ===== */
.app-container {
    height: 100vh;
    display: flex;
    flex-direction: column;
    background: #f8f9fa;
}

/* ===== Toolbar ===== */
.app-toolbar {
    position: fixed;
    bottom: 2.5rem;
    left: 50%;
    transform: translateX(-50%);
    background: rgba(255, 255, 255, 0.9);
    backdrop-filter: blur(10px);
    padding: 0.375rem 0.75rem;
    border-radius: 20px;
    display: flex;
    flex-direction: row;
    gap: 0.75rem;
    box-shadow: 0 12px 40px rgba(0, 0, 0, 0.2);
    z-index: 50;
    border: 1px solid rgba(255, 255, 255, 0.5);
}

.icon-btn {
    background: transparent;
    border: none;
    color: #667eea;
    width: 48px;
    height: 48px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.2s ease;
}

.icon-btn:hover {
    background: rgba(102, 126, 234, 0.1);
    transform: translateY(-2px);
    color: #764ba2;
}

.icon-btn:active {
    transform: translateY(0);
}

/* ===== Main Content ===== */
.main-content {
    display: flex;
    flex: 1;
    overflow: hidden;
}

/* ===== Template Overlay ===== */
.template-overlay {
    position: fixed;
    inset: 0;
    background: rgba(248, 249, 250, 0.95);
    backdrop-filter: blur(10px);
    z-index: 100;
    display: flex;
    justify-content: center;
    overflow-y: auto;
    padding: 2rem;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.3s ease;
}

.template-overlay.visible {
    opacity: 1;
    pointer-events: auto;
}

.overlay-content {
    max-width: 1200px;
    width: 100%;
}

.overlay-content h2 {
    font-size: 2rem;
    font-weight: 800;
    color: #333;
    margin-bottom: 2rem;
    text-align: center;
}

.template-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(100px, 1fr));
    gap: 1.5rem;
    padding-bottom: 2rem;
    align-items: start;
}

.template-card {
    background: white;
    border: 2px solid #e0e0e0;
    border-radius: 12px;
    overflow: hidden;
    cursor: pointer;
    transition: all 0.3s ease;
}

.template-card:hover {
    border-color: #667eea;
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(102, 126, 234, 0.2);
}

.template-card.active {
    border-color: #667eea;
    box-shadow: 0 4px 16px rgba(102, 126, 234, 0.3);
}

.template-preview {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    position: relative;
    overflow: hidden;
}

.preview-content {
    position: absolute;
    inset: 0;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    padding: 1rem;
}

.preview-logo {
    width: 30px;
    height: 30px;
    background: rgba(255, 255, 255, 0.3);
    border-radius: 50%;
    margin: 0 auto;
}

.preview-text {
    background: rgba(0, 0, 0, 0.6);
    color: white;
    padding: 0.75rem;
    font-size: 0.75rem;
    text-align: center;
    border-radius: 4px;
    font-style: italic;
}

.template-name {
    padding: 0.75rem;
    font-weight: 600;
    text-align: center;
    color: #333;
    font-size: 0.9rem;
}

/* ===== Canvas Area ===== */
.canvas-area {
    position: relative;
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    /* Center canvas vertically */
    padding: 0;
    /* Remove padding to maximize space */
    background: #f8f9fa;
    overflow: hidden;
    /* Prevent scrollbars on parent */
}

.canvas-container {
    background: white;
    border-radius: 12px;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.1);
    padding: 0;
    display: flex;
    justify-content: center;
    align-items: center;
    flex: 1;
    width: 100%;
    height: 100%;
}

#canvasWrapper {
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.15);
    border-radius: 8px;
    overflow: hidden;
    line-height: 0;
    /* Remove extra space below canvas */
}

.instructions {
    position: absolute;
    top: 2rem;
    left: 1rem;
    background: rgba(255, 255, 255, 0.9);
    backdrop-filter: blur(10px);
    border-radius: 12px;
    padding: 1.25rem 1.75rem;
    max-width: 450px;
    width: auto;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.1);
    z-index: 40;
    border: 1px solid rgba(255, 255, 255, 0.5);
    transition: all 0.3s ease;
}

.instructions.hidden {
    opacity: 0;
    pointer-events: none;
    transform: translateY(-10px);
}

.instructions .close-btn {
    position: absolute;
    top: 0.5rem;
    right: 0.75rem;
    background: none;
    border: none;
    font-size: 1.5rem;
    color: #999;
    cursor: pointer;
    line-height: 1;
    padding: 2px;
    transition: color 0.2s;
}

.instructions .close-btn:hover {
    color: #667eea;
}

.instructions p {
    font-weight: 700;
    margin-bottom: 0.5rem;
    color: #667eea;
    font-size: 0.95rem;
}

.instructions ul {
    list-style: none;
    padding: 0;
    display: flex;
    flex-wrap: wrap;
    gap: 0.75rem 1.5rem;
}

.instructions li {
    color: #666;
    font-size: 0.85rem;
    flex: 0 0 auto;
}

.instructions li::before {
    content: "✓ ";
    color: #667eea;
    font-weight: bold;
    margin-right: 0.5rem;
}

/* ===== Scrollbar Styling ===== */
.template-overlay::-webkit-scrollbar {
    width: 8px;
}

.template-overlay::-webkit-scrollbar-track {
    background: transparent;
}

.template-overlay::-webkit-scrollbar-thumb {
    background: #cbd5e0;
    border-radius: 4px;
}

.template-overlay::-webkit-scrollbar-thumb:hover {
    background: #a0aec0;
}

/* ===== Responsive Design ===== */
@media (max-width: 768px) {
    .canvas-area {
        padding: 0.25rem;
    }
}

/* ===== Animations ===== */
@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(10px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.template-card {
    animation: fadeIn 0.3s ease;
}

/* ===== Loading State ===== */
.loading {
    display: inline-block;
    width: 20px;
    height: 20px;
    border: 3px solid rgba(255, 255, 255, 0.3);
    border-radius: 50%;
    border-top-color: white;
    animation: spin 1s ease-in-out infinite;
}

@keyframes spin {
    to {
        transform: rotate(360deg);
    }
}