:root {
    --primary-color: #3b82f6;
    --primary-hover: #2563eb;
    --danger-color: #ef4444;
    --danger-hover: #dc2626;
    --success-color: #10b981;
    --warning-color: #f59e0b;
    --gray-50: #f9fafb;
    --gray-100: #f3f4f6;
    --gray-200: #e5e7eb;
    --gray-300: #d1d5db;
    --gray-400: #9ca3af;
    --gray-500: #6b7280;
    --gray-600: #4b5563;
    --gray-700: #374151;
    --gray-800: #1f2937;
    --gray-900: #111827;
    
    /* Light mode colors (default) */
    --bg-primary: #f9fafb;
    --bg-secondary: #ffffff;
    --text-primary: #111827;
    --text-secondary: #6b7280;
    --border-color: #e5e7eb;
}

[data-theme="dark"] {
    --primary-color: #60a5fa;
    --primary-hover: #3b82f6;
    --danger-color: #f87171;
    --danger-hover: #ef4444;
    --success-color: #34d399;
    --warning-color: #fbbf24;
    
    /* Dark mode colors */
    --bg-primary: #111827;
    --bg-secondary: #1f2937;
    --text-primary: #f9fafb;
    --text-secondary: #d1d5db;
    --border-color: #374151;
    
    /* Gray scale for dark mode */
    --gray-50: #111827;
    --gray-100: #1f2937;
    --gray-200: #374151;
    --gray-300: #4b5563;
    --gray-400: #6b7280;
    --gray-500: #9ca3af;
    --gray-600: #d1d5db;
    --gray-700: #e5e7eb;
    --gray-800: #f3f4f6;
    --gray-900: #f9fafb;
}

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

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
    background-color: var(--bg-primary);
    color: var(--text-primary);
    line-height: 1.5;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    transition: background-color 0.3s ease, color 0.3s ease;
}

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

/* Navbar */
.navbar {
    background-color: var(--bg-secondary);
    border-bottom: 1px solid var(--border-color);
    position: sticky;
    top: 0;
    z-index: 100;
    transition: background-color 0.3s ease, border-color 0.3s ease;
}

@media (max-width: 768px) {
    .navbar {
        position: relative;
    }
}

.navbar .container {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 1rem;
    gap: 2rem;
}

.navbar-brand {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-size: 1.25rem;
    font-weight: 600;
    color: var(--gray-900);
    text-decoration: none;
}

.navbar-brand i {
    color: var(--primary-color);
}

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

.navbar-item {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    color: var(--gray-600);
    text-decoration: none;
    font-weight: 500;
    transition: color 0.2s;
}

.navbar-item:hover {
    color: var(--primary-color);
}

/* Auth UI */
.navbar-auth {
    display: flex;
    align-items: center;
}

.user-menu {
    display: flex;
    align-items: center;
    gap: 1rem;
}

.user-avatar {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    border: 2px solid var(--gray-200);
}

.username {
    font-weight: 500;
    color: var(--text-secondary);
}

/* Dark Mode Toggle */
.dark-mode-toggle {
    background: none;
    border: none;
    cursor: pointer;
    padding: 0.5rem;
    color: var(--text-secondary);
    font-size: 1.25rem;
    transition: color 0.3s ease;
    margin-left: 1rem;
}

.dark-mode-toggle:hover {
    color: var(--primary-color);
}

/* Mobile Menu Toggle */
.mobile-menu-toggle {
    display: none;
    background: none;
    border: none;
    cursor: pointer;
    padding: 0.5rem;
    color: var(--text-secondary);
    font-size: 1.25rem;
    transition: color 0.3s ease;
    margin-left: 0.5rem;
}

.mobile-menu-toggle:hover {
    color: var(--primary-color);
}

/* Navbar Actions */
.navbar-actions {
    display: flex;
    align-items: center;
}

/* Main Content */
.main-content {
    flex: 1;
    padding: 2rem 0;
}

/* Page Header */
.page-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 2rem;
}

.page-header h1 {
    font-size: 2rem;
    font-weight: 700;
}

.header-actions {
    display: flex;
    gap: 0.75rem;
    align-items: center;
}

/* Search Section */
.search-section {
    background-color: var(--bg-secondary);
    padding: 1.5rem;
    border-radius: 0.5rem;
    margin-bottom: 2rem;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
    transition: background-color 0.3s ease;
}

.search-form {
    display: flex;
    gap: 1rem;
}

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

.search-input-wrapper {
    position: relative;
    flex: 1;
}

