/* ===== style.css (full, with new credit styles) ===== */

:root {
    --bg-color: #030303;
    --card-bg: rgba(15, 15, 15, 0.7);
    --text-main: #ffffff;
    --text-muted: #8e8e93;
    --border-color: rgba(255, 255, 255, 0.08);
    --accent-primary: #a855f7;
    --accent-secondary: #3b82f6;
    --glass-bg: rgba(255, 255, 255, 0.03);
    --shadow: 0 20px 40px rgba(0, 0, 0, 0.4);
}

[data-theme="light"] {
    --bg-color: #f8fafc;
    --card-bg: rgba(255, 255, 255, 0.8);
    --text-main: #0f172a;
    --text-muted: #64748b;
    --border-color: rgba(0, 0, 0, 0.1);
    --glass-bg: rgba(255, 255, 255, 0.5);
    --shadow: 0 10px 30px rgba(0, 0, 0, 0.05);
}

* { margin: 0; padding: 0; box-sizing: border-box; }

body {
    font-family: 'Plus Jakarta Sans', sans-serif;
    background-color: var(--bg-color);
    color: var(--text-main);
    transition: background-color 0.4s ease;
    min-height: 100vh;
}

.mesh-gradient {
    position: fixed;
    inset: 0;
    z-index: -2;
    background:
        radial-gradient(at 0% 0%, rgba(168, 85, 247, 0.05) 0, transparent 50%),
        radial-gradient(at 100% 100%, rgba(59, 130, 246, 0.05) 0, transparent 50%);
}
.glow-orb {
    position: fixed;
    border-radius: 50%;
    filter: blur(100px);
    z-index: -1;
    opacity: 0.15;
}
.orb-1 { width: 400px; height: 400px; background: var(--accent-primary); top: -100px; left: -100px; }
.orb-2 { width: 500px; height: 500px; background: var(--accent-secondary); bottom: -150px; right: -150px; }

.navbar {
    position: sticky;
    top: 0;
    z-index: 1000;
    background: var(--glass-bg);
    backdrop-filter: blur(20px);
    border-bottom: 1px solid var(--border-color);
}
.nav-container {
    max-width: 1600px;
    margin: 0 auto;
    padding: 0.6rem 1rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
}
.logo {
    display: flex;
    align-items: center;
    gap: 10px;
    font-weight: 700;
    font-size: 1.1rem;
}
.logo-wrapper {
    width: 30px;
    height: 30px;
    background: linear-gradient(135deg, var(--accent-primary), var(--accent-secondary));
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
}
.logo-icon { color: white; width: 16px; height: 16px; }
.logo-text small { font-size: 0.6rem; opacity: 0.7; vertical-align: super; }
.nav-btn {
    background: var(--glass-bg);
    border: 1px solid var(--border-color);
    color: var(--text-main);
    padding: 0.4rem 0.8rem;
    border-radius: 10px;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    gap: 6px;
    font-size: 0.85rem;
    transition: 0.2s;
}
.nav-btn:hover {
    background: var(--border-color);
}

.app-container {
    display: grid;
    grid-template-columns: 280px 1fr 340px;
    max-width: 1800px;
    margin: 0 auto;
}
.sidebar-history,
.sidebar-settings {
    padding: 2rem 1.5rem;
    height: calc(100vh - 60px);
    position: sticky;
    top: 60px;
    overflow-y: auto;
    border-right: 1px solid var(--border-color);
}
.sidebar-settings {
    border-right: none;
    border-left: 1px solid var(--border-color);
}
.sidebar-header h3 {
    font-size: 0.8rem;
    text-transform: uppercase;
    color: var(--text-muted);
    letter-spacing: 1px;
    margin-bottom: 1.5rem;
    display: flex;
    align-items: center;
    gap: 8px;
}
.history-list {
    display: flex;
    flex-direction: column;
    gap: 12px;
}
.history-item {
    width: 100%;
    aspect-ratio: 1;
    border-radius: 12px;
    overflow: hidden;
    border: 1px solid var(--border-color);
    cursor: pointer;
    transition: 0.3s;
}
.history-item:hover { border-color: var(--accent-primary); }
.history-item img { width: 100%; height: 100%; object-fit: cover; }

