/* WeMories - Mobile-First Styles v2 */
:root {
    --primary: #d4a574;
    --primary-dark: #c4956a;
    --secondary: #8b7355;
    --accent: #f0e6d8;
    --background: #faf8f5;
    --text: #3d3226;
    --text-light: #6d6256;
    --white: #ffffff;
    --success: #7cb87c;
    --error: #e57373;
    --shadow: 0 4px 20px rgba(0,0,0,0.08);
    --radius: 16px;
    --radius-sm: 8px;
}

* { margin: 0; padding: 0; box-sizing: border-box; }
html, body { height: 100%; }

body {
    font-family: 'Lato', sans-serif;
    background: var(--background);
    color: var(--text);
    line-height: 1.6;
    -webkit-tap-highlight-color: transparent;
    overflow-x: hidden;
}

.container {
    max-width: 520px;
    margin: 0 auto;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    padding: 16px;
    padding-bottom: 100px;
}

/* Header */
.header {
    text-align: center;
    padding: 16px 0 20px;
}

.logo {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
}

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

.logo h1 {
    font-family: 'Playfair Display', serif;
    font-size: 2.2rem;
    font-weight: 600;
    color: var(--primary);
    letter-spacing: 2px;
}

.subtitle {
    font-size: 0.95rem;
    color: var(--text-light);
    margin-top: 6px;
    font-weight: 300;
}

/* Name Section */
.name-section { margin-bottom: 16px; }

.name-section label {
    display: block;
    font-size: 0.85rem;
    color: var(--text-light);
    margin-bottom: 6px;
}

.name-section input {
    width: 100%;
    padding: 12px 16px;
    border: 2px solid var(--accent);
    border-radius: var(--radius);
    font-size: 1rem;
    font-family: inherit;
    background: var(--white);
    transition: border-color 0.3s, box-shadow 0.3s;
}

.name-section input:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 4px rgba(212, 165, 116, 0.2);
}

/* Info Box */
.info-box {
    display: flex;
    align-items: flex-start;
    gap: 10px;
    background: linear-gradient(135deg, rgba(212, 165, 116, 0.15), rgba(212, 165, 116, 0.05));
    border: 1px solid rgba(212, 165, 116, 0.3);
    border-radius: var(--radius);
    padding: 12px 14px;
    margin-bottom: 20px;
}

.info-icon { font-size: 1.2rem; }
.info-box p { font-size: 0.85rem; color: var(--text); }

/* Memory Builder */
.memory-builder {
    display: flex;
    flex-direction: column;
    gap: 16px;
    flex: 1;
}

/* Memory Sections */
.memory-section {
    background: var(--white);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    overflow: hidden;
}

.section-header {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 12px 16px;
    background: var(--accent);
    cursor: pointer;
}

.section-icon { font-size: 1.3rem; }

.section-header h3 {
    flex: 1;
    font-size: 1rem;
    font-weight: 600;
    color: var(--text);
}

.section-status {
    font-size: 0.85rem;
    color: var(--success);
    font-weight: 600;
}

.section-status.active {
    background: var(--success);
    color: white;
    padding: 2px 8px;
    border-radius: 10px;
}

.section-content {
    padding: 14px;
}

/* Compact Upload Area */
.upload-area.compact {
    padding: 20px;
    border: 2px dashed var(--accent);
    border-radius: var(--radius-sm);
    text-align: center;
    cursor: pointer;
    transition: all 0.3s;
}

.upload-area.compact:hover,
.upload-area.compact.dragover {
    border-color: var(--primary);
    background: rgba(212, 165, 116, 0.05);
}

.upload-area.compact.has-content {
    padding: 12px;
    border-style: solid;
    border-color: var(--primary);
    background: rgba(212, 165, 116, 0.1);
}

.upload-area.compact p {
    color: var(--text-light);
    font-size: 0.9rem;
    margin: 0;
}

/* Photo Previews */
.photo-previews {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    margin-top: 12px;
}

.photo-thumb {
    position: relative;
    width: 80px;
    height: 80px;
    border-radius: var(--radius-sm);
    overflow: hidden;
    box-shadow: var(--shadow);
}

.photo-thumb img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.btn-remove-photo {
    position: absolute;
    top: 4px;
    right: 4px;
    width: 22px;
    height: 22px;
    border: none;
    background: rgba(0,0,0,0.6);
    color: white;
    border-radius: 50%;
    font-size: 12px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
}

/* Text Area */
.text-area-container {
    position: relative;
}

#text-message {
    width: 100%;
    min-height: 100px;
    padding: 14px;
    border: 2px solid var(--accent);
    border-radius: var(--radius-sm);
    font-size: 1rem;
    font-family: inherit;
    resize: vertical;
    background: var(--background);
    transition: border-color 0.3s, box-shadow 0.3s;
}

#text-message:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 4px rgba(212, 165, 116, 0.2);
}

.char-count {
    position: absolute;
    bottom: 8px;
    right: 12px;
    font-size: 0.75rem;
    color: var(--text-light);
}

/* Audio Recorder */
.audio-recorder.compact {
    text-align: center;
    padding: 16px;
}

