/* Reset and Base Styles */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, sans-serif;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    min-height: 100vh;
    color: #333;
    line-height: 1.6;
}

.app-container {
    max-width: 480px;
    margin: 0 auto;
    background: #fff;
    min-height: 100vh;
    box-shadow: 0 0 20px rgba(0, 0, 0, 0.1);
}

/* Header */
.header {
    background: linear-gradient(135deg, #4F46E5 0%, #7C3AED 100%);
    color: white;
    padding: 1rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
    position: sticky;
    top: 0;
    z-index: 100;
}

.header h1 {
    font-size: 1.5rem;
    font-weight: 600;
}

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

.app-logo {
    width: 32px;
    height: 32px;
    filter: brightness(0) invert(1);
}

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

.add-btn {
    background: rgba(255, 255, 255, 0.2);
    border: 1px solid rgba(255, 255, 255, 0.3);
    color: white;
    padding: 0.5rem 1rem;
    border-radius: 20px;
    font-size: 0.9rem;
    cursor: pointer;
    transition: all 0.3s ease;
}

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

.settings-btn {
    background: rgba(255, 255, 255, 0.2);
    border: 1px solid rgba(255, 255, 255, 0.3);
    color: white;
    padding: 0.5rem;
    border-radius: 50%;
    cursor: pointer;
    transition: all 0.3s ease;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 40px;
    height: 40px;
}

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

.settings-icon {
    width: 20px;
    height: 20px;
    filter: brightness(0) invert(1);
}

.install-btn {
    background: rgba(255, 255, 255, 0.2);
    border: 1px solid rgba(255, 255, 255, 0.3);
    color: white;
    padding: 0.5rem;
    border-radius: 50%;
    cursor: pointer;
    transition: all 0.3s ease;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 40px;
    height: 40px;
}

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

.install-icon {
    width: 20px;
    height: 20px;
    filter: brightness(0) invert(1);
}



/* Cards Container */
.cards-container {
    padding: 1rem;
    display: grid;
    gap: 1rem;
    grid-template-columns: 1fr;
}



/* Card Styles */
.card {
    background: white;
    border-radius: 16px;
    padding: 1.5rem 1.5rem 1.5rem 2.5rem;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.1);
    border: 1px solid #e5e7eb;
    cursor: pointer;
    transition: all 0.3s ease;
    position: relative;
    overflow: hidden;
}

.card::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 16px;
    background: var(--card-color, #4F46E5);
    z-index: 1;
}

.card:hover {
    transform: translateY(-2px);
    box-shadow: 0 8px 30px rgba(0, 0, 0, 0.15);
}

.card.dragging {
    opacity: 0.5;
    transform: rotate(5deg) scale(0.95);
    z-index: 1000;
}

.card.drag-over {
    border: 2px dashed #4F46E5;
    background: rgba(79, 70, 229, 0.05);
}

.card.reorder-handle {
    cursor: grab;
    position: relative;
}

.card.reorder-handle:active {
    cursor: grabbing;
}

.card.reorder-handle::after {
    content: '';
    position: absolute;
    left: 8px;
    top: 50%;
    transform: translateY(-50%);
    width: 16px;
    height: 16px;
    background-image: url('data:image/svg+xml,<svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" viewBox="0 0 16 16" fill="none" stroke="%236b7280" stroke-width="1.5" stroke-linecap="round" stroke-linejoin="round"><circle cx="4" cy="4" r="1"/><circle cx="12" cy="4" r="1"/><circle cx="4" cy="8" r="1"/><circle cx="12" cy="8" r="1"/><circle cx="4" cy="12" r="1"/><circle cx="12" cy="12" r="1"/></svg>');
    background-repeat: no-repeat;
    background-position: center;
    background-size: contain;
    opacity: 0.6;
    cursor: grab;
    z-index: 2;
}

.card.reorder-handle:hover::after {
    opacity: 0.8;
}

.card.reorder-handle:active::after {
    cursor: grabbing;
}

.card-header {
    display: flex;
    justify-content: flex-start;
    align-items: center;
    margin-bottom: 1rem;
    height: 60px;
}

.card-content {
    display: flex;
    align-items: center;
    gap: 1rem;
    width: 100%;
    height: 100%;
    padding: 16px 0 0 0;
    margin: 0;
}