.main-content { padding: 2rem 1.5rem; }
.hero { text-align: center; margin-bottom: 3rem; }
.badge {
    display: inline-block;
    padding: 4px 12px;
    background: var(--glass-bg);
    border: 1px solid var(--border-color);
    border-radius: 20px;
    font-size: 0.7rem;
    color: var(--accent-primary);
    margin-bottom: 1rem;
}
.hero h1 { font-size: 3.5rem; font-weight: 800; margin-bottom: 1rem; }
.text-gradient {
    background: linear-gradient(to right, var(--accent-primary), var(--accent-secondary));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
}

.prompt-card {
    max-width: 850px;
    margin: 0 auto 5rem auto;
    background: var(--card-bg);
    border: 1px solid var(--accent-primary);
    border-radius: 24px;
    padding: 1.5rem;
    backdrop-filter: blur(25px);
    box-shadow: 0 30px 60px rgba(0, 0, 0, 0.5), 0 0 20px rgba(168, 85, 247, 0.1);
}
.input-wrapper textarea {
    width: 100%;
    height: 120px;
    background: transparent;
    border: none;
    color: var(--text-main);
    font-size: 1.1rem;
    resize: none;
    outline: none;
}
.prompt-footer {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-top: 1rem;
    padding-top: 1rem;
    border-top: 1px solid var(--border-color);
}
.prompt-tools { display: flex; gap: 10px; }
.tool-btn {
    background: var(--glass-bg);
    border: 1px solid var(--border-color);
    color: var(--text-muted);
    width: 38px;
    height: 38px;
    border-radius: 10px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: 0.3s;
}
.tool-btn:hover { background: var(--border-color); color: var(--text-main); }
.btn-primary-premium {
    background: linear-gradient(135deg, var(--accent-primary), var(--accent-secondary));
    color: white;
    border: none;
    padding: 0.8rem 2rem;
    border-radius: 14px;
    font-weight: 700;
    cursor: pointer;
    transition: 0.3s;
}
.btn-primary-premium:hover { transform: scale(1.02); opacity: 0.9; }
.btn-primary-premium:disabled { opacity: 0.5; cursor: not-allowed; transform: none; }

.setting-group { margin-bottom: 1.5rem; }
.setting-group label {
    font-size: 0.75rem;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 1px;
    margin-bottom: 0.6rem;
    display: flex;
    align-items: center;
    gap: 6px;
}
.premium-select,
.premium-input {
    width: 100%;
    background: var(--glass-bg);
    border: 1px solid var(--border-color);
    color: var(--text-main);
    padding: 0.7rem;
    border-radius: 10px;
    outline: none;
    font-size: 0.9rem;
}
.premium-select option { background: var(--bg-color); }
.ratio-grid,
.quality-selector,
.count-selector {
    display: grid;
    gap: 6px;
    background: var(--glass-bg);
    padding: 6px;
    border-radius: 12px;
    border: 1px solid var(--border-color);
}
.ratio-grid { grid-template-columns: repeat(3, 1fr); }
.quality-selector { grid-template-columns: repeat(3, 1fr); }
.count-selector { grid-template-columns: repeat(3, 1fr); }
.ratio-btn,
.quality-btn,
.count-btn {
    background: transparent;
    border: none;
    color: var(--text-muted);
    padding: 0.5rem;
    border-radius: 8px;
    cursor: pointer;
    font-size: 0.75rem;
    transition: 0.3s;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 4px;
}
.ratio-btn.active,
.quality-btn.active,
.count-btn.active {
    background: var(--accent-primary);
    color: white;
}
.settings-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 12px;
}

