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

:root {
    --primary-color: #2196F3;
    --primary-dark: #1565C0;
    --secondary-color: #4CAF50;
    --error-color: #f44336;
    --success-color: #4CAF50;
    --warning-color: #FF9800;
    --bg-color: #f5f5f5;
    --card-bg: #ffffff;
    --text-color: #333333;
    --text-light: #666666;
    --border-color: #e0e0e0;
    --shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
    --radius: 8px;
}

body {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    background: #ffffff;
    color: var(--text-color);
    line-height: 1.6;
    min-height: 100vh;
}

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

header {
    text-align: center;
    padding: 30px 0;
    background: linear-gradient(135deg, var(--primary-color), var(--primary-dark));
    color: white;
    border-radius: var(--radius);
    margin-bottom: 30px;
    box-shadow: var(--shadow);
}

header h1 {
    font-size: 2.5rem;
    margin-bottom: 10px;
}

.header-top {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.header-brand {
    display: flex;
    align-items: center;
    gap: 20px;
}

.header-brand .school-name {
    font-size: 2rem;
    font-weight: 700;
    margin-bottom: 5px;
}

.header-brand h2 {
    font-size: 1.3rem;
    margin-bottom: 5px;
    font-weight: 500;
}

.header-brand p {
    opacity: 0.9;
    font-size: 0.95rem;
}

.user-info {
    display: flex;
    align-items: center;
    gap: 12px;
    background: rgba(255, 255, 255, 0.2);
    padding: 8px 16px;
    border-radius: var(--radius);
}

#userDisplay {
    font-weight: 500;
}

.subtitle {
    font-size: 1.1rem;
    opacity: 0.9;
}

.tabs {
    display: flex;
    gap: 10px;
    margin-bottom: 30px;
    background: var(--card-bg);
    padding: 10px;
    border-radius: var(--radius);
    box-shadow: var(--shadow);
}

.tab-btn {
    flex: 1;
    padding: 15px 30px;
    border: none;
    background: transparent;
    color: var(--text-light);
    font-size: 1.1rem;
    font-weight: 600;
    cursor: pointer;
    border-radius: var(--radius);
    transition: all 0.3s ease;
}

.tab-btn:hover {
    background: var(--bg-color);
}

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

.tab-content {
    display: none;
}

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

.panel {
    background: var(--card-bg);
    border-radius: var(--radius);
    padding: 25px;
    margin-bottom: 20px;
    box-shadow: var(--shadow);
}

.panel h2 {
    color: var(--primary-dark);
    margin-bottom: 20px;
    padding-bottom: 10px;
    border-bottom: 2px solid var(--border-color);
    font-size: 1.3rem;
}

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

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

.form-group input,
.form-group select {
    width: 100%;
    padding: 12px 15px;
    border: 2px solid var(--border-color);
    border-radius: var(--radius);
    font-size: 1rem;
    transition: border-color 0.3s ease;
}

.form-group input:focus,
.form-group select:focus {
    outline: none;
    border-color: var(--primary-color);
}

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

.input-group input {
    flex: 1;
}

.btn {
    padding: 12px 25px;
    border: none;
    border-radius: var(--radius);
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
}

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

.btn-primary:hover {
    background: var(--primary-dark);
    transform: translateY(-2px);
    box-shadow: 0 4px 10px rgba(33, 150, 243, 0.3);
}

.btn-primary:disabled {
    background: #ccc;
    cursor: not-allowed;
    transform: none;
    box-shadow: none;
}

.btn-secondary {
    background: var(--secondary-color);
    color: white;
}

.btn-secondary:hover {
    background: #1976D2;
}

.btn-small {
    padding: 8px 15px;
    font-size: 0.9rem;
}

.btn-danger {
    background: var(--error-color);
    color: white;
}

.btn-danger:hover {
    background: #D32F2F;
}

.lista-vazia {
    text-align: center;
    color: var(--text-light);
    padding: 30px;
    font-style: italic;
}

