/* Reset e Variáveis */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

:root {
    --primary-color: #2563eb;
    --primary-hover: #1d4ed8;
    --success-color: #10b981;
    --error-color: #ef4444;
    --warning-color: #f59e0b;
    --text-primary: #1f2937;
    --text-secondary: #6b7280;
    --border-color: #d1d5db;
    --bg-light: #f9fafb;
    --bg-white: #ffffff;
    --shadow-sm: 0 1px 2px 0 rgba(0, 0, 0, 0.05);
    --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.1);
    --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.1);
    --radius: 8px;
    --transition: all 0.3s ease;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
    background: #f4f5f7;
    min-height: 100vh;
    padding: 2rem 1.5rem;
    color: var(--text-primary);
    line-height: 1.6;
}

.container {
    max-width: 1100px;
    margin: 0 auto;
    background: var(--bg-white);
    border-radius: 16px;
    box-shadow: 0 15px 35px rgba(0, 0, 0, 0.05);
    overflow: hidden;
}

/* Header */
header {
    background: linear-gradient(120deg, #1f3b7f, #273960);
    color: white;
    padding: 2.5rem 2rem;
    text-align: left;
}

.header-content {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: 2rem;
}

header h1 {
    font-size: 2.1rem;
    font-weight: 700;
    margin-bottom: 0.5rem;
}

.subtitle {
    font-size: 1rem;
    opacity: 0.9;
    font-weight: 400;
}

.header-actions {
    display: flex;
    align-items: center;
    gap: 1rem;
}

.user-info {
    display: flex;
    align-items: center;
    gap: 1rem;
    background: rgba(255, 255, 255, 0.1);
    padding: 0.75rem 1rem;
    border-radius: var(--radius);
    backdrop-filter: blur(10px);
}

.user-name {
    font-weight: 500;
    font-size: 0.95rem;
}

.btn-logout {
    background: rgba(239, 68, 68, 0.9);
    color: white;
    border: none;
    padding: 0.5rem 1rem;
    border-radius: var(--radius);
    cursor: pointer;
    font-weight: 500;
    font-size: 0.875rem;
    transition: var(--transition);
    display: flex;
    align-items: center;
    gap: 0.4rem;
}

.btn-logout:hover {
    background: rgba(220, 38, 38, 1);
    transform: translateY(-1px);
}

.btn-logout svg {
    width: 16px;
    height: 16px;
}

/* Main Content */
main {
    padding: 2.25rem 2rem 2.5rem;
}

.form-section {
    margin-bottom: 1.75rem;
}

.form-section h2 {
    font-size: 1.25rem;
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: 1.5rem;
    padding-bottom: 0.5rem;
    border-bottom: 2px solid var(--bg-light);
}

/* Form Groups */
.form-group {
    margin-bottom: 1.5rem;
}

label {
    display: block;
    font-weight: 500;
    color: var(--text-primary);
    margin-bottom: 0.5rem;
    font-size: 0.875rem;
}

label.required::after {
    content: " *";
    color: var(--primary-color);
}

input[type="file"],
select,
input[type="month"],
input[type="text"],
input[type="email"],
input[type="password"] {
    width: 100%;
    padding: 0.75rem;
    border: 1px solid var(--border-color);
    border-radius: var(--radius);
    font-size: 1rem;
    transition: var(--transition);
    background-color: var(--bg-white);
    color: var(--text-primary);
}

input[type="file"]:focus,
select:focus,
input[type="month"]:focus,
input[type="text"]:focus,
input[type="email"]:focus,
input[type="password"]:focus {
    outline: none;
    border-color: var(--primary-color);
    box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.08);
}

.help-text {
    display: block;
    margin-top: 0.25rem;
    font-size: 0.75rem;
    color: var(--text-secondary);
}

.error-message {
    display: block;
    margin-top: 0.25rem;
    font-size: 0.75rem;
    color: var(--error-color);
    min-height: 1.25rem;
}

/* Message Container */
.message-container {
    margin-bottom: 1.5rem;
    animation: slideDown 0.3s ease;
}