.section-header {
    display: flex;
    flex-direction: column;
    align-items: center;
    margin-bottom: 3rem;
}
.section-header h2 { font-size: 2.5rem; font-weight: 800; margin-bottom: 0.5rem; }
.section-header .divider {
    width: 80px;
    height: 5px;
    background: linear-gradient(to right, var(--accent-primary), var(--accent-secondary));
    border-radius: 10px;
}
.results-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
    gap: 2rem;
}
.result-card {
    background: var(--card-bg);
    border: 1px solid var(--border-color);
    border-radius: 20px;
    overflow: hidden;
    position: relative;
    transition: 0.4s;
}
.result-card:hover {
    transform: translateY(-8px);
    border-color: var(--accent-primary);
}
.result-card img { width: 100%; display: block; }
.result-overlay {
    position: absolute;
    inset: 0;
    background: linear-gradient(to top, rgba(0,0,0,0.7), transparent);
    display: flex;
    align-items: flex-end;
    justify-content: center;
    gap: 12px;
    padding-bottom: 1.5rem;
    opacity: 0;
    transition: 0.3s;
}
.result-card:hover .result-overlay { opacity: 1; }
.action-icon-btn {
    background: rgba(255,255,255,0.15);
    border: 1px solid rgba(255,255,255,0.2);
    color: white;
    width: 40px;
    height: 40px;
    border-radius: 50%;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: 0.2s;
}
.action-icon-btn:hover { background: rgba(255,255,255,0.3); transform: scale(1.1); }
.empty-state {
    text-align: center;
    padding: 4rem 0;
    color: var(--text-muted);
}
.empty-visual { font-size: 3rem; margin-bottom: 1rem; }

.site-footer {
    border-top: 1px solid var(--border-color);
    background: var(--glass-bg);
    backdrop-filter: blur(20px);
    margin-top: 4rem;
    padding: 2rem 1.5rem;
}
.footer-content {
    max-width: 1200px;
    margin: 0 auto;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 1.5rem;
}
.footer-brand {
    display: flex;
    align-items: center;
    gap: 10px;
    font-weight: 700;
    font-size: 1.1rem;
}
.footer-logo { width: 28px; height: 28px; }
.footer-title small { font-size: 0.6rem; opacity: 0.7; vertical-align: super; }
.footer-links {
    display: flex;
    gap: 2rem;
    flex-wrap: wrap;
    justify-content: center;
}
.footer-links a {
    color: var(--text-muted);
    text-decoration: none;
    font-size: 0.9rem;
    transition: 0.3s;
}
.footer-links a:hover { color: var(--accent-primary); }
.footer-bottom {
    text-align: center;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.5rem;
}
.footer-bottom p { color: var(--text-muted); font-size: 0.8rem; }
.github-link {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    color: var(--accent-primary);
    text-decoration: none;
    font-size: 0.85rem;
    font-weight: 600;
    transition: 0.3s;
}
.github-link:hover { opacity: 0.8; }

/* ----- New credit badge style ----- */
.footer-credit {
    margin-top: 0.5rem;
    font-size: 0.75rem;
    color: var(--text-muted);
    letter-spacing: 0.3px;
    border-top: 1px solid var(--border-color);
    padding-top: 0.8rem;
    width: 100%;
    max-width: 400px;
}
.footer-credit strong {
    color: var(--accent-primary);
    font-weight: 600;
    background: linear-gradient(135deg, var(--accent-primary), var(--accent-secondary));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.mobile-only { display: none; }
.desktop-only { display: block; }
.hidden { display: none; }
.btn-text {
    background: none;
    border: none;
    color: var(--text-muted);
    font-size: 0.75rem;
    cursor: pointer;
    transition: 0.3s;
}
.btn-text:hover { color: var(--accent-primary); }

.loader {
    width: 24px;
    height: 24px;
    border: 3px solid rgba(255,255,255,0.3);
    border-top-color: #fff;
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

#toast-container {
    position: fixed;
    bottom: 30px;
    right: 30px;
    z-index: 9999;
}
.toast {
    background: var(--card-bg);
    color: var(--text-main);
    padding: 1rem 1.5rem;
    border-radius: 15px;
    border-left: 4px solid var(--accent-primary);
    backdrop-filter: blur(20px);
    margin-top: 10px;
    animation: slideIn 0.3s ease;
}
@keyframes slideIn {
    from { transform: translateX(100%); opacity: 0; }
    to { transform: translateX(0); opacity: 1; }
}

.drawer-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.5);
    backdrop-filter: blur(4px);
    z-index: 1999;
    display: none;
}
.drawer-overlay.active { display: block; }

