/* --- RENAFORTE MODERN DESIGN SYSTEM --- */
:root {
    /* Brand Colors */
    --brand-primary: #a3112d;
    /* Renaforte Red - Deeper, more corporate */
    --brand-primary-hover: #8a0e26;
    --brand-light: #fdf2f4;

    /* Neutral / Text Colors (Slate Scale) */
    --text-main: #0f172a;
    /* Slate 900 */
    --text-secondary: #475569;
    /* Slate 600 */
    --text-muted: #94a3b8;
    /* Slate 400 */
    --border-color: #e2e8f0;
    /* Slate 200 */
    --bg-app: #f8fafc;
    /* Slate 50 */
    --bg-card: #ffffff;

    /* Semantic Colors */
    --success: #16a34a;
    /* Emerald 600 */
    --warning: #ca8a04;
    /* Yellow 600 */
    --error: #dc2626;
    /* Red 600 */

    /* UI Variables */
    --radius-lg: 16px;
    --radius-md: 12px;
    --radius-sm: 8px;
    --shadow-sm: 0 1px 2px 0 rgb(0 0 0 / 0.05);
    --shadow-md: 0 4px 6px -1px rgb(0 0 0 / 0.1), 0 2px 4px -2px rgb(0 0 0 / 0.1);
    --shadow-lg: 0 10px 15px -3px rgb(0 0 0 / 0.1), 0 4px 6px -4px rgb(0 0 0 / 0.1);

    /* Header Height */
    --header-height: 80px;
}

/* --- RESET & BASE --- */
* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

