/* public/styles.css */

:root {
    /* Light Theme (Default) */
    --bg-body: #f0f2f5;
    --bg-card: #ffffff;
    --bg-header: #343a40;
    --bg-hover: #f8f9fa;
    --text-main: #333333;
    --text-muted: #666666;
    --text-header: #ffffff;
    --border-color: #dee2e6;
    --input-bg: #ffffff;
    --shadow: rgba(0, 0, 0, 0.1);

    /* Status Colors */
    --success: #28a745;
    --danger: #dc3545;
    --warning: #ffc107;
    --info: #17a2b8;
    --primary: #007bff;
}

/* Dark Mode Overrides */
body.dark-mode {
    --bg-body: #121212;
    --bg-card: #1e1e1e;
    --bg-header: #2c2c2c;
    --bg-hover: #2a2a2a;
    --text-main: #e0e0e0;
    --text-muted: #b0b0b0;
    --text-header: #e0e0e0;
    --border-color: #444444;
    --input-bg: #2d2d2d;
    --shadow: rgba(0, 0, 0, 0.5);
}

body.dark-mode::before {
    content: "";
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.7);
    z-index: -1;
    pointer-events: none;
}

body {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    padding: 20px;
    max-width: 900px;
    margin: 0 auto;
    background-color: var(--bg-body);
    color: var(--text-main);
    background-repeat: no-repeat;
    background-position: center center;
    background-size: cover;
    background-attachment: fixed;
    min-height: 100vh;
    transition: background-color 0.3s, color 0.3s;
}

h1,
h2,
h3,
h4,
h5,
h6 {
    color: var(--text-main);
}

#controls {
    margin-bottom: 20px;
}

button {
    padding: 12px 24px;
    font-size: 16px;
    font-weight: bold;
    color: white;
    border: none;
    cursor: pointer;
    border-radius: 6px;
    transition: background-color 0.2s, transform 0.1s;
    margin-right: 10px;
    margin-bottom: 10px;
    /* Global button gap */
}

/* Specific Buttons */
#sendEmailsBtn {
    background-color: var(--primary);
}

#sendEmailsBtn:hover {
    background-color: #0056b3;
}

#sendEmailsBtn:disabled {
    background-color: #ccc;
    cursor: not-allowed;
}

#viewBtn {
    background-color: var(--success);
}

#viewBtn:hover {
    background-color: #218838;
}

#terminal {
    background-color: #1e1e1e;
    color: #d4d4d4;
    border-radius: 6px;
    padding: 15px;
    height: 300px;
    overflow-y: auto;
    font-family: 'Consolas', 'Monaco', 'Courier New', monospace;
    font-size: 14px;
    line-height: 1.4;
    white-space: pre-wrap;
    box-shadow: 0 4px 6px var(--shadow);
    margin-top: 30px;
}

#progressContainer {
    display: none;
    margin-bottom: 20px;
    background-color: var(--border-color);
    border-radius: 6px;
    overflow: hidden;
    height: 30px;
    border: 1px solid var(--border-color);
    box-shadow: inset 0 1px 2px var(--shadow);
}

#progressBar {
    width: 0%;
    height: 100%;
    background-color: var(--info);
    text-align: center;
    line-height: 30px;
    color: white;
    font-weight: bold;
    font-size: 14px;
    transition: width 0.3s ease;
}

/* Table Styling */
#tableContainer,
.card,
.service-card {
    margin-top: 20px;
    background: var(--bg-card);
    padding: 20px;
    border-radius: 8px;
    box-shadow: 0 2px 4px var(--shadow);
}

#tableContainer {
    display: none;
}

table {
    width: 100%;
    border-collapse: collapse;
    font-size: 15px;
    background-color: var(--bg-card);
    color: var(--text-main);
}

th,
td {
    border: 1px solid var(--border-color);
    padding: 12px;
    text-align: left;
    vertical-align: middle;
}

th {
    background-color: var(--bg-header);
    color: var(--text-header);
    font-weight: bold;
}

