/* SMGW Tracker - Mobile-First CSS */

:root {
    --primary: #2563eb;
    --primary-dark: #1d4ed8;
    --success: #22c55e;
    --danger: #ef4444;
    --warning: #f59e0b;
    --secondary: #6b7280;
    --bg-primary: #ffffff;
    --bg-secondary: #f3f4f6;
    --text-primary: #111827;
    --text-secondary: #6b7280;
    --border-color: #e5e7eb;
    --shadow: 0 1px 3px rgba(0,0,0,0.1);
    --shadow-lg: 0 4px 6px rgba(0,0,0,0.1);
    --radius: 8px;
}

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

html {
    font-size: 16px;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, sans-serif;
    background: var(--bg-secondary);
    color: var(--text-primary);
    line-height: 1.5;
    min-height: 100vh;
}

/* Login Page */
.login-page {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 100vh;
    padding: 1rem;
    background: linear-gradient(135deg, var(--primary) 0%, var(--primary-dark) 100%);
}

.login-container {
    background: white;
    border-radius: var(--radius);
    box-shadow: var(--shadow-lg);
    padding: 2rem;
    width: 100%;
    max-width: 400px;
}

.login-header {
    text-align: center;
    margin-bottom: 2rem;
}

.login-header h1 {
    color: var(--primary);
    font-size: 1.75rem;
    margin-bottom: 0.5rem;
}

.login-header p {
    color: var(--text-secondary);
}

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

.navbar-brand a {
    color: white;
    text-decoration: none;
    font-weight: bold;
    font-size: 1.25rem;
}

.navbar-toggle {
    background: none;
    border: none;
    color: white;
    font-size: 1.5rem;
    cursor: pointer;
    display: block;
}

.navbar-menu {
    display: none;
    width: 100%;
    flex-direction: column;
    gap: 0.5rem;
    padding-top: 1rem;
}

.navbar-menu.active {
    display: flex;
}

.nav-link {
    color: rgba(255,255,255,0.9);
    text-decoration: none;
    padding: 0.5rem 0;
}

.nav-link:hover {
    color: white;
}

.nav-user {
    border-top: 1px solid rgba(255,255,255,0.2);
    padding-top: 0.75rem;
    margin-top: 0.5rem;
}

.nav-username {
    display: block;
    font-weight: 500;
    margin-bottom: 0.5rem;
}

@media (min-width: 768px) {
    .navbar-toggle {
        display: none;
    }

    .navbar-menu {
        display: flex;
        flex-direction: row;
        width: auto;
        padding-top: 0;
        align-items: center;
    }

    .nav-link {
        padding: 0.5rem 1rem;
    }

    .nav-user {
        border-top: none;
        border-left: 1px solid rgba(255,255,255,0.2);
        padding-top: 0;
        margin-top: 0;
        padding-left: 1rem;
        margin-left: 1rem;
        display: flex;
        align-items: center;
        gap: 1rem;
    }

    .nav-username {
        margin-bottom: 0;
    }
}

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

/* Page Header */
.page-header {
    margin-bottom: 1.5rem;
}

.page-header h1 {
    font-size: 1.5rem;
    margin-bottom: 0.25rem;
}

.page-header .lead {
    color: var(--text-secondary);
    font-size: 1.1rem;
}

/* Cards */
.card {
    background: white;
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    margin-bottom: 1rem;
}

.card-header {
    padding: 1rem;
    border-bottom: 1px solid var(--border-color);
}

.card-header h3 {
    font-size: 1rem;
    margin: 0;
}

.card-body {
    padding: 1rem;
}

/* Forms */
.form-group {
    margin-bottom: 1rem;
}

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

.form-control {
    width: 100%;
    padding: 0.75rem;
    border: 1px solid var(--border-color);
    border-radius: var(--radius);
    font-size: 1rem;
    transition: border-color 0.2s;
}

.form-control:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.1);
}

