/* ============================================
   Gem & Mineral Collection — Admin Panel
   Clean, modern admin design
   ============================================ */

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

:root {
    --color-bg: #f8f9fb;
    --color-surface: #ffffff;
    --color-border: #e5e7ec;
    --color-text: #1a1d26;
    --color-text-muted: #6b7280;
    --color-accent: #7c3aed;
    --color-accent-hover: #6d28d9;
    --color-accent-light: #ede9fe;
    --color-success: #059669;
    --color-success-light: #d1fae5;
    --color-warning: #d97706;
    --color-warning-light: #fef3c7;
    --color-danger: #dc2626;
    --color-danger-light: #fee2e2;
    --font-main: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Inter', Roboto, sans-serif;
    --radius: 8px;
    --radius-lg: 12px;
    --shadow-sm: 0 1px 2px rgba(0,0,0,0.05);
    --shadow: 0 1px 3px rgba(0,0,0,0.08), 0 1px 2px rgba(0,0,0,0.04);
    --shadow-md: 0 4px 6px rgba(0,0,0,0.05), 0 2px 4px rgba(0,0,0,0.04);
    --transition: 0.2s ease;
}

body {
    font-family: var(--font-main);
    background: var(--color-bg);
    color: var(--color-text);
    line-height: 1.5;
    -webkit-font-smoothing: antialiased;
}

a { color: var(--color-accent); text-decoration: none; }
a:hover { color: var(--color-accent-hover); }
img { max-width: 100%; height: auto; }

/* Admin Nav */
.admin-nav {
    background: linear-gradient(135deg, #7c3aed 0%, #5b21b6 100%);
    color: white;
    padding: 0 1.5rem;
    box-shadow: 0 2px 10px rgba(124, 58, 237, 0.3);
    position: sticky;
    top: 0;
    z-index: 100;
}

.admin-nav-inner {
    max-width: 1200px;
    margin: 0 auto;
    display: flex;
    align-items: center;
    justify-content: space-between;
    height: 56px;
}

.admin-logo { color: white; font-weight: 700; font-size: 1.1rem; letter-spacing: -0.01em; }
.admin-logo:hover { color: white; }

.admin-nav-links { display: flex; gap: 0.25rem; }

.admin-nav .nav-link {
    color: rgba(255,255,255,0.8);
    padding: 0.4rem 0.85rem;
    border-radius: 8px;
    font-size: 0.85rem;
    font-weight: 500;
    transition: all var(--transition);
}

.admin-nav .nav-link:hover { background: rgba(255,255,255,0.15); color: white; }
.nav-logout { opacity: 0.65; }
.nav-logout:hover { opacity: 1; }

/* Main */
.admin-main {
    max-width: 1200px;
    margin: 0 auto;
    padding: 2rem 1.5rem;
}

/* Alerts */
.alert {
    padding: 0.75rem 1rem;
    border-radius: var(--radius);
    margin-bottom: 1.5rem;
    font-size: 0.875rem;
    font-weight: 500;
    display: flex;
    align-items: center;
    gap: 0.5rem;
    animation: slideDown 0.3s ease;
}

@keyframes slideDown {
    from { opacity: 0; transform: translateY(-8px); }
    to { opacity: 1; transform: translateY(0); }
}

.alert-success { background: var(--color-success-light); color: #065f46; border-left: 4px solid var(--color-success); }
.alert-error { background: var(--color-danger-light); color: #991b1b; border-left: 4px solid var(--color-danger); }
.alert-warning { background: var(--color-warning-light); color: #92400e; border-left: 4px solid var(--color-warning); }

/* Stats Grid */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
    gap: 1rem;
    margin-bottom: 2.5rem;
}

.stat-card {
    background: var(--color-surface);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-lg);
    padding: 1.5rem;
    text-align: center;
    transition: all var(--transition);
    box-shadow: var(--shadow-sm);
}

.stat-card:hover {
    box-shadow: var(--shadow-md);
    border-color: var(--color-accent-light);
    transform: translateY(-2px);
}

.stat-number {
    display: block;
    font-size: 2.25rem;
    font-weight: 700;
    color: var(--color-accent);
    letter-spacing: -0.02em;
}

.stat-label {
    display: block;
    font-size: 0.8rem;
    color: var(--color-text-muted);
    margin-top: 0.25rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    font-weight: 500;
}

/* Sections */
.section { margin-bottom: 2rem; }

.section-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 1.25rem;
    flex-wrap: wrap;
    gap: 0.75rem;
}

.section-header h2 { font-size: 1.25rem; font-weight: 600; letter-spacing: -0.01em; }
.section-header h3 { font-size: 1.1rem; font-weight: 600; }

.section-description { color: var(--color-text-muted); font-size: 0.875rem; margin-bottom: 1.5rem; line-height: 1.6; }
.header-actions { display: flex; gap: 0.5rem; }

/* Data Table */
.data-table {
    width: 100%;
    background: var(--color-surface);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-lg);
    overflow: hidden;
    box-shadow: var(--shadow-sm);
    border-collapse: collapse;
}

