/* === DESIGN TOKENS === */
:root {
    --bg: #0a0a0f;
    --bg-card: #13131a;
    --bg-hover: #1c1c26;
    --border: #2a2a38;
    --border-light: #38384a;
    --text: #e8e8f0;
    --text-muted: #8888a0;
    --text-dim: #5a5a70;
    --accent: #7c6af7;
    --accent-hover: #9280ff;
    --accent-dim: rgba(124, 106, 247, 0.15);
    --success: #22c55e;
    --error: #ef4444;
    --warning: #f59e0b;
    --radius: 12px;
    --radius-sm: 8px;
    --shadow: 0 8px 32px rgba(0, 0, 0, 0.5);
    --transition: 0.18s ease;
    --nav-height: 60px;
    --font: 'Inter', system-ui, -apple-system, sans-serif;
}

/* === RESET & BASE === */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

html { font-size: 16px; -webkit-font-smoothing: antialiased; }

body {
    font-family: var(--font);
    background: var(--bg);
    color: var(--text);
    min-height: 100vh;
    line-height: 1.5;
}

a { color: inherit; text-decoration: none; }
button { cursor: pointer; font-family: inherit; }
input, select, textarea { font-family: inherit; }

main { padding: 24px; max-width: 1200px; margin: 0 auto; }
main.with-nav { padding-top: calc(var(--nav-height) + 24px); }

/* === NAVBAR === */
.nav-bar {
    position: fixed;
    top: 0; left: 0; right: 0;
    height: var(--nav-height);
    background: rgba(10, 10, 15, 0.92);
    backdrop-filter: blur(16px);
    border-bottom: 1px solid var(--border);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 24px;
    z-index: 100;
}

.nav-brand {
    display: flex;
    align-items: center;
    gap: 10px;
    font-size: 17px;
    font-weight: 600;
    color: var(--text);
    letter-spacing: -0.3px;
}

.nav-brand svg { color: var(--accent); }

.nav-actions { display: flex; gap: 12px; align-items: center; }

.btn-nav {
    background: none;
    border: 1px solid var(--border);
    color: var(--text-muted);
    padding: 6px 16px;
    border-radius: var(--radius-sm);
    font-size: 14px;
    transition: all var(--transition);
}
.btn-nav:hover { border-color: var(--border-light); color: var(--text); }

/* === PAGE HEADER === */
.page-header {
    display: flex;
    align-items: center;
    gap: 16px;
    margin-bottom: 28px;
    flex-wrap: wrap;
}

.page-header-left {
    display: flex;
    align-items: center;
    gap: 14px;
    flex: 1;
}

.page-title {
    font-size: 22px;
    font-weight: 600;
    letter-spacing: -0.4px;
    color: var(--text);
}

.page-subtitle {
    font-size: 14px;
    color: var(--text-muted);
    margin-left: 4px;
}

.btn-back {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    color: var(--text-muted);
    font-size: 14px;
    padding: 6px 12px;
    border-radius: var(--radius-sm);
    border: 1px solid var(--border);
    transition: all var(--transition);
    white-space: nowrap;
}
.btn-back:hover { color: var(--text); border-color: var(--border-light); background: var(--bg-hover); }

/* === BUTTONS === */
.btn-primary {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    background: var(--accent);
    color: #fff;
    border: none;
    padding: 10px 20px;
    border-radius: var(--radius-sm);
    font-size: 14px;
    font-weight: 500;
    transition: all var(--transition);
}
.btn-primary:hover { background: var(--accent-hover); transform: translateY(-1px); }
.btn-primary:disabled { opacity: 0.5; cursor: not-allowed; transform: none; }
.btn-primary.w-full { width: 100%; }

.btn-secondary {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    background: var(--bg-card);
    color: var(--text);
    border: 1px solid var(--border);
    padding: 10px 16px;
    border-radius: var(--radius-sm);
    font-size: 14px;
    font-weight: 500;
    transition: all var(--transition);
    white-space: nowrap;
}
.btn-secondary:hover { border-color: var(--border-light); background: var(--bg-hover); }

