/* Import Google Font similar to Calibri */
@import url('https://fonts.googleapis.com/css2?family=Carlito&display=swap');

/* Reset and base styles */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

html {
    scroll-behavior: smooth;
}

body {
    font-family: 'Carlito', 'Calibri', Arial, sans-serif;
    background-color: #f0f0f0;
    padding: 20px;
}

/* Container for the entire application */
.app-container {
    max-width: 1520px; /* Adjusted for a 60px nav + 20px gap + 1400px content */
    margin: 0 auto;
    display: flex;
    gap: 20px;
    align-items: flex-start; /* Align items to the top */
}

/* Quick Nav Sidebar */
.quick-nav {
    flex: 0 0 60px; /* Do not grow, do not shrink, base width of 60px */
    position: sticky;
    top: 20px;
    align-self: flex-start;
    max-height: 95vh;
    overflow-y: auto;
    background-color: #ffffff;
    border-radius: 8px;
    box-shadow: 0 2px 10px rgba(0,0,0,0.08);
    transition: width 0.3s ease;
    overflow-x: hidden;
}

.quick-nav:hover {
    width: 220px; /* Expand on hover to show text */
}

.quick-nav h4 {
    color: #333;
    font-size: 16px;
    margin-bottom: 10px;
    border-bottom: 1px solid #ddd;
    padding-bottom: 5px;
}

.quick-nav ul {
    list-style: none;
    padding: 0;
    margin: 0;
}

.quick-nav li a {
    display: flex;
    align-items: center;
    padding: 15px 20px;
    color: #333;
    text-decoration: none;
    font-size: 14px;
    white-space: nowrap;
    transition: background-color 0.2s, color 0.2s;
}

.quick-nav li a .fas {
    font-size: 18px;
    min-width: 20px; /* Aligns text when nav expands */
    text-align: center;
}

.quick-nav li a span {
    margin-left: 20px;
    opacity: 0;
    transition: opacity 0.2s ease;
}

.quick-nav:hover li a span {
    opacity: 1;
    transition-delay: 0.1s; /* Delay span fade-in slightly */
}

.quick-nav li a:hover {
    background-color: #e8f4f8;
    color: #2c5aa0;
}

/* Form section styling */
.form-section {
    flex: 1;
    background: white;
    padding: 30px;
    border-radius: 8px;
    box-shadow: 0 2px 10px rgba(0,0,0,0.1);
    max-height: 95vh;
    overflow-y: auto;
}

.form-section h2 {
    color: #333;
    margin-bottom: 20px;
    padding-bottom: 10px;
}

.form-section h3 {
    margin-top: 30px;
    margin-bottom: 15px;
    color: #444;
    border-bottom: 1px solid #eee;
    padding-bottom: 8px;
}

.form-section h3 .fas {
    margin-right: 10px;
    color: #3498db; /* A nice blue color to match the primary button */
}

.form-section h3[id] {
    scroll-margin-top: 180px; /* Offset for the sticky header */
}

/* Form controls */
.form-group {
    margin-bottom: 20px;
}

.form-group label {
    display: block;
    font-weight: bold;
    margin-bottom: 5px;
    color: #555;
}

.form-group input,
.form-group select,
.form-group textarea {
    width: 100%;
    padding: 10px;
    border: 1px solid #ddd;
    border-radius: 4px;
    font-size: 14px;
}

.form-group textarea {
    resize: vertical;
    min-height: 80px;
}

/* Employee selector */
.employee-selector {
    background: #f8f9fa;
    padding: 15px;
    border-radius: 4px;
    margin-bottom: 20px;
}

.sticky-header {
    position: sticky;
    top: -30px; /* Nudge up to sit flush with the top of the container */
    z-index: 10;
    /* The background is inherited from .form-section but we'll ensure it's white */
    background: #ffffff; 
    /* Adjust padding to create space and account for the negative top positioning */
    padding-top: 30px; 
    padding-bottom: 20px;
    /* Add a subtle shadow to indicate elevation */
    box-shadow: 0 2px 4px rgba(0,0,0,0.05); 
    /* Ensures the header doesn't shrink */
    margin-left: -30px; 
    margin-right: -30px;
    /* Match the form section's horizontal padding */
    padding-left: 30px; 
    padding-right: 30px;
}

.button-group {
    display: flex;
    gap: 10px;
    margin-top: 10px;
}

button {
    padding: 10px 20px;
    border: none;
    border-radius: 4px;
    cursor: pointer;
    font-size: 14px;
    transition: background-color 0.3s;
}

.btn-primary {
    background-color: #3498db;
    color: white;
}

.btn-primary:hover {
    background-color: #2980b9;
}

