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

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Roboto', 'Arial', sans-serif;
    background-color: #f8f9fa;
    color: #333;
    overflow-x: hidden;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

/* Loading Screen */
.loading-screen {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100vh;
    background: linear-gradient(135deg, #1B4A3A, #2c5530);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 9999;
}

.loading-content {
    text-align: center;
    color: white;
}

.loading-icon {
    font-size: 4rem;
    margin-bottom: 1rem;
    animation: pulse 2s infinite;
}

.loading-spinner {
    width: 40px;
    height: 40px;
    border: 3px solid rgba(255,255,255,0.3);
    border-radius: 50%;
    border-top-color: white;
    animation: spin 1s ease-in-out infinite;
    margin: 1rem auto;
}

/* App Container */
.app-container {
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    padding-bottom: 80px; /* Space for bottom navigation */
}

/* Header */
.app-header {
    background: linear-gradient(135deg, #1B4A3A, #2c5530);
    color: white;
    padding: 1rem;
    box-shadow: 0 2px 10px rgba(0,0,0,0.1);
    position: sticky;
    top: 0;
    z-index: 100;
}

.header-content {
    display: flex;
    justify-content: space-between;
    align-items: center;
    max-width: 600px;
    margin: 0 auto;
}

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

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

.icon-btn {
    background: rgba(255,255,255,0.1);
    border: none;
    color: white;
    width: 40px;
    height: 40px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: background-color 0.2s;
    position: relative;
}

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

.notification-badge {
    position: absolute;
    top: -5px;
    right: -5px;
    background: #e74c3c;
    color: white;
    border-radius: 50%;
    width: 20px;
    height: 20px;
    font-size: 0.75rem;
    display: flex;
    align-items: center;
    justify-content: center;
}

/* Main Content */
.main-content {
    flex: 1;
    padding: 1rem;
    max-width: 600px;
    margin: 0 auto;
    width: 100%;
}

/* Bottom Navigation */
.bottom-nav {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    background: white;
    border-top: 1px solid #e9ecef;
    display: flex;
    padding: 0.5rem 0;
    z-index: 100;
    box-shadow: 0 -2px 10px rgba(0,0,0,0.1);
}

.nav-item {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 0.5rem;
    cursor: pointer;
    transition: color 0.2s;
    color: #666;
}

.nav-item.active {
    color: #1B4A3A;
}

.nav-item i {
    font-size: 1.2rem;
    margin-bottom: 0.25rem;
}

.nav-item span {
    font-size: 0.75rem;
    font-weight: 500;
}

/* Cards */
.card {
    background: white;
    border-radius: 12px;
    padding: 1.5rem;
    margin-bottom: 1rem;
    box-shadow: 0 2px 10px rgba(0,0,0,0.05);
    border: 1px solid #e9ecef;
}

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

.card-title {
    font-size: 1.1rem;
    font-weight: 600;
    color: #2c3e50;
}

/* Buttons */
.btn {
    background: #1B4A3A;
    color: white;
    border: none;
    padding: 0.75rem 1.5rem;
    border-radius: 8px;
    font-size: 0.9rem;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s;
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    text-decoration: none;
    justify-content: center;
}

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

.btn-secondary {
    background: #6c757d;
}

.btn-secondary:hover {
    background: #5a6268;
}

.btn-danger {
    background: #e74c3c;
}

.btn-danger:hover {
    background: #c0392b;
}

.btn-success {
    background: #27ae60;
}

.btn-success:hover {
    background: #229954;
}

.btn-full {
    width: 100%;
}

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

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

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

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

.form-control:focus {
    outline: none;
    border-color: #1B4A3A;
    box-shadow: 0 0 0 2px rgba(27, 74, 58, 0.1);
}

/* 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;
}

/* Startup Authentication Modal */
.startup-auth-modal {
    background: rgba(0,0,0,0.8);
    backdrop-filter: blur(5px);
    animation: fadeInAuth 0.5s ease-out;
}

.startup-auth-modal .modal-content {
    animation: slideUpAuth 0.5s ease-out;
    border: 2px solid #1B4A3A;
    box-shadow: 0 20px 60px rgba(0,0,0,0.3);
}

@keyframes fadeInAuth {
    from { opacity: 0; }
    to { opacity: 1; }
}

@keyframes slideUpAuth {
    from { 
        transform: translateY(50px) scale(0.95);
        opacity: 0;
    }
    to { 
        transform: translateY(0) scale(1);
        opacity: 1;
    }
}

.modal-content {
    background: white;
    border-radius: 12px;
    padding: 2rem;
    width: 100%;
    max-width: 400px;
    max-height: 90vh;
    overflow-y: auto;
    position: relative;
}

.scanner-modal .modal-content {
    max-width: 500px;
}

.close {
    position: absolute;
    top: 1rem;
    right: 1rem;
    font-size: 1.5rem;
    cursor: pointer;
    color: #666;
}

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

.badge-success { background: #d4edda; color: #155724; }
.badge-warning { background: #fff3cd; color: #856404; }
.badge-danger { background: #f8d7da; color: #721c24; }
.badge-info { background: #d1ecf1; color: #0c5460; }
.badge-secondary { background: #e2e3e5; color: #383d41; }

/* Animations */
@keyframes pulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.5; }
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

.fade-in {
    animation: fadeIn 0.3s ease-in;
}

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

/* Responsive Design */
@media (min-width: 768px) {
    .main-content {
        padding: 2rem;
    }
    
    .card {
        padding: 2rem;
    }
}

/* Dark Mode Support */
@media (prefers-color-scheme: dark) {
    body {
        background-color: #1a1a1a;
        color: #ffffff;
    }
    
    .card {
        background: #2d2d2d;
        border-color: #404040;
    }
    
    .form-control {
        background: #2d2d2d;
        border-color: #404040;
        color: white;
    }
    
    .bottom-nav {
        background: #2d2d2d;
        border-top-color: #404040;
    }
}

/* Event Details Modal Specific Styles */
.event-details-modal .modal-content {
    max-width: 500px;
}

.event-details-header {
    display: flex;
    align-items: center;
    gap: 1rem;
    margin-bottom: 1.5rem;
}

.event-details-header img {
    width: 60px;
    height: 60px;
    border-radius: 8px;
    object-fit: cover;
}

.event-details-info {
    margin-bottom: 1rem;
}

.event-details-info strong {
    color: #1B4A3A;
    display: inline-block;
    min-width: 100px;
}

.event-description {
    background: #f8f9fa;
    padding: 1rem;
    border-radius: 8px;
    margin: 1rem 0;
    border-left: 4px solid #1B4A3A;
}

.event-details-buttons {
    display: flex;
    gap: 0.5rem;
    justify-content: flex-end;
    margin-top: 1.5rem;
}

/* RFID Card Selection Styles */
.card-option {
    transition: all 0.2s ease;
    flex: 1;
    min-width: 140px;
    max-width: 180px;
    display: flex !important;
    flex-direction: column;
    justify-content: space-between;
    height: auto;
    margin-bottom: 0 !important;
    background: white;
}

.card-option:hover {
    background-color: #f8f9fa;
    border-color: #1B4A3A !important;
    transform: translateY(-2px);
    box-shadow: 0 4px 8px rgba(0,0,0,0.1);
}

.card-option input[type="radio"]:checked + * {
    background-color: #e8f5e8;
}

.card-option input[type="radio"] {
    accent-color: #1B4A3A;
    margin-bottom: 0.5rem;
}

.card-option input[type="radio"]:checked {
    accent-color: #1B4A3A;
}

.card-option.selected {
    border-color: #1B4A3A !important;
    background-color: #e8f5e8 !important;
}

/* Scope selection styling */
.scope-option:hover {
    border-color: #1B4A3A !important;
    background-color: #f8f9fa;
}

.scope-option input[type="radio"]:checked + * {
    background-color: #e8f5e8;
}

.scope-option:has(input[type="radio"]:checked) {
    border-color: #1B4A3A !important;
    background-color: #e8f5e8 !important;
}

.add-token-form h4 {
    color: #1B4A3A;
    margin-bottom: 1rem;
    border-bottom: 2px solid #e9ecef;
    padding-bottom: 0.5rem;
}

.btn.btn-primary {
    background-color: #1B4A3A;
    border-color: #1B4A3A;
    color: white;
}

.btn.btn-primary:hover {
    background-color: #0f2d1f;
    border-color: #0f2d1f;
}

.btn.btn-secondary {
    background-color: #6c757d;
    border-color: #6c757d;
    color: white;
}

.btn.btn-secondary:hover {
    background-color: #545b62;
    border-color: #545b62;
}

#available-cards-list {
    background-color: #f8f9fa;
    display: flex;
    flex-wrap: wrap;
    justify-content: space-between;
    gap: 0.5rem;
    padding: 0.75rem !important;
}

#available-cards-list:empty::after {
    content: "No cards available";
    display: block;
    text-align: center;
    color: #6c757d;
    padding: 1rem;
    font-style: italic;
    width: 100%;
}

/* Horizontal scrollbar styling */
#available-cards-list::-webkit-scrollbar {
    height: 8px;
}

#available-cards-list::-webkit-scrollbar-track {
    background: #f1f1f1;
    border-radius: 4px;
}

#available-cards-list::-webkit-scrollbar-thumb {
    background: #c1c1c1;
    border-radius: 4px;
}

#available-cards-list::-webkit-scrollbar-thumb:hover {
    background: #a8a8a8;
}

/* Modal Layout for RFID Cards */
.add-token-form {
    display: flex;
    flex-direction: column;
    height: 100%;
    max-height: 80vh;
}

.modal-header-fixed {
    flex-shrink: 0;
    padding-bottom: 1rem;
    border-bottom: 1px solid #e9ecef;
    margin-bottom: 1rem;
}

.modal-body-scrollable {
    flex: 1;
    overflow-y: auto;
    padding-right: 0.5rem;
    margin-right: -0.5rem;
}

.modal-body-scrollable::-webkit-scrollbar {
    width: 6px;
}

.modal-body-scrollable::-webkit-scrollbar-track {
    background: #f1f1f1;
    border-radius: 3px;
}

.modal-body-scrollable::-webkit-scrollbar-thumb {
    background: #c1c1c1;
    border-radius: 3px;
}

.modal-body-scrollable::-webkit-scrollbar-thumb:hover {
    background: #a8a8a8;
}

/* Ensure modal content doesn't overflow */
#add-token-modal .modal-content {
    max-height: 85vh;
    overflow: hidden;
    display: flex;
    flex-direction: column;
}