/* 
  RPCOR - Portal Design System 
  Theme: Clean, Premium, Medical
*/

:root {
    /* Colors */
    --primary-blue: #004E89;
    --primary-dark: #003B66;
    --primary-light: #E0F2FE;
    --accent-red: #D93025;
    --accent-red-hover: #b92b21;

    --text-dark: #1F2937;
    --text-gray: #4B5563;
    --text-light: #9CA3AF;

    --bg-body: #F3F4F6;
    --bg-white: #FFFFFF;

    --border-color: #E5E7EB;
    --border-focus: #004E89;

    --shadow-sm: 0 1px 2px 0 rgba(0, 0, 0, 0.05);
    --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06);
    --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -2px rgba(0, 0, 0, 0.05);

    --radius-sm: 0.375rem;
    --radius-md: 0.5rem;
    --radius-lg: 0.75rem;

    --font-family: 'Inter', system-ui, -apple-system, sans-serif;
}

/* Base */
body {
    font-family: var(--font-family);
    color: var(--text-dark);
    background-color: var(--bg-body);
    margin: 0;
    padding: 0;
    line-height: 1.5;
    -webkit-font-smoothing: antialiased;
}

a {
    text-decoration: none;
    color: inherit;
    transition: all 0.2s ease;
}

h1,
h2,
h3,
h4,
h5,
h6 {
    margin: 0 0 1rem 0;
    font-weight: 600;
    color: var(--primary-blue);
    line-height: 1.25;
}

h1 {
    font-size: 1.875rem;
}

h2 {
    font-size: 1.5rem;
}

h3 {
    font-size: 1.25rem;
    color: var(--text-dark);
}

p {
    margin: 0 0 1rem 0;
    color: var(--text-gray);
}

/* Layout */
.container {
    max-width: 1100px;
    margin: 0 auto;
    padding: 0 1.5rem;
}

.portal-header {
    background: var(--bg-white);
    border-bottom: 1px solid var(--border-color);
    padding: 1rem 0;
    margin-bottom: 2rem;
    position: sticky;
    top: 0;
    z-index: 50;
    box-shadow: var(--shadow-sm);
}

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

.logo-text {
    font-weight: 700;
    font-size: 1.25rem;
    color: var(--primary-blue);
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

/* Navigation & User Menu */
.admin-nav {
    display: flex;
    gap: 0.5rem;
}

.admin-nav a {
    padding: 0.5rem 1rem;
    border-radius: var(--radius-md);
    font-weight: 500;
    color: var(--text-gray);
    font-size: 0.95rem;
}

.admin-nav a:hover {
    background-color: var(--bg-body);
    color: var(--primary-blue);
}

.admin-nav a.active {
    background-color: var(--primary-light);
    color: var(--primary-blue);
}

.user-menu {
    display: flex;
    align-items: center;
    gap: 1.5rem;
    font-size: 0.9rem;
    color: var(--text-gray);
}

.user-menu span {
    display: none;
    /* Hide name on mobile */
}

@media (min-width: 640px) {
    .user-menu span {
        display: inline-block;
    }
}

/* Cards & Containers */
.card {
    background: var(--bg-white);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-sm);
    border: 1px solid var(--border-color);
    padding: 1.5rem;
    margin-bottom: 1.5rem;
}

.grid-2 {
    display: grid;
    grid-template-columns: 1fr;
    gap: 1.5rem;
}

@media (min-width: 900px) {
    .grid-2 {
        grid-template-columns: 1fr 1fr;
    }

    .grid-2.sidebar-right {
        grid-template-columns: 2fr 1fr;
    }

    .grid-2.sidebar-left {
        grid-template-columns: 1fr 2fr;
    }
}

/* Buttons */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    padding: 0.625rem 1.25rem;
    border-radius: var(--radius-md);
    font-weight: 600;
    font-size: 0.95rem;
    cursor: pointer;
    border: 1px solid transparent;
    transition: all 0.2s;
    line-height: 1;
}

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

