:root {
    --primary-color: #5a67d8;
    --primary-color-hover: #4c5ad9;
    --background-color: #f7fafc;
    --card-bg-color: #ffffff;
    --text-color: #4a5568;
    --heading-color: #2d3748;
    --border-color: #e2e8f0;
    --success-color: #38a169;
    --danger-color: #e53e3e;
    --font-family: 'Poppins', sans-serif;
}

*, *::before, *::after {
    box-sizing: border-box;
}

body {
    font-family: var(--font-family);
    background-color: var(--background-color);
    color: var(--text-color);
    margin: 0;
    padding: 2rem 1rem;
    display: flex;
    justify-content: center;
    align-items: flex-start;
    min-height: 100vh;
}

.container {
    width: 100%;
    max-width: 900px;
    text-align: center;
}

header {
    margin-bottom: 2.5rem;
}

h1 {
    font-size: 2.5rem;
    color: var(--heading-color);
    font-weight: 600;
    margin-bottom: 0.5rem;
}

.subtitle {
    font-size: 1.1rem;
    color: var(--secondary-color);
    margin: 0;
}

.main-content {
    background: var(--card-bg-color);
    border-radius: 12px;
    box-shadow: 0 10px 25px rgba(0,0,0,0.08);
    overflow: hidden;
}

.tabs {
    display: flex;
    background-color: #edf2f7;
}

.tab-button {
    flex: 1;
    padding: 1rem;
    font-size: 1rem;
    font-weight: 500;
    font-family: var(--font-family);
    color: var(--secondary-color);
    background: transparent;
    border: none;
    border-bottom: 3px solid transparent;
    cursor: pointer;
    transition: all 0.3s ease;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
}

.tab-button.active, .tab-button:hover {
    color: var(--primary-color);
    background-color: var(--card-bg-color);
}

.tab-button.active {
    border-bottom-color: var(--primary-color);
}

.tab-panel {
    display: none;
    padding: 2rem;
    animation: fadeIn 0.5s ease;
}

.tab-panel.active {
    display: block;
}

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

.upload-area {
    margin-bottom: 1.5rem;
}

.upload-label {
    display: block;
    border: 2px dashed var(--border-color);
    border-radius: 8px;
    padding: 2rem;
    text-align: center;
    cursor: pointer;
    transition: border-color 0.3s, background-color 0.3s;
}

.upload-label:hover {
    border-color: var(--primary-color);
    background-color: #f8f9fa;
}

.upload-label i {
    font-size: 3rem;
    color: var(--primary-color);
    margin-bottom: 0.5rem;
}

.upload-label p {
    font-weight: 500;
    margin: 0 0 0.5rem 0;
    color: var(--heading-color);
}

#file-name {
    font-size: 0.9rem;
    color: var(--secondary-color);
}

button.submit-btn {
    width: 100%;
    background-color: var(--primary-color);
    color: white;
    border: none;
    padding: 0.8rem;
    margin-top: 1rem;
    border-radius: 8px;
    font-size: 1rem;
    font-weight: 500;
    cursor: pointer;
    transition: background-color 0.3s, box-shadow 0.3s;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
}

button.submit-btn:hover {
    background-color: var(--primary-color-hover);
    box-shadow: 0 4px 15px rgba(90, 103, 216, 0.3);
}

.upload-form {
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.form-buttons {
    display: flex;
    gap: 1rem;
    justify-content: center;
}

.form-buttons button {
    flex: 1;
    max-width: 200px;
}

.result-container {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 2rem;
    align-items: flex-start;
}

#image-display-area canvas {
    width: 100%;
    height: auto;
    border-radius: 8px;
    border: 1px solid var(--border-color);
}

.webcam-controls {
    display: flex;
    justify-content: center;
    gap: 1rem;
    margin-bottom: 1.5rem;
}

.webcam-controls button {
    background-color: var(--primary-color);
    color: white;
    border: none;
    padding: 0.75rem 1.5rem;
    border-radius: 8px;
    font-size: 1rem;
    cursor: pointer;
    transition: background-color 0.3s;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
}

.webcam-controls button:disabled {
    background-color: #a0aec0;
    cursor: not-allowed;
}

.clear-btn {
    background-color: var(--danger-color) !important;
    color: white;
    border: none;
    padding: 0.75rem 1.5rem;
    border-radius: 8px;
    font-size: 1rem;
    cursor: pointer;
    transition: background-color 0.3s;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
}

.clear-btn:hover {
    background-color: #c53030 !important;
}

.clear-btn:disabled {
    background-color: #a0aec0 !important;
    cursor: not-allowed;
}

#webcam-container {
    position: relative;
    width: 100%;
    max-width: 500px;
    margin: 0 auto;
    border-radius: 8px;
    overflow: hidden;
    border: 1px solid var(--border-color);
}

#webcam-video {
    width: 100%;
    height: auto;
    display: block;
}

#webcam-canvas {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
}

.result-area {
    text-align: left;
    height: 100%;
}

.result-card {
    background-color: #f7fafc;
    border: 1px solid var(--border-color);
    border-radius: 8px;
    padding: 1rem;
    transition: box-shadow 0.3s;
}

.result-card:hover {
    box-shadow: 0 4px 10px rgba(0,0,0,0.05);
}

.result-card h4 {
    margin: 0 0 1rem 0;
    color: var(--heading-color);
    border-bottom: 1px solid var(--border-color);
    padding-bottom: 0.75rem;
}

.result-card ul {
    list-style-type: none;
    padding: 0;
    margin: 0;
    font-size: 0.9rem;
}

.result-card li {
    display: flex;
    justify-content: space-between;
    padding: 0.3rem 0;
}

.spinner {
    border: 5px solid #e2e8f0;
    border-top: 5px solid var(--primary-color);
    border-radius: 50%;
    width: 50px;
    height: 50px;
    animation: spin 1s linear infinite;
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    z-index: 1000;
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

@media (max-width: 768px) {
    .result-container {
        grid-template-columns: 1fr;
    }
    #webcam {
        padding: 1rem;
    }
}

.results-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
    gap: 1rem;
    margin-top: 1rem;
}

.recognized-persons-list {
    margin-top: 2rem;
    padding-top: 1.5rem;
    border-top: 2px solid var(--border-color);
}

.recognized-persons-list h3 {
    color: var(--heading-color);
    margin-bottom: 1rem;
    text-align: center;
}

.person-entry {
    background-color: #f7fafc;
    border: 1px solid var(--border-color);
    border-radius: 8px;
    padding: 1rem;
    margin-bottom: 0.5rem;
    transition: box-shadow 0.3s;
    position: relative;
}

.person-entry:hover {
    box-shadow: 0 4px 10px rgba(0,0,0,0.05);
}

.person-entry .timestamp {
    position: absolute;
    top: 0.5rem;
    right: 0.5rem;
    font-size: 0.8rem;
    color: #718096;
    background-color: white;
    padding: 0.2rem 0.5rem;
    border-radius: 4px;
    border: 1px solid var(--border-color);
}