/* Reset and base styles */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

:root {
    --primary-color: #3AAFA9;
    --primary-hover: #2B7A78;
    --secondary-color: #706e6b;
    --success-color: #3AAFA9;
    --background: #f3f3f3;
    --card-bg: #ffffff;
    --text-primary: #080707;
    --text-secondary: #706e6b;
    --border-color: #dddbda;
    --shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
    --shadow-lg: 0 4px 12px rgba(0, 0, 0, 0.15);
    --radius: 8px;
    --radius-lg: 12px;
}

/* ======================
   Login Screen Styles
   ====================== */
.login-screen {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 24px;
    background: linear-gradient(135deg, #f8f9fa 0%, #e9ecef 100%);
    z-index: 1000;
}

.login-screen.active {
    display: flex;
}

.login-container {
    text-align: center;
    max-width: 400px;
    width: 100%;
    padding: 40px 32px;
    background: white;
    border-radius: 16px;
    box-shadow: 0 4px 24px rgba(0, 0, 0, 0.1);
}

.login-logo {
    width: 100px;
    height: 100px;
    margin-bottom: 24px;
    border-radius: 20px;
    box-shadow: 0 4px 12px rgba(58, 175, 169, 0.3);
}

.login-container h1 {
    font-size: 1.75rem;
    font-weight: 700;
    color: #3AAFA9;
    margin-bottom: 12px;
}

.login-description {
    color: #6c757d;
    font-size: 1rem;
    margin-bottom: 32px;
    line-height: 1.5;
}

.login-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 12px;
    width: 100%;
    padding: 14px 24px;
    font-size: 1rem;
    font-weight: 600;
    color: #333;
    background: white;
    border: 2px solid #e0e0e0;
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.2s ease;
}

.login-btn:hover {
    border-color: #3AAFA9;
    background: #f8f9fa;
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
}

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

.login-btn:disabled {
    opacity: 0.7;
    cursor: not-allowed;
    transform: none;
}

.microsoft-logo {
    width: 20px;
    height: 20px;
    flex-shrink: 0;
}

.login-note {
    margin-top: 20px;
    font-size: 0.85rem;
    color: #6c757d;
}

.login-error {
    margin-top: 16px;
    padding: 12px;
    background: #fff5f5;
    border: 1px solid #fed7d7;
    border-radius: 8px;
    color: #c53030;
    font-size: 0.9rem;
}

html, body {
    height: 100%;
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, sans-serif;
    background: var(--background);
    color: var(--text-primary);
    line-height: 1.5;
}

#app {
    min-height: 100%;
    display: flex;
    flex-direction: column;
    max-width: 600px;
    margin: 0 auto;
    padding: 0 16px;
}

/* Header */
.app-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 16px 0;
    border-bottom: 1px solid var(--border-color);
    margin-bottom: 24px;
}

.header-left {
    display: flex;
    align-items: center;
    gap: 12px;
}

.header-right {
    display: flex;
    align-items: center;
    gap: 12px;
}

.app-header .logo {
    height: 36px;
    width: auto;
}

.app-header h1 {
    font-size: 1.25rem;
    font-weight: 600;
    color: var(--primary-color);
}

.user-name {
    font-size: 0.8rem;
    color: var(--text-secondary);
    max-width: 100px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.logout-btn {
    padding: 6px 12px;
    font-size: 0.75rem;
    color: var(--text-secondary);
    background: transparent;
    border: 1px solid var(--border-color);
    border-radius: 6px;
    cursor: pointer;
    transition: all 0.2s ease;
}

.logout-btn:hover {
    color: #c53030;
    border-color: #c53030;
    background: #fff5f5;
}

/* Steps */
.step {
    display: none;
    animation: fadeIn 0.3s ease;
}

.step.active {
    display: block;
}

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

.step h2 {
    font-size: 1.5rem;
    font-weight: 600;
    margin-bottom: 8px;
}

.step-description {
    color: var(--text-secondary);
    margin-bottom: 24px;
}

/* Back button */
.back-btn {
    background: none;
    border: none;
    color: var(--primary-color);
    font-size: 1rem;
    cursor: pointer;
    padding: 8px 0;
    margin-bottom: 16px;
    display: flex;
    align-items: center;
    gap: 4px;
}

.back-btn:hover {
    text-decoration: underline;
}

/* Site Grid */
.site-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 12px;
}

.site-btn {
    padding: 16px 12px;
    background: var(--card-bg);
    border: 2px solid var(--border-color);
    border-radius: var(--radius-lg);
    cursor: pointer;
    text-align: center;
    transition: all 0.2s ease;
    font-size: 0.95rem;
    font-weight: 500;
}

.site-btn:hover {
    border-color: var(--primary-color);
    box-shadow: var(--shadow);
    transform: translateY(-2px);
}

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

.site-btn.selected {
    border-color: var(--primary-color);
    background: rgba(0, 112, 210, 0.1);
}

/* Site Filter Note */
.site-filter-note {
    font-size: 0.875rem;
    color: var(--text-secondary);
    margin-bottom: 16px;
    padding: 8px 12px;
    background: rgba(0, 112, 210, 0.08);
    border-radius: var(--radius);
}

