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

:root {
    --primary: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    --primary-dark: #5568d3;
    --secondary: #f093fb;
    --success: #4ade80;
    --error: #f87171;
    --warning: #fbbf24;
    --bg-dark: #0f172a;
    --bg-card: #1e293b;
    --bg-input: #334155;
    --text-primary: #f1f5f9;
    --text-secondary: #94a3b8;
    --border: #334155;
    --shadow: 0 20px 25px -5px rgba(0, 0, 0, 0.3);
}

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
    background: var(--bg-dark);
    color: var(--text-primary);
    line-height: 1.6;
    min-height: 100vh;
}

.container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 20px;
}

/* Header */
.header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 20px 0;
    margin-bottom: 40px;
    border-bottom: 2px solid var(--border);
}

.logo {
    display: flex;
    align-items: center;
    gap: 15px;
}

.logo h1 {
    font-size: 24px;
    font-weight: 700;
    background: var(--primary);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.user-info {
    display: flex;
    align-items: center;
    gap: 15px;
}

.user-info span {
    color: var(--text-secondary);
    font-size: 14px;
}

/* Buttons */
.btn-primary,
.btn-secondary {
    padding: 12px 24px;
    border: none;
    border-radius: 8px;
    font-size: 16px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
    outline: none;
}

.btn-primary {
    background: var(--primary);
    color: white;
    box-shadow: 0 4px 6px -1px rgba(102, 126, 234, 0.3);
}

.btn-primary:hover {
    transform: translateY(-2px);
    box-shadow: 0 10px 15px -3px rgba(102, 126, 234, 0.4);
}

.btn-secondary {
    background: var(--bg-input);
    color: var(--text-primary);
}

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

.btn-tertiary {
    padding: 12px 24px;
    border: 2px solid var(--border);
    border-radius: 8px;
    font-size: 16px;
    font-weight: 600;
    cursor: pointer;
    background: transparent;
    color: var(--text-secondary);
    transition: all 0.3s ease;
}

.btn-tertiary:hover {
    border-color: var(--text-secondary);
    color: var(--text-primary);
}

/* Auth Section */
.auth-container {
    max-width: 450px;
    margin: 60px auto;
    background: var(--bg-card);
    border-radius: 16px;
    padding: 40px;
    box-shadow: var(--shadow);
}

.auth-tabs {
    display: flex;
    gap: 10px;
    margin-bottom: 30px;
}

.tab-btn {
    flex: 1;
    padding: 12px;
    background: transparent;
    border: none;
    color: var(--text-secondary);
    font-size: 16px;
    font-weight: 600;
    cursor: pointer;
    border-bottom: 2px solid transparent;
    transition: all 0.3s ease;
}

.tab-btn.active {
    color: var(--text-primary);
    border-bottom-color: #667eea;
}

.tab-content {
    display: none;
}

.tab-content.active {
    display: block;
    animation: fadeIn 0.3s ease;
}

.tab-content h2 {
    margin-bottom: 25px;
    font-size: 28px;
}

/* Forms */
.form-group {
    margin-bottom: 20px;
}

.form-group label {
    display: block;
    margin-bottom: 8px;
    color: var(--text-secondary);
    font-size: 14px;
    font-weight: 500;
}

.form-group input {
    width: 100%;
    padding: 12px 16px;
    background: var(--bg-input);
    border: 2px solid var(--border);
    border-radius: 8px;
    color: var(--text-primary);
    font-size: 16px;
    transition: all 0.3s ease;
}

.form-group input:focus {
    outline: none;
    border-color: #667eea;
    box-shadow: 0 0 0 3px rgba(102, 126, 234, 0.1);
}

.form-group small {
    display: block;
    margin-top: 5px;
    color: var(--text-secondary);
    font-size: 12px;
}

.form-group button {
    width: 100%;
    margin-top: 10px;
}

/* Navigation Tabs */
.nav-tabs {
    display: flex;
    gap: 10px;
    margin-bottom: 30px;
    background: var(--bg-card);
    padding: 8px;
    border-radius: 12px;
}

.nav-btn {
    flex: 1;
    padding: 12px 20px;
    background: transparent;
    border: none;
    color: var(--text-secondary);
    font-size: 16px;
    font-weight: 600;
    cursor: pointer;
    border-radius: 8px;
    transition: all 0.3s ease;
}

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

/* Cards */
.card {
    background: var(--bg-card);
    border-radius: 16px;
    padding: 30px;
    box-shadow: var(--shadow);
    margin-bottom: 20px;
}

.card h2 {
    margin-bottom: 25px;
    font-size: 24px;
}

.card h3 {
    margin-bottom: 20px;
    font-size: 20px;
}

/* Content Sections */
.content-section {
    display: none;
}

.content-section.active {
    display: block;
    animation: fadeIn 0.3s ease;
}

/* File Upload */
.file-upload {
    margin-bottom: 25px;
}

.file-upload input[type="file"] {
    display: none;
}

.file-label {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 40px;
    background: var(--bg-input);
    border: 2px dashed var(--border);
    border-radius: 12px;
    cursor: pointer;
    transition: all 0.3s ease;
}

.file-label:hover {
    border-color: #667eea;
    background: #2d3748;
}

.file-label svg {
    margin-bottom: 15px;
    color: #667eea;
}

.file-label span {
    color: var(--text-secondary);
    font-size: 16px;
}

/* QR Display */
.result-card {
    border: 2px solid var(--success);
}

.qr-display {
    display: flex;
    gap: 30px;
    margin: 25px 0;
    align-items: center;
}

.qr-display img {
    width: 200px;
    height: 200px;
    border-radius: 12px;
    background: white;
    padding: 10px;
}

.qr-info {
    flex: 1;
}

.qr-info p {
    margin-bottom: 12px;
    font-size: 16px;
}

.qr-info code {
    background: var(--bg-input);
    padding: 4px 8px;
    border-radius: 4px;
    font-family: 'Monaco', monospace;
    color: #fbbf24;
}

/* Scanner */
.scanner-container {
    margin: 25px 0;
    border-radius: 12px;
    overflow: hidden;
}

.scanner {
    width: 100%;
    max-width: 500px;
    margin: 0 auto;
    border-radius: 12px;
    overflow: hidden;
}

.scanner-placeholder {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 60px;
    background: var(--bg-input);
    border-radius: 12px;
    color: var(--text-secondary);
}

.scanner-placeholder svg {
    margin-bottom: 20px;
    opacity: 0.5;
}

/* Manual Entry */
.manual-entry {
    margin-top: 30px;
    padding-top: 30px;
    border-top: 2px solid var(--border);
}

.manual-entry p {
    margin-bottom: 15px;
    color: var(--text-secondary);
}

.input-group {
    display: flex;
    gap: 10px;
}

.input-group input {
    flex: 1;
    padding: 12px 16px;
    background: var(--bg-input);
    border: 2px solid var(--border);
    border-radius: 8px;
    color: var(--text-primary);
    font-size: 16px;
}

.input-group input:focus {
    outline: none;
    border-color: #667eea;
}

/* Button Group */
.button-group {
    display: flex;
    gap: 10px;
    margin-top: 20px;
}

.button-group button {
    flex: 1;
}

/* Scan Info */
.scan-info {
    margin: 20px 0;
}

.scan-info p {
    margin-bottom: 12px;
    font-size: 16px;
}

/* Documents List */
.documents-list {
    display: grid;
    gap: 15px;
}

.document-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 20px;
    background: var(--bg-input);
    border-radius: 12px;
    transition: all 0.3s ease;
}

