:root {
    --primary-color: #6366f1;
    --primary-hover: #4f46e5;
    --bg-color: #0f172a;
    --card-bg: #1e293b;
    --text-main: #f8fafc;
    --text-muted: #94a3b8;
    --danger: #ef4444;
    --success: #22c55e;
    --overlay-bg: rgba(0, 0, 0, 0.8);
    --modal-bg: #1e293b;
    --radius-lg: 1.25rem;
    --radius-md: 0.75rem;
    --transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    -webkit-tap-highlight-color: transparent;
}

body {
    font-family: 'Outfit', sans-serif;
    background-color: var(--bg-color);
    color: var(--text-main);
    line-height: 1.5;
    overflow-x: hidden;
}

#app {
    max-width: 500px;
    margin: 0 auto;
    min-height: 100vh;
    padding: 125px 1.5rem 1.5rem 1.5rem; /* Increased space for taller header */
    display: flex;
    flex-direction: column;
}

#app-header {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    z-index: 1000;
    background: rgba(15, 23, 42, 0.85);
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
    padding: 12px 0;
    display: flex;
    flex-direction: column;
    align-items: center;
}

.header-content {
    width: 100%;
    max-width: 500px;
    display: flex;
    flex-direction: column;
    gap: 12px;
    padding: 0 1.5rem;
}

.header-top {
    display: flex;
    justify-content: space-between;
    align-items: center;
    width: 100%;
}

.search-container {
    position: relative;
    width: 100%;
    display: flex;
    align-items: center;
}

#search-input {
    width: 100%;
    background: rgba(255, 255, 255, 0.08);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 12px;
    padding: 10px 40px;
    color: var(--text-main);
    font-size: 0.95rem;
    outline: none;
    transition: var(--transition);
}

#search-input:focus {
    background: rgba(255, 255, 255, 0.12);
    border-color: var(--primary-color);
    box-shadow: 0 0 0 4px rgba(99, 102, 241, 0.1);
}

.search-icon {
    position: absolute;
    left: 12px;
    font-size: 1rem;
    opacity: 0.5;
    pointer-events: none;
}

#clear-search {
    position: absolute;
    right: 12px;
    background: none;
    border: none;
    color: var(--text-muted);
    font-size: 1.2rem;
    cursor: pointer;
    padding: 0;
    line-height: 1;
}


.logo {
    font-size: 1.5rem;
    font-weight: 700;
    background: linear-gradient(135deg, #818cf8 0%, #c084fc 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    letter-spacing: -0.5px;
}

.user-profile {
    display: flex;
    align-items: center;
}

#user-info {
    display: flex;
    align-items: center;
    gap: 8px;
    background: rgba(255, 255, 255, 0.05);
    padding: 4px 10px;
    border-radius: 20px;
    border: 1px solid rgba(255, 255, 255, 0.1);
}

#user-avatar {
    width: 30px;
    height: 30px;
    border-radius: 50%;
    border: 1.5px solid var(--primary-color);
    object-fit: cover;
}

.btn-logout {
    background: none;
    border: none;
    color: var(--text-muted);
    font-size: 1.25rem;
    cursor: pointer;
    line-height: 1;
    padding: 0;
    margin-left: 4px;
}

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

.btn-icon {
    background: rgba(255, 255, 255, 0.1);
    border: 1px solid rgba(255, 255, 255, 0.1);
    width: 40px;
    height: 40px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: var(--transition);
}

.btn-icon:hover {
    background: rgba(255, 255, 255, 0.2);
    transform: translateY(-1px);
}


/* Card Grid */
.card-grid {
    display: grid;
    grid-template-columns: 1fr;
    gap: 1rem;
}

.card {
    background: var(--card-bg);
    border-radius: var(--radius-lg);
    padding: 1.25rem;
    border: 1px solid rgba(255, 255, 255, 0.05);
    display: flex;
    justify-content: space-between;
    align-items: center;
    cursor: pointer;
    transition: var(--transition);
    box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06);
}

.card:active {
    transform: scale(0.98);
    background: rgba(255, 255, 255, 0.05);
}

.card-info h3 {
    font-size: 1.1rem;
    margin-bottom: 0.25rem;
}

.card-info p {
    font-size: 0.875rem;
    color: var(--text-muted);
    font-family: monospace;
}

.card-type-tag {
    font-size: 0.7rem;
    padding: 0.2rem 0.5rem;
    border-radius: 1rem;
    background: rgba(99, 102, 241, 0.1);
    color: var(--primary-color);
    text-transform: uppercase;
}

/* Empty State */
#empty-state {
    text-align: center;
    padding: 4rem 1rem;
}

.empty-icon {
    font-size: 4rem;
    margin-bottom: 1rem;
    opacity: 0.5;
}