.site-filter-note strong {
    color: var(--primary-color);
}

/* Form Section Headers */
.form-section-header {
    font-size: 1rem;
    font-weight: 600;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-top: 24px;
    margin-bottom: 12px;
    padding-bottom: 8px;
    border-bottom: 2px solid var(--border-color);
}

.form-section-header:first-of-type {
    margin-top: 0;
}

/* Form Sections */
.form-section {
    margin-bottom: 16px;
}

.form-section.hidden {
    display: none;
}

/* Generic hidden class */
.hidden {
    display: none !important;
}

/* Form Cards */
.form-cards {
    display: flex;
    flex-direction: column;
    gap: 16px;
    margin-bottom: 8px;
}

.form-card {
    display: flex;
    align-items: center;
    gap: 16px;
    padding: 20px;
    background: var(--card-bg);
    border: 2px solid var(--border-color);
    border-radius: var(--radius-lg);
    cursor: pointer;
    text-align: left;
    transition: all 0.2s ease;
    width: 100%;
}

.form-card:hover {
    border-color: var(--primary-color);
    box-shadow: var(--shadow-lg);
    transform: translateY(-2px);
}

.form-card:active {
    transform: translateY(0);
}

.card-icon {
    font-size: 2rem;
    width: 50px;
    height: 50px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--background);
    border-radius: var(--radius);
}

.card-icon.mip-icon {
    background: linear-gradient(135deg, #00695c 0%, #26a69a 100%);
}

.card-content {
    flex: 1;
}

.card-content h3 {
    font-size: 1.1rem;
    font-weight: 600;
    margin-bottom: 4px;
}

.card-content p {
    font-size: 0.875rem;
    color: var(--text-secondary);
}

.card-arrow {
    font-size: 1.5rem;
    color: var(--text-secondary);
}

/* Choice Cards (for Application form search/blank choice) */
.choice-cards {
    display: flex;
    flex-direction: column;
    gap: 16px;
    margin-top: 24px;
}

.choice-card {
    display: flex;
    align-items: center;
    gap: 16px;
    padding: 24px 20px;
    background: var(--card-bg);
    border: 2px solid var(--border-color);
    border-radius: var(--radius-lg);
    cursor: pointer;
    text-align: left;
    transition: all 0.2s ease;
    width: 100%;
}

.choice-card:hover {
    border-color: var(--primary-color);
    box-shadow: var(--shadow-lg);
    transform: translateY(-2px);
}

.choice-card:active {
    transform: translateY(0);
}

.choice-icon {
    font-size: 2.5rem;
    width: 60px;
    height: 60px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--background);
    border-radius: var(--radius);
}

.choice-content {
    flex: 1;
}

.choice-content h3 {
    font-size: 1.15rem;
    font-weight: 600;
    margin-bottom: 4px;
}

.choice-content p {
    font-size: 0.9rem;
    color: var(--text-secondary);
    margin-bottom: 8px;
}

.choice-note {
    display: inline-block;
    font-size: 0.75rem;
    color: var(--primary-color);
    background: rgba(58, 175, 169, 0.1);
    padding: 4px 10px;
    border-radius: 12px;
    font-weight: 500;
}

/* Search */
.search-container {
    margin-bottom: 24px;
}

.search-input-wrapper {
    position: relative;
}

#search-input {
    width: 100%;
    padding: 16px 48px;
    font-size: 1rem;
    border: 2px solid var(--border-color);
    border-radius: var(--radius-lg);
    background: var(--card-bg);
    transition: border-color 0.2s ease;
}

#search-input:focus {
    outline: none;
    border-color: var(--primary-color);
    box-shadow: 0 0 0 3px rgba(0, 112, 210, 0.15);
}

.search-icon {
    position: absolute;
    left: 16px;
    top: 50%;
    transform: translateY(-50%);
    font-size: 1.25rem;
    pointer-events: none;
}

.loading-spinner {
    position: absolute;
    right: 16px;
    top: 50%;
    transform: translateY(-50%);
    width: 24px;
    height: 24px;
    border: 3px solid var(--border-color);
    border-top-color: var(--primary-color);
    border-radius: 50%;
    display: none;
}

.loading-spinner.active {
    display: block;
    animation: spin 0.8s linear infinite;
}

@keyframes spin {
    to { transform: translateY(-50%) rotate(360deg); }
}

/* Search Results */
.search-results {
    margin-top: 8px;
    background: var(--card-bg);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    overflow: hidden;
    max-height: 300px;
    overflow-y: auto;
}

.search-result-item {
    display: flex;
    align-items: center;
    padding: 14px 16px;
    border-bottom: 1px solid var(--border-color);
    cursor: pointer;
    transition: background 0.15s ease;
}

.search-result-item:last-child {
    border-bottom: none;
}

.search-result-item:hover {
    background: var(--background);
}

.result-avatar {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background: var(--primary-color);
    color: white;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 600;
    margin-right: 12px;
    flex-shrink: 0;
}

.result-info {
    flex: 1;
    min-width: 0;
}