th.sortable {
    cursor: pointer;
    user-select: none;
    position: relative;
}

th.sortable:hover {
    background-color: #454d55;
}

.row-even {
    background-color: var(--bg-card);
}

.row-odd {
    background-color: var(--bg-body);
}

.member-cell {
    vertical-align: top;
    font-weight: 600;
}

.merged-cell {
    border-top: none;
    border-bottom: none;
}

.skill-cell {
    color: var(--text-main);
}

.date-cell {
    color: var(--text-muted);
    white-space: nowrap;
}

.no-skill {
    color: var(--success);
    font-style: italic;
}

.email-label {
    display: flex;
    align-items: center;
    cursor: pointer;
    font-weight: normal;
    font-size: 14px;
    color: var(--text-main);
}

.email-label input,
.header-checkbox-label input {
    margin-right: 8px;
    width: 16px;
    height: 16px;
    background-color: var(--input-bg);
    border: 1px solid var(--border-color);
}

.header-checkbox-label {
    display: flex;
    align-items: center;
    cursor: pointer;
    color: var(--text-header);
}

/* Global Floating Back Button (TOP LEFT) */
.back-btn {
    position: fixed;
    top: 20px;
    left: 20px;
    /* Left aligned */
    z-index: 2000;
    text-decoration: none;
    color: #fff;
    background-color: #343a40;
    width: 45px;
    height: 45px;
    border-radius: 50%;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 4px 6px rgba(0, 0, 0, 0.3);
    transition: all 0.2s ease;
}

.back-btn:hover {
    background-color: #23272b;
    transform: translateY(-2px);
    box-shadow: 0 6px 8px rgba(0, 0, 0, 0.4);
}

#scrollTopBtn {
    position: fixed;
    bottom: 20px;
    right: 20px;
    z-index: 1000;
    font-size: 18px;
    border: none;
    outline: none;
    background-color: var(--bg-header);
    color: white;
    cursor: pointer;
    padding: 10px;
    border-radius: 50%;
    width: 45px;
    height: 45px;
    display: none;
    align-items: center;
    justify-content: center;
    box-shadow: 0 4px 6px var(--shadow);
    transition: all 0.3s;
}

#scrollTopBtn:hover {
    background-color: #23272b;
    transform: translateY(-3px);
}

/* Modals */
.modal {
    display: none;
    position: fixed;
    z-index: 1000;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    overflow: auto;
    background-color: rgba(0, 0, 0, 0.4);
}

.modal-content {
    background-color: var(--bg-card);
    color: var(--text-main);
    margin: 10% auto;
    padding: 20px;
    border: 1px solid var(--border-color);
    width: 80%;
    max-width: 500px;
    border-radius: 8px;
    box-shadow: 0 4px 8px var(--shadow);
    position: relative;
    max-height: 80vh;
    overflow-y: auto;
}

.close-btn {
    color: var(--text-muted);
    float: right;
    font-size: 28px;
    font-weight: bold;
    cursor: pointer;
    position: absolute;
    top: 10px;
    right: 15px;
}

.close-btn:hover {
    color: var(--text-main);
}

input[type="text"],
input[type="password"],
input[type="email"],
input[type="number"],
select,
textarea {
    background-color: var(--input-bg);
    color: var(--text-main);
    border: 1px solid var(--border-color);
    border-radius: 4px;
    padding: 8px;
}

/* Profile Menu */
.profile-menu {
    position: absolute;
    top: 20px;
    left: 20px;
    z-index: 100;
}

.profile-btn {
    background-color: var(--bg-card);
    color: var(--text-main);
    padding: 10px 16px;
    font-size: 16px;
    border: 1px solid var(--border-color);
    cursor: pointer;
    border-radius: 20px;
    display: flex;
    align-items: center;
    gap: 8px;
    box-shadow: 0 2px 5px var(--shadow);
    transition: all 0.2s;
}

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

/* --- HEADER MENU (DROPDOWN) --- */
.header-menu {
    position: relative;
    /* Flows with content */
    display: inline-block;
    z-index: 100;
}