.recording-indicator {
    display: none;
    align-items: center;
    justify-content: center;
    gap: 10px;
    margin-bottom: 12px;
}

.recording-indicator.active { display: flex; }

.pulse {
    width: 10px;
    height: 10px;
    background: var(--error);
    border-radius: 50%;
    animation: pulse 1s infinite;
}

@keyframes pulse {
    0%, 100% { transform: scale(1); opacity: 1; }
    50% { transform: scale(1.3); opacity: 0.7; }
}

#recording-time {
    font-size: 1.2rem;
    font-weight: 600;
    font-family: monospace;
}

.btn-record {
    width: 70px;
    height: 70px;
    border-radius: 50%;
    border: 3px solid var(--primary);
    background: var(--white);
    cursor: pointer;
    transition: all 0.3s;
    display: flex;
    align-items: center;
    justify-content: center;
    margin: 0 auto;
}

.btn-record:hover { background: var(--accent); transform: scale(1.05); }

.btn-record.recording {
    background: var(--error);
    border-color: var(--error);
    animation: recordPulse 1s infinite;
}

@keyframes recordPulse {
    0%, 100% { box-shadow: 0 0 0 0 rgba(229, 115, 115, 0.4); }
    50% { box-shadow: 0 0 0 15px rgba(229, 115, 115, 0); }
}

.record-icon { font-size: 1.8rem; }
.record-hint { margin-top: 10px; color: var(--text-light); font-size: 0.85rem; }

/* Audio Preview */
.audio-preview {
    margin-top: 12px;
    padding: 12px;
    background: var(--background);
    border-radius: var(--radius-sm);
}

#audio-player { width: 100%; height: 40px; }

.btn-small {
    padding: 6px 12px;
    font-size: 0.8rem;
    border: none;
    border-radius: var(--radius-sm);
    cursor: pointer;
    margin-top: 8px;
}

.btn-remove {
    background: var(--error);
    color: white;
}

/* Submit Section */
.submit-section {
    margin-top: 20px;
    text-align: center;
}

.btn {
    width: 100%;
    padding: 14px 24px;
    border: none;
    border-radius: var(--radius);
    font-size: 1rem;
    font-weight: 600;
    font-family: inherit;
    cursor: pointer;
    transition: all 0.3s;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
}

.btn-large { padding: 18px 24px; font-size: 1.1rem; }

.btn-primary {
    background: var(--primary);
    color: var(--white);
    box-shadow: 0 4px 15px rgba(212, 165, 116, 0.4);
}

.btn-primary:hover:not(:disabled) {
    background: var(--primary-dark);
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(212, 165, 116, 0.5);
}

.btn-primary:disabled {
    opacity: 0.4;
    cursor: not-allowed;
    transform: none;
}

.btn-icon { font-size: 1.2rem; }

.submit-hint {
    margin-top: 10px;
    font-size: 0.85rem;
    color: var(--text-light);
}

.submit-hint.ready {
    color: var(--success);
    font-weight: 600;
}

/* Modal */
.modal {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.5);
    align-items: center;
    justify-content: center;
    padding: 20px;
    z-index: 1000;
}

.modal.active { display: flex; }

.modal-content {
    background: var(--white);
    border-radius: var(--radius);
    padding: 36px 28px;
    text-align: center;
    max-width: 340px;
    width: 100%;
    animation: modalIn 0.3s ease;
}

@keyframes modalIn {
    from { opacity: 0; transform: scale(0.9); }
    to { opacity: 1; transform: scale(1); }
}

.success-icon { font-size: 3.5rem; margin-bottom: 14px; }

.modal-content h2 {
    font-family: 'Playfair Display', serif;
    color: var(--primary);
    margin-bottom: 8px;
}

.modal-content p { color: var(--text-light); margin-bottom: 20px; }

/* Loading */
.loading-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(255,255,255,0.95);
    align-items: center;
    justify-content: center;
    flex-direction: column;
    gap: 16px;
    z-index: 1001;
}

.loading-overlay.active { display: flex; }

.spinner {
    width: 44px;
    height: 44px;
    border: 4px solid var(--accent);
    border-top-color: var(--primary);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}

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

#loading-text { color: var(--text); font-size: 0.95rem; }

/* Stats Bar */
.stats-bar {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    background: var(--white);
    padding: 14px;
    text-align: center;
    box-shadow: 0 -4px 20px rgba(0,0,0,0.08);
}

.gallery-link {
    color: var(--text);
    text-decoration: none;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    font-weight: 500;
}

.gallery-link:hover { color: var(--primary); }
.gallery-link .arrow { transition: transform 0.3s; }
.gallery-link:hover .arrow { transform: translateX(4px); }
#total-memories { font-weight: 700; color: var(--primary); }

/* Back link */
.back-link {
    position: absolute;
    left: 20px;
    color: var(--text);
    text-decoration: none;
    font-size: 0.9rem;
}

.back-link:hover { color: var(--primary); }
.gallery-container .header { position: relative; }

/* Responsive */
@media (max-width: 360px) {
    .container { padding: 12px; }
    .logo h1 { font-size: 1.8rem; }
    .photo-thumb { width: 60px; height: 60px; }
}