.card-avatar {
    flex-shrink: 0;
    width: 56px;
    height: 56px;
    border-radius: 50%;
    overflow: hidden;
    background: #f3f4f6;
    display: flex;
    align-items: center;
    justify-content: center;
    margin: 0;
    padding: 8px;
}

.card-avatar img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.card-name {
    font-size: 1.2rem;
    font-weight: 600;
    color: #1f2937;
    flex: 1;
    display: flex;
    align-items: center;
    margin: 0;
    padding: 0;
    line-height: 1;
}

.card-number {
    font-family: 'Courier New', monospace;
    font-size: 0.9rem;
    color: #6b7280;
    background: #f3f4f6;
    padding: 0.25rem 0.5rem;
    border-radius: 4px;
    display: inline-block;
}

.card-barcode {
    margin-top: 1rem;
    text-align: center;
}

.card-barcode svg {
    max-width: 100%;
    height: 60px;
}

/* Modal Styles */
.modal {
    display: none;
    position: fixed;
    z-index: 1000;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.5);
    backdrop-filter: blur(5px);
}

.modal.show {
    display: flex;
    align-items: center;
    justify-content: center;
}

.modal-content {
    background: white;
    border-radius: 16px;
    width: 90%;
    max-width: 400px;
    max-height: 90vh;
    overflow-y: auto;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
    animation: modalSlideIn 0.3s ease;
}

.scanner-content {
    max-width: 500px;
    max-height: 80vh;
}

@keyframes modalSlideIn {
    from {
        opacity: 0;
        transform: translateY(-20px) scale(0.95);
    }
    to {
        opacity: 1;
        transform: translateY(0) scale(1);
    }
}

.modal-header {
    padding: 1.5rem 1.5rem 1rem;
    border-bottom: 1px solid #e5e7eb;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.modal-header h2 {
    font-size: 1.25rem;
    font-weight: 600;
    color: #1f2937;
    max-width: calc(100% - 50px); /* Account for close button */
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.close-btn {
    background: none;
    border: none;
    font-size: 1.5rem;
    color: #6b7280;
    cursor: pointer;
    padding: 0;
    width: 30px;
    height: 30px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    transition: background-color 0.2s;
}

.close-btn:hover {
    background-color: #f3f4f6;
}

/* Form Styles */
.form-group {
    margin-bottom: 1.5rem;
    padding: 0 1.5rem;
}

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

.form-group input,
.form-group select {
    width: 100%;
    padding: 0.75rem;
    border: 2px solid #e5e7eb;
    border-radius: 8px;
    font-size: 1rem;
    transition: border-color 0.2s;
}

.form-group input:focus,
.form-group select:focus {
    outline: none;
    border-color: #4F46E5;
    box-shadow: 0 0 0 3px rgba(79, 70, 229, 0.1);
}

.form-group input[type="color"] {
    height: 50px;
    padding: 0.25rem;
    cursor: pointer;
}

/* Name and Color Row Layout */
.name-color-row {
    display: flex;
    gap: 0.75rem;
    align-items: stretch;
}

.name-color-row input[type="text"] {
    flex: 1;
}

.color-picker {
    width: 50px !important;
    height: 50px !important;
    padding: 0.25rem !important;
    border-radius: 8px;
    cursor: pointer;
    flex-shrink: 0;
}

/* Footer */
.footer {
    background: transparent;
    padding: 1rem;
    margin-top: 0;
    border-top: none;
    position: relative;
}

.footer-content {
    max-width: 480px;
    margin: 0 auto;
}

.footer-text {
    font-size: 0.875rem;
    color: #6b7280;
    text-align: center;
    font-weight: 400;
    margin: 0 auto;
    display: flex;
    justify-content: center;
    align-items: center;
}

/* Hide footer when empty state is shown */
#emptyState:not([style*="display: none"]) ~ .footer,
#emptyState:not([style*="display: none"]) + .footer {
    display: none;
}

/* Alternative approach: hide footer when empty state is visible */
.app-container:has(#emptyState:not([style*="display: none"])) .footer {
    display: none;
}

/* Update Notification in Footer */
.update-notification {
    position: absolute;
    right: 1rem;
    top: 50%;
    transform: translateY(-50%);
}

