/* ============ FONT IMPORTS ============ */
@import url('https://fonts.googleapis.com/css2?family=Cormorant+Garamond:ital,wght@0,400;0,600;0,700;1,400&family=Nunito:wght@400;500;600;700&family=Libre+Baskerville:ital,wght@0,400;0,700;1,400&family=Karla:wght@400;500;600;700&family=Bebas+Neue&family=Sora:wght@400;500;600;700&family=Righteous&family=Outfit:wght@400;500;600;700&family=Playfair+Display:ital,wght@0,700;0,900;1,400&family=DM+Sans:wght@400;500;600;700&family=Fraunces:ital,wght@0,700;0,900;1,400&family=Nunito+Sans:wght@400;500;600;700&display=swap');

/* ============ THEME DEFINITIONS ============ */
:root {
  --accent: #c9a96e; --accent-light: #dfc08a; --accent-glow: rgba(201,169,110,0.25);
  --bg: #0e0c0a; --bg-card: #1a1714; --bg-elevated: #221f1a;
  --text: #f5f0e8; --text-dim: #8a8078; --border: #2a2520;
  --font-display: 'Cormorant Garamond', serif; --font-body: 'Nunito', sans-serif;
  --radius: 16px; --radius-sm: 10px;
  --safe-bottom: env(safe-area-inset-bottom, 0px);
  --splash-deco: '✦'; --splash-extra: none; --btn-text: var(--bg);
}

[data-theme="mariage-classic"] {
  --accent: #c9a96e; --accent-light: #dfc08a; --accent-glow: rgba(201,169,110,0.25);
  --bg: #0e0c0a; --bg-card: #1a1714; --bg-elevated: #221f1a;
  --text: #f5f0e8; --text-dim: #8a8078; --border: #2a2520;
  --font-display: 'Cormorant Garamond', serif; --font-body: 'Nunito', sans-serif;
  --splash-deco: '✦'; --btn-text: #0e0c0a;
  --splash-extra: radial-gradient(ellipse at 50% 0%, rgba(201,169,110,0.08) 0%, transparent 60%);
}

[data-theme="mariage-boheme"] {
  --accent: #7d9a6e; --accent-light: #a3bf96; --accent-glow: rgba(125,154,110,0.25);
  --bg: #11100e; --bg-card: #1a1916; --bg-elevated: #22211d;
  --text: #f0ece4; --text-dim: #8a857a; --border: #2a2822;
  --font-display: 'Libre Baskerville', serif; --font-body: 'Karla', sans-serif;
  --splash-deco: '❋'; --btn-text: #fff;
  --splash-extra: radial-gradient(ellipse at 30% 80%, rgba(125,154,110,0.06) 0%, transparent 50%), radial-gradient(ellipse at 70% 20%, rgba(180,160,120,0.05) 0%, transparent 50%);
}

[data-theme="mariage-modern"] {
  --accent: #ffffff; --accent-light: #cccccc; --accent-glow: rgba(255,255,255,0.1);
  --bg: #050505; --bg-card: #0f0f0f; --bg-elevated: #1a1a1a;
  --text: #ffffff; --text-dim: #666666; --border: #222222;
  --font-display: 'Bebas Neue', sans-serif; --font-body: 'Sora', sans-serif;
  --splash-deco: '◆'; --btn-text: #000;
  --splash-extra: repeating-linear-gradient(90deg, rgba(255,255,255,0.02) 0px, rgba(255,255,255,0.02) 1px, transparent 1px, transparent 80px);
}

[data-theme="soiree-festive"] {
  --accent: #ff3c78; --accent-light: #ff6b9d; --accent-glow: rgba(255,60,120,0.2);
  --bg: #0a0014; --bg-card: #150024; --bg-elevated: #1e0030;
  --text: #ffffff; --text-dim: #8866aa; --border: #2a1848;
  --font-display: 'Righteous', cursive; --font-body: 'Outfit', sans-serif;
  --splash-deco: '★'; --btn-text: #fff;
  --splash-extra: radial-gradient(ellipse at 20% 50%, rgba(255,60,120,0.08) 0%, transparent 50%), radial-gradient(ellipse at 80% 50%, rgba(100,50,255,0.08) 0%, transparent 50%);
}