.result-name {
    font-weight: 500;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.result-details {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    align-items: center;
}

.result-email {
    font-size: 0.875rem;
    color: var(--text-secondary);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.result-birthdate {
    font-size: 0.8rem;
    color: var(--text-secondary);
    background: var(--background);
    padding: 2px 8px;
    border-radius: 4px;
    white-space: nowrap;
}

.no-results {
    padding: 24px;
    text-align: center;
    color: var(--text-secondary);
}

/* Skip Search */
.skip-search {
    text-align: center;
    padding-top: 16px;
    border-top: 1px solid var(--border-color);
}

/* Buttons */
.primary-btn {
    width: 100%;
    padding: 16px 24px;
    font-size: 1.1rem;
    font-weight: 600;
    color: white;
    background: var(--primary-color);
    border: none;
    border-radius: var(--radius-lg);
    cursor: pointer;
    transition: background 0.2s ease;
}

.primary-btn:hover {
    background: var(--primary-hover);
}

.primary-btn:active {
    transform: scale(0.98);
}

.secondary-btn {
    padding: 12px 24px;
    font-size: 1rem;
    color: var(--text-secondary);
    background: transparent;
    border: 1px solid var(--border-color);
    border-radius: var(--radius);
    cursor: pointer;
    transition: all 0.2s ease;
}

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

/* Confirm Details */
.confirm-details {
    margin-bottom: 24px;
}

.confirm-card {
    background: var(--card-bg);
    border-radius: var(--radius-lg);
    padding: 20px;
    box-shadow: var(--shadow);
}

.confirm-row {
    display: flex;
    justify-content: space-between;
    padding: 12px 0;
    border-bottom: 1px solid var(--border-color);
}

.confirm-row:last-child {
    border-bottom: none;
}

.confirm-row .label {
    color: var(--text-secondary);
    font-weight: 500;
}

.confirm-row .value {
    font-weight: 600;
    text-align: right;
}

/* Install Banner (Top) */
.install-banner {
    background: linear-gradient(135deg, var(--primary-color) 0%, #005bb5 100%);
    color: white;
    padding: 16px;
    margin: -0px -16px 16px -16px;
    border-radius: 0 0 var(--radius-lg) var(--radius-lg);
    animation: slideDown 0.4s ease;
}

@keyframes slideDown {
    from {
        opacity: 0;
        transform: translateY(-100%);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.install-banner.hidden {
    display: none;
}

.install-banner-content {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 12px;
}

.install-banner-icon {
    flex-shrink: 0;
}

.install-banner-icon img {
    border-radius: 10px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.2);
}

.install-banner-text strong {
    display: block;
    font-size: 1.1rem;
    margin-bottom: 2px;
}

.install-banner-text p {
    font-size: 0.875rem;
    opacity: 0.9;
    margin: 0;
}

.install-banner-actions {
    display: flex;
    gap: 10px;
}

.install-banner-install {
    flex: 1;
    padding: 12px 20px;
    font-size: 1rem;
    font-weight: 600;
    color: var(--primary-color);
    background: white;
    border: none;
    border-radius: var(--radius);
    cursor: pointer;
    transition: transform 0.2s ease;
}

.install-banner-install:hover {
    transform: scale(1.02);
}

.install-banner-install:active {
    transform: scale(0.98);
}

.install-banner-dismiss {
    padding: 12px 16px;
    font-size: 0.9rem;
    color: rgba(255, 255, 255, 0.9);
    background: rgba(255, 255, 255, 0.15);
    border: none;
    border-radius: var(--radius);
    cursor: pointer;
}

.install-banner-dismiss:hover {
    background: rgba(255, 255, 255, 0.25);
}

/* Install Prompt (Bottom - fallback) */
.install-prompt {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    padding: 16px;
    background: var(--card-bg);
    box-shadow: 0 -4px 12px rgba(0, 0, 0, 0.15);
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 16px;
    z-index: 100;
}

.install-prompt.hidden {
    display: none;
}

.install-prompt p {
    flex: 1;
    font-weight: 500;
}

.install-buttons {
    display: flex;
    gap: 8px;
}

.install-btn {
    padding: 10px 20px;
    font-weight: 600;
    color: white;
    background: var(--success-color);
    border: none;
    border-radius: var(--radius);
    cursor: pointer;
}

.dismiss-btn {
    padding: 10px 16px;
    color: var(--text-secondary);
    background: none;
    border: none;
    cursor: pointer;
}

/* Responsive */
@media (max-width: 480px) {
    .app-header h1 {
        font-size: 1.25rem;
    }

    .form-card {
        padding: 16px;
    }

    .card-icon {
        width: 40px;
        height: 40px;
        font-size: 1.5rem;
    }

    .install-prompt {
        flex-direction: column;
        text-align: center;
    }
}

/* Dark mode support */
@media (prefers-color-scheme: dark) {
    :root {
        --background: #1a1a1a;
        --card-bg: #2d2d2d;
        --text-primary: #f5f5f5;
        --text-secondary: #a0a0a0;
        --border-color: #404040;
    }

    #search-input {
        color: var(--text-primary);
    }
}
