@import url('https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600;700;800&display=swap');

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

:root {
  --bg: #0b0b13; --surface: rgba(255,255,255,0.04); --surface-hover: rgba(255,255,255,0.07);
  --border: rgba(255,255,255,0.08); --border-light: rgba(255,255,255,0.12);
  --text: #ffffff; --text-secondary: rgba(255,255,255,0.6); --text-muted: rgba(255,255,255,0.35);
  --primary: #8b5cf6; --primary-hover: #7c3aed; --secondary: #ec4899;
  --gradient: linear-gradient(135deg, #8b5cf6, #ec4899);
  --success: #10b981; --error: #ef4444; --warning: #f59e0b;
  --radius: 16px; --radius-sm: 10px; --radius-xs: 6px;
  --shadow: 0 8px 32px rgba(0,0,0,0.4);
  --glass: rgba(255,255,255,0.03); --glass-border: rgba(255,255,255,0.06);
}

html { font-size: 16px; scroll-behavior: smooth; }
body { font-family: 'Inter', -apple-system, sans-serif; background: var(--bg); color: var(--text); min-height: 100vh; overflow-x: hidden; line-height: 1.6; }
body::before { content: ''; position: fixed; inset: 0; background: radial-gradient(ellipse at 20% 50%, rgba(139,92,246,0.08), transparent 60%), radial-gradient(ellipse at 80% 20%, rgba(236,72,153,0.06), transparent 60%); pointer-events: none; z-index: 0; }

a { color: var(--primary); text-decoration: none; }
button { cursor: pointer; font-family: inherit; border: none; outline: none; }
input, select, textarea { font-family: inherit; outline: none; }

::-webkit-scrollbar { width: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: rgba(255,255,255,0.1); border-radius: 3px; }

.btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px; padding: 12px 28px; border-radius: var(--radius-sm); font-weight: 600; font-size: 0.95rem; transition: all 0.3s; position: relative; overflow: hidden; white-space: nowrap; }
.btn-primary { background: var(--gradient); color: #fff; box-shadow: 0 4px 20px rgba(139,92,246,0.3); }
.btn-primary:hover { transform: translateY(-2px); box-shadow: 0 6px 28px rgba(139,92,246,0.45); }
.btn-outline { background: transparent; border: 1.5px solid var(--border-light); color: var(--text-secondary); }
.btn-outline:hover { border-color: var(--primary); color: var(--primary); background: rgba(139,92,246,0.05); }
.btn-danger { background: rgba(239,68,68,0.15); color: var(--error); }
.btn-danger:hover { background: rgba(239,68,68,0.25); }
.btn-sm { padding: 8px 14px; font-size: 0.82rem; border-radius: var(--radius-xs); }
.btn-icon { width: 36px; height: 36px; min-width: 36px; padding: 0; border-radius: var(--radius-sm); display: inline-flex; align-items: center; justify-content: center; background: var(--surface); border: 1px solid var(--border); color: var(--text-secondary); transition: all 0.3s; }
.btn-icon:hover { background: var(--surface-hover); color: var(--text); border-color: var(--primary); }

.card { background: var(--glass); border: 1px solid var(--glass-border); border-radius: var(--radius); padding: 24px; backdrop-filter: blur(20px); -webkit-backdrop-filter: blur(20px); }
.card-header { display: flex; align-items: center; justify-content: space-between; margin-bottom: 20px; gap: 12px; flex-wrap: wrap; }
.card-title { font-size: 1.05rem; font-weight: 700; display: flex; align-items: center; gap: 10px; }

.input-field { width: 100%; padding: 11px 14px; background: rgba(255,255,255,0.04); border: 1.5px solid var(--border); border-radius: var(--radius-sm); color: var(--text); font-size: 0.95rem; transition: all 0.3s; }
.input-field:focus { border-color: var(--primary); background: rgba(139,92,246,0.05); box-shadow: 0 0 0 3px rgba(139,92,246,0.1); }
.input-field::placeholder { color: var(--text-muted); }
.input-group { margin-bottom: 14px; }
.input-label { display: block; margin-bottom: 6px; font-size: 0.83rem; font-weight: 500; color: var(--text-secondary); }

.badge { display: inline-flex; align-items: center; gap: 4px; padding: 3px 9px; border-radius: 20px; font-size: 0.72rem; font-weight: 600; }
.badge-success { background: rgba(16,185,129,0.15); color: var(--success); }
.badge-warning { background: rgba(245,158,11,0.15); color: var(--warning); }

@keyframes fadeIn { from { opacity: 0; transform: translateY(16px); } to { opacity: 1; transform: translateY(0); } }
@keyframes slideUp { from { opacity: 0; transform: translateY(40px); } to { opacity: 1; transform: translateY(0); } }
@keyframes scaleIn { from { opacity: 0; transform: scale(0.9); } to { opacity: 1; transform: scale(1); } }
@keyframes check-draw { to { stroke-dashoffset: 0; } }
@keyframes circle-draw { to { stroke-dashoffset: 0; } }
.fade-in { animation: fadeIn 0.5s ease; }
.slide-up { animation: slideUp 0.6s ease; }

/* ===== LOGIN PAGE ===== */
.login-page { display: flex; align-items: center; justify-content: center; min-height: 100vh; padding: 20px; position: relative; z-index: 1; }
.login-card { width: 100%; max-width: 400px; padding: 40px 32px; text-align: center; animation: scaleIn 0.6s ease; }
.login-icon { width: 68px; height: 68px; margin: 0 auto 20px; background: var(--gradient); border-radius: 50%; display: flex; align-items: center; justify-content: center; font-size: 30px; box-shadow: 0 8px 32px rgba(139,92,246,0.3); }
.login-title { font-size: 1.4rem; font-weight: 800; margin-bottom: 6px; }
.login-subtitle { color: var(--text-muted); font-size: 0.88rem; margin-bottom: 28px; }
.login-error { background: rgba(239,68,68,0.1); border: 1px solid rgba(239,68,68,0.2); border-radius: var(--radius-xs); padding: 10px; color: var(--error); font-size: 0.83rem; margin-bottom: 16px; display: none; }

/* ===== HEADER ===== */
.header { display: flex; align-items: center; justify-content: space-between; padding: 14px 24px; border-bottom: 1px solid var(--border); background: rgba(11,11,19,0.9); backdrop-filter: blur(20px); position: sticky; top: 0; z-index: 100; gap: 12px; }
.header-brand { display: flex; align-items: center; gap: 10px; font-size: 1rem; font-weight: 700; white-space: nowrap; }
.header-brand span { background: var(--gradient); -webkit-background-clip: text; -webkit-text-fill-color: transparent; }
.header-right { display: flex; align-items: center; gap: 12px; }
.header-user { color: var(--text-secondary); font-size: 0.85rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 140px; }

/* ===== ADMIN ===== */
.admin-container { max-width: 1200px; margin: 0 auto; padding: 24px 20px; position: relative; z-index: 1; }
.admin-grid { display: grid; gap: 20px; }

.deadline-row { display: flex; gap: 12px; align-items: flex-end; flex-wrap: wrap; }
.deadline-row .input-group { flex: 1; min-width: 180px; margin-bottom: 0; }
.deadline-current { margin-top: 12px; padding: 11px 14px; background: rgba(139,92,246,0.08); border-radius: var(--radius-xs); color: var(--text-secondary); font-size: 0.83rem; }
.deadline-current strong { color: var(--primary); }

/* ===== CLIENTS TABLE ===== */
.table-wrapper { overflow-x: auto; -webkit-overflow-scrolling: touch; margin: 0 -4px; }
.clients-table { width: 100%; border-collapse: collapse; min-width: 540px; }
.clients-table th { text-align: left; padding: 10px 12px; font-size: 0.75rem; font-weight: 600; color: var(--text-muted); text-transform: uppercase; letter-spacing: 0.5px; border-bottom: 1px solid var(--border); white-space: nowrap; }
.clients-table td { padding: 12px; border-bottom: 1px solid var(--border); font-size: 0.87rem; vertical-align: middle; }
.clients-table tr:last-child td { border-bottom: none; }
.clients-table tbody tr { cursor: pointer; transition: background 0.2s; }
.clients-table tbody tr:hover { background: var(--surface-hover); }
.clients-table tbody tr.active { background: rgba(139,92,246,0.08); }
.password-cell { font-family: 'Courier New', monospace; color: var(--warning); font-weight: 500; }
.copy-btn { background: none; border: none; cursor: pointer; font-size: 0.8rem; padding: 2px 5px; border-radius: 4px; opacity: 0.5; transition: opacity 0.2s; vertical-align: middle; }
.copy-btn:hover { opacity: 1; background: rgba(255,255,255,0.08); }
.no-data { text-align: center; padding: 36px; color: var(--text-muted); font-size: 0.88rem; }

/* ===== PHOTOS PANEL ===== */
.photos-panel { border: 1.5px solid rgba(139,92,246,0.2); }
.photos-panel-title { font-size: 0.95rem; color: var(--primary); }
.upload-zone { border: 2px dashed var(--border-light); border-radius: var(--radius-sm); padding: 28px 16px; text-align: center; cursor: pointer; transition: all 0.3s; margin-bottom: 20px; }
.upload-zone:hover, .upload-zone.dragover { border-color: var(--primary); background: rgba(139,92,246,0.05); }
.upload-zone-icon { font-size: 1.8rem; margin-bottom: 8px; }
.upload-zone-text { color: var(--text-secondary); font-size: 0.88rem; }
.upload-zone-hint { color: var(--text-muted); font-size: 0.78rem; margin-top: 4px; }
.upload-progress { display: none; margin-bottom: 16px; }
.progress-bar { height: 4px; background: var(--surface); border-radius: 2px; overflow: hidden; }
.progress-fill { height: 100%; width: 0; background: var(--gradient); border-radius: 2px; transition: width 0.3s; }

.admin-photos-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(130px, 1fr)); gap: 10px; }
.admin-photo-item { display: flex; flex-direction: column; gap: 6px; }
.admin-photo-card { position: relative; border-radius: var(--radius-sm); overflow: hidden; aspect-ratio: 1; background: var(--surface); }
.admin-photo-card img { width: 100%; height: 100%; object-fit: cover; }
.admin-photo-name { font-size: 0.72rem; color: var(--text-muted); text-align: center; word-break: break-all; line-height: 1.3; overflow: hidden; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; }
.admin-photo-card.selected-photo { outline: 3px solid var(--success); outline-offset: -3px; }
.admin-photo-card.selected-photo::after { content: '✓ Выбрано'; position: absolute; bottom: 0; left: 0; right: 0; background: rgba(16,185,129,0.9); color: #fff; text-align: center; padding: 4px; font-size: 0.72rem; font-weight: 600; }
.photo-delete-btn { position: absolute; top: 5px; right: 5px; width: 26px; height: 26px; border-radius: 50%; background: rgba(0,0,0,0.7); color: #fff; display: flex; align-items: center; justify-content: center; font-size: 13px; opacity: 0; transition: opacity 0.2s; border: none; cursor: pointer; }
.admin-photo-card:hover .photo-delete-btn { opacity: 1; }
.selected-filename { font-size: 0.75rem; color: var(--text-muted); font-style: italic; margin-left: 4px; word-break: break-all; }
.reset-btn { font-size: 0.75rem; padding: 3px 8px; border-radius: 4px; background: rgba(239,68,68,0.12); color: var(--error); border: 1px solid rgba(239,68,68,0.2); cursor: pointer; margin-left: 6px; transition: background 0.2s; white-space: nowrap; }
.reset-btn:hover { background: rgba(239,68,68,0.25); }

/* ===== MODAL ===== */
.modal-overlay { position: fixed; inset: 0; background: rgba(0,0,0,0.7); backdrop-filter: blur(8px); z-index: 200; display: none; align-items: center; justify-content: center; padding: 16px; }
.modal-overlay.active { display: flex; }
.modal { width: 100%; max-width: 420px; animation: scaleIn 0.3s ease; }
.modal-body { text-align: center; }
.modal-actions { display: flex; gap: 12px; margin-top: 22px; }
.modal-actions .btn { flex: 1; }

/* ===== GALLERY (CLIENT) ===== */
.gallery-container { max-width: 700px; margin: 0 auto; padding: 24px 16px; position: relative; z-index: 1; }

.timer-section { text-align: center; margin-bottom: 36px; animation: fadeIn 0.6s ease; }
.timer-label { font-size: 0.95rem; color: var(--text-secondary); margin-bottom: 16px; font-weight: 500; }
.timer-grid { display: flex; justify-content: center; gap: 10px; flex-wrap: wrap; }
.timer-box { background: var(--glass); border: 1px solid var(--glass-border); border-radius: var(--radius); padding: 16px 18px; min-width: 80px; flex: 1; max-width: 120px; backdrop-filter: blur(20px); }
.timer-value { font-size: 2.4rem; font-weight: 800; background: var(--gradient); -webkit-background-clip: text; -webkit-text-fill-color: transparent; line-height: 1; }
.timer-unit { font-size: 0.7rem; color: var(--text-muted); text-transform: uppercase; letter-spacing: 1px; margin-top: 5px; }
.timer-expired { color: var(--error); font-size: 1.05rem; font-weight: 600; padding: 20px; }

.photos-grid { display: flex; flex-direction: column; gap: 24px; animation: slideUp 0.6s ease; }

/* ===== PHOTO CARD with CSS watermark text ===== */
.photo-card { position: relative; border-radius: var(--radius); overflow: hidden; background: var(--surface); border: 2px solid transparent; transition: all 0.4s; }
.photo-card:hover { border-color: var(--primary); box-shadow: 0 10px 36px rgba(139,92,246,0.2); }
.photo-card-img-wrap { position: relative; width: 100%; }
.photo-card img { width: 100%; height: auto; max-height: 70vh; object-fit: contain; display: block; pointer-events: none; user-select: none; -webkit-user-drag: none; -webkit-user-select: none; background: #111; }

/* CSS watermark - 3 rows at 25% / 50% / 75% */
.photo-card-img-wrap { position: relative; width: 100%; overflow: hidden; }
.photo-watermark {
  position: absolute;
  inset: 0;
  pointer-events: none;
  z-index: 1;
  display: flex;
  flex-direction: column;
  justify-content: space-evenly;
  align-items: center;
  transform: rotate(-25deg);
  overflow: visible;
}
.photo-watermark-row {
  display: flex;
  justify-content: center;
  gap: 20px;
  width: 160%;
}
.photo-watermark-text {
  color: rgba(255,255,255,0.28);
  font-size: clamp(24px, 5.5vw, 52px);
  font-weight: 900;
  letter-spacing: 0.15em;
  text-transform: uppercase;
  user-select: none;
  -webkit-user-select: none;
  text-shadow: 0 2px 8px rgba(0,0,0,0.6);
  white-space: nowrap;
  flex-shrink: 0;
}

.photo-card-footer { padding: 12px 14px; display: flex; justify-content: center; }
.photo-select-btn { width: 100%; padding: 12px 28px; background: var(--gradient); border: none; color: #fff; border-radius: var(--radius-sm); font-weight: 600; font-size: 0.95rem; cursor: pointer; transition: opacity 0.2s, transform 0.2s; }
.photo-select-btn:hover { opacity: 0.9; transform: scale(1.02); }

.confirm-modal .confirm-photo { width: 140px; height: 105px; object-fit: cover; border-radius: var(--radius-sm); margin: 14px auto; display: block; pointer-events: none; border: 2px solid var(--border-light); }
.confirm-modal h3 { font-size: 1.15rem; margin-bottom: 8px; }
.confirm-modal p { color: var(--text-secondary); font-size: 0.88rem; }

/* ===== THANK YOU ===== */
.thankyou-screen { display: none; text-align: center; padding: 60px 20px; animation: fadeIn 0.8s ease; position: relative; z-index: 1; }
.thankyou-screen.active { display: block; }
.thankyou-icon { width: 90px; height: 90px; margin: 0 auto 22px; }
.thankyou-icon svg { width: 100%; height: 100%; }
.thankyou-icon .circle { fill: none; stroke: var(--success); stroke-width: 3; stroke-dasharray: 283; stroke-dashoffset: 283; animation: circle-draw 0.6s ease forwards; }
.thankyou-icon .check { fill: none; stroke: var(--success); stroke-width: 4; stroke-linecap: round; stroke-linejoin: round; stroke-dasharray: 50; stroke-dashoffset: 50; animation: check-draw 0.4s ease 0.5s forwards; }
.thankyou-title { font-size: 1.8rem; font-weight: 800; margin-bottom: 8px; background: var(--gradient); -webkit-background-clip: text; -webkit-text-fill-color: transparent; }
.thankyou-subtitle { color: var(--text-secondary); font-size: 1rem; }

/* ===== RESPONSIVE ===== */
@media (max-width: 640px) {
  .header { padding: 12px 14px; }
  .header-brand { font-size: 0.9rem; }
  .header-brand .subtitle { display: none; }
  .header-user { max-width: 90px; font-size: 0.78rem; }

  .admin-container { padding: 14px 12px; }
  .admin-grid { gap: 14px; }
  .card { padding: 16px 14px; }
  .card-header { flex-wrap: wrap; gap: 10px; }
  .card-header > div:last-child { width: 100%; display: flex; gap: 8px; }
  .card-header > div:last-child .btn { flex: 1; justify-content: center; font-size: 0.78rem; }

  .deadline-row { flex-direction: column; }
  .deadline-row .input-group { min-width: 0; width: 100%; }
  .deadline-row .btn { width: 100%; }

  .clients-table { min-width: 400px; }
  .clients-table th, .clients-table td { padding: 9px 8px; font-size: 0.78rem; }

  .gallery-container { padding: 14px 12px; }
  .timer-section { margin-bottom: 24px; }
  .timer-box { min-width: 60px; padding: 12px 10px; }
  .timer-value { font-size: 1.8rem; }
  .timer-unit { font-size: 0.62rem; }
  .timer-grid { gap: 8px; }

  .photos-grid { grid-template-columns: repeat(2, 1fr); gap: 10px; }
  .photo-select-btn { padding: 8px 16px; font-size: 0.8rem; }
  .photo-watermark-text { font-size: 11px; }

  .admin-photos-grid { grid-template-columns: repeat(auto-fill, minmax(90px, 1fr)); gap: 8px; }

  .modal-overlay { padding: 12px; align-items: flex-end; }
  .modal { max-width: 100%; border-radius: var(--radius) var(--radius) 0 0; }
  .modal-actions { flex-direction: column; }
  .modal-actions .btn { width: 100%; }

  .login-card { padding: 32px 20px; }
  .login-title { font-size: 1.2rem; }

  .thankyou-screen { padding: 40px 16px; }
  .thankyou-title { font-size: 1.4rem; }
  .upload-zone { padding: 20px 12px; }
}

@media (max-width: 380px) {
  .photos-grid { grid-template-columns: 1fr; }
  .timer-value { font-size: 1.5rem; }
  .btn-sm { padding: 7px 10px; font-size: 0.76rem; }
}

@media (min-width: 641px) and (max-width: 900px) {
  .photos-grid { grid-template-columns: repeat(auto-fill, minmax(180px, 1fr)); }
  .admin-container { padding: 20px 16px; }
}
