/* App-specific styles */

/* Views */
.view {
    display: none;
    min-height: 100vh;
    flex-direction: column;
}

.view.active {
    display: flex;
}

/* App Header */
.app-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: var(--space-3) var(--space-4);
    background: var(--bg-secondary);
    border-bottom: 1px solid var(--border-default);
    position: sticky;
    top: 0;
    z-index: 100;
}

.app-header h1 {
    font-size: var(--text-xl);
    margin: 0;
    flex: 1;
    text-align: center;
}

/* Icon Buttons */
.btn-icon {
    width: 44px;
    height: 44px;
    padding: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    background: transparent;
    border: none;
    color: var(--text-primary);
    border-radius: var(--radius-md);
}

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

.btn-light {
    color: var(--bg-primary);
}

.btn-light:hover {
    background: rgba(0, 0, 0, 0.2);
}

/* Card List */
.card-list {
    flex: 1;
    padding: var(--space-4);
    display: flex;
    flex-direction: column;
    gap: var(--space-3);
    overflow-y: auto;
    padding-bottom: calc(var(--space-4) + env(safe-area-inset-bottom));
}

/* Card Item */
.card-item {
    display: flex;
    align-items: center;
    gap: var(--space-4);
    padding: var(--space-4);
    background: var(--bg-secondary);
    border: 1px solid var(--border-default);
    border-radius: var(--radius-lg);
    cursor: pointer;
    transition: all var(--transition-fast);
}

.card-item:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow-lg);
}

.card-item:active {
    transform: translateY(0);
}

.card-color-bar {
    width: 6px;
    height: 60px;
    border-radius: var(--radius-sm);
    flex-shrink: 0;
}

.card-info {
    flex: 1;
    min-width: 0;
}

.card-name {
    font-weight: var(--font-semibold);
    font-size: var(--text-lg);
    margin-bottom: var(--space-1);
    display: flex;
    align-items: center;
    gap: var(--space-2);
}

.card-name .star {
    color: var(--accent-yellow);
}

.card-number {
    color: var(--text-secondary);
    font-family: var(--font-mono);
    font-size: var(--text-sm);
}

.card-mini-barcode {
    width: 80px;
    height: 40px;
    flex-shrink: 0;
}

.card-mini-barcode canvas {
    width: 100%;
    height: 100%;
    object-fit: contain;
}

/* Empty State */
.empty-state {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: var(--space-8);
    text-align: center;
}

.empty-state.hidden {
    display: none;
}

.empty-icon {
    color: var(--text-muted);
    margin-bottom: var(--space-6);
}

.empty-state h2 {
    margin-bottom: var(--space-2);
}

.empty-state p {
    color: var(--text-secondary);
    margin-bottom: var(--space-6);
}

/* Form */
.form-container {
    flex: 1;
    padding: var(--space-4);
    overflow-y: auto;
    padding-bottom: calc(var(--space-8) + env(safe-area-inset-bottom));
}

.form-group {
    margin-bottom: var(--space-5);
}

.form-group label {
    margin-bottom: var(--space-2);
}

.form-actions {
    display: flex;
    gap: var(--space-3);
    margin-top: var(--space-6);
}

.form-actions button {
    flex: 1;
}

#deleteCardBtn {
    display: none;
}

#deleteCardBtn.visible {
    display: flex;
}

/* Color Picker */
.color-picker {
    display: flex;
    align-items: center;
    gap: var(--space-4);
}

.color-picker input[type="color"] {
    width: 50px;
    height: 44px;
    padding: 2px;
    border-radius: var(--radius-md);
    cursor: pointer;
}

.color-presets {
    display: flex;
    gap: var(--space-2);
}

.color-preset {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    border: 2px solid transparent;
    cursor: pointer;
    transition: all var(--transition-fast);
    padding: 0;
}

.color-preset:hover {
    transform: scale(1.1);
}

.color-preset:focus {
    outline: none;
    border-color: var(--text-primary);
}

/* Barcode Preview */
.barcode-preview-container {
    margin-top: var(--space-6);
}

.barcode-preview {
    background: white;
    border-radius: var(--radius-lg);
    padding: var(--space-4);
    min-height: 120px;
    display: flex;
    align-items: center;
    justify-content: center;
    margin-top: var(--space-2);
}

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

.preview-placeholder {
    color: var(--text-muted);
    font-size: var(--text-sm);
}

.barcode-preview canvas + .preview-placeholder {
    display: none;
}

/* Full Screen Barcode View */
.barcode-fullscreen {
    background: white;
    color: var(--bg-primary);
}

.barcode-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: var(--space-3) var(--space-4);
    padding-top: calc(var(--space-3) + env(safe-area-inset-top));
    background: var(--gradient-primary);
}

.barcode-header h1 {
    font-size: var(--text-xl);
    margin: 0;
    flex: 1;
    text-align: center;
    color: var(--bg-primary);
}

.barcode-main {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: var(--space-6);
}

.barcode-main canvas {
    max-width: 100%;
    max-height: 60vh;
}

.barcode-number {
    margin-top: var(--space-4);
    font-family: var(--font-mono);
    font-size: var(--text-xl);
    letter-spacing: 0.1em;
    color: var(--bg-primary);
}

.barcode-footer {
    padding: var(--space-4);
    padding-bottom: calc(var(--space-4) + env(safe-area-inset-bottom));
    background: var(--bg-secondary);
}

.barcode-footer button {
    width: 100%;
}

.barcode-footer svg {
    fill: none;
}

.barcode-footer button.favorited svg {
    fill: var(--accent-yellow);
    stroke: var(--accent-yellow);
}

/* Scanner View */
.scanner-container {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: var(--space-4);
    background: black;
}

#scannerPreview {
    width: 100%;
    max-width: 400px;
    aspect-ratio: 1;
    background: var(--bg-secondary);
    border-radius: var(--radius-lg);
    overflow: hidden;
}

#scannerPreview video {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.scanner-hint {
    color: var(--text-secondary);
    margin-top: var(--space-4);
    text-align: center;
}

/* Utilities */
.hidden {
    display: none !important;
}

/* Mobile optimizations */
@media (max-width: 480px) {
    .card-mini-barcode {
        display: none;
    }
}

/* Screen brightness hint */
@media (prefers-color-scheme: dark) {
    .barcode-fullscreen::before {
        content: '';
        position: fixed;
        top: 0;
        left: 0;
        right: 0;
        bottom: 0;
        background: white;
        z-index: -1;
    }
}

/* Safe area insets for notched phones */
@supports (padding: env(safe-area-inset-top)) {
    .app-header {
        padding-top: calc(var(--space-3) + env(safe-area-inset-top));
    }
}
