@import url('https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700&display=swap');

:root {
    --bg-color: #f4f7f6;
    --text: #1a202c;
    --primary: #2f594f; 
    --primary-hover: #1e3a34;
    --accent: #b1d366;
    --accent-hover: #9cbe50;
    --line: #e2e8f0;
    --muted: #64748b;
    --danger: #ef4444;
    --notice-bg: #b1d36614;
    --error-bg: #ef444414;
    --primary-bg: #2f594f14;
}

* {
    box-sizing: border-box;
    scrollbar-width: none; /* Firefox */
    -ms-overflow-style: none; /* IE/Edge */
}
*::-webkit-scrollbar {
    display: none; /* Chrome/Safari/Opera */
}

[hidden] {
    display: none !important;
}

body {
    margin: 0;
    font-family: 'Inter', system-ui, -apple-system, sans-serif;
    background: var(--bg-color);
    color: var(--text);
    min-height: 100vh;
    line-height: 1.5;
    -webkit-font-smoothing: antialiased;
}

hr {
    border: none;
    border-top: 2px solid var(--line);
    margin: 32px 0;
    width: 100%;
    grid-column: 1 / -1;
}

a {
    color: var(--primary);
    text-decoration: none;
    font-weight: 600;
}
a:hover {
    color: var(--accent);
}

.shell {
    width: min(1400px, calc(100% - 48px));
    margin: 0 auto;
    padding: 24px 0 48px;
}

/* TOPBAR */
.topbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    margin-bottom: 48px;
    padding: 16px 0;
    border-bottom: 2px solid var(--line);
}

.brand {
    font-size: 24px;
    font-weight: 700;
    color: var(--primary);
}

.tabs {
    display: flex;
    gap: 16px;
}

.tabs a, .button, button {
    min-height: 48px;
    background: #ffffff;
    border: 1px solid var(--line);
    border-radius: 8px;
    padding: 8px 24px;
    font-weight: 600;
    font-size: 15px;
    color: var(--text);
    cursor: pointer;
    text-decoration: none;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s ease;
    box-shadow: 0 1px 3px rgba(0,0,0,0.05);
}

.tabs a:hover, .button:hover, button:hover:not(.primary):not(.danger) {
    background: #f8fafc;
    color: var(--primary);
    border-color: var(--primary);
    transform: translateY(-1px);
    box-shadow: 0 4px 6px rgba(0,0,0,0.05);
}

.tabs a.active {
    background: var(--primary);
    color: #ffffff;
    border-color: var(--primary);
}

.button.primary, button.primary {
    background: var(--primary);
    color: #ffffff;
    border: none;
    box-shadow: 0 4px 12px rgba(47, 89, 79, 0.2);
}

.button.primary:hover, button.primary:hover {
    background: var(--primary-hover);
    color: #ffffff;
    box-shadow: 0 6px 16px rgba(47, 89, 79, 0.3);
    transform: translateY(-1px);
}

.button.danger, button.danger {
    background: var(--danger);
    color: #ffffff;
    border: none;
    box-shadow: 0 4px 12px rgba(239, 68, 68, 0.2);
}
.button.danger:hover, button.danger:hover {
    background: #dc2626;
    box-shadow: 0 6px 16px rgba(239, 68, 68, 0.3);
    transform: translateY(-1px);
}

/* PANELS & CARDS (Now transparent / bare) */
.panel {
    background: transparent;
    border: none;
    padding: 0;
    margin-bottom: 24px;
    box-shadow: none;
}

.grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 32px;
}

.field {
    display: flex;
    flex-direction: column;
    gap: 8px;
}
.field.full {
    grid-column: 1 / -1;
}

label {
    font-weight: 600;
    font-size: 14px;
    color: var(--primary);
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

/* FORMS */
input, select, textarea {
    width: 100%;
    min-height: 48px;
    border: 2px solid var(--line);
    padding: 8px 16px;
    font-family: inherit;
    font-size: 16px;
    background: #ffffff;
    color: var(--text);
    border-radius: 8px;
    box-shadow: 0 2px 4px rgba(0,0,0,0.02) inset;
    transition: border-color 0.2s ease, box-shadow 0.2s ease;
}

input:focus, select:focus, textarea:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px var(--primary-bg);
}

input[readonly], input[disabled], select[disabled] {
    background-color: #f1f5f9 !important;
    color: var(--muted) !important;
    border-style: solid !important;
    border-color: var(--line) !important;
    cursor: not-allowed;
    opacity: 0.75;
}