.data-table th, .data-table td {
    padding: 0.75rem 1rem;
    text-align: left;
    border-bottom: 1px solid var(--color-border);
    font-size: 0.875rem;
}

.data-table th {
    background: var(--color-bg);
    font-weight: 600;
    font-size: 0.75rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--color-text-muted);
}

.data-table tbody tr { transition: background var(--transition); }
.data-table tbody tr:hover { background: #f9f8ff; }
.data-table tbody tr:last-child td { border-bottom: none; }

.cell-photo { width: 56px; }
.cell-date { white-space: nowrap; color: var(--color-text-muted); font-size: 0.8rem; }
.cell-actions { white-space: nowrap; }
.cell-drag { width: 30px; cursor: grab; }

.table-thumb {
    width: 44px;
    height: 44px;
    object-fit: cover;
    border-radius: 6px;
    border: 1px solid var(--color-border);
}

.no-photo {
    display: inline-flex;
    width: 44px;
    height: 44px;
    align-items: center;
    justify-content: center;
    background: var(--color-bg);
    border-radius: 6px;
    font-size: 1.1rem;
    border: 1px solid var(--color-border);
}

.row-inactive { opacity: 0.45; }

/* Badges */
.badge {
    display: inline-block;
    padding: 0.2rem 0.6rem;
    border-radius: 20px;
    font-size: 0.7rem;
    font-weight: 600;
    letter-spacing: 0.02em;
    text-transform: uppercase;
}

.badge-green { background: var(--color-success-light); color: #065f46; }
.badge-gray { background: #f0f0f2; color: #6b7280; }
.badge-blue { background: #dbeafe; color: #1e40af; }

/* Forms */
.form-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 2.5rem;
}

@media (max-width: 768px) { .form-grid { grid-template-columns: 1fr; } }

.form-column { min-width: 0; }

.form-section-title {
    font-size: 0.8rem;
    color: var(--color-text-muted);
    margin-bottom: 1.25rem;
    padding-bottom: 0.5rem;
    border-bottom: 2px solid var(--color-accent-light);
    text-transform: uppercase;
    letter-spacing: 0.06em;
    font-weight: 600;
}

.form-group { margin-bottom: 1.1rem; }

.form-group label {
    display: block;
    font-weight: 600;
    font-size: 0.8rem;
    margin-bottom: 0.35rem;
    color: var(--color-text);
}

.form-input {
    width: 100%;
    padding: 0.55rem 0.85rem;
    border: 1px solid var(--color-border);
    border-radius: var(--radius);
    font-size: 0.875rem;
    font-family: inherit;
    background: white;
    transition: all var(--transition);
    color: var(--color-text);
}

.form-input:focus {
    outline: none;
    border-color: var(--color-accent);
    box-shadow: 0 0 0 3px rgba(124, 58, 237, 0.1);
}

.form-input-sm { max-width: 150px; }
.form-input-xs { max-width: 200px; font-size: 0.8rem; padding: 0.3rem 0.5rem; }
.form-input-color { width: 60px; height: 38px; padding: 3px; cursor: pointer; border-radius: var(--radius); }

.form-hint { display: block; font-size: 0.75rem; color: var(--color-text-muted); margin-top: 0.3rem; }

.form-row { display: flex; gap: 1.5rem; align-items: center; flex-wrap: wrap; }

.checkbox-label {
    display: flex !important;
    align-items: center;
    gap: 0.5rem;
    font-weight: 400 !important;
    cursor: pointer;
    font-size: 0.875rem;
}

.checkbox-group { display: flex; flex-wrap: wrap; gap: 0.25rem 1rem; }

.form-actions {
    display: flex;
    gap: 0.5rem;
    align-items: center;
    margin-top: 2rem;
    padding-top: 1.5rem;
    border-top: 1px solid var(--color-border);
}
.form-actions-danger {
    margin-top: 1rem;
    padding-top: 1rem;
    border-top: 1px solid var(--color-border);
    justify-content: flex-end;
}

.inline-form { display: inline-block; }
.delete-form { margin-left: auto; }

/* Collapsible Form Cards */
.form-card {
    background: var(--color-surface);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-lg);
    margin-bottom: 1rem;
    box-shadow: var(--shadow-sm);
    overflow: hidden;
}

.form-card-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0.85rem 1.25rem;
    cursor: pointer;
    user-select: none;
    transition: background var(--transition);
    background: var(--color-bg);
    border-bottom: 1px solid transparent;
}

.form-card-header:hover { background: #eeedf5; }

.form-card-header h3 {
    font-size: 0.95rem;
    font-weight: 600;
    margin: 0;
}

.collapse-icon {
    font-size: 1.2rem;
    color: var(--color-text-muted);
    transition: transform 0.25s ease;
    font-weight: bold;
}

.collapsible .form-card-body {
    max-height: 0;
    overflow: hidden;
    transition: max-height 0.35s ease, padding 0.35s ease;
    padding: 0 1.25rem;
}

.collapsible.open .form-card-body {
    max-height: 2000px;
    padding: 1rem 1.25rem 1.25rem;
}

.collapsible.open .form-card-header {
    border-bottom: 1px solid var(--color-border);
}

.collapsible.open .collapse-icon {
    transform: rotate(90deg);
}

.form-card:not(.collapsible) .form-card-body {
    padding: 1.25rem;
}

/* Field grid inside sections — compact 2-column layout */
.field-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 0.75rem 1.5rem;
}

.field-grid .form-group { margin-bottom: 0; }
.field-grid .form-group-full { grid-column: 1 / -1; }

@media (max-width: 600px) {
    .field-grid { grid-template-columns: 1fr; }
}

/* Buttons */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 0.5rem 1.1rem;
    border-radius: var(--radius);
    font-size: 0.85rem;
    font-weight: 500;
    border: none;
    cursor: pointer;
    text-decoration: none;
    transition: all var(--transition);
    color: var(--color-text);
    background: var(--color-bg);
    border: 1px solid var(--color-border);
    font-family: inherit;
}