/* ============================================================ */
/* Mobile Bottom Sheet – fixed to bottom, with drag handle       */
/* ============================================================ */

@media (max-width: 1100px) {
    .app-container { grid-template-columns: 1fr; }
    .sidebar-history,
    .sidebar-settings { display: none; }
    .mobile-only { display: inline-flex; }

    .sidebar-settings.active {
        display: block !important;
        position: fixed;
        bottom: 0;
        left: 0;
        right: 0;
        top: auto;
        height: 50vh;
        z-index: 2000;
        background: var(--card-bg);
        backdrop-filter: blur(30px);
        border-radius: 30px 30px 0 0;
        border: 1px solid var(--border-color);
        border-bottom: none;
        padding: 0;
        animation: slideUpSheet 0.5s cubic-bezier(0.25, 1, 0.5, 1);
        overflow: hidden;
        transform: translateY(0);
    }

    .drag-handle {
        display: flex;
        justify-content: center;
        align-items: center;
        padding: 12px 0 4px 0;
        cursor: grab;
        user-select: none;
        touch-action: none;
    }
    .drag-handle:active { cursor: grabbing; }
    .drag-bar {
        display: block;
        width: 40px;
        height: 5px;
        background: var(--border-color);
        border-radius: 10px;
        transition: background 0.2s;
    }
    .drag-handle:hover .drag-bar {
        background: var(--text-muted);
    }

    .settings-header {
        display: flex;
        justify-content: space-between;
        align-items: center;
        padding: 0 1.5rem 1rem 1.5rem;
        border-bottom: 1px solid var(--border-color);
    }
    .settings-header .btn-close.desktop-only { display: none; }
    .settings-header h3 {
        font-size: 0.9rem;
        color: var(--text-muted);
        text-transform: uppercase;
        letter-spacing: 1px;
    }

    .settings-container {
        padding: 1.5rem;
        overflow-y: auto;
        -webkit-overflow-scrolling: touch;
        height: calc(50vh - 70px);
        scroll-behavior: smooth;
    }

    .ratio-grid { grid-template-columns: repeat(3, 1fr); }
}

@keyframes slideUpSheet {
    from { transform: translateY(100%); }
    to { transform: translateY(0); }
}

/* Info pages */
.info-page .hero { padding-top: 3rem; }
.info-page .info-card {
    max-width: 800px;
    margin: 0 auto 3rem auto;
    background: var(--card-bg);
    border: 1px solid var(--border-color);
    border-radius: 24px;
    padding: 2rem;
    backdrop-filter: blur(25px);
    box-shadow: var(--shadow);
}
.info-page .info-card h2 {
    font-size: 1.5rem;
    margin-bottom: 1rem;
    color: var(--accent-primary);
}
.info-page .info-card p {
    color: var(--text-muted);
    line-height: 1.7;
    margin-bottom: 1rem;
}
.info-page .info-card a {
    color: var(--accent-secondary);
    text-decoration: none;
}
.info-page .info-card a:hover { text-decoration: underline; }
.info-page .info-card ul {
    color: var(--text-muted);
    padding-left: 1.5rem;
    line-height: 1.8;
    margin-bottom: 1rem;
}
.info-page .info-card li { margin-bottom: 0.5rem; }
.info-page .back-link {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    color: var(--text-muted);
    text-decoration: none;
    font-size: 0.9rem;
    margin-bottom: 2rem;
    transition: 0.3s;
}
.info-page .back-link:hover { color: var(--accent-primary); }