[data-theme="soiree-chic"] {
  --accent: #d4a855; --accent-light: #e8c678; --accent-glow: rgba(212,168,85,0.2);
  --bg: #08080a; --bg-card: #121215; --bg-elevated: #1a1a1e;
  --text: #f0ede6; --text-dim: #6a6870; --border: #252528;
  --font-display: 'Playfair Display', serif; --font-body: 'DM Sans', sans-serif;
  --splash-deco: '◈'; --btn-text: #08080a;
  --splash-extra: radial-gradient(ellipse at 50% 30%, rgba(212,168,85,0.06) 0%, transparent 50%);
}

[data-theme="garden-party"] {
  --accent: #d4726a; --accent-light: #e8918a; --accent-glow: rgba(212,114,106,0.15);
  --bg: #faf7f2; --bg-card: #ffffff; --bg-elevated: #f0ece4;
  --text: #2c2826; --text-dim: #8a857e; --border: #e0dbd2;
  --font-display: 'Fraunces', serif; --font-body: 'Nunito Sans', sans-serif;
  --splash-deco: '✿'; --btn-text: #fff;
  --splash-extra: radial-gradient(ellipse at 50% 100%, rgba(212,114,106,0.08) 0%, transparent 60%);
}

/* ============ BASE ============ */
* { margin: 0; padding: 0; box-sizing: border-box; }
html, body { font-family: var(--font-body); background: var(--bg); color: var(--text); min-height: 100vh; min-height: 100dvh; overflow-x: hidden; -webkit-font-smoothing: antialiased; }

/* ============ SPLASH / LOGIN ============ */
.splash-screen { position: fixed; inset: 0; z-index: 1000; background: var(--bg); display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 20px; padding: 40px; transition: opacity 0.5s, transform 0.5s; }
.splash-screen::before { content: ''; position: absolute; inset: 0; background: var(--splash-extra); pointer-events: none; }
.splash-screen.hidden { opacity: 0; transform: scale(1.05); pointer-events: none; }

