/* ============================================================
   ImgHost — Premium Cream & White Light Theme
   ============================================================ */

:root {
    --bg-primary: #faf7f2;
    --bg-secondary: #ffffff;
    --bg-card: rgba(255, 255, 255, 0.85);
    --bg-card-hover: rgba(255, 255, 255, 0.95);
    --glass-border: rgba(212, 203, 190, 0.5);
    --glass-shadow: 0 10px 30px rgba(160, 140, 115, 0.08);
    --accent: #6366f1;
    --accent-glow: rgba(99, 102, 241, 0.2);
    --accent-light: #818cf8;
    --accent-gradient: linear-gradient(135deg, #6366f1, #4338ca);
    --text-primary: #1c1917;
    --text-secondary: #57534e;
    --text-muted: #8c857b;
    --danger: #ef4444;
    --danger-hover: #dc2626;
    --success: #10b981;
    --border-radius: 16px;
    --border-radius-sm: 12px;
    --border-radius-xs: 8px;
    --transition: 0.25s cubic-bezier(0.4, 0, 0.2, 1);
    --font: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
}

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

html { font-size: 16px; scroll-behavior: smooth; }

body {
    font-family: var(--font);
    background: var(--bg-primary);
    color: var(--text-primary);
    min-height: 100vh;
    line-height: 1.6;
    -webkit-font-smoothing: antialiased;
}

/* Subtly warm background highlights */
body::before {
    content: '';
    position: fixed;
    inset: 0;
    background:
        radial-gradient(ellipse at 15% 15%, rgba(245, 237, 224, 0.8) 0%, transparent 60%),
        radial-gradient(ellipse at 85% 85%, rgba(238, 228, 213, 0.6) 0%, transparent 60%);
    pointer-events: none;
    z-index: 0;
}

/* ---- Card Styling ---- */
.glass-card {
    background: var(--bg-card);
    border: 1px solid var(--glass-border);
    border-radius: var(--border-radius);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    box-shadow: var(--glass-shadow);
    transition: all var(--transition);
}

.glass-card:hover {
    border-color: rgba(99, 102, 241, 0.3);
    box-shadow: 0 14px 40px rgba(160, 140, 115, 0.12);
}

/* ---- Header ---- */
.header {
    position: sticky;
    top: 0;
    z-index: 100;
    background: rgba(250, 247, 242, 0.9);
    backdrop-filter: blur(16px);
    border-bottom: 1px solid var(--glass-border);
    padding: 0 2rem;
}

.header-inner {
    max-width: 1200px;
    margin: 0 auto;
    display: flex;
    align-items: center;
    justify-content: space-between;
    height: 68px;
}

.logo {
    display: flex;
    align-items: center;
    gap: 0.6rem;
    text-decoration: none;
    color: var(--text-primary);
    font-weight: 700;
    font-size: 1.3rem;
}

.logo-icon { font-size: 1.6rem; }

.nav-tag {
    font-size: 0.82rem;
    color: var(--text-secondary);
    padding: 6px 14px;
    background: rgba(255, 255, 255, 0.8);
    border: 1px solid var(--glass-border);
    border-radius: 999px;
    font-weight: 500;
}

.nav-back {
    color: var(--accent);
    text-decoration: none;
    font-size: 0.9rem;
    font-weight: 600;
    transition: color var(--transition);
}
.nav-back:hover { color: #4338ca; }

/* ---- Main ---- */
.main {
    position: relative;
    z-index: 1;
    max-width: 1200px;
    margin: 0 auto;
    padding: 2.5rem 2rem;
}

/* ---- Hero ---- */
.hero {
    text-align: center;
    padding: 2rem 0 2.5rem;
}

.hero-title {
    font-size: clamp(2.2rem, 5vw, 3.4rem);
    font-weight: 800;
    letter-spacing: -0.03em;
    color: #1c1917;
    margin-bottom: 0.75rem;
}

.gradient-text {
    background: var(--accent-gradient);
    -webkit-background-clip: text;
    background-clip: text;
    -webkit-text-fill-color: transparent;
}

.hero-subtitle {
    color: var(--text-secondary);
    font-size: 1.1rem;
    max-width: 520px;
    margin: 0 auto 2rem;
}

/* ---- Dropzone ---- */
.dropzone {
    max-width: 620px;
    margin: 0 auto;
    border: 2px dashed rgba(99, 102, 241, 0.35);
    border-radius: var(--border-radius);
    padding: 3.5rem 2rem;
    cursor: pointer;
    transition: all var(--transition);
    background: rgba(255, 255, 255, 0.7);
    box-shadow: 0 8px 30px rgba(212, 203, 190, 0.15);
    position: relative;
}

.dropzone:hover, .dropzone.dragover {
    border-color: var(--accent);
    background: rgba(255, 255, 255, 0.95);
    box-shadow: 0 0 35px var(--accent-glow);
}

.dropzone-content { text-align: center; }

.dropzone-icon {
    color: var(--accent);
    margin-bottom: 1rem;
    animation: float 3s ease-in-out infinite;
}

@keyframes float {
    0%, 100% { transform: translateY(0); }
    50% { transform: translateY(-8px); }
}

.dropzone-label {
    color: var(--text-secondary);
    font-size: 1.05rem;
}

.dropzone-browse {
    color: var(--accent);
    cursor: pointer;
    font-weight: 600;
    text-decoration: underline;
    text-underline-offset: 3px;
}

/* ---- Progress Bar ---- */
.dropzone-progress { padding: 1rem 0; }

.progress-bar {
    width: 100%;
    height: 8px;
    background: rgba(0,0,0,0.06);
    border-radius: 999px;
    overflow: hidden;
}

.progress-fill {
    height: 100%;
    width: 0%;
    background: var(--accent-gradient);
    border-radius: 999px;
    transition: width 0.3s ease;
}

.progress-text {
    color: var(--text-secondary);
    font-size: 0.9rem;
    margin-top: 0.5rem;
    text-align: center;
    font-weight: 500;
}

/* ---- Section Title ---- */
.section-title {
    font-size: 1.6rem;
    font-weight: 700;
    color: #1c1917;
    margin: 3.5rem 0 1.5rem;
    text-align: center;
}

/* ---- Upload Results ---- */
.results-list {
    display: flex;
    flex-direction: column;
    gap: 1.5rem;
}

.result-card {
    display: flex;
    gap: 1.5rem;
    padding: 1.75rem;
    animation: fadeInUp 0.4s ease;
}

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

.result-preview {
    flex: 0 0 200px;
    border-radius: var(--border-radius-sm);
    overflow: hidden;
    background: #f0ebe1;
    border: 1px solid var(--glass-border);
}

.result-img {
    width: 100%;
    height: 150px;
    object-fit: cover;
    display: block;
}

.result-info { flex: 1; min-width: 0; }

.result-name {
    font-size: 1.1rem;
    font-weight: 700;
    color: #1c1917;
    margin-bottom: 0.25rem;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.result-meta {
    display: flex;
    gap: 1rem;
    margin-bottom: 1.25rem;
}

.meta-item {
    font-size: 0.85rem;
    color: var(--text-muted);
    font-weight: 500;
}

/* ---- Link Groups ---- */
.result-links, .viewer-links {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 0.85rem;
}

.link-group label {
    display: block;
    font-size: 0.75rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: var(--text-muted);
    margin-bottom: 0.3rem;
}

.copy-row {
    display: flex;
    gap: 0;
}

.link-input {
    flex: 1;
    min-width: 0;
    background: #ffffff;
    border: 1px solid var(--glass-border);
    border-right: none;
    border-radius: var(--border-radius-xs) 0 0 var(--border-radius-xs);
    color: var(--text-primary);
    font-family: var(--font);
    font-size: 0.85rem;
    padding: 0.55rem 0.75rem;
    outline: none;
    transition: border-color var(--transition);
}

.link-input:focus { border-color: var(--accent); }

.copy-btn {
    padding: 0.55rem 0.9rem;
    background: var(--accent);
    color: #fff;
    border: none;
    border-radius: 0 var(--border-radius-xs) var(--border-radius-xs) 0;
    font-family: var(--font);
    font-size: 0.82rem;
    font-weight: 600;
    cursor: pointer;
    white-space: nowrap;
    transition: background var(--transition);
}

.copy-btn:hover { background: #4338ca; }
.copy-btn.copied {
    background: var(--success);
}

/* ---- Delete Token ---- */
.result-delete {
    margin-top: 1rem;
    font-size: 0.82rem;
    color: var(--text-muted);
}
.delete-token-code {
    background: #fee2e2;
    color: #b91c1c;
    padding: 3px 8px;
    border-radius: 6px;
    font-size: 0.78rem;
    font-weight: 600;
    word-break: break-all;
}

/* ---- Gallery Grid ---- */
.gallery-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
    gap: 1.25rem;
}

.gallery-item {
    position: relative;
    border-radius: var(--border-radius-sm);
    overflow: hidden;
    background: #ffffff;
    border: 1px solid var(--glass-border);
    box-shadow: 0 4px 16px rgba(160, 140, 115, 0.06);
    cursor: pointer;
    transition: all var(--transition);
    text-decoration: none;
}

.gallery-item:hover {
    transform: translateY(-5px);
    box-shadow: 0 16px 36px rgba(160, 140, 115, 0.15);
    border-color: rgba(99, 102, 241, 0.4);
}

.gallery-thumb {
    width: 100%;
    height: 180px;
    object-fit: cover;
    display: block;
}

.gallery-overlay {
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    padding: 0.6rem 0.85rem;
    background: linear-gradient(transparent, rgba(28, 25, 23, 0.85));
    display: flex;
    justify-content: space-between;
    align-items: flex-end;
}

.gallery-name {
    color: #ffffff;
    font-size: 0.8rem;
    font-weight: 600;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 140px;
}

.gallery-views {
    color: rgba(255,255,255,0.85);
    font-size: 0.75rem;
    font-weight: 500;
}

.gallery-empty {
    text-align: center;
    color: var(--text-muted);
    padding: 4rem 0;
    font-size: 1.05rem;
}

/* ---- Viewer Page ---- */
.viewer-main { padding-top: 2rem; }

.viewer-content {
    display: grid;
    grid-template-columns: 1fr 400px;
    gap: 2rem;
    align-items: start;
}

.viewer-image-wrapper {
    padding: 1.5rem;
    text-align: center;
    min-height: 350px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: #ffffff;
}

.viewer-img {
    max-width: 100%;
    max-height: 70vh;
    border-radius: var(--border-radius-sm);
    object-fit: contain;
    box-shadow: 0 10px 30px rgba(0,0,0,0.08);
}

.viewer-details { padding: 1.75rem; background: #ffffff; }

.viewer-name {
    font-size: 1.25rem;
    font-weight: 700;
    color: #1c1917;
    margin-bottom: 1.5rem;
    word-break: break-word;
}

.viewer-stats {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 0.85rem;
    margin-bottom: 1.75rem;
}

.stat-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 0.85rem;
    background: #faf7f2;
    border-radius: var(--border-radius-sm);
    border: 1px solid var(--glass-border);
}

.stat-icon { font-size: 1.3rem; margin-bottom: 0.25rem; }
.stat-value { font-size: 1rem; font-weight: 700; color: var(--text-primary); }
.stat-label { font-size: 0.72rem; color: var(--text-muted); text-transform: uppercase; letter-spacing: 0.05em; font-weight: 600; }

.viewer-links {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
    margin-bottom: 1.5rem;
}

.viewer-links .copy-row { display: flex; }

.viewer-actions {
    display: flex;
    gap: 0.85rem;
}

/* ---- Buttons ---- */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 0.7rem 1.4rem;
    border: none;
    border-radius: var(--border-radius-xs);
    font-family: var(--font);
    font-size: 0.9rem;
    font-weight: 600;
    cursor: pointer;
    text-decoration: none;
    transition: all var(--transition);
    flex: 1;
    text-align: center;
}

.btn-primary {
    background: var(--accent-gradient);
    color: #fff;
}
.btn-primary:hover { opacity: 0.92; box-shadow: 0 6px 24px var(--accent-glow); }

.btn-secondary {
    background: #f0ebe1;
    color: var(--text-primary);
    border: 1px solid var(--glass-border);
}
.btn-secondary:hover { background: #e6dfd3; }

.btn-danger {
    background: var(--danger);
    color: #fff;
}
.btn-danger:hover { background: var(--danger-hover); }

/* ---- Modal ---- */
.modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(28, 25, 23, 0.4);
    backdrop-filter: blur(6px);
    z-index: 200;
    display: flex;
    align-items: center;
    justify-content: center;
    animation: fadeIn 0.2s ease;
}

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

.modal {
    width: 90%;
    max-width: 440px;
    padding: 2.25rem;
    background: #ffffff;
}

.modal h3 {
    font-size: 1.3rem;
    font-weight: 700;
    margin-bottom: 0.5rem;
}

.modal p {
    color: var(--text-secondary);
    font-size: 0.95rem;
    margin-bottom: 1.25rem;
}

.modal .link-input {
    width: 100%;
    border-right: 1px solid var(--glass-border);
    border-radius: var(--border-radius-xs);
    margin-bottom: 1.25rem;
}

.modal-actions {
    display: flex;
    gap: 0.85rem;
}

.delete-error {
    color: var(--danger);
    font-size: 0.88rem;
    margin-top: 0.85rem;
    font-weight: 500;
}

/* ---- Viewer Error ---- */
.viewer-error {
    text-align: center;
    padding: 5rem 2rem;
}
.viewer-error h2 { margin-bottom: 0.5rem; font-size: 1.8rem; }
.viewer-error p { color: var(--text-secondary); margin-bottom: 1.5rem; }
.viewer-error .btn { display: inline-flex; flex: unset; }

/* ---- Footer ---- */
.footer {
    text-align: center;
    padding: 2.5rem 2rem;
    color: var(--text-muted);
    font-size: 0.88rem;
    border-top: 1px solid var(--glass-border);
    margin-top: 5rem;
}

.footer-link {
    color: var(--accent);
    text-decoration: none;
    font-weight: 600;
}
.footer-link:hover { text-decoration: underline; }

/* ---- Responsive ---- */
@media (max-width: 900px) {
    .viewer-content {
        grid-template-columns: 1fr;
    }
    .result-card {
        flex-direction: column;
    }
    .result-preview { flex: unset; }
    .result-img { height: 220px; }
}

@media (max-width: 600px) {
    .main { padding: 1rem; }
    .result-links, .viewer-stats { grid-template-columns: 1fr; }
    .gallery-grid { grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); }
    .gallery-thumb { height: 130px; }
    .hero-title { font-size: 2rem; }
}
