/**
 * RESIZE-V4.CSS - Redesigned Image Resize Tool
 * Matches reference design exactly
 */

:root {
    /* Unified Color System - Professional Blue */
    --bg: #f8fafc;
    --bg-white: #ffffff;
    --text: #0f172a;
    --text-secondary: #475569;
    --text-muted: #94a3b8;
    --primary: #2563eb;
    --primary-hover: #1d4ed8;
    --primary-light: rgba(37, 99, 235, 0.08);
    --success: #16a34a;
    --border: #e2e8f0;
    --border-light: #f1f5f9;
    --font: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
    --radius: 10px;
    --radius-lg: 14px;
    --shadow: 0 2px 8px rgba(0,0,0,0.06);
}

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

html, body { height: 100%; }

body {
    font-family: var(--font);
    font-size: 15px;
    line-height: 1.5;
    color: var(--text);
    background: var(--bg);
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

a { color: inherit; text-decoration: none; }
button { font: inherit; cursor: pointer; border: none; background: none; }
input, select { font: inherit; }
img, svg { display: block; max-width: 100%; }

.container { width: 100%; max-width: 1100px; margin: 0 auto; padding: 0 20px; }

/* Header */
.header {
    background: var(--bg-white);
    border-bottom: 1px solid var(--border);
    padding: 14px 0;
    position: sticky;
    top: 0;
    z-index: 100;
}

.header__inner { display: flex; align-items: center; justify-content: space-between; }
.back-btn { display: flex; align-items: center; justify-content: center; width: 40px; height: 40px; background: #f5f5f5; border-radius: 10px; color: #333; margin-right: 12px; transition: all 0.2s; text-decoration: none; }
.back-btn:hover { background: var(--primary); color: white; }
.back-btn svg { width: 20px; height: 20px; }
.logo { display: flex; align-items: center; gap: 10px; font-size: 18px; font-weight: 700; }
.logo__icon { width: 28px; height: 28px; color: var(--primary); }
.nav { display: flex; gap: 4px; }
.nav__link { padding: 8px 14px; font-size: 14px; font-weight: 500; color: var(--text-secondary); border-radius: 6px; transition: all 0.2s; }
.nav__link:hover { color: var(--text); background: var(--bg); }
.nav__link--active { color: var(--primary); background: var(--primary-light); }

/* Pages */
.page { display: none !important; flex: 1; }
.page.active { display: flex !important; align-items: center; justify-content: center; }

/* Upload Page */
#page-upload { background: linear-gradient(180deg, var(--bg) 0%, var(--bg-white) 100%); }

.upload-box {
    text-align: center;
    padding: 60px 20px;
    max-width: 580px;
    margin: 0 auto;
}

.upload-title { font-size: 40px; font-weight: 700; margin-bottom: 16px; }
.upload-desc { font-size: 17px; color: var(--text-secondary); line-height: 1.7; margin-bottom: 40px; }
.upload-desc .highlight { color: var(--primary); font-weight: 500; }

.dropzone { display: flex; flex-direction: column; align-items: center; }

.upload-btn {
    display: inline-flex;
    padding: 18px 48px;
    font-size: 17px;
    font-weight: 600;
    color: white;
    background: var(--primary);
    border-radius: var(--radius-lg);
    cursor: pointer;
    transition: all 0.2s;
    box-shadow: 0 4px 14px rgba(74, 144, 217, 0.35);
}

.upload-btn:hover { background: var(--primary-hover); transform: translateY(-2px); }
.upload-hint { margin-top: 16px; font-size: 14px; color: var(--text-muted); }

/* Editor Page */
#page-editor.active { display: flex !important; align-items: stretch; justify-content: stretch; }

.editor {
    display: flex;
    width: 100%;
    max-width: 960px;
    margin: 20px auto;
    background: var(--bg-white);
    border-radius: var(--radius-lg);
    box-shadow: 0 4px 20px rgba(0,0,0,0.08);
    overflow: hidden;
    max-height: calc(100vh - 100px);
}

/* Preview Area */
.editor__preview {
    flex: 1;
    display: flex;
    flex-direction: column;
    padding: 20px;
    background: var(--bg);
    min-width: 0;
}

.preview-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 16px;
}

.add-more-btn {
    display: inline-flex;
    align-items: center;
    padding: 8px 16px;
    font-size: 13px;
    font-weight: 500;
    color: var(--primary);
    background: var(--primary-light);
    border-radius: var(--radius);
    cursor: pointer;
    transition: all 0.2s;
}

.add-more-btn:hover { background: rgba(74, 144, 217, 0.2); }

.image-counter {
    font-size: 13px;
    color: var(--text-muted);
}

.preview-area {
    display: flex;
    flex-wrap: wrap;
    gap: 12px;
    justify-content: center;
    align-content: flex-start;
    background: var(--bg-white);
    border-radius: var(--radius);
    padding: 16px;
    max-height: 280px;
    overflow-y: auto;
}

.img-thumb {
    position: relative;
    width: 110px;
    background: #fafafa;
    border: 1px solid var(--border);
    border-radius: 8px;
    overflow: hidden;
}

.img-thumb img {
    width: 100%;
    aspect-ratio: 1;
    object-fit: contain;
}

.img-remove {
    position: absolute;
    top: 4px;
    right: 4px;
    width: 22px;
    height: 22px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(0,0,0,0.6);
    border-radius: 50%;
    color: white;
    font-size: 16px;
    line-height: 1;
    opacity: 0;
    transition: opacity 0.2s;
    cursor: pointer;
    border: none;
}

.img-thumb:hover .img-remove { opacity: 1; }

.image-nav {
    display: none;
    align-items: center;
    justify-content: center;
    gap: 16px;
    margin-top: 16px;
}

.image-nav.visible { display: flex; }

.nav-arrow {
    width: 36px;
    height: 36px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--bg-white);
    border: 1px solid var(--border);
    border-radius: 50%;
    color: var(--text-secondary);
    transition: all 0.2s;
}

