/* === Base Reset === */
*, *::before, *::after {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

:root {
    --bg-primary: #1a1a2e;
    --bg-secondary: #16213e;
    --bg-card: #1f2940;
    --bg-input: #2a3555;
    --text-primary: #e8e8e8;
    --text-secondary: #a0a8c0;
    --text-muted: #6b7280;
    --accent: #d4a843;
    --accent-hover: #e6bc5a;
    --border: #2d3a56;
    --success: #27ae60;
    --error: #e74c3c;
    --info: #3498db;
    --danger: #e74c3c;
    --danger-hover: #c0392b;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, sans-serif;
    background: var(--bg-primary);
    color: var(--text-primary);
    line-height: 1.6;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

a {
    color: var(--accent);
    text-decoration: none;
}
a:hover {
    color: var(--accent-hover);
}

/* === Navbar === */
.navbar {
    background: var(--bg-secondary);
    border-bottom: 1px solid var(--border);
    padding: 0 2rem;
    display: flex;
    align-items: center;
    justify-content: space-between;
    height: 60px;
}

.nav-brand a {
    color: var(--accent);
    font-size: 1.2rem;
    font-weight: 700;
    letter-spacing: 0.5px;
}

.nav-links {
    display: flex;
    align-items: center;
    gap: 1.5rem;
}

.nav-links a {
    color: var(--text-secondary);
    font-size: 0.9rem;
    padding: 0.3rem 0;
    transition: color 0.2s;
    position: relative;
}
.nav-links a:hover,
.nav-links a.active {
    color: var(--text-primary);
}
.nav-links a.active::after {
    content: '';
    position: absolute;
    bottom: -18px;
    left: 0;
    right: 0;
    height: 2px;
    background: var(--accent);
}

.nav-user {
    color: var(--text-muted);
    font-size: 0.85rem;
    padding-left: 1rem;
    border-left: 1px solid var(--border);
}

.btn-logout {
    color: var(--text-muted) !important;
    font-size: 0.85rem;
}
.btn-logout:hover {
    color: var(--error) !important;
}

/* Badge */
.badge {
    background: var(--error);
    color: white;
    font-size: 0.7rem;
    padding: 1px 6px;
    border-radius: 10px;
    vertical-align: super;
    margin-left: 4px;
}

.header-badge {
    background: var(--accent);
    color: var(--bg-primary);
    font-size: 0.8rem;
    padding: 2px 10px;
    border-radius: 12px;
    font-weight: 600;
}

/* === Container === */
.container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 2rem;
    flex: 1;
    width: 100%;
}

/* === Page Header === */
.page-header {
    display: flex;
    align-items: center;
    gap: 1rem;
    margin-bottom: 1.5rem;
}
.page-header h1 {
    font-size: 1.5rem;
    font-weight: 600;
}

/* === Alerts === */
.alert {
    padding: 0.75rem 1rem;
    border-radius: 6px;
    margin-bottom: 1rem;
    font-size: 0.9rem;
}
.alert-success { background: rgba(39, 174, 96, 0.15); border: 1px solid var(--success); color: #5dde8f; }
.alert-error { background: rgba(231, 76, 60, 0.15); border: 1px solid var(--error); color: #f08070; }
.alert-info { background: rgba(52, 152, 219, 0.15); border: 1px solid var(--info); color: #72b4e8; }

/* === Forms === */
.form-group {
    margin-bottom: 1rem;
}
.form-group label {
    display: block;
    margin-bottom: 0.4rem;
    font-size: 0.85rem;
    color: var(--text-secondary);
    font-weight: 500;
}

.form-control {
    width: 100%;
    padding: 0.6rem 0.8rem;
    background: var(--bg-input);
    border: 1px solid var(--border);
    border-radius: 6px;
    color: var(--text-primary);
    font-size: 0.9rem;
    transition: border-color 0.2s;
}
.form-control:focus {
    outline: none;
    border-color: var(--accent);
}
.form-control-sm {
    padding: 0.4rem 0.6rem;
    font-size: 0.85rem;
}

select.form-control {
    cursor: pointer;
}

.form-error {
    display: block;
    color: var(--error);
    font-size: 0.8rem;
    margin-top: 0.3rem;
}

.checkbox-group {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}
.checkbox-group label {
    margin-bottom: 0;
}

.radio-group {
    display: flex;
    gap: 1.5rem;
}
.radio-option {
    display: flex;
    align-items: center;
    gap: 0.4rem;
}
.radio-option label {
    margin-bottom: 0;
    cursor: pointer;
    color: var(--text-primary);
}

.form-row-inline {
    display: flex;
    gap: 1rem;
    flex-wrap: wrap;
    align-items: flex-end;
}
.form-row-inline .form-group {
    flex: 1;
    min-width: 140px;
}

/* === Buttons === */
.btn {
    display: inline-block;
    padding: 0.6rem 1.2rem;
    border: none;
    border-radius: 6px;
    font-size: 0.9rem;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s;
    text-align: center;
}
.btn-primary {
    background: var(--accent);
    color: var(--bg-primary);
}
.btn-primary:hover {
    background: var(--accent-hover);
    color: var(--bg-primary);
}
.btn-secondary {
    background: var(--bg-input);
    color: var(--text-secondary);
    border: 1px solid var(--border);
}
.btn-secondary:hover {
    background: var(--border);
    color: var(--text-primary);
}
.btn-danger {
    background: var(--danger);
    color: white;
}
.btn-danger:hover {
    background: var(--danger-hover);
    color: white;
}
.btn-block {
    display: block;
    width: 100%;
}
.btn-sm {
    padding: 0.35rem 0.7rem;
    font-size: 0.8rem;
}

/* === Auth Page === */
.auth-container {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: calc(100vh - 140px);
}
.auth-card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: 12px;
    padding: 2.5rem;
    width: 100%;
    max-width: 400px;
}
.auth-card h1 {
    text-align: center;
    font-size: 1.4rem;
    color: var(--accent);
    margin-bottom: 0.3rem;
}
.auth-subtitle {
    text-align: center;
    color: var(--text-muted);
    font-size: 0.9rem;
    margin-bottom: 1.5rem;
}

/* === Upload Form === */
.upload-form {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: 12px;
    padding: 2rem;
}

.form-row {
    display: flex;
    gap: 2rem;
}
.image-col {
    flex: 1;
    min-width: 300px;
}
.fields-col {
    flex: 1;
    min-width: 300px;
}

.drop-zone {
    border: 2px dashed var(--border);
    border-radius: 8px;
    padding: 2rem;
    text-align: center;
    cursor: pointer;
    transition: border-color 0.2s, background 0.2s;
    min-height: 300px;
    display: flex;
    align-items: center;
    justify-content: center;
    position: relative;
    overflow: hidden;
}
.drop-zone:hover,
.drop-zone.drag-over {
    border-color: var(--accent);
    background: rgba(212, 168, 67, 0.05);
}

.drop-zone input[type="file"] {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    opacity: 0;
    cursor: pointer;
}

.drop-zone-prompt {
    color: var(--text-muted);
}
.drop-zone-prompt svg {
    margin-bottom: 0.5rem;
    color: var(--border);
}
.drop-zone-prompt p {
    font-size: 0.9rem;
    margin-bottom: 0.3rem;
}
.drop-zone-hint {
    font-size: 0.75rem;
    color: var(--text-muted);
}

.image-preview {
    max-width: 100%;
    max-height: 400px;
    border-radius: 6px;
    object-fit: contain;
}

/* === Tables === */
.table-responsive {
    overflow-x: auto;
}
.table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.9rem;
}
.table th {
    text-align: left;
    padding: 0.75rem 0.8rem;
    color: var(--text-muted);
    font-weight: 500;
    font-size: 0.8rem;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    border-bottom: 1px solid var(--border);
}
.table td {
    padding: 0.75rem 0.8rem;
    border-bottom: 1px solid rgba(45, 58, 86, 0.5);
    vertical-align: middle;
}
.table tbody tr:hover {
    background: rgba(212, 168, 67, 0.03);
}

.clickable-row {
    cursor: pointer;
}

.row-unread {
    background: rgba(212, 168, 67, 0.06);
}
.row-unread td {
    font-weight: 500;
}

.dot-new {
    display: inline-block;
    width: 8px;
    height: 8px;
    background: var(--accent);
    border-radius: 50%;
}

.thumb {
    width: 50px;
    height: 50px;
    object-fit: cover;
    border-radius: 4px;
    border: 1px solid var(--border);
}

/* === Tags === */
.tag {
    display: inline-block;
    padding: 2px 8px;
    border-radius: 4px;
    font-size: 0.75rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.3px;
}
.tag-analysis {
    background: rgba(52, 152, 219, 0.15);
    color: #72b4e8;
}
.tag-baseline {
    background: rgba(212, 168, 67, 0.15);
    color: var(--accent);
}

/* === Filters === */
.filters {
    margin-bottom: 1rem;
}
.filter-form {
    display: flex;
    gap: 0.75rem;
    align-items: center;
}

/* === Detail Page === */
.detail-layout {
    display: flex;
    gap: 2rem;
    align-items: flex-start;
}
.detail-image {
    flex: 1;
    min-width: 300px;
}
.full-image {
    width: 100%;
    max-height: 600px;
    object-fit: contain;
    border-radius: 8px;
    border: 1px solid var(--border);
    background: var(--bg-secondary);
}

.detail-info {
    flex: 1;
    min-width: 300px;
}

.info-card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: 12px;
    padding: 1.5rem;
    margin-bottom: 1rem;
}
.info-card h2 {
    font-size: 1.1rem;
    margin-bottom: 1rem;
    color: var(--accent);
}

.info-table {
    width: 100%;
}
.info-table th {
    text-align: left;
    padding: 0.5rem 1rem 0.5rem 0;
    color: var(--text-muted);
    font-weight: 500;
    font-size: 0.85rem;
    width: 140px;
    vertical-align: top;
}
.info-table td {
    padding: 0.5rem 0;
    font-size: 0.9rem;
}

.detail-actions {
    display: flex;
    gap: 1rem;
    flex-wrap: wrap;
}
.inline-form {
    display: inline;
}

/* === Cards === */
.card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: 12px;
    padding: 1.5rem;
    margin-bottom: 1.5rem;
}
.card h2 {
    font-size: 1.1rem;
    margin-bottom: 1rem;
    color: var(--accent);
}

/* === Pagination === */
.pagination {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 1rem;
    margin-top: 1.5rem;
}
.page-info {
    color: var(--text-muted);
    font-size: 0.85rem;
}

/* === Empty State === */
.empty-state {
    text-align: center;
    padding: 3rem 1rem;
    color: var(--text-muted);
}
.empty-state p {
    margin-bottom: 1rem;
}

/* === Footer === */
.footer {
    text-align: center;
    padding: 1rem;
    color: var(--text-muted);
    font-size: 0.75rem;
    border-top: 1px solid var(--border);
}

/* === Responsive === */
@media (max-width: 768px) {
    .navbar {
        padding: 0 1rem;
    }
    .nav-links {
        gap: 0.8rem;
    }
    .container {
        padding: 1rem;
    }
    .form-row {
        flex-direction: column;
    }
    .detail-layout {
        flex-direction: column;
    }
    .form-row-inline {
        flex-direction: column;
    }
    .filter-form {
        flex-wrap: wrap;
    }
}