.btn-success {
    background-color: #27ae60;
    color: white;
}

.btn-success:hover {
    background-color: #229954;
}

.btn-danger {
    background-color: #e74c3c;
    color: white;
}

.btn-danger:hover {
    background-color: #c0392b;
}

.btn-secondary {
    background-color: #95a5a6;
    color: white;
}

.btn-secondary:hover {
    background-color: #7f8c8d;
}

/* Dynamic list items */
.list-item {
    display: flex;
    gap: 10px;
    margin-bottom: 10px;
    align-items: center;
}

.list-item input,
.list-item textarea {
    flex: 1;
}

.list-item button {
    padding: 5px 10px;
    font-size: 12px;
}

/* Enhanced grid layout for multi-column editors */
.list-item.resp-item {
    display: grid;
    grid-template-columns: 2fr 1fr 2fr 2fr 0.3fr auto;
    gap: 8px;
    align-items: start;
    padding-bottom: 8px;
    border-bottom: 1px solid #eee;
}

.list-item.resp-item:last-child {
    border-bottom: none;
}

.list-header {
    display: grid;
    grid-template-columns: 2fr 1fr 2fr 2fr 0.3fr auto;
    gap: 8px;
    font-weight: bold;
    color: #333;
    margin-bottom: 10px;
    padding-bottom: 5px;
    border-bottom: 2px solid #ccc;
}

.list-header-2 {
    display: grid;
    grid-template-columns: 2fr 1fr 2fr 1.5fr auto;
    gap: 8px;
    font-weight: bold;
    color: #333;
    margin-bottom: 10px;
    padding-bottom: 5px;
    border-bottom: 2px solid #ccc;
}

.list-item.report-item {
    display: grid;
    grid-template-columns: 2fr 1fr 2fr 1.5fr auto;
    gap: 8px;
    align-items: start;
}

.list-item.resp-item textarea,
.list-item.report-item textarea,
.list-item.resp-item input,
.list-item.report-item input {
    width: 100%;
    padding: 8px;
    font-size: 13px;
}

/* Message notifications */
.message {
    padding: 10px 15px;
    margin: 10px 0;
    border-radius: 4px;
    font-weight: 500;
}

.message.success {
    background-color: #d4edda;
    color: #155724;
    border: 1px solid #c3e6cb;
}

.message.error {
    background-color: #f8d7da;
    color: #721c24;
    border: 1px solid #f5c6cb;
}

/* Compensation grid */
.compensation-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 15px;
}

.compensation-grid .form-group {
    margin-bottom: 0;
}

/* Scrollbar styling */
::-webkit-scrollbar {
    width: 8px;
}

::-webkit-scrollbar-track {
    background: #f1f1f1;
}

::-webkit-scrollbar-thumb {
    background: #888;
    border-radius: 4px;
}

::-webkit-scrollbar-thumb:hover {
    background: #555;
}

/* Styles for the floating toggle button */
.floating-toggle-btn {
    position: fixed;
    top: 75px; /* Position it below the new logout button */
    right: 30px;
    z-index: 20;
    background-color: #333;
    color: white;
    border: none;
    border-radius: 50%;
    width: 40px;
    height: 40px;
    font-size: 16px;
    cursor: pointer;
    box-shadow: 0 2px 8px rgba(0,0,0,0.25);
    transition: background-color 0.2s, transform 0.2s;
    display: flex;
    justify-content: center;
    align-items: center;
}

.floating-toggle-btn:hover {
    background-color: #555;
    transform: scale(1.1);
}

/* Utility classes to control visibility */
.section-hidden {
    display: none !important;
}

.form-section.full-width {
    flex-grow: 2; /* Allows it to take up the freed space */
}

/* Responsive adjustments */
@media (max-width: 1480px) {
    .quick-nav {
        display: none;
    }
    .app-container {
        max-width: 1400px; /* Adjust container when nav is hidden */
    }
}

/* Styles for responsibility table */
.resp-primary {
    min-width: 50px;
    max-width: 50px;
}

/* Styles for floating action buttons */
.btn-logout {
    position: fixed;
    top: 20px;
    right: 30px;
    z-index: 30;
    background-color: #f44336;
    color: white;
    border: none;
    border-radius: 50%;
    width: 40px;
    height: 40px;
    font-size: 16px;
    cursor: pointer;
    box-shadow: 0 2px 8px rgba(0,0,0,0.25);
    transition: background-color 0.2s, transform 0.2s;
    display: flex;
    justify-content: center;
    align-items: center;
}

.btn-logout:hover {
    background-color: #d32f2f;
    transform: scale(1.1);
}