.menu-btn {
    background-color: #343a40;
    color: white;
    padding: 10px 16px;
    font-size: 16px;
    border: none;
    cursor: pointer;
    border-radius: 4px;
    display: flex;
    align-items: center;
    gap: 8px;
    box-shadow: 0 2px 5px rgba(0, 0, 0, 0.2);
    transition: background-color 0.2s;

    /* FIX: Remove bottom margin so menu attaches */
    margin-bottom: 0 !important;
    border-bottom-left-radius: 0;
    border-bottom-right-radius: 0;
}

.menu-btn:hover {
    background-color: #23272b;
}

.dropdown-content {
    display: none;
    position: absolute;
    right: 0;
    /* Anchor to bottom of button */
    top: 100%;
    margin-top: 0;
    /* Remove gap */

    background-color: #f9f9f9;
    /* Force Light Background */
    color: #333333;
    /* Force Dark Text */

    min-width: 180px;
    box-shadow: 0 8px 16px 0 rgba(0, 0, 0, 0.2);
    border-radius: 4px;
    border-top-right-radius: 0;
    border-top-left-radius: 0;
    z-index: 1000;
    border: 1px solid #ddd;
    border-top: none;

    /* FIX: Allow submenus to fly out */
    overflow: visible;
}

.dropdown-content a {
    color: #333;
    /* Explicit dark color */
    padding: 12px 16px;
    text-decoration: none;
    display: block;
    text-align: left;
    transition: background-color 0.2s;
}

.dropdown-content a:hover {
    background-color: #f1f1f1;
    color: #007bff;
}

.show {
    display: block;
}

.profile-dropdown {
    left: 0;
    right: auto;
    min-width: 160px;
}

.logout {
    color: #dc3545 !important;
    border-top: 1px solid #eee;
}

.logout:hover {
    background-color: #ffe6e6 !important;
    color: #bd2130 !important;
}

/* --- SUBMENU STYLES --- */
.dropdown-submenu {
    position: relative;
}

.dropdown-submenu>a::after {
    content: "◀";
    /* Left arrow indicates flyout to left */
    float: right;
    margin-right: 0;
    font-size: 10px;
    opacity: 0.5;
    margin-top: 4px;
}

.dropdown-submenu .submenu-content {
    display: none;
    position: absolute;
    /* Fly out to the LEFT of the main menu */
    top: 0;
    right: 100%;

    margin-top: -1px;
    /* Align borders */

    background-color: #f9f9f9;
    /* Force Light Background */
    color: #333;
    /* Force Dark Text */

    min-width: 200px;
    box-shadow: 0 8px 16px 0 var(--shadow);
    border-radius: 4px;
    border: 1px solid var(--border-color);
    z-index: 20;
}

.dropdown-submenu:hover>.submenu-content {
    display: block;
}

/* Action Bar */
.action-bar {
    background-color: var(--bg-card);
    padding: 15px 20px;
    border-radius: 8px;
    box-shadow: 0 2px 5px var(--shadow);
    margin-bottom: 20px;
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 15px;
    border: 1px solid var(--border-color);
}

.action-group {
    display: flex;
    align-items: center;
    gap: 10px;
}

.days-wrapper {
    display: flex;
    align-items: center;
    background-color: var(--bg-body);
    padding: 5px 10px;
    border-radius: 4px;
    border: 1px solid var(--border-color);
}

.days-wrapper input {
    width: 60px;
    text-align: center;
}

/* Filter Chips */
.type-toggles {
    display: flex;
    gap: 8px;
}

.type-badge {
    padding: 6px 12px;
    border-radius: 15px;
    font-size: 13px;
    cursor: pointer;
    border: 1px solid var(--border-color);
    background: var(--bg-hover);
    color: var(--text-muted);
    user-select: none;
}

.type-badge.active {
    background-color: var(--bg-header);
    color: white;
    border-color: var(--bg-header);
}

.type-badge.expired-filter.active {
    background-color: #dc3545;
    border-color: #dc3545;
}