.form-error {
    color: var(--danger);
    font-size: 0.875rem;
    margin-top: 0.25rem;
    display: block;
}

.form-hint {
    color: var(--text-secondary);
    font-size: 0.875rem;
    margin-top: 0.25rem;
    display: block;
}

.form-check {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.form-check-input {
    width: 1.25rem;
    height: 1.25rem;
}

.form-actions {
    display: flex;
    gap: 1rem;
    margin-top: 1.5rem;
}

/* Buttons */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 0.75rem 1.5rem;
    border: none;
    border-radius: var(--radius);
    font-size: 1rem;
    font-weight: 500;
    cursor: pointer;
    text-decoration: none;
    transition: all 0.2s;
    gap: 0.5rem;
}

.btn-primary {
    background: var(--primary);
    color: white;
}

.btn-primary:hover {
    background: var(--primary-dark);
}

.btn-success {
    background: var(--success);
    color: white;
}

.btn-danger {
    background: var(--danger);
    color: white;
}

.btn-warning {
    background: var(--warning);
    color: white;
}

.btn-secondary {
    background: var(--secondary);
    color: white;
}

.btn-outline {
    background: transparent;
    border: 1px solid var(--border-color);
    color: var(--text-primary);
}

.btn-outline:hover {
    background: var(--bg-secondary);
}

.btn-block {
    width: 100%;
}

.btn-large {
    padding: 1rem 2rem;
    font-size: 1.1rem;
}

.btn-medium {
    padding: 0.875rem 1.5rem;
}

.btn-sm {
    padding: 0.375rem 0.75rem;
    font-size: 0.875rem;
}

.btn-icon {
    font-size: 1.25rem;
}

/* Action Buttons */
.action-buttons {
    display: flex;
    flex-direction: column;
    gap: 1rem;
    margin-bottom: 2rem;
}

.action-row {
    display: flex;
    gap: 1rem;
}

.action-row .btn {
    flex: 1;
}

/* Tables */
.table-responsive {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
}

.table {
    width: 100%;
    border-collapse: collapse;
    background: white;
    border-radius: var(--radius);
    overflow: hidden;
}

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

.table th {
    background: var(--bg-secondary);
    font-weight: 600;
}

.table tr:hover {
    background: var(--bg-secondary);
}

.table-sm th,
.table-sm td {
    padding: 0.5rem;
    font-size: 0.875rem;
}

.font-mono {
    font-family: ui-monospace, monospace;
}

/* Stats Grid */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 1rem;
    margin-bottom: 2rem;
}

@media (min-width: 768px) {
    .stats-grid {
        grid-template-columns: repeat(3, 1fr);
    }
}

@media (min-width: 1024px) {
    .stats-grid {
        grid-template-columns: repeat(6, 1fr);
    }
}

.stat-card {
    background: white;
    border-radius: var(--radius);
    padding: 1rem;
    text-align: center;
    box-shadow: var(--shadow);
}

.stat-value {
    font-size: 2rem;
    font-weight: bold;
    color: var(--text-primary);
}

.stat-label {
    font-size: 0.875rem;
    color: var(--text-secondary);
}

.stat-success .stat-value { color: var(--success); }
.stat-danger .stat-value { color: var(--danger); }
.stat-warning .stat-value { color: var(--warning); }
.stat-primary .stat-value { color: var(--primary); }

/* Badges */
.badge {
    display: inline-block;
    padding: 0.25rem 0.5rem;
    border-radius: 4px;
    font-size: 0.75rem;
    font-weight: 500;
    text-transform: uppercase;
}