.btn-restricted {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    background: var(--accent-dim);
    color: var(--accent);
    border: 1px solid rgba(124, 106, 247, 0.3);
    padding: 8px 16px;
    border-radius: var(--radius-sm);
    font-size: 14px;
    font-weight: 500;
    transition: all var(--transition);
    margin-left: auto;
}
.btn-restricted:hover { background: rgba(124, 106, 247, 0.25); border-color: var(--accent); }

/* === ALERTS === */
.alert {
    padding: 12px 16px;
    border-radius: var(--radius-sm);
    font-size: 14px;
    margin-bottom: 16px;
}
.alert-error { background: rgba(239, 68, 68, 0.12); border: 1px solid rgba(239, 68, 68, 0.3); color: #fca5a5; }
.alert-success { background: rgba(34, 197, 94, 0.1); border: 1px solid rgba(34, 197, 94, 0.3); color: #86efac; }

/* === EMPTY STATE === */
.empty-state {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 16px;
    padding: 80px 24px;
    text-align: center;
    color: var(--text-muted);
}
.empty-state svg { opacity: 0.3; }
.empty-state p { font-size: 16px; }

/* =============================================
   LOGIN PAGE
   ============================================= */
.login-page {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 24px;
    background: radial-gradient(ellipse at 50% 0%, rgba(124, 106, 247, 0.1) 0%, transparent 65%);
}

.login-card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: 18px;
    padding: 32px 28px;
    width: 100%;
    max-width: 360px;
    box-shadow: var(--shadow);
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 18px;
}

.login-header {
    display: flex;
    align-items: center;
    gap: 10px;
    width: 100%;
    justify-content: center;
}

.login-icon {
    width: 34px;
    height: 34px;
    background: var(--accent-dim);
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--accent);
    flex-shrink: 0;
}

.login-title {
    font-size: 20px;
    font-weight: 600;
    letter-spacing: -0.3px;
}

.login-subtitle {
    font-size: 14px;
    color: var(--text-muted);
    margin-top: -10px;
    text-align: center;
}

/* === PIN DISPLAY === */
.pin-display {
    display: flex;
    gap: 12px;
    justify-content: center;
    margin: 8px 0;
}

.pin-dot {
    width: 14px;
    height: 14px;
    border-radius: 50%;
    border: 2px solid var(--border-light);
    background: transparent;
    transition: all var(--transition);
}

.pin-dot.filled {
    background: var(--accent);
    border-color: var(--accent);
    box-shadow: 0 0 12px rgba(124, 106, 247, 0.5);
}

/* === NUMPAD === */
.numpad {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 8px;
    width: 100%;
    max-width: 240px;
}

.numpad.numpad-sm { max-width: 240px; gap: 8px; }

.numpad-key {
    aspect-ratio: 1;
    background: var(--bg-hover);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    color: var(--text);
    font-size: 20px;
    font-weight: 500;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all var(--transition);
    user-select: none;
}

.numpad-key:hover { background: var(--border); border-color: var(--border-light); }
.numpad-key:active { transform: scale(0.93); }
.numpad-del { font-size: 16px; }
.numpad-zero { grid-column: span 2; aspect-ratio: unset; }

.pin-display.pin-sm .pin-dot { width: 12px; height: 12px; }

.btn-enter:hover:not(:disabled) { background: var(--accent-hover); transform: translateY(-1px); }
.btn-enter:disabled { opacity: 0.4; cursor: not-allowed; }

/* =============================================
   SEARCH BAR
   ============================================= */
.search-bar {
    display: flex;
    align-items: center;
    gap: 10px;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    padding: 10px 14px;
    margin-bottom: 24px;
    color: var(--text-muted);
    transition: border-color var(--transition);
}
.search-bar:focus-within { border-color: var(--accent); color: var(--accent); }

.search-input {
    flex: 1;
    background: none;
    border: none;
    outline: none;
    color: var(--text);
    font-size: 14px;
    font-family: var(--font);
}
.search-input::placeholder { color: var(--text-dim); }