/* Demo Banner */
.demo-banner {
    background-color: var(--warning);
    color: #333;
    font-weight: bold;
    text-align: center;
    padding: 12px;
    margin: -20px -20px 20px -20px;
    border-bottom: 1px solid #e0a800;
    display: none;
    font-size: 14px;
    position: relative;
    z-index: 50;
}

/* --- HEADER ROW LAYOUT (Title + Menu + Logo) --- */
.header-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 20px;
    margin-top: 10px;
    padding-left: 60px;
    /* Space for Profile Button */
    position: relative;
    gap: 15px;
}

#headerLogo {
    height: 50px;
    width: auto;
    margin-right: 15px;
}

#mainHeader {
    margin: 0;
    font-size: 2rem;
    flex-grow: 1;
    text-align: center;
    /* Adjust padding to balance logo and menu roughly */
    padding-right: 60px;
}

/* --- GLOBAL HELP SYSTEM REPAIR --- */
#globalHelpBtn {
    position: fixed;
    top: 20px;
    right: 20px;
    z-index: 2000;
    width: 45px;
    height: 45px;
    border-radius: 50%;
    background-color: var(--info);
    color: white;
    border: none;
    cursor: pointer;
    box-shadow: 0 4px 6px rgba(0, 0, 0, 0.3);
    display: flex;
    align-items: center;
    justify-content: center;
    transition: transform 0.2s, background-color 0.2s;
    margin: 0;
    padding: 0;
}

#globalHelpBtn:hover {
    background-color: #138496;
    transform: scale(1.1);
}

.help-modal-overlay {
    display: none;
    position: fixed;
    z-index: 3000;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.5);
    opacity: 0;
    transition: opacity 0.3s ease;
}

.help-modal-overlay.show {
    display: block;
    opacity: 1;
}

.help-modal-content {
    background-color: var(--bg-card);
    color: var(--text-main);
    margin: 10vh auto;
    padding: 25px;
    border: 1px solid var(--border-color);
    width: 90%;
    max-width: 500px;
    border-radius: 8px;
    box-shadow: 0 5px 15px rgba(0, 0, 0, 0.3);
    position: relative;
    animation: slideDown 0.3s ease-out;
    max-height: 80vh;
    overflow-y: auto;
}

.help-close-btn {
    color: var(--text-muted);
    float: right;
    font-size: 28px;
    font-weight: bold;
    cursor: pointer;
    line-height: 20px;
}

.help-close-btn:hover {
    color: var(--text-main);
}

.help-body {
    line-height: 1.6;
    color: var(--text-main);
}

.help-body ul,
.help-body ol {
    padding-left: 20px;
    margin-top: 10px;
}

.help-body li {
    margin-bottom: 8px;
}

@keyframes slideDown {
    from {
        transform: translateY(-50px);
        opacity: 0;
    }

    to {
        transform: translateY(0);
        opacity: 1;
    }
}