#document, #vehicle_plate {
    text-transform: uppercase;
}

/* Checkboxes & Radios */
.radio-group {
    display: flex;
    gap: 16px;
}
.radio-btn {
    display: flex;
    align-items: center;
    gap: 8px;
    cursor: pointer;
    background: #ffffff;
    border: 2px solid var(--line);
    border-radius: 8px;
    padding: 12px 24px;
    flex: 1;
    justify-content: center;
    font-weight: 600;
    transition: all 0.2s ease;
}
.radio-btn input[type="radio"] {
    display: none;
}
.radio-btn:hover {
    border-color: var(--primary);
}
.radio-btn:has(input[type="radio"]:checked) {
    background: var(--primary);
    border-color: var(--primary);
    color: #ffffff;
}

/* Gates specific overrides */
.gates label {
    font-size: 15px;
    color: var(--muted);
}
.gates .radio-group {
    margin-top: 8px;
}

.checks {
    display: flex;
    flex-direction: column;
}
.check {
    display: flex;
    gap: 12px;
    align-items: center;
    font-weight: 500;
    font-size: 16px;
    cursor: pointer;
    color: var(--text);
    text-transform: none;
}
.check input[type="checkbox"] {
    width: 24px;
    height: 24px;
    min-height: auto;
    padding: 0;
    background: transparent;
    border: none;
    box-shadow: none;
    margin: 0;
    accent-color: var(--primary);
    cursor: pointer;
}

/* ALERTS */
.notice, .error, .success {
    padding: 10px 16px;
    margin-bottom: 32px;
    font-size: 16px;
    font-weight: 500;
    border: 2px solid;
    border-radius: 8px;
    display: flex;
    align-items: center;
    gap: 12px;
    /* background: transparent !important; */
}

#message.floating-message {
    position: fixed;
    top: 24px;
    left: 50%;
    transform: translateX(-50%);
    z-index: 9999;
    box-shadow: 0 10px 25px -5px rgba(0, 0, 0, 0.2);
    width: 90%;
    max-width: 500px;
    margin-bottom: 0;
}

.notice { background-color: var(--notice-bg); color: var(--primary); border-color: var(--accent) !important; }
.error { background-color: var(--error-bg); color: var(--danger); border-color: var(--danger) !important; }
.success { background-color: var(--primary-bg); color: var(--primary); border-color: var(--primary) !important; }

.actions {
    display: flex;
    justify-content: flex-end;
    gap: 16px;
    margin-top: 32px;
    padding-top: 32px;
    border-top: 2px solid var(--line);
}

.rules {
    border: none;
    border-left: 4px solid var(--accent);
    padding: 5px 24px;
    background: #f1f5f9;
    font-size: 15px;
    margin-bottom: 24px;
    color: var(--text);
}

/* CONSULTAS SECTION */
.consultas-header {
    margin-top: 0;
    margin-bottom: 32px;
    font-size: 28px;
    font-weight: 700;
    color: var(--primary);
}
.consultas-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 16px;
    margin-bottom: 32px;
}
.consulta-card {
    background: transparent;
    border: 2px solid var(--line);
    padding: 16px;
    cursor: pointer;
}
.consulta-card:hover {
    border-color: var(--primary);
}
.consulta-card h3 {
    margin: 0 0 8px 0;
    font-size: 16px;
    font-weight: 700;
    color: var(--primary);
}
.consulta-card p {
    margin: 0;
    font-size: 13px;
    color: var(--muted);
}

/* TABLES */
.table-responsive {
    width: 100%;
    overflow-x: auto;
    border: 1px solid var(--line);
    border-radius: 12px;
    background: #ffffff;
    box-shadow: 0 4px 6px rgba(0, 0, 0, 0.02);
}
table {
    width: 100%;
    border-collapse: collapse;
    background: #ffffff;
}
th, td {
    padding: 16px 24px;
    text-align: left;
    border-bottom: 1px solid var(--line);
    font-size: 14px;
}
th {
    background: #ffffff;
    font-weight: 600;
    color: var(--muted);
    text-transform: uppercase;
    letter-spacing: 0.05em;
    font-size: 12px;
    border-bottom: 1px solid var(--line);
}
tr:last-child td {
    border-bottom: none;
}
tbody tr {
    transition: background-color 0.2s ease;
}
tbody tr:hover {
    background: var(--primary-bg);
}