.badge-admin { background: #7c3aed; color: white; }
.badge-viewer { background: #0891b2; color: white; }
.badge-monteur { background: #059669; color: white; }
.badge-dispatcher { background: #d97706; color: white; }

.badge-success { background: #dcfce7; color: #166534; }
.badge-danger { background: #fee2e2; color: #991b1b; }
.badge-warning { background: #fef3c7; color: #92400e; }
.badge-secondary { background: #e5e7eb; color: #374151; }

.badge-unknown { background: #e5e7eb; color: #374151; }
.badge-in_stock { background: #dcfce7; color: #166534; }
.badge-installed { background: #dbeafe; color: #1e40af; }
.badge-returned { background: #e0e7ff; color: #3730a3; }
.badge-lost { background: #fee2e2; color: #991b1b; }
.badge-defect { background: #fef3c7; color: #92400e; }

.badge-received { background: #dcfce7; color: #166534; }

/* Alerts */
.alert {
    padding: 1rem;
    border-radius: var(--radius);
    margin-bottom: 1rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.alert-success { background: #dcfce7; color: #166534; }
.alert-danger { background: #fee2e2; color: #991b1b; }
.alert-warning { background: #fef3c7; color: #92400e; }
.alert-info { background: #dbeafe; color: #1e40af; }

.alert-close {
    background: none;
    border: none;
    font-size: 1.25rem;
    cursor: pointer;
    opacity: 0.7;
}

/* SMGW Cards (Mobile) */
.smgw-list {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
}

.smgw-card {
    background: white;
    border-radius: var(--radius);
    padding: 1rem;
    box-shadow: var(--shadow);
}

.smgw-serial {
    font-family: ui-monospace, monospace;
    font-weight: 600;
    font-size: 1.1rem;
}

.smgw-date {
    color: var(--text-secondary);
    font-size: 0.875rem;
    margin: 0.5rem 0;
}

.smgw-actions {
    display: flex;
    gap: 0.5rem;
}

/* Modals */
.modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0,0,0,0.5);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
    padding: 1rem;
}

.modal-content {
    background: white;
    border-radius: var(--radius);
    width: 100%;
    max-width: 500px;
    max-height: 90vh;
    overflow-y: auto;
}

.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 1rem;
    border-bottom: 1px solid var(--border-color);
}

.modal-header h3 {
    margin: 0;
}

.modal-close {
    background: none;
    border: none;
    font-size: 1.5rem;
    cursor: pointer;
    color: var(--text-secondary);
}

.modal-body {
    padding: 1rem;
}

.modal-footer {
    padding: 1rem;
    border-top: 1px solid var(--border-color);
    display: flex;
    gap: 1rem;
    justify-content: flex-end;
}

/* Filters */
.filters .card-body {
    padding: 1rem;
}

.filter-form {
    display: flex;
    flex-wrap: wrap;
    gap: 1rem;
    align-items: flex-end;
}

.filter-form .form-group {
    flex: 1;
    min-width: 150px;
    margin-bottom: 0;
}

.filter-form .btn {
    flex-shrink: 0;
}

/* Pagination */
.pagination {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 1rem;
    margin-top: 1rem;
    padding: 1rem;
}

.page-info {
    color: var(--text-secondary);
}

/* Profile */
.profile-info {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
}

.profile-row {
    display: flex;
    gap: 1rem;
}

.profile-label {
    color: var(--text-secondary);
    min-width: 120px;
}

.profile-value {
    font-weight: 500;
}

.profile-actions {
    margin-top: 1.5rem;
}

/* Toast */
#toast-container {
    position: fixed;
    bottom: 1rem;
    right: 1rem;
    z-index: 2000;
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.toast {
    padding: 1rem;
    border-radius: var(--radius);
    background: var(--text-primary);
    color: white;
    animation: slideIn 0.3s ease;
    max-width: 300px;
}

.toast-success { background: var(--success); }
.toast-danger { background: var(--danger); }
.toast-warning { background: var(--warning); }

@keyframes slideIn {
    from {
        transform: translateX(100%);
        opacity: 0;
    }
    to {
        transform: translateX(0);
        opacity: 1;
    }
}

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

.section h2 {
    font-size: 1.25rem;
    margin-bottom: 1rem;
}

/* Empty State */
.empty-state {
    text-align: center;
    padding: 3rem 1rem;
    color: var(--text-secondary);
}

.empty-state p {
    margin-bottom: 1rem;
}

/* Utilities */
.mt-1 { margin-top: 0.5rem; }
.mt-2 { margin-top: 1rem; }
.text-warning { color: var(--warning); }
.text-danger { color: var(--danger); }
.warning-row { background: #fef3c7; }
.inactive { opacity: 0.6; }

.cards-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
    gap: 1rem;
}

.details-cell {
    max-width: 300px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.details-cell code {
    font-size: 0.75rem;
    background: var(--bg-secondary);
    padding: 0.125rem 0.25rem;
    border-radius: 3px;
}

/* Scanner */
.scanner-container {
    margin-bottom: 1rem;
}

.scanner-container video {
    width: 100%;
    border-radius: var(--radius);
}

/* Scanned Items */
.scanned-list {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    margin-bottom: 1rem;
}

.scanned-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    background: white;
    padding: 0.75rem 1rem;
    border-radius: var(--radius);
    font-family: ui-monospace, monospace;
}

/* Results */
.results-section {
    background: white;
    border-radius: var(--radius);
    padding: 1rem;
}

.results-summary {
    display: flex;
    gap: 2rem;
    margin-bottom: 1rem;
    padding-bottom: 1rem;
    border-bottom: 1px solid var(--border-color);
}

.results-detail {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.result-item {
    display: flex;
    justify-content: space-between;
    padding: 0.5rem;
    border-radius: 4px;
}

.result-success {
    background: #dcfce7;
}

.result-error {
    background: #fee2e2;
}

/* Manual Entry */
.manual-entry {
    background: white;
    padding: 1rem;
    border-radius: var(--radius);
    margin-bottom: 1rem;
}

/* Scan Buttons */
.scan-buttons {
    display: flex;
    flex-direction: column;
    gap: 1rem;
    margin-bottom: 1.5rem;
}

/* Submit Section */
.submit-section {
    margin-top: 1rem;
}

/* Action Buttons Small */
.action-buttons-small {
    margin-bottom: 1.5rem;
}

/* Text Muted */
.text-muted {
    color: var(--text-secondary);
}

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

/* Monteur List */
.monteur-list {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
    gap: 1rem;
}

.monteur-card {
    background: white;
    border-radius: var(--radius);
    padding: 1rem;
    box-shadow: var(--shadow);
    text-decoration: none;
    color: inherit;
    transition: box-shadow 0.2s;
}

.monteur-card:hover {
    box-shadow: var(--shadow-lg);
}

.monteur-name {
    font-weight: 600;
    margin-bottom: 0.25rem;
}

.monteur-team {
    color: var(--text-secondary);
    font-size: 0.875rem;
}

.monteur-count {
    margin-top: 0.5rem;
    font-weight: 500;
    color: var(--primary);
}

/* Transaction List */
.transaction-list {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.transaction-item {
    display: grid;
    grid-template-columns: auto 1fr auto auto;
    gap: 1rem;
    align-items: center;
    background: white;
    padding: 0.75rem 1rem;
    border-radius: var(--radius);
    font-size: 0.9rem;
}

.transaction-type {
    font-weight: 600;
    font-size: 0.75rem;
    padding: 0.25rem 0.5rem;
    background: var(--bg-secondary);
    border-radius: 4px;
}

.transaction-serial {
    font-family: ui-monospace, monospace;
}

.transaction-user {
    color: var(--text-secondary);
}

.transaction-date {
    color: var(--text-secondary);
    font-size: 0.85rem;
}

/* SMGW List Compact */
.smgw-list-compact {
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
    background: white;
    border-radius: var(--radius);
    padding: 0.5rem;
    max-height: 300px;
    overflow-y: auto;
}

.smgw-item-compact {
    display: flex;
    justify-content: space-between;
    padding: 0.5rem;
    border-bottom: 1px solid var(--border-color);
}

.smgw-item-compact:last-child {
    border-bottom: none;
}

.smgw-item-compact .serial {
    font-family: ui-monospace, monospace;
    font-size: 0.875rem;
}

.smgw-item-compact .holder {
    color: var(--text-secondary);
    font-size: 0.875rem;
}

/* Form Control Large */
.form-control-lg {
    padding: 1rem;
    font-size: 1.1rem;
}

/* Alerts List */
.alerts-list {
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.alert-card {
    background: white;
    border-radius: var(--radius);
    padding: 1rem;
    box-shadow: var(--shadow);
    border-left: 4px solid var(--secondary);
}

.alert-card.alert-critical { border-left-color: var(--danger); }
.alert-card.alert-high { border-left-color: #f97316; }
.alert-card.alert-medium { border-left-color: var(--warning); }
.alert-card.alert-low { border-left-color: var(--secondary); }

.alert-card.alert-acknowledged {
    opacity: 0.6;
    background: var(--bg-secondary);
}

.alert-header {
    display: flex;
    gap: 0.75rem;
    align-items: center;
    margin-bottom: 0.5rem;
}

.alert-severity {
    font-size: 0.7rem;
    padding: 0.2rem 0.5rem;
}

.badge-critical { background: var(--danger); color: white; }
.badge-high { background: #f97316; color: white; }
.badge-medium { background: var(--warning); color: white; }
.badge-low { background: var(--secondary); color: white; }

.alert-type {
    font-size: 0.75rem;
    color: var(--text-secondary);
}

.alert-date {
    font-size: 0.8rem;
    color: var(--text-secondary);
    margin-left: auto;
}

.alert-title {
    font-weight: 600;
    margin-bottom: 0.25rem;
}

.alert-message {
    color: var(--text-secondary);
    font-size: 0.9rem;
}

.alert-related {
    font-size: 0.85rem;
    color: var(--text-secondary);
    margin-top: 0.25rem;
}

.alert-footer {
    margin-top: 0.75rem;
    padding-top: 0.5rem;
    border-top: 1px solid var(--border-color);
}

/* Alert Summary in Dashboard */
.alerts-summary {
    background: white;
    border-radius: var(--radius);
    padding: 1rem;
    margin-bottom: 1.5rem;
}

.alerts-summary.has-alerts {
    border-left: 4px solid var(--danger);
}

.alerts-summary-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 0.75rem;
}

.alerts-summary-header h3 {
    margin: 0;
}

.alerts-mini-list {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.alert-mini-item {
    display: flex;
    gap: 0.5rem;
    align-items: center;
    padding: 0.5rem;
    background: var(--bg-secondary);
    border-radius: 4px;
    font-size: 0.9rem;
}

/* Button Group */
.btn-group {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
}

/* Offboarding Options */
.offboard-options {
    display: flex;
    flex-direction: column;
    gap: 1rem;
    margin-bottom: 1.5rem;
}

.offboard-option {
    padding: 1rem;
    border: 1px solid var(--border-color);
    border-radius: var(--radius);
    cursor: pointer;
}

.offboard-option:hover {
    border-color: var(--primary);
}

.offboard-label {
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
    cursor: pointer;
}

.offboard-label input[type="radio"] {
    position: absolute;
    opacity: 0;
}

.offboard-option:has(input:checked) {
    border-color: var(--primary);
    background: rgba(37, 99, 235, 0.05);
}

.offboard-title {
    font-weight: 600;
}

.offboard-desc {
    font-size: 0.9rem;
    color: var(--text-secondary);
}

.offboard-select {
    margin-top: 1rem;
}

/* Code Block */
.code-block {
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: var(--radius);
    padding: 1rem;
    font-family: ui-monospace, monospace;
    font-size: 0.9rem;
    overflow-x: auto;
    white-space: pre;
}