.turma-item {
    background: var(--bg-color);
    padding: 15px;
    border-radius: var(--radius);
    margin-bottom: 10px;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.turma-info h3 {
    color: var(--primary-dark);
    margin-bottom: 5px;
}

.turma-info p {
    color: var(--text-light);
    font-size: 0.9rem;
}

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

.aluno-item {
    background: var(--bg-color);
    padding: 12px 15px;
    border-radius: var(--radius);
    margin-bottom: 8px;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.aluno-numero {
    background: var(--primary-color);
    color: white;
    width: 30px;
    height: 30px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: bold;
    margin-right: 15px;
}

.aluno-nome {
    flex: 1;
}

.qr-container {
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 20px;
}

#qrcode {
    margin: 20px 0;
    padding: 20px;
    background: white;
    border-radius: var(--radius);
    border: 3px solid var(--primary-color);
}

.qr-info {
    background: var(--bg-color);
    padding: 15px;
    border-radius: var(--radius);
    margin-bottom: 20px;
    width: 100%;
}

.qr-info p {
    margin-bottom: 8px;
}

.timer {
    color: var(--warning-color);
    font-size: 1.2rem;
    font-weight: bold;
}

#scannerContainer {
    position: relative;
    width: 100%;
    max-width: 400px;
    margin: 0 auto;
    border-radius: var(--radius);
    overflow: hidden;
    background: #000;
    aspect-ratio: 1;
}

#video {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.scanner-overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    pointer-events: none;
}

.scanner-frame {
    width: 200px;
    height: 200px;
    border: 3px solid var(--primary-color);
    border-radius: 10px;
    box-shadow: 0 0 0 9999px rgba(0, 0, 0, 0.5);
}

.scanner-controls {
    display: flex;
    justify-content: center;
    gap: 10px;
    margin-top: 20px;
}

.chamada-info {
    background: linear-gradient(135deg, var(--primary-color), var(--primary-dark));
    color: white;
    padding: 20px;
    border-radius: var(--radius);
    margin-bottom: 20px;
}

.chamada-info .timer {
    color: #FFD700;
    font-size: 1.3rem;
}

.success-message,
.error-message {
    text-align: center;
    padding: 30px;
}

.success-message {
    background: linear-gradient(135deg, #E8F5E9, #C8E6C9);
    border-radius: var(--radius);
}

.success-message h2 {
    color: var(--success-color);
    font-size: 2rem;
    margin-bottom: 15px;
}

.error-message {
    background: linear-gradient(135deg, #FFEBEE, #FFCDD2);
    border-radius: var(--radius);
}

.error-message h2 {
    color: var(--error-color);
    font-size: 2rem;
    margin-bottom: 15px;
}

.info-text {
    text-align: center;
    color: var(--text-light);
    font-size: 0.9rem;
    margin-top: 10px;
}

.lista-presencas {
    max-height: 300px;
    overflow-y: auto;
}

.presenca-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 12px 15px;
    background: var(--bg-color);
    border-radius: var(--radius);
    margin-bottom: 8px;
}

.presenca-item .checkmark {
    color: var(--success-color);
    font-size: 1.2rem;
}

.modal {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.7);
    z-index: 1000;
    align-items: center;
    justify-content: center;
}

.modal.show {
    display: flex;
}

.modal-content {
    background: var(--card-bg);
    padding: 30px;
    border-radius: var(--radius);
    max-width: 500px;
    width: 90%;
    max-height: 80vh;
    overflow-y: auto;
    position: relative;
}

.modal-close {
    position: absolute;
    top: 15px;
    right: 20px;
    font-size: 2rem;
    cursor: pointer;
    color: var(--text-light);
}

.modal-close:hover {
    color: var(--text-color);
}

.chamada-card {
    background: var(--bg-color);
    padding: 15px;
    border-radius: var(--radius);
    margin-bottom: 10px;
    border-left: 4px solid var(--primary-color);
}

.chamada-card h4 {
    color: var(--primary-dark);
    margin-bottom: 8px;
}

.chamada-card p {
    font-size: 0.9rem;
    color: var(--text-light);
    margin-bottom: 5px;
}

.status-badge {
    display: inline-block;
    padding: 4px 12px;
    border-radius: 20px;
    font-size: 0.8rem;
    font-weight: 600;
}

.status-ativa {
    background: var(--success-color);
    color: white;
}

.status-expirada {
    background: var(--text-light);
    color: white;
}