.nav-arrow:hover:not(:disabled) { border-color: var(--primary); color: var(--primary); }
.nav-arrow:disabled { opacity: 0.4; cursor: not-allowed; }
.nav-arrow svg { width: 18px; height: 18px; }

.nav-info { font-size: 14px; color: var(--text-secondary); }

/* Settings Panel */
.editor__settings {
    width: 340px;
    flex-shrink: 0;
    padding: 24px;
    display: flex;
    flex-direction: column;
    overflow-y: auto;
}

.settings-title {
    font-size: 20px;
    font-weight: 700;
    text-align: center;
    margin-bottom: 28px;
    color: var(--text);
}

.settings-form {
    display: flex;
    flex-direction: column;
    gap: 20px;
}

/* Dimension Row */
.dimension-row {
    display: flex;
    align-items: flex-end;
    gap: 12px;
}

.dim-group {
    flex: 1;
}

.dim-group label,
.setting-row label,
.two-col-row label {
    display: block;
    font-size: 14px;
    font-weight: 500;
    color: var(--text-secondary);
    margin-bottom: 8px;
}

.dim-group input {
    width: 100%;
    padding: 14px 16px;
    font-size: 16px;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    background: var(--bg-white);
    transition: all 0.2s;
}

.dim-group input:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px var(--primary-light);
}

/* Lock Button */
.lock-btn {
    width: 40px;
    height: 40px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--primary);
    border-radius: 50%;
    color: white;
    margin-bottom: 4px;
    transition: all 0.2s;
}

.lock-btn:not(.active) {
    background: var(--border);
    color: var(--text-muted);
}

.lock-btn svg { width: 18px; height: 18px; }

/* Unit Select */
.unit-select {
    flex: 1;
    max-width: 140px;
}

.unit-select select {
    width: 100%;
    padding: 14px 36px 14px 16px;
    font-size: 15px;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    background: var(--bg-white);
    appearance: none;
    cursor: pointer;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%23666' stroke-width='2'%3E%3Cpath d='M6 9l6 6 6-6'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 12px center;
}

.unit-select select:focus {
    outline: none;
    border-color: var(--primary);
}

/* Setting Row */
.setting-row {
    display: flex;
    flex-direction: column;
}

.input-with-suffix {
    display: flex;
    align-items: center;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    overflow: hidden;
    background: var(--bg-white);
}

.input-with-suffix input {
    flex: 1;
    padding: 14px 16px;
    font-size: 16px;
    border: none;
    background: transparent;
}

.input-with-suffix input:focus { outline: none; }

.input-with-suffix .suffix {
    padding: 0 16px;
    font-size: 14px;
    color: var(--text-muted);
    background: var(--bg);
    height: 100%;
    display: flex;
    align-items: center;
    border-left: 1px solid var(--border);
}

/* Two Column Row */
.two-col-row {
    display: flex;
    gap: 16px;
    flex-wrap: wrap;
}

.two-col-row .col {
    flex: 1;
    min-width: 80px;
}

.two-col-row select {
    width: 100%;
    padding: 14px 36px 14px 16px;
    font-size: 15px;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    background: var(--bg-white);
    appearance: none;
    cursor: pointer;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%23666' stroke-width='2'%3E%3Cpath d='M6 9l6 6 6-6'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 12px center;
}

.two-col-row select:focus {
    outline: none;
    border-color: var(--primary);
}

/* Background Options */
.bg-options {
    display: flex;
    gap: 10px;
    padding-top: 6px;
}

.bg-btn {
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    border: 2px solid transparent;
    transition: all 0.2s;
}

.bg-btn.active { border-color: var(--primary); }

.bg-circle {
    width: 24px;
    height: 24px;
    border-radius: 50%;
    border: 2px solid var(--border);
}