/* Mobile Responsiveness */
@media screen and (max-width: 768px) {

    /* Header Stack */
    .header-row {
        flex-direction: column;
        padding-left: 0;
        margin-top: 60px;
        /* Clear profile button */
        gap: 15px;
    }

    #mainHeader {
        margin: 0;
        padding-right: 0;
        text-align: center;
        font-size: 1.5rem;
    }

    .header-menu {
        width: 100%;
    }

    .menu-btn {
        width: 100%;
        justify-content: center;
    }

    .dropdown-content {
        width: 100%;
    }

    #headerLogo {
        margin-right: 0;
        height: 60px;
    }

    /* Slightly larger on mobile stack */

    /* Stack action bar */
    .action-bar,
    .action-group {
        flex-direction: column;
        align-items: stretch;
    }

    #controls button,
    #controls div {
        margin-right: 0;
        width: 100%;
        margin-bottom: 10px;
    }

    #daysInput {
        width: 100% !important;
    }

    /* Tables Card View */
    table,
    thead,
    tbody,
    th,
    td,
    tr {
        display: block;
    }

    thead tr {
        position: absolute;
        top: -9999px;
        left: -9999px;
    }

    tr {
        margin-bottom: 15px;
        box-shadow: 0 2px 4px var(--shadow);
    }

    td {
        border: none;
        border-bottom: 1px solid var(--border-color);
        position: relative;
        padding-left: 45%;
        text-align: right;
        min-height: 40px;
        display: flex;
        align-items: center;
        justify-content: flex-end;
        gap: 10px;
    }

    td:last-child {
        border-bottom: none;
    }

    td::before {
        position: absolute;
        left: 15px;
        width: 40%;
        font-weight: bold;
        text-align: left;
        color: var(--text-muted);
        content: attr(data-label);
    }

    #skillsTable td:nth-of-type(1)::before {
        content: "Member";
    }

    #skillsTable td:nth-of-type(2)::before {
        content: "Skill";
    }

    #skillsTable td:nth-of-type(3)::before {
        content: "Due Date";
    }

    #skillsTable td:nth-of-type(4)::before {
        content: "Actions";
    }

    .dropdown-submenu .submenu-content {
        position: static;
        box-shadow: none;
        border: none;
        border-left: 2px solid var(--border-color);
        margin-left: 10px;
    }

    .dropdown-submenu>a::after {
        content: "▼";
        float: right;
    }

    .profile-menu {
        top: 15px;
        left: 15px;
    }
}

/* --- TOAST NOTIFICATIONS --- */
#toast-container {
    position: fixed;
    top: 20px;
    right: 20px;
    z-index: 9999;
}

.toast {
    background-color: var(--bg-header);
    /* Use header dark grey */
    color: #fff;
    padding: 15px 20px;
    border-radius: 4px;
    margin-bottom: 10px;
    opacity: 0;
    transform: translateY(-10px);
    transition: all 0.3s ease-in-out;
    display: flex;
    align-items: center;
    gap: 12px;
    min-width: 280px;
    box-shadow: 0 4px 10px rgba(0, 0, 0, 0.3);
}

.toast.show {
    opacity: 1;
    transform: translateY(0);
}

.toast-message {
    flex-grow: 1;
    font-size: 14px;
}

.toast-close {
    cursor: pointer;
    font-size: 20px;
    opacity: 0.7;
    line-height: 1;
}

.toast-close:hover {
    opacity: 1;
}

.toast-success {
    border-left: 5px solid #28a745;
}

.toast-error {
    border-left: 5px solid #dc3545;
}

.toast-info {
    border-left: 5px solid #17a2b8;
}

.toast-warning {
    border-left: 5px solid #ffc107;
}

/* [NEW] Status Circles for Dashboard */
.status-circle {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 24px;
    height: 24px;
    border-radius: 50%;
    margin-left: 6px;
    vertical-align: middle;
    transition: transform 0.2s ease;
}

.status-circle:hover {
    transform: scale(1.1);
}

.status-circle.sent {
    background-color: #e7f5ff;
    /* Light Blue/Teal bg */
    border: 1px solid #17a2b8;
    color: #17a2b8;
}

.status-circle.submitted {
    background-color: #e6ffed;
    /* Light Green bg */
    border: 1px solid #28a745;
    color: #28a745;
}

/* Remove link underlines if the circle is inside an anchor */
a .status-circle {
    text-decoration: none;
}