@media (max-width: 600px) {
    .hero h1 { font-size: 2.2rem; }
    .prompt-card { padding: 1rem; margin: 0 10px 3rem 10px; }
    .footer-links { gap: 1rem; }
    .settings-container { padding: 1rem; }
}

/* ---- Delete confirmation modal ---- */
.modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.6);
    backdrop-filter: blur(6px);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 99999;
    animation: fadeIn 0.2s ease;
}

.modal-box {
    background: var(--card-bg);
    backdrop-filter: blur(30px);
    border: 1px solid var(--border-color);
    border-radius: 24px;
    padding: 2rem 2.5rem;
    max-width: 400px;
    width: 90%;
    box-shadow: var(--shadow);
    text-align: center;
}

.modal-box h3 {
    font-size: 1.3rem;
    margin-bottom: 0.75rem;
    color: var(--text-main);
}

.modal-box p {
    color: var(--text-muted);
    margin-bottom: 1.5rem;
    font-size: 0.95rem;
}

.modal-actions {
    display: flex;
    gap: 1rem;
    justify-content: center;
}

.modal-btn {
    padding: 0.6rem 1.8rem;
    border: none;
    border-radius: 12px;
    font-weight: 600;
    font-size: 0.9rem;
    cursor: pointer;
    transition: 0.2s;
}

.modal-btn.cancel-btn {
    background: var(--glass-bg);
    color: var(--text-muted);
    border: 1px solid var(--border-color);
}

.modal-btn.cancel-btn:hover {
    background: var(--border-color);
}

.modal-btn.confirm-btn {
    background: #ef4444;
    color: white;
}

.modal-btn.confirm-btn:hover {
    background: #dc2626;
}

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

/* ---- Delete button in overlay (trash icon) ---- */
.action-icon-btn.del-btn {
    background: rgba(239, 68, 68, 0.25);
    border-color: rgba(239, 68, 68, 0.4);
}

.action-icon-btn.del-btn:hover {
    background: rgba(239, 68, 68, 0.5);
    transform: scale(1.1);
}

/* ---- Credit badge (KivodeAI) - already added in footer, but ensure style exists ---- */
.footer-credit {
    margin-top: 0.5rem;
    font-size: 0.75rem;
    color: var(--text-muted);
    letter-spacing: 0.3px;
    border-top: 1px solid var(--border-color);
    padding-top: 0.8rem;
    width: 100%;
    max-width: 400px;
}
.footer-credit strong {
    color: var(--accent-primary);
    font-weight: 600;
    background: linear-gradient(135deg, var(--accent-primary), var(--accent-secondary));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

/* PWA Banner Animation */
@keyframes slideUpBanner {
    from {
        transform: translateX(-50%) translateY(100%);
        opacity: 0;
    }
    to {
        transform: translateX(-50%) translateY(0);
        opacity: 1;
    }
}

/* PWA Banner Button Hover */
#pwa-install-btn:hover {
    transform: scale(1.05);
    box-shadow: 0 6px 20px rgba(168, 85, 247, 0.4);
}

#pwa-close-btn:hover {
    background: var(--border-color);
    color: var(--text-main);
}

#pwa-update-btn:hover {
    transform: scale(1.05);
    opacity: 0.9;
}

/* Mobile responsive */
@media (max-width: 480px) {
    #pwa-banner {
        padding: 0.8rem 1rem;
        bottom: 16px;
        border-radius: 16px;
    }
    #pwa-banner .app-icon {
        width: 44px;
        height: 44px;
    }
    #pwa-banner .app-icon svg {
        width: 22px;
        height: 22px;
    }
    #pwa-banner .title {
        font-size: 0.9rem;
    }
    #pwa-banner .subtitle {
        font-size: 0.75rem;
    }
    #pwa-install-btn {
        padding: 0.4rem 1rem;
        font-size: 0.8rem;
    }
    #pwa-close-btn {
        width: 34px;
        height: 34px;
        font-size: 1rem;
    }
    #pwa-update {
        bottom: 80px;
        padding: 0.6rem 1rem;
        font-size: 0.8rem;
    }
}