.btn:hover { background: #eeedf2; color: var(--color-text); }

.btn-primary {
    background: var(--color-accent);
    color: white;
    border-color: var(--color-accent);
    box-shadow: 0 1px 3px rgba(124, 58, 237, 0.2);
}

.btn-primary:hover {
    background: var(--color-accent-hover);
    color: white;
    box-shadow: 0 2px 8px rgba(124, 58, 237, 0.3);
    transform: translateY(-1px);
}

.btn-secondary { background: white; color: var(--color-text); }
.btn-danger { background: var(--color-danger); color: white; border-color: var(--color-danger); }
.btn-danger:hover { background: #b91c1c; color: white; }
.btn-warning { background: var(--color-warning); color: white; border-color: var(--color-warning); }
.btn-success { background: var(--color-success); color: white; border-color: var(--color-success); }
.btn-sm { padding: 0.35rem 0.75rem; font-size: 0.8rem; }
.btn-xs { padding: 0.2rem 0.55rem; font-size: 0.75rem; }
.btn-block { width: 100%; text-align: center; }

/* Login Page */
.login-body {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 100vh;
    background: linear-gradient(135deg, #7c3aed 0%, #4c1d95 50%, #1e1b4b 100%);
}

.login-card {
    background: white;
    padding: 2.5rem;
    border-radius: 16px;
    box-shadow: 0 25px 60px rgba(0, 0, 0, 0.2);
    width: 100%;
    max-width: 400px;
    text-align: center;
}

.login-card h1 { font-size: 1.5rem; margin-bottom: 0.25rem; }
.login-subtitle { color: var(--color-text-muted); margin-bottom: 1.5rem; font-size: 0.9rem; }
.login-card .form-group { text-align: left; }

/* Upload Area */
.upload-area {
    background: var(--color-surface);
    border: 2px dashed var(--color-border);
    border-radius: var(--radius-lg);
    padding: 2.5rem;
    text-align: center;
    margin-bottom: 2rem;
    transition: all var(--transition);
}

.upload-area:hover { border-color: var(--color-accent); background: #faf8ff; }

.upload-label {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.5rem;
    cursor: pointer;
    color: var(--color-text-muted);
}

.upload-icon { font-size: 2.5rem; }
.upload-label small { font-size: 0.75rem; }
.upload-input { display: none; }
.upload-area-inline { padding: 1.5rem; margin-bottom: 0; border: none; }
.photo-preview-grid { display: flex; flex-wrap: wrap; gap: 0.5rem; margin-top: 0.75rem; }
.photo-preview-item { position: relative; }
.photo-preview-item img { width: 80px; height: 80px; object-fit: cover; border-radius: 6px; border: 1px solid var(--color-border); display: block; }
.photo-preview-remove { position: absolute; top: -6px; right: -6px; width: 20px; height: 20px; border-radius: 50%; border: none; background: #dc2626; color: #fff; font-size: 14px; line-height: 20px; text-align: center; padding: 0; cursor: pointer; }

/* Photo Grid (admin) */
.photo-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
    gap: 1rem;
}

.photo-card {
    background: var(--color-surface);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-lg);
    overflow: hidden;
    box-shadow: var(--shadow-sm);
    transition: all var(--transition);
}

.photo-card:hover { box-shadow: var(--shadow-md); }

.photo-card-image {
    position: relative;
    aspect-ratio: 1;
    overflow: hidden;
}

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

.photo-badge {
    position: absolute;
    top: 8px;
    left: 8px;
    background: var(--color-accent);
    color: white;
    padding: 0.2rem 0.6rem;
    border-radius: 20px;
    font-size: 0.65rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.drag-handle {
    position: absolute;
    top: 8px;
    right: 8px;
    background: rgba(0,0,0,0.5);
    color: white;
    width: 26px;
    height: 26px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 6px;
    cursor: grab;
    font-size: 0.8rem;
    backdrop-filter: blur(4px);
}

.photo-card-actions {
    padding: 0.5rem 0.6rem;
    display: flex;
    flex-wrap: wrap;
    gap: 0.35rem;
}

.caption-form { display: flex !important; gap: 0.25rem; flex: 1; }

.photo-meta {
    display: block;
    padding: 0 0.6rem 0.5rem;
    color: var(--color-text-muted);
    font-size: 0.7rem;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.sortable-table .drag-handle {
    position: static;
    background: none;
    color: var(--color-text-muted);
    width: auto;
    height: auto;
    font-size: 1.1rem;
    backdrop-filter: none;
}

.text-muted { color: var(--color-text-muted); }

/* Responsive */
@media (max-width: 768px) {
    .admin-nav-inner { flex-direction: column; height: auto; padding: 0.75rem 0; gap: 0.5rem; }
    .admin-nav-links { flex-wrap: wrap; justify-content: center; }
    .stats-grid { grid-template-columns: repeat(2, 1fr); }
    .photo-grid { grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); }
}