/* QUEUE */
.queue {
    background: var(--bg-color);
    color: var(--text);
}
.queue h1 {
    font-size: 48px;
    margin: 0 0 48px;
    font-weight: 700;
    color: var(--primary);
}
.queue-table th, .queue-table td {
    padding: 24px;
    font-size: 24px;
}
.queue-table th {
    font-size: 16px;
    background: transparent;
    border-bottom: 2px solid var(--primary);
}
.turn {
    background: var(--primary);
    color: #ffffff;
    padding: 12px 24px;
    border-radius: 8px;
    font-weight: 700;
    display: inline-block;
    box-shadow: 0 4px 12px var(--primary-bg);
}

/* MATERIAL UI TABLE STYLES */
.visitor-info {
    display: flex;
    flex-direction: column;
    gap: 4px;
}
.visitor-name {
    font-size: 15px;
    font-weight: 600;
    color: var(--text);
    display: flex;
    align-items: center;
    gap: 8px;
}
.badge {
    font-size: 11px;
    font-weight: 700;
    color: var(--primary);
    background: var(--primary-bg);
    padding: 2px 6px;
    border-radius: 4px;
    letter-spacing: 0.05em;
}
.visitor-meta {
    font-size: 13px;
    color: var(--muted);
}
.mui-field-group {
    display: flex;
    gap: 16px;
}
.mui-field {
    display: flex;
    flex-direction: column;
    gap: 4px;
}
.mui-field label {
    font-size: 11px;
    color: var(--muted);
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}
.mui-input {
    background: transparent !important;
    border: none !important;
    border-bottom: 2px solid var(--line) !important;
    border-radius: 0 !important;
    padding: 4px 0 !important;
    font-size: 14px !important;
    box-shadow: none !important;
    transition: border-color 0.2s ease !important;
    min-height: auto !important;
}
.mui-input:focus {
    border-bottom-color: var(--primary) !important;
    box-shadow: none !important;
}
.plate-input {
    width: 80px;
    text-transform: uppercase;
}
.turn-input {
    width: 50px;
    text-align: center;
}
.time-group-vertical {
    display: flex;
    flex-direction: column;
    gap: 8px;
}
.time-row {
    display: flex;
    align-items: center;
    gap: 8px;
}
.time-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    flex-shrink: 0;
}
.time-dot.entry {
    background: var(--primary);
}
.time-dot.exit {
    background: var(--muted);
}
.time-input {
    width: 140px;
    font-family: inherit;
    font-size: 13px !important;
}
.actions-cell {
    display: flex;
    gap: 8px;
    align-items: center;
}
.mui-btn {
    padding: 8px !important;
    width: 40px;
    height: 40px;
    border-radius: 50% !important;
    display: flex;
    align-items: center;
    justify-content: center;
}
.mui-btn svg {
    flex-shrink: 0;
}

/* INLINE EDIT STYLES FOR CLOSED ROWS */
.closed-row input.mui-input {
    pointer-events: none;
    border-bottom-color: transparent !important;
    color: var(--muted) !important;
}
.closed-row.editing input.mui-input {
    pointer-events: auto;
    border-bottom-color: var(--line) !important;
    color: var(--text) !important;
}
.closed-row.editing input.mui-input:focus {
    border-bottom-color: var(--primary) !important;
}
.closed-row.editing .view-only {
    display: none !important;
}
.closed-row.editing .edit-only {
    display: flex !important;
}

@media (max-width: 768px) {
    .grid { grid-template-columns: 1fr; }
    .topbar { flex-direction: column; align-items: flex-start; gap: 24px; }
    .tabs { flex-wrap: wrap; }
    .tabs a { flex: 1; text-align: center; }
    .exit-reminder-box { padding: 56px 24px 40px; }
    .exit-reminder-mark { width: 76px; height: 76px; font-size: 52px; }
    .exit-reminder-box h2 { font-size: 32px; }
    .exit-reminder-box p { font-size: 18px; }
}