.search-input-wrapper i {
    position: absolute;
    left: 1rem;
    top: 50%;
    transform: translateY(-50%);
    color: var(--gray-400);
    transition: color 0.3s ease;
}

.search-input {
    width: 100%;
    padding: 0.75rem 1rem 0.75rem 2.5rem;
    border: 1px solid var(--border-color);
    border-radius: 0.375rem;
    font-size: 1rem;
    background-color: var(--bg-secondary);
    color: var(--text-primary);
    transition: all 0.3s ease;
}

.category-select,
.status-select,
.location-select {
    padding: 0.75rem 1rem;
    border: 1px solid var(--border-color);
    border-radius: 0.375rem;
    font-size: 1rem;
    background-color: var(--bg-secondary);
    color: var(--text-primary);
    transition: all 0.3s ease;
}

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

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

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

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

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

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

.btn-secondary:hover {
    background-color: var(--gray-700);
}

.btn-outline {
    background-color: var(--bg-secondary);
    color: var(--text-primary);
    border: 1px solid var(--border-color);
    transition: all 0.3s ease;
}

.btn-outline:hover {
    background-color: var(--gray-50);
}

.btn-search {
    background-color: var(--gray-900);
    color: white;
    transition: all 0.3s ease;
}

.btn-search:hover {
    background-color: var(--gray-800);
}

[data-theme="dark"] .btn-search {
    background-color: var(--gray-100);
    color: var(--gray-900);
}

[data-theme="dark"] .btn-search:hover {
    background-color: var(--gray-200);
}

.btn-sm {
    padding: 0.5rem 1rem;
    font-size: 0.875rem;
}

/* Items Grid */
.items-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
    gap: 1.5rem;
}

.item-card {
    background-color: var(--bg-secondary);
    border-radius: 0.5rem;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
    overflow: hidden;
    transition: transform 0.2s, box-shadow 0.2s, background-color 0.3s ease;
    display: flex;
    flex-direction: column;
    height: 100%;
}

.item-card:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
}

.item-header {
    padding: 1.5rem 1.5rem 1rem;
    border-bottom: 1px solid var(--gray-100);
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
}

.item-title {
    font-size: 1.125rem;
    font-weight: 600;
    margin-bottom: 0.5rem;
    flex: 1;
}