.bg-circle.white { background: #ffffff; }
.bg-circle.black { background: #1a1a1a; border-color: #1a1a1a; }

/* Resize Button */
.resize-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    width: 100%;
    padding: 16px;
    margin-top: 8px;
    font-size: 16px;
    font-weight: 600;
    color: white;
    background: var(--primary);
    border-radius: var(--radius-lg);
    transition: all 0.2s;
    box-shadow: 0 4px 14px rgba(74, 144, 217, 0.35);
}

.resize-btn:hover { background: var(--primary-hover); transform: translateY(-1px); }
.resize-btn:disabled { opacity: 0.5; cursor: not-allowed; }
.resize-btn svg { width: 20px; height: 20px; }

.privacy-note {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    margin-top: 12px;
    font-size: 13px;
    color: var(--success);
}

.privacy-note svg { width: 14px; height: 14px; }

/* Download Page */
#page-download.active { display: flex !important; }

.download-box {
    text-align: center;
    padding: 40px 20px;
    max-width: 550px;
    margin: 0 auto;
    width: 100%;
}

.success-icon { width: 80px; height: 80px; margin: 0 auto 24px; color: var(--success); }
.success-icon svg { width: 100%; height: 100%; }

.download-title { font-size: 28px; font-weight: 700; margin-bottom: 8px; }
.download-info { font-size: 16px; color: var(--primary); font-weight: 500; margin-bottom: 24px; }

.results {
    margin-bottom: 24px;
    background: var(--bg-white);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    max-height: 200px;
    overflow-y: auto;
}

.result-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 16px;
    border-bottom: 1px solid var(--border-light);
    text-align: left;
}

.result-item:last-child { border-bottom: none; }
.result-thumb { width: 40px; height: 40px; object-fit: contain; background: #fafafa; border-radius: 4px; }
.result-info { flex: 1; }
.result-name { font-size: 13px; font-weight: 500; }
.result-dims { font-size: 11px; color: var(--text-muted); }
.result-dims span { color: var(--primary); font-weight: 500; }

.download-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    padding: 18px 40px;
    font-size: 16px;
    font-weight: 600;
    color: white;
    background: var(--success);
    border-radius: var(--radius-lg);
    transition: all 0.2s;
    margin-bottom: 24px;
}

.download-btn:hover { background: #16a34a; transform: translateY(-2px); }
.download-btn svg { width: 22px; height: 22px; }

/* Share */
.share-section { margin-bottom: 24px; padding: 20px; background: var(--bg); border-radius: var(--radius-lg); }
.share-label { font-size: 13px; color: var(--text-muted); margin-bottom: 12px; }
.share-buttons { display: flex; justify-content: center; gap: 10px; }

.share-btn {
    width: 44px;
    height: 44px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    transition: all 0.2s;
}

.share-btn svg { width: 20px; height: 20px; }
.share-btn--facebook { background: #1877f2; color: white; }
.share-btn--twitter { background: #1da1f2; color: white; }
.share-btn--whatsapp { background: #25d366; color: white; }
.share-btn--copy { background: var(--bg-white); border: 1px solid var(--border); color: var(--text-secondary); }
.share-btn:hover { transform: translateY(-2px); box-shadow: 0 4px 12px rgba(0,0,0,0.15); }

.more-actions { display: flex; align-items: center; justify-content: center; gap: 16px; }
.link-btn { font-size: 14px; font-weight: 500; color: var(--primary); }
.link-btn:hover { text-decoration: underline; }
.divider { color: var(--text-muted); }

/* Processing */
.processing {
    position: fixed;
    inset: 0;
    z-index: 200;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(255, 255, 255, 0.95);
    opacity: 0;
    visibility: hidden;
    transition: all 0.3s;
}

.processing.active { opacity: 1; visibility: visible; }
.processing__modal { text-align: center; }

.spinner {
    width: 48px;
    height: 48px;
    margin: 0 auto 20px;
    border: 3px solid var(--border);
    border-top-color: var(--primary);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}

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

.processing__modal p { font-size: 16px; color: var(--text-secondary); margin-bottom: 16px; }

.progress { width: 200px; height: 4px; background: var(--border); border-radius: 2px; overflow: hidden; }
.progress__bar { height: 100%; width: 0; background: var(--primary); transition: width 0.2s; }

/* Footer */
.footer {
    padding: 20px;
    text-align: center;
    font-size: 13px;
    color: var(--text-muted);
    border-top: 1px solid var(--border);
    background: var(--bg-white);
    margin-top: auto;
}

/* Responsive */
@media (max-width: 900px) {
    .editor {
        flex-direction: column;
        margin: 20px;
        max-height: none;
    }
    
    .editor__settings {
        width: 100%;
        max-height: none;
    }
    
    .nav { display: none; }
}

@media (max-width: 500px) {
    .upload-title { font-size: 28px; }
    .editor__settings { padding: 24px 20px; }
    .dimension-row { flex-wrap: wrap; }
    .unit-select { max-width: 100%; flex: 1 1 100%; margin-top: 12px; }
    .two-col-row .col { min-width: 100%; }
}