.btn-primary:hover {
    background-color: var(--primary-dark);
    transform: translateY(-1px);
}

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

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

.btn-danger {
    background-color: transparent;
    border-color: #fee2e2;
    color: var(--accent-red);
}

.btn-danger:hover {
    background-color: #fee2e2;
    color: var(--accent-red-hover);
}

.btn-sm {
    padding: 0.4rem 0.8rem;
    font-size: 0.85rem;
}

/* Forms */
.form-group {
    margin-bottom: 1.25rem;
}

.form-label {
    display: block;
    margin-bottom: 0.375rem;
    font-weight: 500;
    font-size: 0.9rem;
    color: var(--text-dark);
}

.form-control {
    width: 100%;
    padding: 0.625rem 0.875rem;
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    font-size: 0.95rem;
    color: var(--text-dark);
    background-color: #fff;
    transition: border-color 0.2s, box-shadow 0.2s;
    box-sizing: border-box;
    /* Important fix */
}

.form-control:focus {
    outline: none;
    border-color: var(--primary-blue);
    box-shadow: 0 0 0 3px var(--primary-light);
}

select.form-control {
    appearance: none;
    background-image: url("data:image/svg+xml,%3csvg xmlns='http://www.w3.org/2000/svg' fill='none' viewBox='0 0 20 20'%3e%3cpath stroke='%236b7280' stroke-linecap='round' stroke-linejoin='round' stroke-width='1.5' d='M6 8l4 4 4-4'/%3e%3c/svg%3e");
    background-position: right 0.5rem center;
    background-repeat: no-repeat;
    background-size: 1.5em 1.5em;
    padding-right: 2.5rem;
}

/* Tables */
.table-responsive {
    overflow-x: auto;
    border-radius: var(--radius-lg);
    border: 1px solid var(--border-color);
    background: white;
}

.table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.95rem;
}

.table th,
.table td {
    padding: 1rem 1.5rem;
    text-align: left;
    border-bottom: 1px solid var(--border-color);
}

.table th {
    background-color: var(--bg-offwhite);
    color: var(--text-gray);
    font-weight: 600;
    text-transform: uppercase;
    font-size: 0.75rem;
    letter-spacing: 0.05em;
    white-space: nowrap;
}

.table tr:last-child td {
    border-bottom: none;
}

.table tr:hover td {
    background-color: #f9fafb;
}

/* Badges & Status */
.badge {
    display: inline-flex;
    padding: 0.25rem 0.625rem;
    border-radius: 9999px;
    font-size: 0.75rem;
    font-weight: 500;
}

.badge-success {
    background-color: #dcfce7;
    color: #166534;
}

.badge-danger {
    background-color: #fee2e2;
    color: #991b1b;
}

/* Alerts */
.alert {
    padding: 1rem 1.25rem;
    border-radius: var(--radius-md);
    margin-bottom: 1.5rem;
    font-size: 0.95rem;
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.alert-error {
    background-color: #fef2f2;
    color: #991b1b;
    border: 1px solid #fee2e2;
}

.alert-success {
    background-color: #f0fdf4;
    color: #166534;
    border: 1px solid #dcfce7;
}

/* Modal do sistema (notificações) */
.portal-modal-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.4);
    z-index: 9998;
    align-items: center;
    justify-content: center;
    padding: 1rem;
}
.portal-modal-overlay.is-open {
    display: flex;
}
.portal-modal-box {
    background: var(--bg-white);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-lg);
    max-width: 420px;
    width: 100%;
    padding: 1.5rem 1.75rem;
    position: relative;
    z-index: 9999;
    animation: portal-modal-in 0.2s ease;
}
@keyframes portal-modal-in {
    from { opacity: 0; transform: scale(0.96); }
    to { opacity: 1; transform: scale(1); }
}
.portal-modal-box .portal-modal-icon {
    width: 48px;
    height: 48px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.5rem;
    margin-bottom: 1rem;
}
.portal-modal-box.portal-modal-success .portal-modal-icon {
    background: #dcfce7;
    color: #166534;
}
.portal-modal-box.portal-modal-error .portal-modal-icon {
    background: #fef2f2;
    color: #991b1b;
}
.portal-modal-box .portal-modal-title {
    font-size: 1.125rem;
    font-weight: 600;
    color: var(--text-dark);
    margin: 0 0 0.5rem 0;
}
.portal-modal-box .portal-modal-message {
    font-size: 0.95rem;
    color: var(--text-gray);
    margin: 0 0 1.25rem 0;
    line-height: 1.5;
}
.portal-modal-box .portal-modal-btn {
    display: block;
    width: 100%;
    padding: 0.6rem 1rem;
    font-size: 0.95rem;
    font-weight: 500;
    border: none;
    border-radius: var(--radius-md);
    cursor: pointer;
    background: var(--primary-blue);
    color: white;
    transition: background 0.2s;
}
.portal-modal-box .portal-modal-btn:hover {
    background: var(--primary-dark);
}
.portal-modal-box.portal-modal-error .portal-modal-btn {
    background: var(--accent-red);
}
.portal-modal-box.portal-modal-error .portal-modal-btn:hover {
    background: var(--accent-red-hover);
}