@media (max-width: 768px) {
    .container {
        padding: 10px;
    }

    header h1 {
        font-size: 1.8rem;
    }

    .header-top {
        flex-direction: column;
        gap: 15px;
    }

    .header-brand {
        flex-direction: column;
        text-align: center;
    }

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

    .tabs {
        flex-direction: column;
    }

    .tab-btn {
        width: 100%;
    }

    .panel {
        padding: 15px;
    }

    .turma-item {
        flex-direction: column;
        align-items: flex-start;
        gap: 10px;
    }

    .turma-actions {
        width: 100%;
    }

    .turma-actions button {
        flex: 1;
    }

    .input-group {
        flex-direction: column;
    }

    #scannerContainer {
        max-width: 300px;
    }

    .scanner-frame {
        width: 150px;
        height: 150px;
    }
}

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

.fade-in {
    animation: fadeIn 0.3s ease;
}

@keyframes pulse {
    0%, 100% {
        transform: scale(1);
    }
    50% {
        transform: scale(1.05);
    }
}

.pulse {
    animation: pulse 1s infinite;
}

/* Login Page Styles */
.login-body {
    background: #ffffff;
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
}

.login-container {
    width: 100%;
    max-width: 420px;
    padding: 20px;
}

.login-card {
    background: white;
    border-radius: 16px;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
    overflow: hidden;
}

.login-header {
    background: linear-gradient(135deg, var(--primary-color), var(--primary-dark));
    color: white;
    padding: 40px 30px;
    text-align: center;
}

.school-name {
    font-size: 2rem;
    font-weight: 700;
    margin-bottom: 5px;
    letter-spacing: 1px;
}

.login-header h2 {
    font-size: 1.4rem;
    margin-bottom: 8px;
    font-weight: 500;
}

.login-header p {
    opacity: 0.9;
    font-size: 0.95rem;
}

.login-role-selector {
    padding: 30px;
}

.role-label {
    text-align: center;
    color: var(--text-light);
    margin-bottom: 20px;
    font-weight: 500;
}

.role-cards {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.role-card {
    display: flex;
    align-items: center;
    gap: 15px;
    padding: 18px 20px;
    border: 2px solid var(--border-color);
    border-radius: var(--radius);
    background: white;
    cursor: pointer;
    transition: all 0.3s ease;
    text-align: left;
}

.role-card:hover {
    border-color: var(--primary-color);
    background: #e3f2fd;
    transform: translateX(5px);
}

.role-card.selected {
    border-color: var(--primary-color);
    background: #bbdefb;
}

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

.role-name {
    font-weight: 600;
    color: var(--text-color);
    font-size: 1.05rem;
}

.role-desc {
    color: var(--text-light);
    font-size: 0.85rem;
}

.login-form {
    padding: 0 30px 30px;
}

.login-form .form-group {
    margin-bottom: 18px;
}

.login-form .form-group label {
    font-size: 0.9rem;
    margin-bottom: 6px;
}

.login-form .form-group input {
    padding: 14px 16px;
    font-size: 1rem;
}

.login-btn {
    width: 100%;
    padding: 14px;
    font-size: 1.1rem;
    margin-top: 10px;
}

.login-erro {
    background: #ffebee;
    color: var(--error-color);
    padding: 12px;
    border-radius: var(--radius);
    text-align: center;
    margin-top: 15px;
    font-size: 0.9rem;
}

.login-footer {
    padding: 20px 30px;
    text-align: center;
    border-top: 1px solid var(--border-color);
}

.login-footer a {
    color: var(--primary-color);
    text-decoration: none;
    font-weight: 600;
}

.login-footer a:hover {
    text-decoration: underline;
}

.btn-back {
    width: calc(100% - 60px);
    margin: 0 30px 30px;
    padding: 12px;
}

@media (max-width: 480px) {
    .login-header {
        padding: 30px 20px;
    }

    .login-header h1 {
        font-size: 1.3rem;
    }

    .login-role-selector,
    .login-form,
    .login-footer {
        padding-left: 20px;
        padding-right: 20px;
    }

    .btn-back {
        width: calc(100% - 40px);
        margin: 0 20px 20px;
    }
}