.document-item:hover {
    background: #3d4b5f;
    transform: translateX(5px);
}

.document-info h4 {
    margin-bottom: 8px;
    font-size: 18px;
}

.document-info p {
    color: var(--text-secondary);
    font-size: 14px;
}

.document-stats {
    display: flex;
    gap: 20px;
}

.stat {
    text-align: center;
}

.stat-value {
    display: block;
    font-size: 24px;
    font-weight: 700;
    color: #667eea;
}

.stat-label {
    display: block;
    font-size: 12px;
    color: var(--text-secondary);
}

/* Toast */
.toast {
    position: fixed;
    bottom: 30px;
    right: 30px;
    padding: 16px 24px;
    background: var(--bg-card);
    border-radius: 12px;
    box-shadow: var(--shadow);
    transform: translateY(100px);
    opacity: 0;
    transition: all 0.3s ease;
    z-index: 1000;
    max-width: 400px;
}

.toast.show {
    transform: translateY(0);
    opacity: 1;
}

.toast.success {
    border-left: 4px solid var(--success);
}

.toast.error {
    border-left: 4px solid var(--error);
}

.toast.warning {
    border-left: 4px solid var(--warning);
}

/* Loading */
.loading {
    text-align: center;
    color: var(--text-secondary);
    padding: 40px;
}

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

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* Responsive - Mobile First */
@media (max-width: 768px) {
    .container {
        padding: 10px;
    }

    /* Header */
    .header {
        flex-direction: column;
        gap: 15px;
        text-align: center;
        padding: 15px 0;
    }

    .logo {
        justify-content: center;
    }

    .logo h1 {
        font-size: 20px;
    }

    .user-info {
        width: 100%;
        justify-content: center;
        flex-wrap: wrap;
    }

    /* Auth Section */
    .auth-container {
        padding: 25px 20px;
        margin: 20px auto;
    }

    .tab-content h2 {
        font-size: 24px;
    }

    /* Buttons - Larger touch targets */
    .btn-primary,
    .btn-secondary {
        padding: 14px 20px;
        font-size: 16px;
        min-height: 48px;
        /* Touch-friendly */
    }

    .tab-btn {
        padding: 14px;
        font-size: 15px;
    }

    .nav-btn {
        padding: 14px 16px;
        font-size: 14px;
    }

    /* Navigation */
    .nav-tabs {
        flex-direction: column;
        gap: 8px;
    }

    .nav-btn {
        width: 100%;
    }

    /* Cards */
    .card {
        padding: 20px 15px;
        margin-bottom: 15px;
    }

    .card h2 {
        font-size: 20px;
        margin-bottom: 20px;
    }

    .card h3 {
        font-size: 18px;
    }

    /* Forms */
    .form-group input {
        padding: 14px 16px;
        font-size: 16px;
        /* Prevents zoom on iOS */
        min-height: 48px;
    }

    /* File Upload */
    .file-label {
        padding: 30px 20px;
    }

    .file-label svg {
        width: 40px;
        height: 40px;
    }

    .file-label span {
        font-size: 14px;
    }

    /* QR Display */
    .qr-display {
        flex-direction: column;
        gap: 20px;
    }

    .qr-display img {
        width: 100%;
        max-width: 280px;
        height: auto;
        aspect-ratio: 1;
    }

    .qr-info p {
        font-size: 15px;
        margin-bottom: 10px;
    }

    .qr-info code {
        font-size: 12px;
        word-break: break-all;
    }

    /* Scanner */
    .scanner-container {
        margin: 20px 0;
    }

    .scanner {
        max-width: 100%;
    }

    .scanner-placeholder {
        padding: 40px 20px;
    }

    .scanner-placeholder svg {
        width: 80px;
        height: 80px;
    }

    /* Manual Entry */
    .input-group {
        flex-direction: column;
    }

    .input-group input {
        width: 100%;
        padding: 14px 16px;
        font-size: 16px;
        min-height: 48px;
    }

    .input-group button {
        width: 100%;
    }

    /* Button Groups */
    .button-group {
        flex-direction: column;
        gap: 10px;
    }

    .button-group button {
        width: 100%;
    }

    /* Documents */
    .document-item {
        flex-direction: column;
        gap: 15px;
        padding: 15px;
    }

    .document-stats {
        width: 100%;
        justify-content: space-around;
    }

    /* Scan Info */
    .scan-info p {
        font-size: 15px;
    }

    /* Toast */
    .toast {
        bottom: 20px;
        right: 10px;
        left: 10px;
        max-width: none;
        font-size: 14px;
    }
}