body {
    font-family: 'Inter', system-ui, -apple-system, sans-serif;
    color: var(--text-main);
    background-color: var(--bg-app);
    line-height: 1.6;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

/* Background Abstract Decor */
.app-background {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100vh;
    background: linear-gradient(135deg, #f8fafc 0%, #f1f5f9 100%);
    z-index: -1;
}

.app-background::before {
    content: '';
    position: absolute;
    top: -100px;
    right: -100px;
    width: 500px;
    height: 500px;
    background: radial-gradient(circle, rgba(163, 17, 45, 0.05) 0%, transparent 70%);
    border-radius: 50%;
    pointer-events: none;
}

/* --- HEADER --- */
.glass-header {
    background: linear-gradient(135deg, var(--brand-primary) 0%, var(--brand-primary-hover) 100%);
    box-shadow: 0 4px 20px rgba(163, 17, 45, 0.25);
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
    height: var(--header-height);
    position: sticky;
    top: 0;
    z-index: 100;
    color: white;
}

.header-content {
    max-width: 1200px;
    margin: 0 auto;
    padding: 0 24px;
    height: 100%;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.logo-area {
    display: flex;
    align-items: center;
    gap: 16px;
}

.header-logo {
    height: 52px;
    /* Slightly larger */
    width: auto;
    background: white;
    padding: 4px;
    border-radius: 8px;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
}

.header-text h1 {
    font-size: 1.25rem;
    font-weight: 700;
    color: white;
    line-height: 1.2;
    letter-spacing: -0.02em;
    text-shadow: 0 1px 2px rgba(0, 0, 0, 0.1);
}

.header-text p {
    font-size: 0.875rem;
    color: rgba(255, 255, 255, 0.9);
}

.user-info span {
    font-size: 0.875rem;
    font-weight: 600;
    color: white;
    background: rgba(255, 255, 255, 0.15);
    padding: 6px 16px;
    border-radius: 20px;
    border: 1px solid rgba(255, 255, 255, 0.2);
    backdrop-filter: blur(4px);
}

/* --- LAYOUT --- */
.container {
    max-width: 1200px;
    margin: 32px auto;
    padding: 0 24px;
}

.dashboard-grid {
    display: grid;
    gap: 24px;
}

/* --- CARDS --- */
.card {
    background: var(--bg-card);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-md);
    border: 1px solid rgba(255, 255, 255, 0.5);
    /* Subtle inner border like glassish */
    overflow: hidden;
    transition: box-shadow 0.3s ease;
}

.card:hover {
    box-shadow: var(--shadow-lg);
}

.card-header {
    padding: 24px;
    border-bottom: 1px solid var(--border-color);
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.card-header h2 {
    font-size: 1.125rem;
    font-weight: 600;
    display: flex;
    align-items: center;
    gap: 8px;
    color: var(--text-main);
}

.card-body {
    padding: 24px;
}

.icon {
    font-size: 1.2rem;
}

/* --- FORM --- */
.form-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
    gap: 20px;
    margin-bottom: 32px;
}

.form-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 20px;
}

.form-group {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.form-group.full-width {
    grid-column: 1 / -1;
}

label {
    font-size: 0.875rem;
    font-weight: 500;
    color: var(--text-secondary);
}

input,
select {
    padding: 10px 14px;
    font-size: 0.95rem;
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    color: var(--text-main);
    background: #fff;
    transition: all 0.2s ease;
}

input:focus {
    outline: none;
    border-color: var(--brand-primary);
    box-shadow: 0 0 0 3px rgba(163, 17, 45, 0.1);
}

.readonly-input {
    background-color: var(--bg-app);
    color: var(--text-main);
    font-weight: 600;
    border-color: transparent;
}

.highlight-group label {
    color: var(--brand-primary);
}

.highlight-group input {
    background-color: var(--brand-light);
    border-color: var(--brand-light);
    font-size: 1.1rem;
    color: var(--brand-primary);
}

/* --- SIGNATURE --- */
.signature-group {
    margin-top: 10px;
    padding: 20px;
    background: var(--bg-app);
    border-radius: var(--radius-md);
    border: 1px dashed var(--border-color);
}

.signature-wrapper {
    display: flex;
    flex-direction: column;
    gap: 10px;
    align-items: flex-end;
}

.signature-pad-container {
    width: 100%;
    height: 160px;
    background: #fff;
    border-radius: var(--radius-sm);
    border: 1px solid var(--border-color);
    cursor: crosshair;
}

.btn-text {
    background: none;
    border: none;
    color: var(--text-muted);
    font-size: 0.8rem;
    text-decoration: underline;
    cursor: pointer;
}

.btn-text:hover {
    color: var(--brand-primary);
}

/* --- BUTTONS --- */
.form-actions {
    display: flex;
    justify-content: flex-end;
    gap: 12px;
    margin-top: 32px;
    padding-top: 24px;
    border-top: 1px solid var(--border-color);
}

.btn {
    padding: 10px 20px;
    border-radius: var(--radius-sm);
    font-size: 0.9rem;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    border: 1px solid transparent;
}

.btn-primary {
    background-color: var(--brand-primary);
    color: white;
    box-shadow: 0 2px 4px rgba(163, 17, 45, 0.2);
}

.btn-primary:hover {
    background-color: var(--brand-primary-hover);
    transform: translateY(-1px);
    box-shadow: 0 4px 6px rgba(163, 17, 45, 0.3);
}

.btn-ghost {
    background: transparent;
    color: var(--text-secondary);
}

.btn-ghost:hover {
    background: var(--bg-app);
    color: var(--text-main);
}

.btn-outline {
    background: transparent;
    border-color: var(--border-color);
    color: var(--text-main);
}

.btn-outline:hover {
    border-color: var(--text-muted);
    background: #fff;
}

.btn.small {
    padding: 6px 12px;
    font-size: 0.8rem;
}

.btn-danger {
    background-color: #fff1f2;
    color: var(--error);
    border: 1px solid #fecdd3;
}

.btn-danger:hover {
    background-color: #ffe4e6;
}

/* --- SEARCH & ACTIONS --- */
.actions-header {
    display: flex;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: 16px;
}

.actions-buttons {
    display: flex;
    gap: 8px;
}

.search-box-container {
    padding: 16px 24px 0 24px;
}

.search-input {
    width: 100%;
    max-width: 400px;
    padding-left: 36px;
    /* Space for icon if added via CSS ::before later, keeping simple for now */
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' fill='none' viewBox='0 0 24 24' stroke='%2394a3b8'%3E%3Cpath stroke-linecap='round' stroke-linejoin='round' stroke-width='2' d='M21 21l-6-6m2-5a7 7 0 11-14 0 7 7 0 0114 0z' /%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: 10px center;
    background-size: 16px;
}

/* --- TABLE --- */
.table-responsive {
    overflow-x: auto;
    padding: 24px;
}

.modern-table {
    width: 100%;
    border-collapse: separate;
    border-spacing: 0;
    min-width: 800px;
}

.modern-table th {
    background: var(--bg-app);
    color: var(--text-secondary);
    font-weight: 600;
    font-size: 0.85rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    padding: 12px 16px;
    text-align: left;
    border-bottom: 2px solid var(--border-color);
}

.modern-table td {
    padding: 16px;
    border-bottom: 1px solid var(--border-color);
    font-size: 0.9rem;
    color: var(--text-main);
    vertical-align: middle;
}

.modern-table tbody tr:hover {
    background-color: var(--bg-app);
}

.modern-table tbody tr:last-child td {
    border-bottom: none;
}

.badge {
    display: inline-block;
    padding: 4px 8px;
    border-radius: 4px;
    background-color: var(--brand-light);
    color: var(--brand-primary);
    font-size: 0.8rem;
    font-weight: 600;
}

.signature-img {
    height: 32px;
    width: auto;
    opacity: 0.8;
}

.action-buttons {
    display: flex;
    gap: 6px;
}

/* --- EMPTY STATE --- */
.empty-state {
    text-align: center;
    padding: 48px 0;
    color: var(--text-muted);
}

.empty-icon {
    font-size: 3rem;
    margin-bottom: 16px;
    opacity: 0.5;
}

/* --- NOTIFICATIONS --- */
.notification {
    position: fixed;
    top: 100px;
    right: 24px;
    padding: 16px 24px;
    border-radius: var(--radius-md);
    background: var(--text-main);
    color: white;
    font-weight: 500;
    box-shadow: var(--shadow-lg);
    z-index: 1000;
    transform: translateY(0);
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    display: flex;
    align-items: center;
    gap: 12px;
}

.notification.hidden {
    transform: translateY(-20px);
    opacity: 0;
    pointer-events: none;
    /* display is NOT none so we can animate */
}

/* Override display none from previous logic if we want smooth animation,
   but script.js uses class removal which sets display back to block naturally.
   However, script defines '.hidden { display: none !important }'. 
   Let's keep compatible: */
.hidden {
    display: none !important;
}

.notification.success {
    background-color: var(--success);
}

.notification.error {
    background-color: var(--error);
}

/* --- FOOTER --- */
footer {
    text-align: center;
    padding: 32px 0;
    color: var(--text-muted);
    font-size: 0.8rem;
}

/* --- RESPONSIVE --- */
@media (max-width: 768px) {
    :root {
        --header-height: auto;
    }

    .header-content {
        flex-direction: column;
        padding: 16px 24px;
        gap: 16px;
        align-items: flex-start;
    }

    .user-info {
        display: none;
    }

    .form-row {
        grid-template-columns: 1fr;
    }

    .card-header {
        flex-direction: column;
        gap: 12px;
        align-items: flex-start;
    }

    .actions-buttons {
        width: 100%;
        justify-content: flex-start;
    }
}

/* --- PRINT --- */
@media print {
    @page {
        margin: 1cm;
        size: landscape;
    }

    body {
        background: white;
        color: black;
        font-size: 10pt;
    }

    .glass-header,
    .app-background,
    footer,
    .form-actions,
    .actions-header,
    .search-box-container,
    .form-card,
    .btn,
    .notification {
        display: none !important;
    }

    .container {
        margin: 0;
        padding: 0;
        max-width: 100%;
    }

    .card {
        box-shadow: none;
        border: none;
        border-radius: 0;
    }

    .dashboard-grid {
        gap: 0;
        display: block;
    }

    .table-container,
    .table-responsive {
        overflow: visiblebox;
    }

    /* Reveal Table for Print even if inside hidden sections? No, table-card is shown */
    .table-card {
        display: block;
    }

    /* Print Header Mockup */
    .table-card::before {
        content: "RENAFORTE - Relatório de Deslocamento";
        display: block;
        font-size: 18pt;
        font-weight: bold;
        text-align: center;
        margin-bottom: 20px;
        border-bottom: 2px solid #000;
        padding-bottom: 10px;
    }

    .modern-table {
        border: 1px solid #000;
        width: 100%;
    }

    .modern-table th {
        background: #eee;
        color: #000;
        border: 1px solid #000;
    }

    .modern-table td {
        border: 1px solid #000;
        padding: 4px;
    }

    /* Hide Actions Column */
    .modern-table th:last-child,
    .modern-table td:last-child {
        display: none;
    }
}

/* --- MOBILE RESPONSIVE TWEAKS --- */
@media (max-width: 480px) {
    .container {
        margin: 16px auto;
        padding: 0 16px;
    }

    .header-content {
        align-items: center; /* Center align on mobile */
        text-align: center;
    }

    .logo-area {
        flex-direction: column;
        gap: 8px;
    }

    .header-logo {
        height: 48px;
    }

    .header-text h1 {
        font-size: 1.1rem;
    }

    .header-text p {
        font-size: 0.8rem;
    }

    .card-header {
        flex-direction: column;
        align-items: center; /* Center align header content */
        text-align: center;
        gap: 16px;
    }

    .card-header h2 {
        font-size: 1rem;
    }

    .form-grid {
        grid-template-columns: 1fr; /* Full width inputs */
    }

    .form-row {
        grid-template-columns: 1fr; /* Stack form rows */
    }
    
    .form-actions {
        flex-direction: column-reverse; /* Stack buttons, save on top (or maintain logial order) - let's keep it simple column */
        flex-direction: column;
        width: 100%;
    }
    
    .form-actions .btn {
        width: 100%; /* Full width buttons */
    }

    .actions-header {
        justify-content: center;
    }
    
    .actions-buttons {
        flex-wrap: wrap; /* Allow buttons to wrap */
        justify-content: center;
    }

    .actions-buttons .btn {
        flex-grow: 1; /* Expand buttons to fill space */
        min-width: 120px; /* Minimum width for touch targets */
    }
    
    .search-input {
        max-width: 100%;
    }
    
    .notification {
        width: 90%; /* Occupy most of the screen width */
        left: 5%;
        right: auto;
        top: 20px; /* Closer to top on mobile */
    }
}