/* ─── Reset & Base ─────────────────────────────────────────────────────────── */
* { margin: 0; padding: 0; box-sizing: border-box; }

body {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    background: #f0f2f5;
    color: #333;
    min-height: 100vh;
}

/* ─── Login Page ────────────────────────────────────────────────────────────── */
#loginPage {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 100vh;
    background: linear-gradient(135deg, #1a73e8 0%, #0d47a1 100%);
}

.login-card {
    background: white;
    border-radius: 16px;
    padding: 40px;
    width: 100%;
    max-width: 400px;
    box-shadow: 0 8px 32px rgba(0,0,0,0.2);
}

.login-logo {
    text-align: center;
    margin-bottom: 32px;
}

.login-logo i {
    font-size: 3rem;
    color: #1a73e8;
    margin-bottom: 12px;
    display: block;
}

.login-logo h1 {
    font-size: 1.8rem;
    color: #333;
    margin-bottom: 4px;
}

.login-logo p {
    color: #666;
    font-size: 0.9rem;
}

/* ─── App Header ────────────────────────────────────────────────────────────── */
.app-header {
    background: #1a73e8;
    color: white;
    padding: 12px 24px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    box-shadow: 0 2px 8px rgba(0,0,0,0.15);
    position: sticky;
    top: 0;
    z-index: 100;
}

.header-left {
    display: flex;
    align-items: center;
    gap: 10px;
    font-size: 1.2rem;
    font-weight: 600;
}

.header-left i { font-size: 1.4rem; }

.header-right {
    display: flex;
    align-items: center;
    gap: 12px;
}

.user-email {
    font-size: 0.85rem;
    opacity: 0.9;
}