.update-btn {
    background: #e5e7eb;
    border: 1px solid #d1d5db;
    color: #374151;
    padding: 0.5rem 1rem;
    border-radius: 6px;
    font-size: 0.875rem;
    cursor: pointer;
    transition: all 0.3s ease;
    white-space: nowrap;
}

.update-btn:hover {
    background: #d1d5db;
    transform: translateY(-1px);
}
/* Settings Modal */
.settings-content {
    padding: 1.5rem 0;
}

.settings-actions {
    display: flex;
    gap: 1rem;
    margin-bottom: 1.5rem;
    justify-content: center;
}

.settings-description {
    font-size: 0.9rem;
    color: #6b7280;
    line-height: 1.5;
    margin: 0;
    text-align: center;
}

/* Avatar Selection */
.avatar-selection {
    margin-top: 0.5rem;
}

.avatar-grid {
    display: grid;
    grid-template-columns: repeat(6, 1fr);
    gap: 0.5rem;
    max-height: 200px;
    overflow-y: auto;
    padding: 0.5rem;
    background: #f9fafb;
    border-radius: 8px;
    border: 2px solid #e5e7eb;
}

.avatar-option {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    cursor: pointer;
    border: 2px solid transparent;
    transition: all 0.2s ease;
    display: flex;
    align-items: center;
    justify-content: center;
    background: white;
}

.avatar-option:hover {
    border-color: #4F46E5;
    transform: scale(1.1);
}

.avatar-option.selected {
    border-color: #4F46E5;
    background: #4F46E5;
    color: white;
}

.avatar-option img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    border-radius: 50%;
}

/* Input with Scan Button */
.input-with-scan {
    display: flex;
    gap: 0.5rem;
    align-items: stretch;
}

.input-with-scan input {
    flex: 1;
}