.search-clear {
    background: none;
    border: none;
    color: var(--text-dim);  
    cursor: pointer;
    display: flex;
    align-items: center;
    transition: color var(--transition);
}
.search-clear:hover { color: var(--text); }

/* =============================================
   GALLERY — FOLDER GRID
   ============================================= */
.folder-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
    gap: 20px;
}

.folder-card-wrap {
    position: relative;
}

.folder-card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    overflow: hidden;
    transition: all var(--transition);
    display: flex;
    flex-direction: column;
    width: 100%;
}
.folder-card:hover { border-color: var(--border-light); transform: translateY(-2px); box-shadow: 0 12px 32px rgba(0,0,0,0.4); }

/* Folder list (Upload page) */
.folder-mgmt-list {
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.folder-mgmt-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 12px;
    border-radius: var(--radius-sm);
    transition: background var(--transition);
}
.folder-mgmt-item:hover { background: var(--bg-hover); }

.folder-mgmt-name {
    flex: 1;
    font-size: 14px;
    color: var(--text);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.folder-mgmt-count {
    font-size: 12px;
    color: var(--text-dim);
    white-space: nowrap;
}

.btn-icon {
    background: none;
    border: 1px solid transparent;
    color: var(--text-dim);
    padding: 5px 6px;
    border-radius: 6px;
    display: flex;
    align-items: center;
    transition: all var(--transition);
    flex-shrink: 0;
}
.btn-icon:hover { color: var(--accent); border-color: rgba(124,106,247,0.3); background: var(--accent-dim); }

.folder-mgmt-edit {
    display: flex;
    align-items: center;
    gap: 6px;
    flex: 1;
}
.folder-mgmt-edit .form-control { padding: 6px 10px; font-size: 13px; }

.folder-thumb {
    position: relative;
    aspect-ratio: 4/3;
    overflow: hidden;
    background: var(--bg-hover);
}
.folder-thumb img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    transition: transform 0.4s ease;
}
.folder-card:hover .folder-thumb img { transform: scale(1.04); }

.folder-thumb-placeholder {
    width: 100%;
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--text-dim);
}

.folder-count {
    position: absolute;
    bottom: 8px;
    right: 8px;
    background: rgba(0,0,0,0.7);
    color: rgba(255,255,255,0.85);
    font-size: 12px;
    padding: 3px 8px;
    border-radius: 20px;
    backdrop-filter: blur(4px);
}

.folder-info {
    padding: 14px;
}

.folder-name {
    font-size: 15px;
    font-weight: 500;
    color: var(--text);
}

/* =============================================
   GALLERY — PHOTO GRID
   ============================================= */
.photo-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
    gap: 6px;
}

.photo-item {
    aspect-ratio: 1;
    overflow: hidden;
    border-radius: var(--radius-sm);
    background: var(--bg-card);
    display: block;
    cursor: pointer;
}
.photo-item img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    transition: transform 0.3s ease;
}
.photo-item:hover img { transform: scale(1.06); }

/* =============================================
   MODAL
   ============================================= */
.modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.75);
    backdrop-filter: blur(6px);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
    padding: 24px;
}

.modal {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: 18px;
    padding: 32px 28px;
    width: 100%;
    max-width: 360px;
    box-shadow: var(--shadow);
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 18px;
}

.modal-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    width: 100%;
}
.modal-header h3 { font-size: 18px; font-weight: 600; }
.modal-close {
    background: none;
    border: none;
    color: var(--text-muted);
    font-size: 18px;
    line-height: 1;
    padding: 4px 8px;
    border-radius: var(--radius-sm);
    transition: all var(--transition);
}
.modal-close:hover { color: var(--text); background: var(--bg-hover); }

.modal-desc {
    font-size: 14px;
    color: var(--text-muted);
    text-align: center;
    width: 100%;
}

/* =============================================
   RESTRICTED PAGE
   ============================================= */
.restricted-page { max-width: 600px; margin: 0 auto; }

.restricted-menu {
    display: flex;
    flex-direction: column;
    gap: 16px;
}

