:root {
    --bg-color: #0f172a;
    --text-primary: #f8fafc;
    --text-secondary: #94a3b8;
    --accent: #3b82f6;
    --accent-hover: #2563eb;
    --glass-bg: rgba(30, 41, 59, 0.7);
    --glass-border: rgba(255, 255, 255, 0.1);
    --success: #10b981;
    --error: #ef4444;
}

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

html, body {
    overflow-x: hidden;
    width: 100%;
}

body {
    font-family: 'Inter', sans-serif;
    background-color: var(--bg-color);
    background-image: 
        radial-gradient(at 0% 0%, rgba(59, 130, 246, 0.15) 0px, transparent 50%),
        radial-gradient(at 100% 100%, rgba(139, 92, 246, 0.15) 0px, transparent 50%);
    background-attachment: fixed;
    color: var(--text-primary);
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    justify-content: flex-start;
    align-items: center;
    padding: 20px;
    overscroll-behavior-x: none;
}

.app-container {
    width: 100%;
    max-width: 100%; /* Changed from 500px to 100% to let media queries handle it, or we can use min(100%, 500px) */
    min-width: 0; /* Prevents flexbox stretching */
    margin: 0 auto;
}

@media (min-width: 500px) {
    .app-container {
        max-width: 500px;
    }
}

header {
    text-align: center;
    margin-bottom: 2rem;
    padding-top: 2rem;
}

header h1 {
    font-size: 2.5rem;
    font-weight: 600;
    background: linear-gradient(to right, #60a5fa, #a78bfa);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    margin-bottom: 0.5rem;
}

header p {
    color: var(--text-secondary);
}

.glass-card {
    background: var(--glass-bg);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border: 1px solid var(--glass-border);
    border-radius: 20px;
    padding: 2rem;
    box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.5);
    transition: all 0.3s ease;
    animation: fadeIn 0.5s ease;
}

.hidden {
    display: none !important;
}

/* Button Styles */
button {
    cursor: pointer;
    font-family: 'Inter', sans-serif;
    font-size: 1rem;
    font-weight: 500;
    border: none;
    border-radius: 12px;
    padding: 1rem 1.5rem;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    width: 100%;
    transition: all 0.2s ease;
}

.primary-btn {
    background: var(--accent);
    color: white;
    box-shadow: 0 4px 14px 0 rgba(59, 130, 246, 0.39);
}

.primary-btn:hover {
    background: var(--accent-hover);
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(59, 130, 246, 0.23);
}

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

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

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

/* Pulse Animation for Camera Button */
.pulse-anim {
    animation: pulse 2s infinite;
}

@keyframes pulse {
    0% { box-shadow: 0 0 0 0 rgba(59, 130, 246, 0.7); }
    70% { box-shadow: 0 0 0 15px rgba(59, 130, 246, 0); }
    100% { box-shadow: 0 0 0 0 rgba(59, 130, 246, 0); }
}

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

/* Loading Spinner */
#loading-indicator {
    text-align: center;
    margin-top: 1rem;
}

.spinner {
    width: 40px;
    height: 40px;
    border: 4px solid rgba(255, 255, 255, 0.1);
    border-left-color: var(--accent);
    border-radius: 50%;
    animation: spin 1s linear infinite;
    margin: 0 auto 1rem;
}

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

/* Form Styles */
.image-preview-container {
    width: 100%;
    height: 200px;
    border-radius: 12px;
    overflow: hidden;
    margin-bottom: 1.5rem;
    border: 1px solid var(--glass-border);
    background: rgba(0, 0, 0, 0.2);
}

#image-preview {
    width: 100%;
    height: 100%;
    object-fit: contain;
}

.form-group {
    margin-bottom: 1.2rem;
}

.form-group label {
    display: block;
    margin-bottom: 0.5rem;
    font-size: 0.9rem;
    color: var(--text-secondary);
}

.form-group input:not([type="checkbox"]),
.form-group select {
    width: 100%;
    max-width: 100%;
    box-sizing: border-box;
    padding: 0.8rem 1rem;
    border-radius: 10px;
    background: rgba(0, 0, 0, 0.2);
    border: 1px solid var(--glass-border);
    color: var(--text-primary);
    font-family: 'Inter', sans-serif;
    font-size: 1rem;
    transition: all 0.2s;
}

.form-group select {
    appearance: none;
    -webkit-appearance: none;
    background-image: url("data:image/svg+xml;charset=UTF-8,%3csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%2394a3b8' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3e%3cpolyline points='6 9 12 15 18 9'%3e%3c/polyline%3e%3c/svg%3e");
    background-repeat: no-repeat;
    background-position: right 1rem center;
    background-size: 1em;
}

.form-group select option {
    background: var(--bg-color);
    color: var(--text-primary);
}

.form-group input:not([type="checkbox"]):focus,
.form-group select:focus {
    outline: none;
    border-color: var(--accent);
    background-color: rgba(0, 0, 0, 0.4);
    box-shadow: 0 0 0 2px rgba(59, 130, 246, 0.2);
}

.form-group input[type="checkbox"] {
    width: 1.2rem;
    height: 1.2rem;
    transform: scale(1.8);
    margin-left: 0.4rem;
    margin-right: 0.8rem;
    cursor: pointer;
    accent-color: var(--accent);
}

.form-actions {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: 1rem;
    margin-top: 2rem;
}