@keyframes slideDown {
    from {
        opacity: 0;
        transform: translateY(-10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.message {
    padding: 1rem;
    border-radius: 12px;
    font-weight: 500;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.5rem;
    position: relative;
}

#messageText {
    flex: 1;
}

.message.success {
    background-color: #d1fae5;
    color: #065f46;
    border: 1px solid var(--success-color);
}

.message.error {
    background-color: #fee2e2;
    color: #991b1b;
    border: 1px solid var(--error-color);
}

.message.warning {
    background-color: #fef3c7;
    color: #92400e;
    border: 1px solid var(--warning-color);
}

/* Botão de Fechar Mensagem */
.close-button {
    background: none;
    border: none;
    font-size: 1.5rem;
    font-weight: bold;
    cursor: pointer;
    padding: 0;
    width: 24px;
    height: 24px;
    display: flex;
    align-items: center;
    justify-content: center;
    line-height: 1;
    opacity: 0.7;
    transition: var(--transition);
    flex-shrink: 0;
}

.close-button:hover {
    opacity: 1;
    transform: scale(1.1);
}

.close-button:focus {
    outline: 2px solid currentColor;
    outline-offset: 2px;
    border-radius: 4px;
}

/* Form Actions */
.form-actions {
    margin-top: 2rem;
    display: flex;
    justify-content: center;
}

.btn-submit {
    background-color: #273960;
    color: white;
    border: none;
    padding: 0.9rem 2.4rem;
    font-size: 1rem;
    font-weight: 600;
    border-radius: var(--radius);
    cursor: pointer;
    transition: var(--transition);
    display: flex;
    align-items: center;
    gap: 0.5rem;
    min-width: 200px;
    justify-content: center;
}

.sidebar .btn-submit,
.sidebar .btn-secondary {
    width: 100%;
    min-width: unset;
    justify-content: flex-start;
    text-align: left;
    padding-left: 1rem;
    padding-right: 1rem;
}

.layout-shell main .btn-submit,
.layout-shell main .btn-secondary {
    justify-content: flex-start;
    text-align: left;
    min-width: unset;
    padding-left: 1rem;
    padding-right: 1rem;
}

.btn-submit:hover:not(:disabled) {
    background-color: var(--primary-hover);
    transform: translateY(-2px);
    box-shadow: var(--shadow-md);
}

.btn-submit:active:not(:disabled) {
    transform: translateY(0);
}

.btn-submit:disabled {
    background-color: var(--text-secondary);
    cursor: not-allowed;
    opacity: 0.7;
}

.btn-secondary {
    background-color: #e5e7eb;
    color: var(--text-primary);
    border: 1px solid #d6d9df;
    padding: 0.6rem 1rem;
    border-radius: var(--radius);
    cursor: pointer;
    font-weight: 600;
    transition: var(--transition);
}

.btn-secondary:hover:not(:disabled) {
    background-color: #d1d5db;
}

.btn-secondary:disabled {
    opacity: 0.6;
    cursor: not-allowed;
}

/* Loading Spinner */
.spinner {
    width: 16px;
    height: 16px;
    border: 2px solid rgba(255, 255, 255, 0.3);
    border-top-color: white;
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}

@keyframes spin {
    to {
        transform: rotate(360deg);
    }
}

/* Responsive */
@media (max-width: 640px) {
    body {
        padding: 1rem 0.75rem;
    }

    header {
        padding: 1.5rem 1rem;
    }

    header h1 {
        font-size: 1.5rem;
    }

    main {
        padding: 1.5rem 1rem;
    }

    .btn-submit {
        width: 100%;
    }
}

/* File Input Customization */
input[type="file"] {
    cursor: pointer;
}

input[type="file"]::file-selector-button {
    background-color: var(--bg-light);
    border: 1px solid var(--border-color);
    border-radius: var(--radius);
    padding: 0.5rem 1rem;
    margin-right: 1rem;
    cursor: pointer;
    font-weight: 500;
    transition: var(--transition);
}

input[type="file"]::file-selector-button:hover {
    background-color: var(--border-color);
}

/* Secções de status e listagem */
.section-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    margin-bottom: 1rem;
}

.list-section {
    margin-top: 1.5rem;
}

.status-card {
    border: 1px solid var(--border-color);
    border-radius: var(--radius);
    padding: 1rem;
    background: var(--bg-white);
    box-shadow: var(--shadow-sm);
}

.status-card.empty {
    color: var(--text-secondary);
    font-style: italic;
}

.status-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    margin-bottom: 1rem;
}

.status-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
    gap: 1rem;
    margin-bottom: 1rem;
}

.status-downloads .downloads {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
}

.label {
    font-size: 0.75rem;
    color: var(--text-secondary);
    margin-bottom: 0.25rem;
}

.value {
    font-weight: 600;
}

.code {
    font-family: ui-monospace, SFMono-Regular, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", "Courier New", monospace;
    font-size: 0.9rem;
    word-break: break-all;
}

.status-badge {
    display: flex;
    align-items: center;
}

.badge {
    display: inline-flex;
    align-items: center;
    padding: 0.2rem 0.55rem;
    border-radius: 999px;
    font-weight: 700;
    font-size: 0.85rem;
    letter-spacing: 0.01em;
}

.badge-success {
    background: #dcfce7;
    color: #166534;
    border: 1px solid #4ade80;
}

.badge-warning {
    background: #fef3c7;
    color: #92400e;
    border: 1px solid #fbbf24;
}

.badge-info {
    background: #e0f2fe;
    color: #075985;
    border: 1px solid #38bdf8;
}

.badge-danger {
    background: #fee2e2;
    color: #991b1b;
    border: 1px solid #f87171;
}