/* Empty States */
.empty-state {
    text-align: center;
    padding: 3rem 1rem;
    color: var(--text-gray);
}

.empty-icon {
    font-size: 2.5rem;
    margin-bottom: 1rem;
    color: var(--text-light);
}

/* Login Page Specifics */
.login-page {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    background: linear-gradient(135deg, #F0F7FF 0%, #FFFFFF 100%);
    padding: 1rem;
}

.login-card {
    background: white;
    width: 100%;
    max-width: 420px;
    padding: 2.5rem;
    border-radius: 1rem;
    box-shadow: 0 20px 25px -5px rgba(0, 0, 0, 0.1), 0 10px 10px -5px rgba(0, 0, 0, 0.04);
}

.login-header {
    text-align: center;
    margin-bottom: 2rem;
}

.login-header img {
    margin-bottom: 1.5rem;
    max-height: 50px;
}

.login-header h2 {
    font-size: 1.5rem;
    color: var(--primary-blue);
    margin-bottom: 0.5rem;
}

.auth-footer {
    text-align: center;
    margin-top: 1.5rem;
    font-size: 0.875rem;
    color: var(--text-light);
}

.auth-footer a:hover {
    color: var(--primary-blue);
    text-decoration: underline;
}

/* Utilities */
.text-center {
    text-align: center;
}

.w-full {
    width: 100%;
}

.mt-4 {
    margin-top: 1rem;
}

.mb-4 {
    margin-bottom: 1rem;
}

@media (max-width: 640px) {

    .table th,
    .table td {
        padding: 0.75rem 1rem;
    }

    .header-content {
        flex-direction: column;
        gap: 1rem;
    }

    .admin-nav {
        width: 100%;
        overflow-x: auto;
        padding-bottom: 0.5rem;
    }

    .grid-2 {
        grid-template-columns: 1fr;
    }
}

/* Abas Upload / Laudo descritivo */
.tabs-laudo {
    display: flex;
    gap: 0.5rem;
    flex-wrap: wrap;
}
.tabs-laudo .tab-btn {
    padding: 0.6rem 1.2rem;
    border: 1px solid var(--border-color);
    background: var(--bg-white);
    color: var(--text-gray);
    border-radius: var(--radius-md);
    cursor: pointer;
    font-size: 0.95rem;
    font-weight: 500;
    transition: background 0.2s, color 0.2s, border-color 0.2s;
}
.tabs-laudo .tab-btn:hover {
    background: var(--primary-light);
    color: var(--primary-dark);
    border-color: var(--primary-light);
}
.tabs-laudo .tab-btn.active {
    background: var(--primary-blue);
    color: white;
    border-color: var(--primary-blue);
}
.tab-panel {
    animation: fadeIn 0.2s ease;
}
@keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}
@media (max-width: 640px) {
    .form-row { grid-template-columns: 1fr !important; }
}