/* Small Mobile Devices */
@media (max-width: 480px) {
    .logo h1 {
        font-size: 18px;
    }

    .logo svg {
        width: 32px;
        height: 32px;
    }

    .auth-container {
        padding: 20px 15px;
    }

    .tab-content h2 {
        font-size: 22px;
    }

    .card h2 {
        font-size: 18px;
    }

    .nav-btn {
        font-size: 13px;
        padding: 12px;
    }

    .qr-display img {
        max-width: 240px;
    }

    .stat-value {
        font-size: 20px;
    }
}

/* Landscape Mobile */
@media (max-width: 768px) and (orientation: landscape) {
    .scanner-placeholder {
        padding: 30px 20px;
    }

    .scanner-placeholder svg {
        width: 60px;
        height: 60px;
    }

    .file-label {
        padding: 25px 20px;
    }
}

/* Tablet */
@media (min-width: 769px) and (max-width: 1024px) {
    .container {
        padding: 15px;
    }

    .qr-display {
        gap: 25px;
    }

    .qr-display img {
        width: 180px;
        height: 180px;
    }
}

/* Touch Device Optimizations */
@media (hover: none) and (pointer: coarse) {

    /* Larger touch targets */
    .btn-primary,
    .btn-secondary {
        min-height: 48px;
        padding: 14px 24px;
    }

    .tab-btn,
    .nav-btn {
        min-height: 44px;
    }

    /* Remove hover effects on touch devices */
    .btn-primary:hover {
        transform: none;
    }

    .file-label:hover {
        border-color: var(--border);
        background: var(--bg-input);
    }

    .document-item:hover {
        background: var(--bg-input);
        transform: none;
    }

    /* Better tap highlighting */
    button,
    a,
    .file-label {
        -webkit-tap-highlight-color: rgba(102, 126, 234, 0.2);
    }
}