.splash-ornament { font-size: 18px; color: var(--accent); letter-spacing: 14px; opacity: 0.5; position: relative; z-index: 1; }
.splash-title { font-family: var(--font-display); font-size: 34px; font-weight: 700; text-align: center; line-height: 1.2; position: relative; z-index: 1; }
[data-theme="mariage-modern"] .splash-title { font-size: 46px; letter-spacing: 6px; text-transform: uppercase; }
[data-theme="soiree-festive"] .splash-title { font-size: 38px; background: linear-gradient(135deg, #ff3c78, #a855f7, #3b82f6); -webkit-background-clip: text; -webkit-text-fill-color: transparent; background-clip: text; }
.splash-subtitle { font-size: 14px; color: var(--text-dim); text-align: center; position: relative; z-index: 1; }

.splash-form { width: 100%; max-width: 320px; display: flex; flex-direction: column; gap: 14px; position: relative; z-index: 1; }
.splash-form input { background: var(--bg-elevated); border: 2px solid var(--border); border-radius: var(--radius-sm); padding: 16px 20px; font-size: 16px; color: var(--text); font-family: var(--font-body); outline: none; transition: border-color 0.2s; }
.splash-form input:focus { border-color: var(--accent); }
.splash-form input::placeholder { color: var(--text-dim); }

.btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px; padding: 16px 28px; border-radius: var(--radius-sm); font-family: var(--font-body); font-size: 16px; font-weight: 600; border: none; cursor: pointer; transition: all 0.2s; -webkit-tap-highlight-color: transparent; }
.btn-primary { background: var(--accent); color: var(--btn-text); }
.btn-primary:active { transform: scale(0.96); }
.btn-primary:disabled { opacity: 0.4; }

/* ============ APP LAYOUT ============ */
.app { display: none; flex-direction: column; min-height: 100vh; min-height: 100dvh; }
.app.active { display: flex; }

.top-bar { display: flex; align-items: center; justify-content: space-between; padding: 12px 20px; padding-top: max(12px, env(safe-area-inset-top, 12px)); background: color-mix(in srgb, var(--bg) 85%, transparent); backdrop-filter: blur(20px); -webkit-backdrop-filter: blur(20px); position: sticky; top: 0; z-index: 100; border-bottom: 1px solid var(--border); }
.top-bar-title { font-family: var(--font-display); font-size: 18px; font-weight: 700; }
[data-theme="mariage-modern"] .top-bar-title { letter-spacing: 3px; text-transform: uppercase; font-size: 14px; }
.top-bar-user { display: flex; align-items: center; gap: 8px; font-size: 14px; color: var(--text-dim); }
.user-avatar { width: 32px; height: 32px; border-radius: 50%; background: var(--accent); display: flex; align-items: center; justify-content: center; font-size: 14px; font-weight: 700; color: var(--btn-text); }

.tab-bar { display: flex; background: color-mix(in srgb, var(--bg) 90%, transparent); backdrop-filter: blur(20px); -webkit-backdrop-filter: blur(20px); position: fixed; bottom: 0; left: 0; right: 0; z-index: 100; padding-bottom: var(--safe-bottom); border-top: 1px solid var(--border); }
.tab { flex: 1; display: flex; flex-direction: column; align-items: center; gap: 4px; padding: 10px 0; color: var(--text-dim); font-size: 11px; font-weight: 500; cursor: pointer; -webkit-tap-highlight-color: transparent; transition: color 0.2s; background: none; border: none; font-family: var(--font-body); }
.tab.active { color: var(--accent); }
.tab svg { width: 24px; height: 24px; stroke: currentColor; fill: none; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }

.content { flex: 1; padding-bottom: calc(70px + var(--safe-bottom)); }
.tab-panel { display: none; padding: 20px; animation: fadeIn 0.3s ease; }
.tab-panel.active { display: block; }
@keyframes fadeIn { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: translateY(0); } }

