/* Reset and base */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
    --primary: #3498db;
    --primary-dark: #2980b9;
    --success: #27ae60;
    --warning: #f39c12;
    --danger: #e74c3c;
    --gray-100: #f8f9fa;
    --gray-200: #e9ecef;
    --gray-300: #dee2e6;
    --gray-500: #6c757d;
    --gray-700: #495057;
    --gray-900: #212529;
    --radius: 8px;
    --shadow: 0 2px 8px rgba(0,0,0,0.1);
}

body {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
    line-height: 1.6;
    color: var(--gray-900);
    background: var(--gray-100);
}

/* Navbar */
.navbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0.75rem 1.5rem;
    background: white;
    box-shadow: var(--shadow);
    position: sticky;
    top: 0;
    z-index: 100;
}

.navbar-brand a {
    font-size: 1.25rem;
    font-weight: 700;
    color: var(--primary);
    text-decoration: none;
}

.navbar-menu { display: flex; gap: 1rem; }

.navbar-user {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.nav-link {
    color: var(--gray-700);
    text-decoration: none;
    padding: 0.25rem 0.5rem;
    border-radius: 4px;
    transition: background 0.2s;
}
.nav-link:hover { background: var(--gray-200); }

.avatar {
    width: 28px;
    height: 28px;
    border-radius: 50%;
}

.user-name { font-size: 0.875rem; color: var(--gray-700); }

.badge {
    font-size: 0.7rem;
    padding: 0.15rem 0.4rem;
    border-radius: 4px;
    font-weight: 600;
    text-transform: uppercase;
}
.badge-admin { background: var(--primary); color: white; }

/* Container */
.container {
    max-width: 1100px;
    margin: 2rem auto;
    padding: 0 1rem;
}

/* Buttons */
.btn {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.5rem 1rem;
    border: none;
    border-radius: var(--radius);
    cursor: pointer;
    font-size: 0.875rem;
    font-weight: 500;
    text-decoration: none;
    transition: background 0.2s, opacity 0.2s;
}
.btn:hover { opacity: 0.9; }
.btn:disabled { opacity: 0.5; cursor: not-allowed; }

.btn-primary { background: var(--primary); color: white; }
.btn-secondary { background: var(--gray-200); color: var(--gray-700); }
.btn-danger { background: var(--danger); color: white; }
.btn-danger-outline { background: white; color: var(--danger); border: 1px solid var(--danger); }

.btn-small { padding: 0.25rem 0.5rem; font-size: 0.75rem; }
.btn-close {
    background: none;
    border: none;
    font-size: 1.5rem;
    cursor: pointer;
    color: var(--gray-500);
}

/* Status-specific buttons */
.btn-printing { background: var(--warning); color: white; }
.btn-printed { background: var(--success); color: white; }
.btn-failed { background: var(--danger); color: white; }
.btn-not-printable { background: var(--gray-500); color: white; }
.btn-requeue { background: var(--gray-200); color: var(--gray-700); }

/* Login */
.login-container {
    max-width: 400px;
    margin: 4rem auto;
    text-align: center;
}
.login-container h1 { font-size: 2rem; color: var(--primary); margin-bottom: 0.5rem; }
.login-subtitle { color: var(--gray-500); margin-bottom: 2rem; }

.login-section {
    margin-bottom: 2rem;
    padding: 1.5rem;
    background: white;
    border-radius: var(--radius);
    box-shadow: var(--shadow);
}
.login-section h3 { margin-bottom: 1rem; color: var(--gray-700); }
.login-section-admin { border-top: 2px solid var(--gray-200); }

.login-buttons { display: flex; flex-direction: column; gap: 0.75rem; }

.btn-google {
    background: white;
    color: var(--gray-700);
    border: 1px solid var(--gray-300);
    padding: 0.75rem 1.5rem;
    font-size: 1rem;
    justify-content: center;
}
.btn-google:hover { background: var(--gray-100); }

.btn-github {
    background: #24292e;
    color: white;
    padding: 0.75rem 1.5rem;
    font-size: 1rem;
    justify-content: center;
}

/* Forms */
.form-group { margin-bottom: 1.5rem; }
.form-group label { display: block; margin-bottom: 0.5rem; font-weight: 500; }

.input, select {
    width: 100%;
    padding: 0.5rem 0.75rem;
    border: 1px solid var(--gray-300);
    border-radius: var(--radius);
    font-size: 0.875rem;
    background: white;
}
.input:focus, select:focus { outline: none; border-color: var(--primary); box-shadow: 0 0 0 2px rgba(52,152,219,0.2); }

.input-inline {
    width: auto;
    flex: 1;
    padding: 0.25rem 0.5rem;
}

.form-row { display: flex; gap: 0.5rem; align-items: end; }
.form-actions { margin-top: 1.5rem; }

/* Drop zone */
.drop-zone {
    border: 2px dashed var(--gray-300);
    border-radius: var(--radius);
    padding: 2rem;
    text-align: center;
    cursor: pointer;
    transition: border-color 0.2s, background 0.2s;
}
.drop-zone:hover, .drop-zone.drag-over {
    border-color: var(--primary);
    background: rgba(52,152,219,0.05);
}
.drop-zone input[type="file"] { display: none; }
.file-info { margin-top: 0.5rem; font-size: 0.875rem; color: var(--gray-500); }

/* Alerts */
.alert {
    padding: 0.75rem 1rem;
    border-radius: var(--radius);
    margin: 1rem 0;
    font-size: 0.875rem;
}
.alert-error { background: #fdecea; color: var(--danger); border: 1px solid #f5c6cb; }
.alert-success { background: #d4edda; color: #155724; border: 1px solid #c3e6cb; }
.alert-warning { background: #fff3cd; color: #856404; border: 1px solid #ffeaa7; }

/* Tables */
.jobs-table {
    width: 100%;
    border-collapse: collapse;
    background: white;
    border-radius: var(--radius);
    overflow: hidden;
    box-shadow: var(--shadow);
}
.jobs-table th, .jobs-table td {
    padding: 0.75rem 1rem;
    text-align: left;
    border-bottom: 1px solid var(--gray-200);
}
.jobs-table th { background: var(--gray-100); font-weight: 600; font-size: 0.8rem; text-transform: uppercase; color: var(--gray-500); }

/* Status badges */
.status-badge {
    display: inline-block;
    padding: 0.2rem 0.5rem;
    border-radius: 4px;
    font-size: 0.75rem;
    font-weight: 600;
    text-transform: uppercase;
}
.status-queued { background: #dbeafe; color: #1e40af; }
.status-printing { background: #fef3c7; color: #92400e; }
.status-printed { background: #d1fae5; color: #065f46; }
.status-failed { background: #fdecea; color: var(--danger); }
.status-not_printable { background: var(--gray-200); color: var(--gray-700); }
.status-rejected { background: #fdecea; color: var(--danger); }
.status-prev-failed { background: #fef3c7; color: #92400e; border: 1px solid #f59e0b; }

/* Queue */
.queue-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1.5rem;
}
.queue-filters { display: flex; gap: 0.5rem; align-items: center; }

.queue-list { display: flex; flex-direction: column; gap: 1rem; }

.queue-card {
    display: flex;
    gap: 1rem;
    background: white;
    border-radius: var(--radius);
    padding: 1rem;
    box-shadow: var(--shadow);
    transition: box-shadow 0.2s;
}
.queue-card:hover { box-shadow: 0 4px 16px rgba(0,0,0,0.15); }

.queue-card-preview {
    flex-shrink: 0;
    position: relative;
}
.queue-card-preview canvas {
    border-radius: var(--radius);
    cursor: grab;
    border: 1px solid var(--gray-200);
}
.queue-card-preview canvas:active {
    cursor: grabbing;
}
.btn-expand {
    position: absolute;
    top: 4px;
    right: 4px;
    background: rgba(255,255,255,0.85);
    border: 1px solid var(--gray-300);
    border-radius: 4px;
    padding: 3px 4px;
    cursor: pointer;
    color: var(--gray-500);
    line-height: 0;
    transition: background 0.2s, color 0.2s;
}
.btn-expand:hover {
    background: white;
    color: var(--gray-900);
}

.queue-card-info { flex: 1; display: flex; flex-direction: column; gap: 0.5rem; }

.queue-card-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.queue-card-meta {
    display: flex;
    flex-wrap: wrap;
    gap: 0.75rem;
    font-size: 0.8rem;
    color: var(--gray-500);
}

.queue-card-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
    align-items: center;
    justify-content: space-between;
}
.status-buttons { display: flex; gap: 0.25rem; flex-wrap: wrap; }
.queue-card-inline { display: flex; gap: 0.25rem; }

.queue-card-feedback {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-size: 0.85rem;
}
.queue-card-feedback label { font-weight: 500; white-space: nowrap; }

.queue-card-reject {
    font-size: 0.85rem;
    color: var(--danger);
    padding: 0.25rem 0.5rem;
    background: #fdecea;
    border-radius: 4px;
}

/* Modal */
.job-modal {
    border: none;
    border-radius: var(--radius);
    box-shadow: 0 8px 32px rgba(0,0,0,0.3);
    padding: 0;
    max-width: 800px;
    width: 90vw;
    margin: auto;
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
}
.job-modal::backdrop { background: rgba(0,0,0,0.5); }

.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 1rem 1.5rem;
    border-bottom: 1px solid var(--gray-200);
}
.modal-header h2 { font-size: 1.1rem; }

.modal-body { padding: 1.5rem; }
.modal-body canvas {
    width: 100%;
    border-radius: var(--radius);
    border: 1px solid var(--gray-200);
    margin-bottom: 1rem;
}
.modal-details p { margin-bottom: 0.5rem; font-size: 0.9rem; }

/* Preview */
#preview-container { margin: 1.5rem 0; }
#preview-container canvas {
    width: 100%;
    max-width: 500px;
    border: 1px solid var(--gray-200);
    border-radius: var(--radius);
}

/* Location form */
.location-form {
    background: white;
    padding: 1.5rem;
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    margin-bottom: 1.5rem;
}
.location-form h3 { margin-bottom: 0.75rem; }

/* Nav badge count */
.nav-link-badge { position: relative; }
.badge-count {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 18px;
    height: 18px;
    padding: 0 5px;
    border-radius: 9px;
    background: var(--danger);
    color: white;
    font-size: 0.65rem;
    font-weight: 700;
    margin-left: 4px;
    vertical-align: middle;
}

/* Pending approval page */
.pending-container {
    max-width: 500px;
    margin: 4rem auto;
    text-align: center;
    background: white;
    padding: 2rem;
    border-radius: var(--radius);
    box-shadow: var(--shadow);
}
.pending-container h1 { font-size: 1.5rem; margin-bottom: 1rem; color: var(--warning); }
.pending-container p { margin-bottom: 0.75rem; color: var(--gray-700); }
.pending-container .btn { margin-top: 1rem; }

/* Utilities */
.empty-state { text-align: center; color: var(--gray-500); padding: 3rem; }
.text-error { color: var(--danger); }

/* Responsive */
@media (max-width: 768px) {
    .queue-card { flex-direction: column; }
    .queue-card-preview canvas { width: 100%; height: auto; }
    .queue-card-actions { flex-direction: column; }
    .form-row { flex-direction: column; }
}