.restricted-card {
    display: flex;
    align-items: center;
    gap: 20px;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 24px;
    transition: all var(--transition);
    cursor: pointer;
}
.restricted-card:hover { border-color: var(--accent); background: var(--bg-hover); transform: translateX(3px); }

.restricted-card-icon {
    width: 72px;
    height: 72px;
    background: var(--accent-dim);
    border-radius: var(--radius-sm);
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--accent);
    flex-shrink: 0;
}

.restricted-card-body { flex: 1; }
.restricted-card-body h3 { font-size: 18px; font-weight: 600; margin-bottom: 4px; }
.restricted-card-body p { font-size: 14px; color: var(--text-muted); }

.restricted-card-arrow { color: var(--text-dim); flex-shrink: 0; }

/* =============================================
   UPLOAD PAGE
   ============================================= */
.upload-container {
    max-width: 700px;
    display: flex;
    flex-direction: column;
    gap: 24px;
}

.upload-section {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 24px;
}

.section-title {
    font-size: 15px;
    font-weight: 600;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.8px;
    margin-bottom: 16px;
    font-size: 12px;
}

/* Folder management list (unified selector + manager) */
.folder-mgmt-list { display: flex; flex-direction: column; gap: 2px; margin-top: 12px; }

.folder-mgmt-empty { font-size: 13px; color: var(--text-dim); padding: 8px 4px; }

.folder-mgmt-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 12px;
    border-radius: var(--radius-sm);
    border: 1px solid transparent;
    cursor: pointer;
    transition: all var(--transition);
}
.folder-mgmt-item:hover { background: var(--bg-hover); }
.folder-mgmt-item.selected {
    background: var(--accent-dim);
    border-color: rgba(124, 106, 247, 0.35);
}

.folder-mgmt-icon { color: var(--text-dim); flex-shrink: 0; }
.folder-mgmt-item.selected .folder-mgmt-icon { color: var(--accent); }