/* Success Section */
#success-section {
    text-align: center;
}

.success-icon {
    margin-bottom: 1rem;
}

#success-section h2 {
    margin-bottom: 0.5rem;
}

#success-section p {
    color: var(--text-secondary);
    margin-bottom: 2rem;
}

/* Tabs */
.app-tabs {
    display: flex;
    justify-content: center;
    gap: 1rem;
    margin-bottom: 2rem;
}

.tab-btn {
    background: transparent;
    color: var(--text-secondary);
    border: 1px solid var(--glass-border);
    border-radius: 12px;
    padding: 0.8rem 1.5rem;
    cursor: pointer;
    transition: all 0.2s;
    width: auto;
}

.tab-btn:hover {
    background: rgba(255, 255, 255, 0.05);
}

.tab-btn.active {
    background: var(--glass-bg);
    color: var(--text-primary);
    border-color: var(--accent);
    box-shadow: 0 0 10px rgba(59, 130, 246, 0.3);
}

.search-date-wrapper {
    width: 100%;
    margin-bottom: 1rem;
}

.search-date-labels {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    margin-bottom: 0.5rem;
}

.search-date-labels label {
    flex: 1;
    font-size: 0.9rem;
    color: var(--text-secondary);
}

.label-spacer {
    width: 1rem; /* match the span approx width */
    flex-shrink: 0;
}

.search-date-inputs {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    width: 100%;
}

.search-date-inputs input {
    flex: 1;
    min-width: 0;
    padding: 0.6rem 0.5rem;
    font-size: 0.9rem;
    border-radius: 10px;
    background: rgba(0, 0, 0, 0.2);
    border: 1px solid var(--glass-border);
    color: var(--text-primary);
    font-family: 'Inter', sans-serif;
    outline: none;
    transition: all 0.2s;
}

.search-date-inputs input:focus {
    border-color: var(--accent);
    background: rgba(0, 0, 0, 0.4);
    box-shadow: 0 0 0 2px rgba(59, 130, 246, 0.2);
}

.date-separator {
    color: var(--text-secondary);
    flex-shrink: 0;
    text-align: center;
}

/* Textarea Styles */
.form-group textarea {
    width: 100%;
    padding: 0.8rem 1rem;
    border-radius: 10px;
    background: rgba(0, 0, 0, 0.2);
    border: 1px solid var(--glass-border);
    color: var(--text-primary);
    font-family: 'Inter', sans-serif;
    font-size: 1rem;
    transition: all 0.2s;
    resize: vertical;
    min-height: 80px;
}

.form-group textarea:focus {
    outline: none;
    border-color: var(--accent);
    background: rgba(0, 0, 0, 0.4);
    box-shadow: 0 0 0 2px rgba(59, 130, 246, 0.2);
}

/* Table */
.table-container {
    margin-top: 2rem;
    width: 100%;
    max-width: 100%;
    overflow-x: auto;
    border-radius: 12px;
    border: 1px solid var(--glass-border);
    background: rgba(0, 0, 0, 0.2);
    /* For WebKit scrollbars on iOS */
    -webkit-overflow-scrolling: touch;
}

.data-table {
    width: 100%;
    border-collapse: collapse;
    color: var(--text-primary);
    font-size: 0.9rem;
}

.data-table th, .data-table td {
    padding: 1rem;
    text-align: left;
    border-bottom: 1px solid var(--glass-border);
    white-space: nowrap;
}

.data-table th {
    background: rgba(255, 255, 255, 0.05);
    font-weight: 600;
    color: var(--text-secondary);
}

.data-table tbody tr:hover {
    background: rgba(255, 255, 255, 0.05);
}

.text-center {
    text-align: center;
}
.mt-4 {
    margin-top: 1rem;
}

/* Modal Styles */
.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw; /* Use vw to prevent iOS wobble */
    height: 100vh; /* Use vh */
    background: rgba(0, 0, 0, 0.7);
    backdrop-filter: blur(5px);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 1000;
    opacity: 1;
    transition: opacity 0.3s ease;
    overflow: hidden; /* Prevent overlay from scrolling */
}

.modal-overlay.hidden {
    opacity: 0;
    pointer-events: none;
    display: flex; /* Keep display flex to allow transition */
}

.modal-content {
    width: 90%;
    max-width: 500px;
    max-height: 90vh;
    overflow-y: auto;
    overflow-x: hidden; /* STRICTLY PREVENT HORIZONTAL WOBBLE */
    padding: 2rem;
    transform: translateY(0);
    transition: transform 0.3s ease;
    overscroll-behavior-x: none;
}

.modal-overlay.hidden .modal-content {
    transform: translateY(20px);
}

.modal-content h2 {
    margin-bottom: 1.5rem;
    font-size: 1.5rem;
    text-align: center;
}

/* Table Row Hover/Click Styles */
.data-table tbody tr {
    cursor: pointer;
    transition: background 0.2s;
}

.data-table tbody tr:hover {
    background: rgba(255, 255, 255, 0.1);
}

@media (max-width: 600px) {
    .glass-card {
        padding: 1.5rem 1rem;
    }
    .modal-content {
        padding: 1.5rem 1rem;
    }
    .legal-links-container {
        flex-direction: column;
        align-items: center;
        gap: 0.8rem !important;
    }
    .search-date-inputs input {
        padding: 0.6rem 0.2rem;
        font-size: 0.85rem;
    }
}