.role-badge {
    background: rgba(255,255,255,0.2);
    padding: 3px 10px;
    border-radius: 12px;
    font-size: 0.75rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.role-badge.admin { background: #e53935; }
.role-badge.manager { background: #f57c00; }
.role-badge.user { background: rgba(255,255,255,0.2); }

/* ─── Tab Navigation ────────────────────────────────────────────────────────── */
.tab-nav {
    background: white;
    border-bottom: 2px solid #e0e0e0;
    display: flex;
    padding: 0 24px;
    gap: 4px;
    overflow-x: auto;
}

.tab-btn {
    background: none;
    border: none;
    padding: 14px 20px;
    cursor: pointer;
    font-size: 0.9rem;
    color: #666;
    border-bottom: 3px solid transparent;
    margin-bottom: -2px;
    white-space: nowrap;
    display: flex;
    align-items: center;
    gap: 6px;
    transition: color 0.2s, border-color 0.2s;
}

.tab-btn:hover { color: #1a73e8; }
.tab-btn.active { color: #1a73e8; border-bottom-color: #1a73e8; font-weight: 600; }

/* ─── Main Content ──────────────────────────────────────────────────────────── */
.tab-content {
    padding: 24px;
    max-width: 1100px;
    margin: 0 auto;
}

.card {
    background: white;
    border-radius: 12px;
    padding: 28px;
    box-shadow: 0 2px 8px rgba(0,0,0,0.08);
    margin-bottom: 20px;
}

.card h2 {
    font-size: 1.3rem;
    color: #333;
    margin-bottom: 24px;
    display: flex;
    align-items: center;
    gap: 8px;
}

.card h2 i { color: #1a73e8; }

.card-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
    flex-wrap: wrap;
    gap: 12px;
}

.card-header h2 { margin-bottom: 0; }

.card-header-actions {
    display: flex;
    align-items: center;
    gap: 10px;
    flex-wrap: wrap;
}

/* ─── Forms ─────────────────────────────────────────────────────────────────── */
.form-group {
    margin-bottom: 18px;
}

.form-group label {
    display: block;
    font-weight: 500;
    color: #555;
    margin-bottom: 6px;
    font-size: 0.9rem;
}

.form-group input,
.form-group select,
.form-group textarea {
    width: 100%;
    padding: 10px 14px;
    border: 1.5px solid #ddd;
    border-radius: 8px;
    font-size: 0.95rem;
    transition: border-color 0.2s, box-shadow 0.2s;
    font-family: inherit;
}

.form-group input:focus,
.form-group select:focus,
.form-group textarea:focus {
    outline: none;
    border-color: #1a73e8;
    box-shadow: 0 0 0 3px rgba(26,115,232,0.12);
}

.form-row {
    display: flex;
    gap: 16px;
}

.flex-1 { flex: 1; }

.input-with-btn {
    display: flex;
    gap: 8px;
}

.input-with-btn input { flex: 1; }

.form-actions {
    display: flex;
    gap: 12px;
    margin-top: 24px;
}

.inline-form {
    display: flex;
    gap: 12px;
    flex-wrap: wrap;
    align-items: flex-end;
}

.inline-form .form-group {
    margin-bottom: 0;
    min-width: 160px;
}

/* ─── Buttons ───────────────────────────────────────────────────────────────── */
.btn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 10px 20px;
    border-radius: 8px;
    border: none;
    cursor: pointer;
    font-size: 0.9rem;
    font-weight: 500;
    transition: background 0.2s, opacity 0.2s, transform 0.1s;
    white-space: nowrap;
    font-family: inherit;
}

.btn:active { transform: scale(0.98); }
.btn:disabled { opacity: 0.5; cursor: not-allowed; }

.btn-primary { background: #1a73e8; color: white; }
.btn-primary:hover:not(:disabled) { background: #1557b0; }

.btn-secondary { background: #6c757d; color: white; }
.btn-secondary:hover:not(:disabled) { background: #545b62; }

.btn-success { background: #28a745; color: white; }
.btn-success:hover:not(:disabled) { background: #1e7e34; }

.btn-danger { background: #dc3545; color: white; }
.btn-danger:hover:not(:disabled) { background: #bd2130; }

.btn-outline {
    background: transparent;
    color: #1a73e8;
    border: 1.5px solid #1a73e8;
}
.btn-outline:hover:not(:disabled) { background: #e8f0fe; }

.btn-sm { padding: 6px 14px; font-size: 0.82rem; }
.btn-full { width: 100%; justify-content: center; }
.btn-icon { padding: 10px 14px; }

/* ─── Messages ──────────────────────────────────────────────────────────────── */
.error-msg {
    background: #fdecea;
    color: #c62828;
    border: 1px solid #f5c6cb;
    padding: 10px 14px;
    border-radius: 8px;
    font-size: 0.9rem;
    margin-bottom: 12px;
}

.success-msg {
    background: #e8f5e9;
    color: #2e7d32;
    border: 1px solid #c8e6c9;
    padding: 10px 14px;
    border-radius: 8px;
    font-size: 0.9rem;
    margin-bottom: 12px;
}

.loading-msg {
    text-align: center;
    padding: 40px;
    color: #666;
    font-size: 0.95rem;
}

/* ─── QR Scanner ────────────────────────────────────────────────────────────── */
.qr-scanner-container {
    background: #000;
    border-radius: 12px;
    overflow: hidden;
    margin-bottom: 18px;
    position: relative;
}

.qr-scanner-header {
    background: rgba(0,0,0,0.7);
    color: white;
    padding: 10px 16px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-size: 0.9rem;
}

#qrVideo {
    width: 100%;
    max-height: 300px;
    object-fit: cover;
    display: block;
}

.scan-status {
    background: rgba(0,0,0,0.7);
    color: #4caf50;
    text-align: center;
    padding: 8px;
    font-size: 0.85rem;
}

/* ─── Entries Table ─────────────────────────────────────────────────────────── */
.entries-table-wrapper {
    overflow-x: auto;
}

.entries-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.88rem;
}

.entries-table th {
    background: #f8f9fa;
    padding: 10px 14px;
    text-align: left;
    font-weight: 600;
    color: #555;
    border-bottom: 2px solid #e0e0e0;
    white-space: nowrap;
}

.entries-table td {
    padding: 10px 14px;
    border-bottom: 1px solid #f0f0f0;
    vertical-align: middle;
}

.entries-table tr:hover td { background: #f8f9fa; }

.entries-table tr.selected td { background: #e8f0fe; }

.entries-table input[type="checkbox"] {
    width: 16px;
    height: 16px;
    cursor: pointer;
}

/* Status badges */
.status-badge {
    display: inline-block;
    padding: 3px 10px;
    border-radius: 12px;
    font-size: 0.75rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.3px;
}

.status-pending { background: #fff3e0; color: #e65100; }
.status-rma_issued { background: #e3f2fd; color: #1565c0; }
.status-nff { background: #f3e5f5; color: #6a1b9a; }
.status-confirmed { background: #fce4ec; color: #880e4f; }

/* ─── Search & Filter inputs ────────────────────────────────────────────────── */
.search-sm {
    padding: 7px 12px;
    border: 1.5px solid #ddd;
    border-radius: 8px;
    font-size: 0.85rem;
    min-width: 180px;
}

.search-sm:focus {
    outline: none;
    border-color: #1a73e8;
}

.filter-sm {
    padding: 7px 12px;
    border: 1.5px solid #ddd;
    border-radius: 8px;
    font-size: 0.85rem;
}

/* ─── Modal ─────────────────────────────────────────────────────────────────── */
.modal {
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.5);
    z-index: 1000;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
}

.modal-content {
    background: white;
    border-radius: 16px;
    width: 100%;
    max-width: 600px;
    max-height: 90vh;
    overflow: hidden;
    display: flex;
    flex-direction: column;
    box-shadow: 0 16px 48px rgba(0,0,0,0.25);
}

.modal-header {
    padding: 20px 24px;
    border-bottom: 1px solid #eee;
    display: flex;
    justify-content: space-between;
    align-items: center;
    background: #f8f9fa;
}

.modal-header h2 { font-size: 1.1rem; color: #333; }

.modal-close {
    background: none;
    border: none;
    font-size: 1.5rem;
    cursor: pointer;
    color: #666;
    line-height: 1;
    padding: 4px 8px;
    border-radius: 4px;
}

.modal-close:hover { background: #eee; }

.modal-body {
    padding: 24px;
    overflow-y: auto;
    flex: 1;
}

/* ─── Users List ────────────────────────────────────────────────────────────── */
.users-list {
    margin-top: 16px;
}

.user-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 12px 16px;
    border: 1px solid #eee;
    border-radius: 8px;
    margin-bottom: 8px;
    background: #fafafa;
}

.user-info { display: flex; flex-direction: column; gap: 2px; }
.user-email-text { font-weight: 500; font-size: 0.9rem; }
.user-company { font-size: 0.8rem; color: #666; }

.user-actions { display: flex; gap: 8px; align-items: center; }

/* ─── Optional tag ──────────────────────────────────────────────────────────── */
.optional-tag {
    font-size: 0.78rem;
    color: #888;
    font-weight: 400;
    font-style: italic;
}

/* ─── Misc ──────────────────────────────────────────────────────────────────── */
.divider {
    border: none;
    border-top: 1px solid #eee;
    margin: 24px 0;
}

.text-muted { color: #666; font-size: 0.9rem; }
.mb-16 { margin-bottom: 16px; }

.no-entries {
    text-align: center;
    padding: 48px 20px;
    color: #999;
}

.no-entries i { font-size: 2.5rem; margin-bottom: 12px; display: block; }

/* ─── Responsive ────────────────────────────────────────────────────────────── */
@media (max-width: 640px) {
    .tab-content { padding: 16px; }
    .card { padding: 20px; }
    .form-row { flex-direction: column; }
    .inline-form { flex-direction: column; }
    .card-header { flex-direction: column; align-items: flex-start; }
    .header-right .user-email { display: none; }
    .form-actions { flex-direction: column; }
    .form-actions .btn { width: 100%; justify-content: center; }
}
