* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    background: linear-gradient(135deg, #0f172a 0%, #1e293b 50%, #064e3b 100%);
    min-height: 100vh;
    color: white;
    overflow-x: hidden;
}

.app {
    display: flex;
    flex-direction: column;
    min-height: 100vh;
}

.container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 0 1rem;
}

/* Header */
.header {
    background: rgba(0, 0, 0, 0.2);
    backdrop-filter: blur(10px);
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
    padding: 1rem 0;
    position: sticky;
    top: 0;
    z-index: 100;
}

.header .container {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.title {
    font-size: 1.5rem;
    font-weight: bold;
}

.refresh-btn {
    background: rgba(255, 255, 255, 0.1);
    border: 1px solid rgba(255, 255, 255, 0.2);
    color: white;
    padding: 0.5rem 1rem;
    border-radius: 0.5rem;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 0.5rem;
    transition: all 0.2s;
}

.refresh-btn:hover {
    background: rgba(255, 255, 255, 0.2);
}

.refresh-btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.refresh-btn.loading #refreshIcon {
    animation: spin 1s linear infinite;
}

@keyframes spin {
    from { transform: rotate(0deg); }
    to { transform: rotate(360deg); }
}

/* Main Content */
.main-content {
    flex: 1;
    padding: 2rem 0;
    padding-bottom: 16rem;
    overflow-y: auto;
}

.candidates-list {
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

/* Candidate Card */
.candidate-card {
    background: rgba(255, 255, 255, 0.1);
    backdrop-filter: blur(10px);
    border: 1px solid rgba(255, 255, 255, 0.2);
    border-radius: 0.75rem;
    padding: 1.5rem;
    transition: all 0.2s;
    cursor: grab;
    user-select: none;
    position: relative;
    overflow: hidden;
}

.candidate-card:active {
    cursor: grabbing;
}

.candidate-card.swipe-left {
    background: rgba(239, 68, 68, 0.2);
}

.candidate-card.swipe-right {
    background: rgba(34, 197, 94, 0.2);
}

.card-content {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
    gap: 1rem;
    margin-bottom: 1rem;
}

.field {
    display: flex;
    flex-direction: column;
    min-width: 0; /* <<< CHANGE 1: Helps grid items handle overflow */
}

.field-label {
    font-size: 0.875rem;
    color: rgba(255, 255, 255, 0.7);
    margin-bottom: 0.25rem;
}

.field-value {
    font-size: 0.875rem;
    font-weight: 500;
    word-break: break-all; /* <<< CHANGE 2: Prevents long text from overflowing */
}

.field-value.mono {
    font-family: 'Courier New', monospace;
}

.field-value.score {
    font-size: 1.125rem;
    font-weight: bold;
    color: #10b981;
}

.badge {
    display: inline-flex;
    align-items: center;
    padding: 0.25rem 0.75rem;
    border-radius: 9999px;
    font-size: 0.75rem;
    font-weight: 600;
    text-transform: uppercase;
}

.badge.qualified {
    background: #059669;
    color: white;
}

.badge.not-qualified {
    background: #dc2626;
    color: white;
}

.card-actions {
    display: flex;
    gap: 0.5rem;
    justify-content: flex-end;
}

.action-btn {
    padding: 0.5rem;
    border: 1px solid;
    border-radius: 0.375rem;
    background: transparent;
    color: white;
    cursor: pointer;
    transition: all 0.2s;
    display: flex;
    align-items: center;
    gap: 0.25rem;
    font-size: 0.875rem;
}

.email-btn {
    border-color: rgba(34, 197, 94, 0.5);
    background: rgba(34, 197, 94, 0.2);
    color: #10b981;
}

.email-btn:hover {
    background: rgba(34, 197, 94, 0.3);
}

.email-btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.delete-btn {
    border-color: rgba(239, 68, 68, 0.5);
    background: rgba(239, 68, 68, 0.2);
    color: #ef4444;
}

.delete-btn:hover {
    background: rgba(239, 68, 68, 0.3);
}

.ai-summary {
    margin-top: 1rem;
}

.ai-summary-label {
    font-size: 0.875rem;
    color: rgba(255, 255, 255, 0.7);
    margin-bottom: 0.5rem;
}

.ai-summary-content {
    font-size: 0.875rem;
    line-height: 1.5;
    max-height: 5rem;
    overflow-y: auto;
    background: rgba(0, 0, 0, 0.2);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 0.375rem;
    padding: 0.75rem;
}

/* Instructions */
.instructions {
    margin-top: 2rem;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 1rem;
    background: rgba(255, 255, 255, 0.1);
    backdrop-filter: blur(10px);
    border: 1px solid rgba(255, 255, 255, 0.2);
    border-radius: 0.5rem;
    padding: 0.75rem 1.5rem;
    width: fit-content;
    margin-left: auto;
    margin-right: auto;
}

.instruction-item {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-size: 0.875rem;
    color: rgba(255, 255, 255, 0.7);
}

.indicator {
    width: 0.5rem;
    height: 0.5rem;
    border-radius: 50%;
}

.indicator.red {
    background: #ef4444;
}

.indicator.green {
    background: #10b981;
}

.divider {
    width: 1px;
    height: 1rem;
    background: rgba(255, 255, 255, 0.2);
}

/* Email Template */
.email-template {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    background: #334155;
    border-top: 1px solid rgba(255, 255, 255, 0.2);
    box-shadow: 0 -4px 6px -1px rgba(0, 0, 0, 0.1);
    padding: 1.5rem 0;
    z-index: 50;
}

.email-template h3 {
    font-size: 1.125rem;
    font-weight: 600;
    margin-bottom: 1rem;
}

.email-template textarea {
    width: 100%;
    min-height: 8rem;
    background: #475569;
    border: 1px solid #64748b;
    border-radius: 0.375rem;
    padding: 0.75rem;
    color: white;
    font-family: inherit;
    font-size: 0.875rem;
    resize: none;
    outline: none;
}

.email-template textarea::placeholder {
    color: rgba(255, 255, 255, 0.5);
}

.email-template textarea:focus {
    border-color: #3b82f6;
    box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.1);
}