.folder-mgmt-name { flex: 1; font-size: 14px; color: var(--text); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.folder-mgmt-count { font-size: 12px; color: var(--text-dim); white-space: nowrap; }

.folder-mgmt-actions { display: flex; gap: 4px; flex-shrink: 0; }

.folder-mgmt-edit {
    display: flex;
    align-items: center;
    gap: 6px;
    flex: 1;
}
.folder-mgmt-edit .form-control { padding: 5px 10px; font-size: 13px; }

.btn-icon {
    background: none;
    border: 1px solid transparent;
    color: var(--text-dim);
    padding: 5px 6px;
    border-radius: 6px;
    display: flex;
    align-items: center;
    cursor: pointer;
    transition: all var(--transition);
    flex-shrink: 0;
}
.btn-icon:hover { color: var(--accent); border-color: rgba(124,106,247,0.3); background: var(--accent-dim); }
.btn-icon-danger:hover { color: var(--error); border-color: rgba(239,68,68,0.3); background: rgba(239,68,68,0.1); }

/* Delete inline confirmation */
.delete-confirm {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-shrink: 0;
    animation: fadeIn 0.15s ease;
}
.delete-confirm-label { font-size: 12px; color: var(--text-muted); white-space: nowrap; }
.btn-confirm-yes {
    background: rgba(239, 68, 68, 0.15);
    border: 1px solid rgba(239, 68, 68, 0.4);
    color: #fca5a5;
    font-size: 12px;
    font-weight: 600;
    padding: 3px 10px;
    border-radius: 5px;
    cursor: pointer;
    transition: all var(--transition);
}
.btn-confirm-yes:hover { background: rgba(239,68,68,0.3); }
.btn-confirm-no {
    background: none;
    border: 1px solid var(--border);
    color: var(--text-muted);
    font-size: 12px;
    padding: 3px 10px;
    border-radius: 5px;
    cursor: pointer;
    transition: all var(--transition);
}
.btn-confirm-no:hover { border-color: var(--border-light); color: var(--text); }

@keyframes fadeIn { from { opacity: 0; transform: translateX(4px); } to { opacity: 1; transform: none; } }

.new-folder-row {
    display: flex;
    gap: 10px;
}

.form-control {
    width: 100%;
    background: var(--bg);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    color: var(--text);
    padding: 10px 14px;
    font-size: 14px;
    transition: border-color var(--transition);
    outline: none;
}
.form-control:focus { border-color: var(--accent); }

select.form-control { cursor: pointer; }

.upload-info {
    font-size: 14px;
    color: var(--text-muted);
    text-align: center;
    padding: 12px;
    background: rgba(245, 158, 11, 0.08);
    border: 1px solid rgba(245, 158, 11, 0.2);
    border-radius: var(--radius-sm);
    margin-top: 12px;
}

.form-msg {
    font-size: 13px;
    padding: 8px 12px;
    border-radius: var(--radius-sm);
    margin-top: 8px;
}
.form-msg-success { background: rgba(34, 197, 94, 0.1); color: #86efac; border: 1px solid rgba(34,197,94,0.3); }
.form-msg-error { background: rgba(239, 68, 68, 0.1); color: #fca5a5; border: 1px solid rgba(239,68,68,0.3); }

/* FilePond overrides */
.filepond--root {
    font-family: var(--font) !important;
}
.filepond--panel-root {
    background-color: var(--bg) !important;
    border: 2px dashed var(--border) !important;
    border-radius: var(--radius-sm) !important;
}
.filepond--drop-label {
    color: var(--text-muted) !important;
}
.filepond--label-action {
    color: var(--accent) !important;
    text-decoration: underline;
    text-underline-offset: 3px;
}
.filepond--item-panel { background-color: var(--bg-card) !important; }

/* =============================================
   SETTINGS PAGE
   ============================================= */
.settings-container {
    max-width: 600px;
    display: flex;
    flex-direction: column;
    gap: 20px;
}

.settings-card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 24px;
    display: flex;
    flex-direction: column;
    gap: 14px;
}

.settings-card-header {
    display: flex;
    align-items: center;
    gap: 10px;
    color: var(--accent);
}
.settings-card-header h3 {
    font-size: 16px;
    font-weight: 600;
    color: var(--text);
}

.settings-desc {
    font-size: 13px;
    color: var(--text-muted);
    line-height: 1.6;
}
.settings-desc code {
    background: var(--bg-hover);
    border: 1px solid var(--border);
    border-radius: 4px;
    padding: 1px 6px;
    font-size: 12px;
    color: var(--accent);
}

.form-group { display: flex; flex-direction: column; gap: 8px; }
.form-group label { font-size: 13px; font-weight: 500; color: var(--text-muted); }

.pin-input {
    max-width: 160px;
    letter-spacing: 8px;
    font-size: 20px;
    text-align: center;
}

.ip-textarea {
    resize: vertical;
    min-height: 120px;
    font-family: 'Courier New', monospace;
    font-size: 14px;
}

/* === FOOTER === */
.site-footer {
    text-align: center;
    padding: 20px 24px;
    font-size: 13px;
    color: var(--text-dim);
    border-top: 1px solid var(--border);
    margin-top: 40px;
}

main + .site-footer {
    max-width: 1200px;
    margin-left: auto;
    margin-right: auto;
}

/* =============================================
   RESPONSIVE
   ============================================= */
@media (max-width: 600px) {
    main { padding: 16px; }
    main.with-nav { padding-top: calc(var(--nav-height) + 16px); }

    .folder-grid { grid-template-columns: repeat(auto-fill, minmax(160px, 1fr)); gap: 12px; }
    .photo-grid { grid-template-columns: repeat(auto-fill, minmax(130px, 1fr)); gap: 4px; }

    .login-card { padding: 32px 24px; }
    .numpad { max-width: 260px; }

    .new-folder-row { flex-direction: column; }
    .page-header { gap: 10px; }
}

@media (max-width: 400px) {
    .numpad { max-width: 220px; gap: 8px; }
    .numpad-key { font-size: 18px; }
}