/* [NEW] Skeleton Loading Animation */
.skeleton {
    background: #f0f2f5;
    background: linear-gradient(to right, #eff1f3 8%, #e2e2e2 18%, #eff1f3 33%);
    background-size: 800px 104px;
    animation: shimmer 1.5s infinite linear;
    color: transparent !important;
    border-radius: 4px;
    display: inline-block;
    height: 16px;
    width: 100%;
}

@keyframes shimmer {
    0% {
        background-position: -468px 0;
    }

    100% {
        background-position: 468px 0;
    }
}

/* [NEW] Empty State Styling */
.empty-state-row td {
    text-align: center;
    padding: 40px;
    background-color: var(--bg-card);
}

.empty-state-content {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    color: var(--text-muted);
}

.empty-state-content h3 {
    margin: 10px 0 5px 0;
    color: var(--text-main);
}

.empty-state-content p {
    margin: 0;
    font-size: 0.9em;
}

.notification-wrapper {
    position: relative;
    display: inline-block;
    margin-right: 10px;
    /* Gap between bell and menu */
}

.notification-btn {
    background-color: #343a40;
    color: white;
    width: 44px;
    /* Fixed width for square shape */
    height: 44px;
    /* Matches standard button height roughly */
    border-radius: 4px;
    display: flex;
    align-items: center;
    justify-content: center;
    text-decoration: none;
    position: relative;
    /* Anchor for badges */
    box-shadow: 0 2px 5px rgba(0, 0, 0, 0.2);
    transition: background-color 0.2s;
}

.notification-btn:hover {
    background-color: #23272b;
    color: #fff;
}

.notif-badge {
    position: absolute;
    color: white;
    border-radius: 50%;
    width: 20px;
    height: 20px;
    font-size: 11px;
    font-weight: bold;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.2);
    border: 1px solid #fff;
    /* Slight border to separate from button */
}

/* Bottom-Left: Sent Status */
.badge-sent {
    background-color: #a19f2e;
    bottom: -6px;
    left: -6px;
    z-index: 10;
}

/* Bottom-Right: Submitted Status */
.badge-submitted {
    background-color: #007bff;
    bottom: -6px;
    right: -6px;
    z-index: 10;
}

/* Mobile Adjustment to keep header aligned */
@media screen and (max-width: 768px) {
    .notification-wrapper {
        margin-right: 0;
        margin-bottom: 10px;
        /* Stack on mobile if needed, or keep inline */
    }
}

.btn-icon svg {
    display: block;
    width: 18px;
    height: 18px;
}

input[type="text"],
input[type="password"],
input[type="email"],
input[type="number"],
select,
textarea {
    background-color: var(--input-bg);
    color: var(--text-main);
    border: 1px solid var(--border-color);
    border-radius: 4px;
    padding: 10px;
    /* Ensure consistent internal padding */
    box-sizing: border-box;
    /* [FIX] Ensures width:100% includes padding/border */
}

* {
    box-sizing: border-box;
    /* Ensures padding doesn't break layout width */
}

.status-circle.accepted {
    background-color: #e6ffed;
    border: 1px solid #28a745;
    color: #28a745;
}

.status-circle.submitted {
    background-color: #e8f0fe;
}

.status-circle.rejected {
    background-color: #fff5f5;
    /* Very light red */
    border: 1px solid var(--danger);
    color: var(--danger);
}

/* Ensure consistent hover behavior */
.status-circle.rejected:hover {
    background-color: #ffdada;
    transform: scale(1.1);
}

/* --- AI & PROCESSING OVERLAYS --- */
.processing-overlay {
    display: none;
    /* Hidden by default */
    position: fixed;
    z-index: 9999;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(255, 255, 255, 0.9);
    text-align: center;
    flex-direction: column;
    align-items: center;
    justify-content: center;
}

/* --- Loading Spinner --- */
.spinner-large {
    width: 60px;
    height: 60px;
    border: 6px solid rgba(0, 123, 255, 0.1);
    border-top: 6px solid var(--primary); /* Uses your theme blue */
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

/* Ensure overlay displays correctly in the flex container */
#loadingOverlay {
    display: none;
    text-align: center;
}

.ai-feedback-box {
    margin-top: 15px;
    padding: 15px;
    background-color: #f0f7ff;
    border: 1px solid #cce5ff;
    border-radius: 6px;
    color: #004085;
    font-size: 0.95em;
    animation: fadeIn 0.5s ease-out;
}

.ai-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 8px;
    font-weight: bold;
    color: var(--primary);
    border-bottom: 1px solid rgba(0, 0, 0, 0.05);
    padding-bottom: 5px;
}

.ai-score-badge {
    background-color: var(--primary);
    color: white;
    padding: 2px 8px;
    border-radius: 12px;
    font-size: 0.85em;
}