/* Reset and Base Styles */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

:root {
    --primary-color: #2563eb;
    --primary-dark: #1d4ed8;
    --secondary-color: #16a34a;
    --secondary-dark: #15803d;
    --danger-color: #dc2626;
    --danger-light: #fee2e2;
    --text-primary: #0f172a;
    --text-secondary: #64748b;
    --text-muted: #94a3b8;
    --bg-primary: #ffffff;
    --bg-secondary: #f8fafc;
    --bg-accent: #f1f5f9;
    --border-color: #e2e8f0;
    --border-focus: #3b82f6;
    --shadow-sm: 0 1px 2px 0 rgba(0, 0, 0, 0.05);
    --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06);
    --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -2px rgba(0, 0, 0, 0.05);
    --shadow-xl: 0 20px 25px -5px rgba(0, 0, 0, 0.1), 0 10px 10px -5px rgba(0, 0, 0, 0.04);
    --radius-sm: 6px;
    --radius-md: 8px;
    --radius-lg: 12px;
    --radius-xl: 16px;
}

body {
    font-family: 'Inter', 'SF Pro Display', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    background: linear-gradient(135deg, #f8fafc 0%, #e2e8f0 100%);
    color: var(--text-primary);
    line-height: 1.6;
    min-height: 100vh;
    font-size: 14px;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

/* Login Page Styles */
.login-page {
    width: 100%;
    padding: 20px;
    background: linear-gradient(135deg, #1e40af 0%, #3b82f6 50%, #6366f1 100%);
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
}

.login-card {
    background: var(--bg-primary);
    padding: 32px;
    border-radius: var(--radius-xl);
    box-shadow: var(--shadow-xl);
    max-width: 420px;
    width: 100%;
    position: relative;
    backdrop-filter: blur(10px);
    border: 1px solid rgba(255, 255, 255, 0.1);
}

.login-card::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 4px;
    background: linear-gradient(90deg, var(--primary-color), var(--secondary-color));
    border-radius: var(--radius-xl) var(--radius-xl) 0 0;
}

.login-header {
    text-align: center;
    margin-bottom: 32px;
}

.logo-placeholder {
    width: 64px;
    height: 64px;
    background: linear-gradient(135deg, var(--primary-color), var(--primary-dark));
    color: white;
    font-size: 28px;
    font-weight: 700;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    margin: 0 auto 16px;
    box-shadow: var(--shadow-md);
    position: relative;
    overflow: hidden;
}

.logo-placeholder::before {
    content: '';
    position: absolute;
    top: -50%;
    left: -50%;
    width: 200%;
    height: 200%;
    background: linear-gradient(45deg, transparent, rgba(255, 255, 255, 0.1), transparent);
    transform: rotate(45deg);
    animation: shine 3s infinite;
}

@keyframes shine {
    0% { transform: translateX(-100%) translateY(-100%) rotate(45deg); }
    50% { transform: translateX(100%) translateY(100%) rotate(45deg); }
    100% { transform: translateX(-100%) translateY(-100%) rotate(45deg); }
}

.login-header h1 {
    font-size: 28px;
    color: var(--text-primary);
    font-weight: 700;
    margin-bottom: 8px;
    background: linear-gradient(135deg, var(--text-primary), var(--text-secondary));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.login-header p {
    font-size: 15px;
    color: var(--text-secondary);
    font-weight: 400;
}

.login-form {
    display: flex;
    flex-direction: column;
    gap: 20px;
}

.form-field {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.form-field label {
    font-size: 14px;
    font-weight: 600;
    color: var(--text-primary);
    letter-spacing: -0.01em;
}

.form-field input {
    width: 100%;
    padding: 14px 16px;
    border: 2px solid var(--border-color);
    border-radius: var(--radius-md);
    font-size: 15px;
    background: var(--bg-secondary);
    transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
    font-family: inherit;
}

.form-field input:focus {
    border-color: var(--border-focus);
    background: var(--bg-primary);
    box-shadow: 0 0 0 4px rgba(59, 130, 246, 0.1);
    outline: none;
    transform: translateY(-1px);
}

.form-field input::placeholder {
    color: var(--text-muted);
}

.error-message {
    font-size: 13px;
    color: var(--danger-color);
    background: var(--danger-light);
    padding: 12px 16px;
    border-radius: var(--radius-md);
    text-align: center;
    border: 1px solid rgba(220, 38, 38, 0.2);
    font-weight: 500;
}

.login-button {
    width: 100%;
    padding: 14px 24px;
    background: linear-gradient(135deg, var(--primary-color), var(--primary-dark));
    color: white;
    border: none;
    border-radius: var(--radius-md);
    font-size: 15px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
    box-shadow: var(--shadow-sm);
    position: relative;
    overflow: hidden;
}

.login-button:hover {
    transform: translateY(-1px);
    box-shadow: var(--shadow-md);
    background: linear-gradient(135deg, var(--primary-dark), #1e3a8a);
}

.login-button:active {
    transform: translateY(0);
}

.back-button {
    display: block;
    width: 100%;
    padding: 14px 24px;
    margin-top: 16px;
    background: linear-gradient(135deg, var(--secondary-color), var(--secondary-dark));
    color: white;
    text-decoration: none;
    border-radius: var(--radius-md);
    font-size: 15px;
    font-weight: 600;
    text-align: center;
    transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
    box-shadow: var(--shadow-sm);
}

.back-button:hover {
    transform: translateY(-1px);
    box-shadow: var(--shadow-md);
    background: linear-gradient(135deg, var(--secondary-dark), #166534);
}

/* Enhanced Dashboard Styles */
.container {
    max-width: 1200px;
    margin: 40px auto;
    padding: 0 20px;
}

.dashboard-card {
    background: var(--bg-primary);
    border-radius: var(--radius-xl);
    box-shadow: var(--shadow-lg);
    overflow: hidden;
    border: 1px solid var(--border-color);
    backdrop-filter: blur(10px);
}

header {
    background: linear-gradient(135deg, var(--bg-primary) 0%, var(--bg-secondary) 100%);
    padding: 32px;
    border-bottom: 1px solid var(--border-color);
    display: flex;
    justify-content: space-between;
    align-items: center;
    position: relative;
}

header::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 4px;
    background: linear-gradient(90deg, var(--primary-color), var(--secondary-color));
}

header h1 {
    margin: 0;
    color: var(--text-primary);
    font-size: 32px;
    font-weight: 700;
    background: linear-gradient(135deg, var(--primary-color), var(--secondary-color));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    letter-spacing: -0.02em;
}

.logout-btn {
    color: var(--danger-color);
    text-decoration: none;
    font-weight: 600;
    padding: 12px 20px;
    border-radius: var(--radius-md);
    transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
    border: 2px solid transparent;
    font-size: 14px;
}

.logout-btn:hover {
    background: var(--danger-light);
    border-color: rgba(220, 38, 38, 0.2);
    text-decoration: none;
    transform: translateY(-1px);
}

.main-content {
    padding: 32px;
}

.upload-section {
    background: var(--bg-secondary);
    padding: 24px;
    border-radius: var(--radius-lg);
    border: 2px dashed var(--border-color);
    margin-bottom: 32px;
    transition: all 0.2s ease;
    position: relative;
}

.upload-section:hover {
    border-color: var(--primary-color);
    background: var(--bg-accent);
}

.upload-form {
    display: flex;
    gap: 16px;
    align-items: end;
}

.upload-form input[type="file"] {
    flex: 1;
    padding: 14px 16px;
    border: 2px solid var(--border-color);
    border-radius: var(--radius-md);
    background: var(--bg-primary);
    font-size: 14px;
    transition: all 0.2s ease;
    cursor: pointer;
}

.upload-form input[type="file"]:focus {
    border-color: var(--border-focus);
    box-shadow: 0 0 0 4px rgba(59, 130, 246, 0.1);
    outline: none;
}

.hidden {
    display: none;
}

.results-section {
    margin-top: 32px;
}

.text-box {
    text-align: left;
    background: var(--bg-secondary);
    padding: 24px;
    border-radius: var(--radius-lg);
    word-wrap: break-word;
    overflow-x: hidden;
    max-width: 100%;
    box-sizing: border-box;
    max-height: 400px;
    overflow-y: auto;
    margin-bottom: 20px;
    border: 1px solid var(--border-color);
    font-family: 'SF Mono', Monaco, 'Cascadia Code', 'Roboto Mono', Consolas, 'Courier New', monospace;
    font-size: 14px;
    line-height: 1.6;
    box-shadow: var(--shadow-sm);
}

.text-box::-webkit-scrollbar {
    width: 8px;
}

.text-box::-webkit-scrollbar-track {
    background: var(--bg-accent);
    border-radius: var(--radius-sm);
}

.text-box::-webkit-scrollbar-thumb {
    background: var(--border-color);
    border-radius: var(--radius-sm);
}

.text-box::-webkit-scrollbar-thumb:hover {
    background: var(--text-muted);
}

#results h2 {
    color: var(--text-primary);
    margin: 24px 0 16px;
    font-size: 24px;
    font-weight: 700;
    position: relative;
    padding-left: 16px;
}

#results h2::before {
    content: '';
    position: absolute;
    left: 0;
    top: 50%;
    transform: translateY(-50%);
    width: 4px;
    height: 24px;
    background: linear-gradient(135deg, var(--primary-color), var(--secondary-color));
    border-radius: 2px;
}

button {
    padding: 14px 24px;
    background: linear-gradient(135deg, var(--primary-color), var(--primary-dark));
    color: white;
    border: none;
    border-radius: var(--radius-md);
    cursor: pointer;
    transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
    font-weight: 600;
    font-size: 14px;
    box-shadow: var(--shadow-sm);
    position: relative;
    overflow: hidden;
}

button:hover {
    transform: translateY(-1px);
    box-shadow: var(--shadow-md);
    background: linear-gradient(135deg, var(--primary-dark), #1e3a8a);
}

button:active {
    transform: translateY(0);
}

.print-btn {
    display: block;
    margin: 24px auto 0;
    background: linear-gradient(135deg, var(--secondary-color), var(--secondary-dark));
}

.print-btn:hover {
    background: linear-gradient(135deg, var(--secondary-dark), #166534);
}

#status {
    margin: 16px 0;
    font-style: italic;
    color: var(--text-secondary);
    padding: 12px 16px;
    background: var(--bg-accent);
    border-radius: var(--radius-md);
    border-left: 4px solid var(--primary-color);
    font-weight: 500;
}

/* Loading Animation */
.loading {
    position: relative;
}

.loading::after {
    content: '';
    position: absolute;
    right: 12px;
    top: 50%;
    transform: translateY(-50%);
    width: 16px;
    height: 16px;
    border: 2px solid rgba(255, 255, 255, 0.3);
    border-radius: 50%;
    border-top-color: white;
    animation: spin 1s ease-in-out infinite;
}

@keyframes spin {
    to { transform: translateY(-50%) rotate(360deg); }
}

/* Progress Bar */
.progress-container {
    width: 100%;
    height: 4px;
    background: var(--bg-accent);
    border-radius: 2px;
    overflow: hidden;
    margin: 16px 0;
}

.progress-bar {
    height: 100%;
    background: linear-gradient(90deg, var(--primary-color), var(--secondary-color));
    width: 0%;
    transition: width 0.3s ease;
    border-radius: 2px;
}

/* Responsive Design */
@media (max-width: 768px) {
    body {
        font-size: 16px; /* Prevent zoom on iOS */
    }
    
    .container {
        margin: 20px auto;
        padding: 0 16px;
    }

    .dashboard-card {
        border-radius: var(--radius-lg);
        margin: 0 -4px;
    }

    header {
        padding: 24px 20px;
        flex-direction: column;
        gap: 16px;
        text-align: center;
    }

    header h1 {
        font-size: 24px;
    }

    .main-content {
        padding: 20px;
    }

    .upload-form {
        flex-direction: column;
        align-items: stretch;
    }

    .upload-form input, 
    .upload-form button {
        width: 100%;
    }

    .text-box {
        max-height: 300px;
        padding: 16px;
        font-size: 14px;
    }

    #results h2 {
        font-size: 20px;
    }

    .login-card {
        padding: 24px;
        margin: 0 4px;
    }

    .login-header h1 {
        font-size: 24px;
    }

    .logo-placeholder {
        width: 56px;
        height: 56px;
        font-size: 24px;
    }
}

@media (max-width: 480px) {
    .upload-section {
        padding: 16px;
    }
    
    .main-content {
        padding: 16px;
    }
    
    header {
        padding: 20px 16px;
    }
    
    .text-box {
        padding: 12px;
    }
}

/* Print Styles */
@media print {
    body {
        background: white;
        color: black;
    }
    
    .container {
        box-shadow: none;
        max-width: none;
        margin: 0;
    }
    
    header, .upload-section, .print-btn, .logout-btn {
        display: none;
    }
    
    .text-box {
        box-shadow: none;
        border: 1px solid #ccc;
        background: white;
        max-height: none;
        overflow: visible;
    }
}

/* Accessibility Improvements */
@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
    }
}

/* Focus indicators for accessibility */
button:focus-visible,
.login-button:focus-visible,
.back-button:focus-visible,
.logout-btn:focus-visible {
    outline: 2px solid var(--border-focus);
    outline-offset: 2px;
}

/* High contrast mode support */
@media (prefers-contrast: high) {
    :root {
        --border-color: #000000;
        --text-secondary: #000000;
        --bg-secondary: #ffffff;
    }
}