.scan-btn {
    background: linear-gradient(135deg, #10B981 0%, #059669 100%);
    color: white;
    border: none;
    padding: 0.75rem 1rem;
    border-radius: 8px;
    font-size: 0.9rem;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.3s ease;
    white-space: nowrap;
    min-width: 80px;
}

.scan-btn:hover {
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(16, 185, 129, 0.3);
}

.scan-btn:active {
    transform: translateY(0);
}

.form-actions {
    padding: 1rem 1.5rem 1.5rem;
    display: flex;
    gap: 1rem;
    justify-content: flex-end;
}

/* Button Styles */
.btn-primary {
    background: linear-gradient(135deg, #4F46E5 0%, #7C3AED 100%);
    color: white;
    border: none;
    padding: 0.75rem 1.5rem;
    border-radius: 8px;
    font-size: 1rem;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.3s ease;
}

.btn-primary:hover {
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(79, 70, 229, 0.3);
}

.btn-secondary {
    background: #f3f4f6;
    color: #374151;
    border: 1px solid #d1d5db;
    padding: 0.75rem 1.5rem;
    border-radius: 8px;
    font-size: 1rem;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.3s ease;
}

.btn-secondary:hover {
    background: #e5e7eb;
}

.btn-danger {
    background: #ef4444;
    color: white;
    border: none;
    padding: 0.75rem 1.5rem;
    border-radius: 8px;
    font-size: 1rem;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.3s ease;
}

.btn-danger:hover {
    background: #dc2626;
    transform: translateY(-1px);
}

/* Scanner Styles */
.scanner-container {
    padding: 1.5rem;
}

.camera-container {
    position: relative;
    width: 100%;
    height: 300px;
    background: #000;
    border-radius: 12px;
    overflow: hidden;
    margin-bottom: 1rem;
}

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

.scanner-overlay {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    background: rgba(0, 0, 0, 0.3);
}

.scanner-frame {
    width: 250px;
    height: 100px;
    border: 2px solid #4F46E5;
    border-radius: 8px;
    background: rgba(79, 70, 229, 0.1);
    position: relative;
}

.scanner-frame::before {
    content: '';
    position: absolute;
    top: -2px;
    left: -2px;
    right: -2px;
    bottom: -2px;
    border: 2px solid transparent;
    border-radius: 8px;
    background: linear-gradient(45deg, #4F46E5, #7C3AED, #4F46E5) border-box;
    -webkit-mask: linear-gradient(#fff 0 0) padding-box, linear-gradient(#fff 0 0);
    -webkit-mask-composite: destination-out;
    mask: linear-gradient(#fff 0 0) padding-box, linear-gradient(#fff 0 0);
    mask-composite: exclude;
    animation: scannerPulse 2s ease-in-out infinite;
}

@keyframes scannerPulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.7; }
}

.scanner-instructions {
    color: white;
    background: rgba(0, 0, 0, 0.7);
    padding: 0.5rem 1rem;
    border-radius: 20px;
    margin-top: 1rem;
    font-size: 0.9rem;
    text-align: center;
}

.scanner-controls {
    display: flex;
    gap: 1rem;
    justify-content: center;
    margin-bottom: 1rem;
}

.scanner-result {
    background: #f9fafb;
    border: 1px solid #e5e7eb;
    border-radius: 8px;
    padding: 1rem;
    margin-top: 1rem;
}

.result-info {
    margin-bottom: 1rem;
}

.result-info p {
    margin-bottom: 0.5rem;
    font-size: 0.9rem;
}

.result-actions {
    display: flex;
    gap: 0.5rem;
    justify-content: center;
}

.result-actions button {
    flex: 1;
    padding: 0.5rem 1rem;
    font-size: 0.9rem;
}

/* Card Detail Modal */
.card-detail-content {
    padding: 1.5rem;
}

.barcode-container {
    text-align: center;
    margin-bottom: 1.5rem;
    padding: 1rem;
    background: #f9fafb;
    border-radius: 8px;
    display: flex;
    justify-content: center;
    align-items: center;
}

.barcode-container svg {
    width: 90%;
    height: auto;
}

.card-info {
    margin-bottom: 1.5rem;
}

.card-info p {
    margin-bottom: 0.5rem;
    font-size: 1rem;
}

.card-actions {
    text-align: center;
}

/* Empty State */
.empty-state {
    text-align: center;
    padding: 3rem 1rem;
    color: #6b7280;
}

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

.empty-state h3 {
    font-size: 1.5rem;
    font-weight: 600;
    color: #374151;
    margin-bottom: 0.5rem;
}

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

/* Responsive Design */
@media (max-width: 480px) {
    .app-container {
        max-width: 100%;
        box-shadow: none;
    }
    
    .header {
        padding: 1rem 1rem;
    }
    
    .cards-container {
        padding: 1rem;
    }
    
    .modal-content {
        width: 95%;
        margin: 1rem;
    }
    
    .scanner-content {
        width: 95%;
        max-height: 90vh;
    }
    
    .camera-container {
        height: 250px;
    }
    
    .scanner-frame {
        width: 200px;
        height: 80px;
    }
    
    .form-actions {
        flex-direction: column;
    }
    
    .form-actions button {
        width: 100%;
    }
    
    .input-with-scan {
        flex-direction: column;
    }
    
    .scan-btn {
        width: 100%;
    }
}

/* iOS Specific Styles */
@supports (-webkit-touch-callout: none) {
    .app-container {
        padding-top: env(safe-area-inset-top);
        padding-bottom: env(safe-area-inset-bottom);
    }
    
    .header {
        padding-top: calc(1rem + env(safe-area-inset-top));
    }
}

/* Loading States */
.loading {
    opacity: 0.6;
    pointer-events: none;
}

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

.card {
    animation: fadeIn 0.3s ease;
}

/* Accessibility */
@media (prefers-reduced-motion: reduce) {
    * {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
    }
}

/* Focus styles for keyboard navigation */
button:focus,
input:focus,
select:focus {
    outline: 2px solid #4F46E5;
    outline-offset: 2px;
} 

/* Icon Button Styles */
.icon-btn {
    background: none;
    border: none;
    padding: 0.5rem;
    border-radius: 50%;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    transition: background 0.2s, box-shadow 0.2s;
    margin: 0 0.25rem;
}
.icon-btn:focus {
    outline: 2px solid #4F46E5;
    outline-offset: 2px;
    background: #f3f4f6;
}
.icon-btn:hover {
    background: #f3f4f6;
    box-shadow: 0 2px 8px rgba(79, 70, 229, 0.08);
}
.icon-btn svg {
    display: block;
} 

.scan-actions {
    display: flex;
    gap: 0.5rem;
    justify-content: center;
} 