.badge-default {
    background: #e5e7eb;
    color: #111827;
    border: 1px solid #d1d5db;
}

.table-wrapper {
    overflow-x: auto;
}

.processamentos-table {
    width: 100%;
    border-collapse: collapse;
    margin-top: 0.5rem;
}

.processamentos-table th,
.processamentos-table td {
    padding: 0.75rem;
    text-align: left;
    border-bottom: 1px solid var(--border-color);
}

.processamentos-table th {
    background: var(--bg-light);
    font-weight: 700;
    font-size: 0.9rem;
}

.processamentos-table td {
    font-size: 0.95rem;
}

.processamentos-table .empty-row {
    text-align: center;
    color: var(--text-secondary);
    font-style: italic;
}

.btn-link {
    color: var(--primary-color);
    font-weight: 600;
    text-decoration: none;
    background: none;
    border: none;
    padding: 0;
    cursor: pointer;
    font-family: inherit;
    font-size: inherit;
}

.btn-link:hover {
    text-decoration: underline;
}

.muted {
    color: var(--text-secondary);
}

.inline-spinner {
    margin: 0.5rem 0;
    color: var(--text-secondary);
    font-size: 0.95rem;
}

@media (max-width: 640px) {
    .section-header {
        flex-direction: column;
        align-items: flex-start;
    }

    .status-row {
        flex-direction: column;
        align-items: flex-start;
    }
}

/* Grades e tabs */
.form-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
    gap: 1.25rem;
}

.form-grid-3 {
    grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
}

.filters-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 1rem;
    margin-bottom: 1rem;
}

.pagination {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    margin-top: 1rem;
    justify-content: flex-end;
}

.tabs {
    display: inline-flex;
    gap: 0.5rem;
    background: #eef1f7;
    padding: 0.35rem;
    border-radius: 12px;
    margin-bottom: 1.5rem;
}

.tab-button {
    border: none;
    background: transparent;
    padding: 0.7rem 1.2rem;
    border-radius: 10px;
    font-weight: 600;
    color: var(--text-secondary);
    cursor: pointer;
    transition: var(--transition);
}

.tab-button.active {
    background: white;
    color: var(--text-primary);
    box-shadow: var(--shadow-sm);
}

.tab-panel {
    display: none;
}

.tab-panel.active {
    display: block;
}

/* ============================================
   PÁGINA DE LOGIN
   ============================================ */

.login-page {
    background: none;
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 100vh;
    padding: 2rem 1rem;
}

.login-container {
    width: 100%;
    max-width: 440px;
}

.login-card {
    background: var(--bg-white);
    border-radius: 16px;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.15);
    overflow: hidden;
}

.login-header {
    background: linear-gradient(120deg, #1f3b7f, #273960);
    color: white;
    padding: 2.5rem 2rem;
    text-align: center;
}

.login-logo {
    width: 150px;
    height: auto;
    margin: 0 auto 1.25rem;
    display: block;
}

.login-header h1 {
    font-size: 1.75rem;
    font-weight: 700;
    margin-bottom: 0.5rem;
}

.login-subtitle {
    font-size: 0.95rem;
    opacity: 0.9;
    font-weight: 400;
}

.login-main {
    padding: 2.5rem 2rem;
}

.login-main .form-group {
    margin-bottom: 1.5rem;
}

.login-main input[type="email"],
.login-main input[type="password"] {
    width: 100%;
    padding: 0.85rem 1rem;
    border: 1px solid var(--border-color);
    border-radius: var(--radius);
    font-size: 1rem;
    transition: var(--transition);
}

.login-main input[type="email"]:focus,
.login-main input[type="password"]:focus {
    outline: none;
    border-color: var(--primary-color);
    box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.1);
}

.login-main .btn-submit {
    width: 100%;
    padding: 1rem;
    font-size: 1rem;
    margin-top: 1rem;
}

.btn-full-width {
    width: 100%;
}

.login-footer {
    background: var(--bg-light);
    padding: 1.25rem 2rem;
    text-align: center;
    border-top: 1px solid var(--border-color);
}

.login-footer p {
    font-size: 0.875rem;
    color: var(--text-secondary);
    margin: 0;
}

/* Responsivo para header com usuário */
@media (max-width: 768px) {
    .header-content {
        flex-direction: column;
        text-align: center;
        align-items: center;
        gap: 1.5rem;
    }

    .header-actions {
        width: 100%;
        justify-content: center;
    }

    .user-info {
        flex-direction: column;
        gap: 0.75rem;
        width: 100%;
    }

    .btn-logout {
        width: 100%;
        justify-content: center;
    }
}

@media (max-width: 640px) {
    .login-page {
        padding: 1rem 0.75rem;
    }

    .login-header {
        padding: 2rem 1.5rem;
    }

    .login-header h1 {
        font-size: 1.5rem;
    }

    .login-main {
        padding: 2rem 1.5rem;
    }
}