.email-info {
    margin-top: 0.5rem;
    font-size: 0.875rem;
    color: rgba(255, 255, 255, 0.6);
}

/* Toast */
.toast-container {
    position: fixed;
    top: 1rem;
    right: 1rem;
    z-index: 1000;
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.toast {
    background: white;
    color: #1f2937;
    padding: 1rem 1.5rem;
    border-radius: 0.5rem;
    box-shadow: 0 10px 15px -3px rgba(0, 0, 0, 0.1);
    max-width: 400px;
    animation: slideIn 0.3s ease-out;
    position: relative;
    border-left: 4px solid #10b981;
}

.toast.error {
    border-left-color: #ef4444;
}

.toast-title {
    font-weight: 600;
    margin-bottom: 0.25rem;
}

.toast-description {
    font-size: 0.875rem;
    color: #6b7280;
}

@keyframes slideIn {
    from {
        transform: translateX(100%);
        opacity: 0;
    }
    to {
        transform: translateX(0);
        opacity: 1;
    }
}

/* Loading Overlay */
.loading-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.5);
    display: none;
    align-items: center;
    justify-content: center;
    z-index: 9999;
}

.loading-overlay.show {
    display: flex;
}

.spinner {
    width: 3rem;
    height: 3rem;
    border: 4px solid rgba(255, 255, 255, 0.3);
    border-top: 4px solid white;
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

/* Sending State */
.sending-spinner {
    width: 1rem;
    height: 1rem;
    border: 2px solid rgba(16, 185, 129, 0.3);
    border-top: 2px solid #10b981;
    border-radius: 50%;
    animation: spin 1s linear infinite;
    margin-right: 0.25rem;
}

/* Responsive */
@media (max-width: 768px) {
    .card-content {
        grid-template-columns: 1fr;
    }
    
    .instructions {
        flex-direction: column;
        gap: 0.5rem;
    }
    
    .divider {
        width: 2rem;
        height: 1px;
    }
    
    .email-template {
        padding: 1rem 0;
    }
    
    .main-content {
        padding-bottom: 12rem;
    }
}

/* Touch feedback */
@media (hover: none) and (pointer: coarse) {
    .candidate-card {
        touch-action: pan-x;
    }
}