.item-header-right {
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.item-code {
    display: inline-block;
    padding: 0.25rem 0.75rem;
    background-color: var(--gray-100);
    color: var(--gray-700);
    border-radius: 0.25rem;
    font-size: 0.875rem;
    font-family: monospace;
}

.item-body {
    padding: 1.5rem;
    flex: 1;
}

.item-description {
    color: var(--gray-600);
    margin-bottom: 1rem;
    line-height: 1.5;
}

.item-details {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.detail-row {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    color: var(--gray-600);
    font-size: 0.875rem;
}

.detail-row i {
    width: 1rem;
    color: var(--gray-400);
}

.status-badge {
    display: inline-block;
    padding: 0.25rem 0.75rem;
    border-radius: 9999px;
    font-size: 0.75rem;
    font-weight: 500;
    text-transform: uppercase;
}

.status-available {
    background-color: #d1fae5;
    color: #065f46;
}

.status-in-use {
    background-color: #dbeafe;
    color: #1e40af;
}

.status-maintenance {
    background-color: #fed7aa;
    color: #92400e;
}

.status-retired {
    background-color: #e5e7eb;
    color: #374151;
}

.status-pending {
    background-color: #fef3c7;
    color: #92400e;
}

.status-damaged {
    background-color: #fecaca;
    color: #991b1b;
}

.status-reserved {
    background-color: #e9d5ff;
    color: #6b21a8;
}

.status-lost {
    background-color: #fee2e2;
    color: #7f1d1d;
}

.status-ordered {
    background-color: #bfdbfe;
    color: #1e3a8a;
}

.status-trash {
    background-color: #d1d5db;
    color: #1f2937;
}

.status-ran-out {
    background-color: #fde68a;
    color: #78350f;
}

.item-footer {
    padding: 1rem 1.5rem;
    background-color: var(--gray-50);
    border-top: 1px solid var(--gray-100);
    display: flex;
    gap: 0.5rem;
    margin-top: auto;
    justify-content: center;
    align-items: center;
}

.item-footer form {
    display: inline-flex;
    margin: 0;
}

.item-footer .btn {
    min-width: 44px;
    min-height: 36px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
}

/* Empty State */
.empty-state {
    text-align: center;
    padding: 4rem 2rem;
    color: var(--gray-500);
}

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

.empty-state h3 {
    font-size: 1.5rem;
    margin-bottom: 0.5rem;
    color: var(--gray-700);
}

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

/* Forms */
.form-card {
    background-color: var(--bg-secondary);
    padding: 2rem;
    border-radius: 0.5rem;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
    max-width: 800px;
    margin: 0 auto;
    transition: background-color 0.3s ease;
}

.form-card h1 {
    margin-bottom: 2rem;
}

.item-form {
    display: flex;
    flex-direction: column;
    gap: 1.5rem;
}

.form-group {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.form-group label {
    font-weight: 500;
    color: var(--gray-700);
}

.form-group input,
.form-group textarea,
.form-group select {
    padding: 0.75rem 1rem;
    border: 1px solid var(--border-color);
    border-radius: 0.375rem;
    font-size: 1rem;
    background-color: var(--bg-primary);
    color: var(--text-primary);
    transition: all 0.3s ease;
}

.form-group input:focus,
.form-group textarea:focus,
.form-group select:focus {
    outline: none;
    border-color: var(--primary-color);
    box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.1);
}

.form-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 1.5rem;
}

.form-help {
    font-size: 0.875rem;
    color: var(--gray-500);
}

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

.disabled-input {
    background-color: var(--gray-100);
    cursor: not-allowed;
}

/* Item Detail */
.breadcrumb {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    margin-bottom: 1.5rem;
    color: var(--gray-600);
    font-size: 0.875rem;
}

.breadcrumb a {
    color: var(--gray-600);
    text-decoration: none;
}

.breadcrumb a:hover {
    color: var(--primary-color);
}

.item-detail-card {
    background-color: var(--bg-secondary);
    border-radius: 0.5rem;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
    overflow: hidden;
    transition: background-color 0.3s ease;
}

.item-detail-header {
    padding: 2rem;
    border-bottom: 1px solid var(--gray-200);
    display: flex;
    justify-content: space-between;
    align-items: start;
}

.item-detail-header h1 {
    font-size: 2rem;
    margin-bottom: 0.5rem;
}

.item-meta {
    display: flex;
    gap: 1rem;
    align-items: center;
}

.item-code-large {
    font-size: 1.125rem;
    font-family: monospace;
    color: var(--gray-600);
}

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

.item-detail-body {
    padding: 2rem;
}

.detail-grid {
    display: grid;
    grid-template-columns: 1fr 300px;
    gap: 3rem;
    margin-bottom: 2rem;
}

.detail-section h3 {
    font-size: 1.125rem;
    margin-bottom: 1rem;
    color: var(--gray-800);
}

.detail-list {
    display: grid;
    grid-template-columns: 120px 1fr;
    gap: 0.75rem;
}

.detail-list dt {
    font-weight: 500;
    color: var(--gray-600);
}

.detail-list dd {
    color: var(--gray-900);
}

.qr-code-preview {
    text-align: center;
}

.qr-code-preview canvas {
    border: 1px solid var(--gray-200);
    border-radius: 0.5rem;
    margin-bottom: 1rem;
}

.qr-actions {
    display: flex;
    justify-content: center;
}

.description-text {
    line-height: 1.6;
    color: var(--gray-700);
}

/* Alerts */
.alert {
    padding: 1rem;
    border-radius: 0.375rem;
    margin-bottom: 1.5rem;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.alert-error {
    background-color: #fee;
    color: var(--danger-color);
    border: 1px solid #fcc;
}

.alert-success {
    background-color: #d1fae5;
    color: #065f46;
    border: 1px solid #a7f3d0;
}

/* Footer */
.footer {
    background-color: var(--bg-secondary);
    border-top: 1px solid var(--border-color);
    padding: 2rem 0;
    text-align: center;
    color: var(--text-secondary);
    margin-top: auto;
    transition: background-color 0.3s ease, border-color 0.3s ease;
}

/* Mobile User Section (hidden on desktop) */
.mobile-user-section {
    display: none;
}

.mobile-user-info {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.75rem;
    border-top: 1px solid var(--border-color);
    margin-top: 0.5rem;
}

.mobile-user-avatar {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    border: 2px solid var(--gray-200);
}

.mobile-username {
    font-weight: 500;
    color: var(--text-primary);
}

/* Responsive */
@media (max-width: 768px) {
    /* Navigation */
    .navbar .container {
        padding: 0.75rem;
        gap: 1rem;
    }
    
    .navbar-brand {
        font-size: 1.1rem;
    }
    
    .navbar-menu {
        display: none;
        position: absolute;
        top: 100%;
        left: 0;
        right: 0;
        background-color: var(--bg-secondary);
        border-bottom: 1px solid var(--border-color);
        flex-direction: column;
        padding: 1rem;
        box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
    }
    
    .navbar-menu.active {
        display: flex;
    }
    
    .navbar-item {
        padding: 0.75rem;
        width: 100%;
        justify-content: flex-start;
    }
    
    .mobile-menu-toggle {
        display: block;
    }
    
    .navbar-auth {
        display: flex;
        align-items: center;
        gap: 0.5rem;
    }
    
    .user-menu {
        gap: 0.5rem;
    }
    
    .user-menu .username {
        display: none;
    }
    
    .user-menu .btn-sm {
        padding: 0.5rem 0.75rem;
        min-height: 44px;
    }
    
    .mobile-user-section {
        display: none;
    }
    
    /* Page Layout */
    .container {
        padding: 0 0.75rem;
    }
    
    .main-content {
        padding: 1.5rem 0;
    }
    
    .page-header {
        flex-direction: column;
        gap: 1rem;
        align-items: stretch;
        margin-bottom: 1.5rem;
    }
    
    .page-header h1 {
        font-size: 1.5rem;
    }
    
    /* Search Section */
    .search-section {
        padding: 1rem;
        margin-bottom: 1.5rem;
    }
    
    .search-row {
        flex-direction: column;
    }
    
    .search-input {
        font-size: 16px; /* Prevents zoom on iOS */
    }
    
    .category-select,
    .status-select,
    .location-select {
        font-size: 16px; /* Prevents zoom on iOS */
        width: 100%;
    }
    
    /* Buttons */
    .btn {
        padding: 0.625rem 1.25rem;
        font-size: 0.875rem;
    }
    
    .btn-sm {
        padding: 0.375rem 0.75rem;
        font-size: 0.75rem;
    }
    
    /* Items Grid */
    .items-grid {
        grid-template-columns: 1fr;
        gap: 1rem;
    }
    
    .item-card {
        box-shadow: 0 1px 2px rgba(0, 0, 0, 0.05);
    }
    
    .item-header {
        padding: 1rem;
    }
    
    .item-title {
        font-size: 1rem;
    }
    
    .item-body {
        padding: 1rem;
    }
    
    .item-footer {
        padding: 0.75rem 1rem;
        gap: 0.375rem;
        flex-wrap: wrap;
        justify-content: center;
    }
    
    .item-footer .btn {
        flex: 0 0 auto;
    }
    
    .item-footer form {
        flex: 0 0 auto;
    }
    
    /* Forms */
    .form-card {
        padding: 1.5rem;
    }
    
    .form-row {
        grid-template-columns: 1fr;
    }
    
    .form-group input,
    .form-group textarea,
    .form-group select {
        font-size: 16px; /* Prevents zoom on iOS */
    }
    
    /* Detail Pages */
    .detail-grid {
        grid-template-columns: 1fr;
        gap: 2rem;
    }
    
    .item-detail-header {
        flex-direction: column;
        gap: 1rem;
        padding: 1.5rem;
    }
    
    .item-detail-header h1 {
        font-size: 1.5rem;
    }
    
    .item-detail-body {
        padding: 1.5rem;
    }
    
    .item-actions {
        width: 100%;
    }
    
    .item-actions .btn {
        flex: 1;
    }
    
    /* Footer */
    .footer {
        padding: 1.5rem 0;
        font-size: 0.875rem;
    }
}

/* Extra small devices */
@media (max-width: 480px) {
    /* Keep item footer buttons in horizontal layout like desktop */
    .item-footer {
        flex-direction: row;
        flex-wrap: wrap;
        justify-content: center;
    }
    
    .item-footer .btn {
        flex: 0 0 auto;
        min-width: auto;
    }
    
    .item-footer form {
        flex: 0 0 auto;
    }
    
    /* Stack form actions vertically */
    .form-actions {
        flex-direction: column;
        align-items: stretch;
    }
    
    .form-actions .btn {
        width: 100%;
    }
    
    /* Smaller status badges on mobile */
    .status-badge {
        font-size: 0.625rem;
        padding: 0.125rem 0.5rem;
    }
    
    /* Adjust item code size */
    .item-code {
        font-size: 0.75rem;
        padding: 0.125rem 0.5rem;
    }
}

/* Touch-friendly adjustments */
@media (hover: none) and (pointer: coarse) {
    /* Increase touch targets */
    .btn {
        min-height: 44px;
        min-width: 44px;
    }
    
    .navbar-item,
    .dark-mode-toggle {
        padding: 0.75rem;
    }
    
    /* Remove hover effects on touch devices */
    .item-card:hover {
        transform: none;
        box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
    }
}