/* ============ CAMERA ============ */
.camera-container { display: flex; flex-direction: column; align-items: center; gap: 20px; padding: 20px 0; }
.camera-preview-wrapper { width: 100%; max-width: 400px; aspect-ratio: 3/4; border-radius: var(--radius); overflow: hidden; background: var(--bg-card); position: relative; border: 1px solid var(--border); }
.camera-preview-wrapper video, .camera-preview-wrapper img { width: 100%; height: 100%; object-fit: cover; }
.camera-preview-wrapper canvas { display: none; }
.camera-flash { position: absolute; inset: 0; background: #fff; opacity: 0; pointer-events: none; transition: opacity 0.1s; }
.camera-flash.active { opacity: 0.8; transition: opacity 0s; }

.camera-controls { display: flex; align-items: center; justify-content: center; gap: 32px; }
.shutter-btn { width: 72px; height: 72px; border-radius: 50%; border: 4px solid var(--accent); background: transparent; cursor: pointer; position: relative; -webkit-tap-highlight-color: transparent; transition: all 0.15s; }
.shutter-btn::after { content: ''; position: absolute; inset: 4px; border-radius: 50%; background: var(--accent); transition: all 0.15s; }
.shutter-btn:active { transform: scale(0.9); }
.shutter-btn:active::after { opacity: 0.7; }

.camera-btn-icon { width: 48px; height: 48px; border-radius: 50%; background: var(--bg-elevated); border: 1px solid var(--border); cursor: pointer; display: flex; align-items: center; justify-content: center; color: var(--text); }
.camera-btn-icon svg { width: 22px; height: 22px; stroke: currentColor; fill: none; stroke-width: 2; }

.photo-meta-form { width: 100%; max-width: 400px; display: flex; flex-direction: column; gap: 12px; }
.photo-meta-form input { background: var(--bg-elevated); border: 1px solid var(--border); border-radius: var(--radius-sm); padding: 14px 16px; font-size: 15px; color: var(--text); font-family: var(--font-body); outline: none; }
.photo-meta-form input:focus { border-color: var(--accent); }

.upload-indicator { display: none; align-items: center; justify-content: center; gap: 12px; padding: 16px; border-radius: var(--radius-sm); font-size: 14px; font-weight: 500; }
.upload-indicator.uploading { display: flex; background: var(--accent-glow); color: var(--accent-light); }
.upload-indicator.success { display: flex; background: rgba(42,157,143,0.15); color: #2a9d8f; }
.upload-indicator.error { display: flex; background: rgba(220,50,50,0.2); color: #ff6b6b; }
.spinner { width: 20px; height: 20px; border: 2px solid transparent; border-top-color: currentColor; border-radius: 50%; animation: spin 0.6s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

.file-upload-area { width: 100%; max-width: 400px; padding: 32px; border: 2px dashed var(--border); border-radius: var(--radius); text-align: center; color: var(--text-dim); cursor: pointer; transition: all 0.2s; }
.file-upload-area:hover, .file-upload-area.dragover { border-color: var(--accent); color: var(--text); background: var(--accent-glow); }
.file-upload-area input { display: none; }
.upload-or { color: var(--text-dim); font-size: 13px; margin: 16px 0; }

.event-locked-msg { display: none; text-align: center; padding: 60px 20px; }
.event-locked-msg.active { display: block; }
.event-locked-msg h2 { font-family: var(--font-display); font-size: 24px; margin-bottom: 12px; }
.event-locked-msg p { color: var(--text-dim); font-size: 15px; }

/* ============ GALLERY ============ */
.gallery-header { display: flex; align-items: center; justify-content: space-between; margin-bottom: 16px; }
.section-title { font-family: var(--font-display); font-size: 22px; font-weight: 700; }
[data-theme="mariage-modern"] .section-title { letter-spacing: 3px; text-transform: uppercase; font-size: 18px; }
.gallery-filters { display: flex; gap: 8px; }
.filter-btn { padding: 8px 16px; border-radius: 20px; background: var(--bg-elevated); color: var(--text-dim); border: 1px solid var(--border); font-size: 13px; font-weight: 500; cursor: pointer; font-family: var(--font-body); transition: all 0.2s; }
.filter-btn.active { background: var(--accent); color: var(--btn-text); border-color: var(--accent); }

.photo-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 3px; }
.photo-cell { aspect-ratio: 1; border-radius: 4px; overflow: hidden; cursor: pointer; position: relative; }
.photo-cell img { width: 100%; height: 100%; object-fit: cover; transition: transform 0.3s; }
.photo-cell:hover img { transform: scale(1.05); }
.photo-cell .like-badge { position: absolute; bottom: 6px; right: 6px; background: rgba(0,0,0,0.7); backdrop-filter: blur(4px); padding: 3px 8px; border-radius: 12px; font-size: 11px; display: flex; align-items: center; gap: 3px; color: #fff; }
.photo-cell .like-badge svg { width: 12px; height: 12px; fill: var(--accent); stroke: none; }
.load-more-btn { width: 100%; padding: 14px; margin-top: 20px; background: var(--bg-elevated); border: 1px solid var(--border); border-radius: var(--radius-sm); color: var(--text-dim); font-family: var(--font-body); font-size: 14px; cursor: pointer; }

/* ============ MODAL ============ */
.photo-modal { position: fixed; inset: 0; z-index: 500; background: rgba(0,0,0,0.95); display: none; flex-direction: column; animation: fadeIn 0.2s; }
.photo-modal.active { display: flex; }
.modal-header { display: flex; align-items: center; justify-content: space-between; padding: 16px 20px; padding-top: max(16px, env(safe-area-inset-top, 16px)); }
.modal-close { width: 40px; height: 40px; border-radius: 50%; background: rgba(255,255,255,0.1); border: none; color: #fff; font-size: 20px; cursor: pointer; display: flex; align-items: center; justify-content: center; }
.modal-image-wrapper { flex: 1; display: flex; align-items: center; justify-content: center; padding: 0 20px; overflow: hidden; }
.modal-image-wrapper img { max-width: 100%; max-height: 100%; object-fit: contain; border-radius: 8px; }
.modal-info { padding: 20px; padding-bottom: max(20px, var(--safe-bottom)); }
.modal-meta { display: flex; align-items: center; justify-content: space-between; margin-bottom: 12px; }
.modal-author { display: flex; align-items: center; gap: 10px; }
.modal-author-name { font-weight: 600; font-size: 15px; color: #fff; }
.modal-date { font-size: 12px; color: #999; }
.modal-title { font-size: 14px; color: #999; margin-bottom: 16px; }
.modal-actions { display: flex; gap: 12px; }
.modal-actions button { flex: 1; padding: 12px; border-radius: var(--radius-sm); font-family: var(--font-body); font-size: 14px; font-weight: 600; border: none; cursor: pointer; display: flex; align-items: center; justify-content: center; gap: 8px; }
.like-btn { background: rgba(230,57,70,0.15); color: #ff6b7a; transition: all 0.2s; }
.like-btn.liked { background: #e63946; color: #fff; }
.like-btn svg { width: 18px; height: 18px; stroke: currentColor; fill: none; stroke-width: 2; }
.like-btn.liked svg { fill: currentColor; }
.download-btn { background: #1e1e1e; color: #fff; }
.download-btn svg { width: 18px; height: 18px; stroke: currentColor; fill: none; stroke-width: 2; }

/* ============ MY PHOTOS ============ */
.my-photos-empty { text-align: center; padding: 60px 20px; color: var(--text-dim); }
.my-photos-empty svg { width: 64px; height: 64px; stroke: var(--border); fill: none; stroke-width: 1.5; margin-bottom: 16px; }

/* ============ TOAST ============ */
.toast { position: fixed; top: max(20px, env(safe-area-inset-top, 20px)); left: 50%; transform: translateX(-50%) translateY(-100px); padding: 12px 24px; border-radius: var(--radius-sm); background: var(--bg-elevated); border: 1px solid var(--border); font-size: 14px; font-weight: 500; z-index: 9999; transition: transform 0.3s cubic-bezier(0.34,1.56,0.64,1); white-space: nowrap; color: var(--text); }
.toast.show { transform: translateX(-50%) translateY(0); }

::-webkit-scrollbar { width: 0; }

/* ============ SPLASH DECORATIONS ============ */

/* Top & bottom deco containers */
.splash-deco-top {
  width: 80%;
  max-width: 320px;
  margin: 0 auto 10px;
  color: var(--accent);
  position: relative;
  z-index: 2;
}

.splash-deco-top .deco { display: none; width: 100%; height: auto; }

[data-theme="mariage-classic"] .deco-classic,
:root:not([data-theme]) .deco-classic { display: block !important; }
[data-theme="mariage-boheme"] .deco-boheme { display: block !important; }
[data-theme="mariage-modern"] .deco-modern { display: block !important; }
[data-theme="soiree-festive"] .deco-festive { display: block !important; }
[data-theme="soiree-chic"] .deco-chic { display: block !important; }
[data-theme="garden-party"] .deco-garden { display: block !important; }

.splash-deco-bottom {
  width: 80%;
  max-width: 320px;
  margin: 20px auto 0;
  color: var(--accent);
  height: 40px;
  position: relative;
}

.splash-deco-bottom::before {
  content: '';
  position: absolute;
  inset: 0;
  border-bottom: 1.5px solid var(--accent);
  border-left: 1.5px solid var(--accent);
  border-right: 1.5px solid var(--accent);
  border-radius: 0 0 60px 60px;
  opacity: 0.35;
}

/* Divider between subtitle and form */
.splash-divider {
  display: flex;
  align-items: center;
  gap: 12px;
  margin: 18px auto;
  width: 70%;
  max-width: 260px;
  color: var(--accent);
}

.splash-divider span:first-child,
.splash-divider span:last-child {
  flex: 1;
  height: 1px;
  background: var(--accent);
  opacity: 0.4;
}

.splash-divider-icon::after {
  content: var(--splash-deco, '✦');
  font-size: 16px;
  opacity: 0.7;
}

/* ============ PHOTO FRAMES ============ */
.photo-cell {
  position: relative;
}

.photo-cell::after {
  content: '';
  position: absolute;
  inset: 0;
  pointer-events: none;
  z-index: 1;
  transition: all 0.3s;
  border: 2px solid var(--accent);
  opacity: 0.25;
  border-radius: 4px;
}

.photo-cell:hover::after {
  opacity: 0.55;
}

/* Classic — double gold frame */
[data-theme="mariage-classic"] .photo-cell::after {
  border-color: #c9a96e;
  box-shadow: inset 0 0 0 4px rgba(201, 169, 110, 0.12);
}

/* Bohème — organic rounded */
[data-theme="mariage-boheme"] .photo-cell::after {
  border-color: #7d9a6e;
  border-radius: 8px;
  border-width: 2px;
  border-style: dashed;
}

/* Modern — corner brackets only */
[data-theme="mariage-modern"] .photo-cell::after {
  border: none;
  background:
    linear-gradient(white, white) top left,
    linear-gradient(white, white) top right,
    linear-gradient(white, white) bottom left,
    linear-gradient(white, white) bottom right,
    linear-gradient(white, white) top left,
    linear-gradient(white, white) top right,
    linear-gradient(white, white) bottom left,
    linear-gradient(white, white) bottom right;
  background-size: 16px 2px, 16px 2px, 16px 2px, 16px 2px, 2px 16px, 2px 16px, 2px 16px, 2px 16px;
  background-repeat: no-repeat;
  background-position: 0 0, 100% 0, 0 100%, 100% 100%, 0 0, 100% 0, 0 100%, 100% 100%;
  opacity: 0.35;
}
[data-theme="mariage-modern"] .photo-cell:hover::after { opacity: 0.7; }

/* Festive — neon glow */
[data-theme="soiree-festive"] .photo-cell::after {
  border-color: #ff3c78;
}
[data-theme="soiree-festive"] .photo-cell:hover::after {
  box-shadow: 0 0 15px rgba(255, 60, 120, 0.3), inset 0 0 15px rgba(255, 60, 120, 0.1);
}

/* Chic — gold double line */
[data-theme="soiree-chic"] .photo-cell::after {
  border-color: #d4a855;
  box-shadow: inset 0 0 0 4px rgba(0,0,0,0.3), inset 0 0 0 5px rgba(212, 168, 85, 0.2);
}

/* Garden — thick soft pastel */
[data-theme="garden-party"] .photo-cell::after {
  border-color: #d4726a;
  border-width: 3px;
  border-radius: 10px;
}

/* ============ MODAL FRAME ============ */
.modal-image-wrapper img {
  border: 3px solid var(--accent);
  box-shadow: 0 10px 50px rgba(0,0,0,0.5);
}

/* ============ LANGUAGE SELECTOR ============ */
.lang-selector {
  position: absolute;
  top: max(16px, env(safe-area-inset-top, 16px));
  right: 20px;
  display: flex;
  gap: 4px;
  z-index: 10;
}

.lang-btn {
  width: 38px;
  height: 32px;
  border-radius: 8px;
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  color: var(--text-dim);
  font-size: 12px;
  font-weight: 700;
  font-family: var(--font-body);
  cursor: pointer;
  transition: all 0.2s;
  -webkit-tap-highlight-color: transparent;
}

.lang-btn.active {
  background: var(--accent);
  color: var(--btn-text);
  border-color: var(--accent);
}

.lang-btn:hover:not(.active) {
  border-color: var(--accent);
  color: var(--text);
}

@media (min-width: 768px) { .photo-grid { grid-template-columns: repeat(4, 1fr); gap: 4px; } }
@media (min-width: 1024px) { .photo-grid { grid-template-columns: repeat(5, 1fr); } }