.sub-text {
    font-size: 0.875rem;
    color: var(--text-muted);
}

/* Floating Action Button & Speed Dial */
.fab-container {
    position: fixed;
    bottom: 2rem;
    right: 2rem;
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    gap: 1rem;
    z-index: 1000; /* 與 Header 同級，確保可點擊 */
}

.fab .icon, .fab-sub .icon {
    pointer-events: none;
}


.fab {
    width: 3.5rem;
    height: 3.5rem;
    border-radius: 50%;
    background: var(--primary-color);
    color: white;
    border: none;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 2rem;
    cursor: pointer;
    box-shadow: 0 10px 15px -3px rgba(0, 0, 0, 0.3);
    transition: var(--transition);
}

.fab.active {
    transform: rotate(45deg);
    background: var(--card-bg);
    border: 1px solid rgba(255, 255, 255, 0.1);
}

.fab-options {
    display: none;
    flex-direction: column;
    gap: 0.75rem;
    align-items: flex-end;
    animation: fadeIn 0.2s ease-out;
}

.fab-options.show {
    display: flex;
}

.fab-sub {
    width: 3rem;
    height: 3rem;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--card-bg);
    color: var(--text-main);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 50%;
    cursor: pointer;
    box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.2);
    transition: var(--transition);
}

.fab-sub:active {
    transform: scale(0.95);
    background: rgba(255, 255, 255, 0.05);
}

.fab-sub .icon {
    font-size: 1.25rem;
}

.fab-sub .label {
    font-size: 0.875rem;
    font-weight: 600;
}

@keyframes fadeIn {
    from { opacity: 0; transform: translateY(10px); }
    to { opacity: 1; transform: translateY(0); }
}

/* Overlays */
.overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: var(--overlay-bg);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
    backdrop-filter: blur(8px);
    transition: var(--transition);
}

.hidden {
    display: none !important;
    opacity: 0;
    pointer-events: none;
}

.overlay-content {
    width: 90%;
    max-width: 400px;
    background: var(--modal-bg);
    border-radius: var(--radius-lg);
    padding: 1.5rem;
    position: relative;
    box-shadow: 0 20px 25px -5px rgba(0, 0, 0, 0.5);
}

.overlay-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1.5rem;
}

.close-btn {
    background: none;
    border: none;
    color: var(--text-muted);
    font-size: 2rem;
    cursor: pointer;
}

/* Scanner */
#reader {
    width: 100%;
    border-radius: var(--radius-md);
    overflow: hidden;
    background: #000;
}

.scanner-actions {
    margin-top: 1rem;
    display: flex;
    justify-content: center;
}

.scanner-hint {
    text-align: center;
    margin-top: 1rem;
    color: var(--text-muted);
}

/* Modals */
.modal-box {
    padding: 2rem;
}

.input-group {
    margin-bottom: 1.25rem;
}

.input-group label {
    display: block;
    font-size: 0.875rem;
    margin-bottom: 0.5rem;
    color: var(--text-muted);
}

.input-group input,
.input-group select {
    width: 100%;
    background: rgba(0, 0, 0, 0.2);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: var(--radius-md);
    padding: 0.75rem 1rem;
    color: var(--text-main);
    font-size: 1rem;
    outline: none;
    transition: var(--transition);
    appearance: none; /* For select */
}

.input-group select {
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' fill='none' viewBox='0 0 24 24' stroke='white'%3E%3Cpath stroke-linecap='round' stroke-linejoin='round' stroke-width='2' d='M19 9l-7 7-7-7'%3E%3C/path%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 1rem center;
    background-size: 1.25rem;
    padding-right: 2.5rem;
}

.input-group input:focus,
.input-group select:focus {
    border-color: var(--primary-color);
}

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

.btn {
    flex: 1;
    padding: 0.75rem;
    border-radius: var(--radius-md);
    border: none;
    font-weight: 600;
    cursor: pointer;
    transition: var(--transition);
}

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

.btn.secondary {
    background: rgba(255, 255, 255, 0.05);
    color: var(--text-main);
}

.btn.danger {
    background: rgba(239, 68, 68, 0.1);
    color: var(--danger);
    border: 1px solid rgba(239, 68, 68, 0.2);
}

/* Detail View */
.detail-box {
    text-align: center;
}

.barcode-display {
    background: white;
    padding: 2rem;
    border-radius: var(--radius-md);
    margin: 1.5rem 0;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
}

#barcode-canvas {
    max-width: 100%;
    height: auto;
}

.barcode-text {
    color: #000;
    margin-top: 1rem;
    font-family: monospace;
    font-weight: bold;
    letter-spacing: 2px;
}

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