/* MODAL & SURVEY */
.modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(22, 47, 74, 0.95);
    display: none;
    align-items: center;
    justify-content: center;
    z-index: 9999;
    padding: 24px;
}
.modal-overlay:not([hidden]) {
    display: flex;
}
.modal-content {
    background: var(--bg-color);
    padding: 48px;
    width: 100%;
    max-width: 600px;
    text-align: center;
}
.exit-reminder-box {
    position: relative;
    max-width: 760px;
    padding: 64px 56px 56px;
    border: 4px solid var(--accent);
    box-shadow: 0 24px 80px rgba(0, 0, 0, 0.35);
}
.modal-close {
    position: absolute;
    top: 16px;
    right: 16px;
    width: 48px;
    min-height: 48px;
    padding: 0;
    border: 2px solid var(--primary);
    background: white;
    color: var(--primary);
    font-size: 28px;
    font-weight: 700;
    line-height: 1;
}
.modal-close:hover {
    background: var(--primary);
    color: #ffffff;
}
.exit-reminder-mark {
    width: 96px;
    height: 96px;
    margin: 0 auto 28px;
    border: 4px solid var(--accent);
    background: var(--primary);
    color: #ffffff;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 64px;
    font-weight: 700;
    line-height: 1;
}
.exit-reminder-box h2 {
    margin: 0;
    color: var(--primary);
    font-size: 44px;
    font-weight: 700;
    line-height: 1.1;
}
.exit-reminder-box p {
    margin: 24px auto 0;
    max-width: 560px;
    color: var(--text);
    font-size: 22px;
    font-weight: 500;
}
.survey-box h2 {
    margin-top: 0;
    font-size: 32px;
    font-weight: 700;
    color: var(--primary);
}
.survey-emojis {
    display: flex;
    justify-content: center;
    gap: 32px;
    margin: 48px 0;
}
.emoji-btn {
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 100px;
    height: 100px;
    background: transparent;
    border: 2px solid var(--line);
    border-radius: 50%;
}
.emoji-btn .emoji {
    font-size: 56px;
    line-height: 1;
    filter: grayscale(1) opacity(0.3);
}
.emoji-btn:hover {
    border-color: var(--primary);
}
.emoji-btn:hover .emoji {
    filter: grayscale(0) opacity(1);
}
.emoji-btn input[type="radio"] {
    display: none;
}
.emoji-btn:has(input[type="radio"]:checked) {
    border-color: var(--primary);
}
.emoji-btn:has(input[type="radio"]:checked) .emoji {
    filter: grayscale(0) opacity(1);
}
.emoji-btn.green:has(input[type="radio"]:checked) { border-color: var(--accent); background: #f4f9d8; }
.emoji-btn.yellow:has(input[type="radio"]:checked) { border-color: #f59e0b; background: #fef3c7; }
.emoji-btn.red:has(input[type="radio"]:checked) { border-color: var(--danger); background: #fee2e2; }


/* LEGAL MODAL SPECIFIC STYLES */
.rules-legal-link {
    margin-top: 12px;
    margin-bottom: 0;
}
.rules-legal-link a {
    text-decoration: underline;
}
.legal-box {
    position: relative;
    max-width: 1000px;
    width: 95%;
    height: 85vh;
    padding: 40px 24px 24px 24px;
    border: 4px solid var(--accent);
    box-shadow: 0 24px 80px rgba(0, 0, 0, 0.35);
    display: flex;
    flex-direction: column;
    text-align: left;
}
.legal-title {
    margin: 0 0 16px 0;
    color: var(--primary);
    font-size: 28px;
    font-weight: 700;
}
.iframe-container {
    flex: 1;
    width: 100%;
    border: 2px solid var(--line);
    border-radius: 4px;
    overflow: auto;
    -webkit-overflow-scrolling: touch;
}
.iframe-container iframe {
    width: 100%;
    height: 100%;
    border: none;
    background: #ffffff;
    display: block;
    overflow: auto;
}

/* ADMIN OVERRIDES */
.admin-shell {
    padding: 20px 0px;
}
.admin-shell .topbar {
    background: #ffffff;
    border: none;
    border-radius: 50px;
    padding: 14px 32px;
    margin: 16px auto 32px auto;
    width: 100%;
    max-width: 90rem;
    box-shadow: 0px 0px 15px rgba(0,0,0,0.2);
}
.admin-shell .topbar .brand {
    color: var(--primary);
}
.admin-shell .topbar .tabs {
    gap: 32px;
}
.admin-shell .topbar .tabs a {
    color: var(--text);
    background: transparent;
    border: none;
    box-shadow: none;
    padding: 8px 0;
    text-decoration: none;
    font-weight: 500;
}
.admin-shell .topbar .tabs a:hover, .admin-shell .topbar .tabs a.active {
    background: transparent;
    box-shadow: none;
    color: var(--accent);
    transform: none;
}
.admin-shell .panel {
    background: #ffffff;
    border: none;
    border-radius: 12px;
    padding: 32px;
    margin-bottom: 24px;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.05);
}
.admin-shell .consulta-card {
    background: #ffffff;
    border-radius: 8px;
}
.admin-shell table {
    background: #ffffff;
}
