/**
 * Quoted Pages Modals CSS
 * 
 * Common CSS styles for modals used in the Quoted Pages plugin.
 * This file provides unified styling for modals used in:
 * - Communication Intent
 * - Page Build Stage
 * - Wrike Tasks
 */

/* Modal Overlay */
.qp-modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.5);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 10000; /* Above everything else */
    visibility: hidden;
    opacity: 0;
    transition: opacity 0.3s, visibility 0.3s;
}

.qp-modal-overlay.visible {
    visibility: visible;
    opacity: 1;
}

/* Modal Container */
.qp-modal {
    background-color: #fff;
    padding: 0;
    border-radius: 8px;
    box-shadow: 0 4px 10px rgba(0, 0, 0, 0.2);
    width: 90%;
    max-width: 500px;
    max-height: 80vh;
    overflow: hidden;
    position: relative;
    display: flex;
    flex-direction: column;
}

/* Modal Header */
.qp-modal-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 8px 15px;
    background-color: #d0d7de;
    border-bottom: 1px solid #ccc;
    position: sticky;
    top: 0;
    z-index: 10;
    flex-wrap: wrap;
}

/* Modal Header Message */
.qp-modal-header-message {
    text-align: center;
    font-size: 0.9em;
}

.qp-modal-header-message span {
    display: inline-block;
    padding: 3px 10px;
    border-radius: 12px;
    font-size: 0.8em;
    font-weight: 500;
    line-height: 1;
}

.qp-modal-header-message .success {
    color: white;
    background-color: #28a745; /* Green */
}

.qp-modal-header-message .error {
    color: white;
    background-color: #dc3545; /* Red */
}

.qp-modal-header-message .info {
    color: white;
    background-color: #17a2b8; /* Blue */
}

/* Modal Close Button */
.qp-modal-close {
    font-size: 20px;
    line-height: 1;
    cursor: pointer;
    color: #333;
    transition: color 0.2s ease;
    margin-left: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.qp-modal-close:hover {
    color: #000;
}

/* Modal Title */
.qp-modal-title {
    margin: 0;
    padding: 0 !important;
    color: #333;
    font-size: 15px;
    font-weight: 600;
    flex-grow: 1;
    line-height: 1.3;
}

/* Modal Content */
.qp-modal-content {
    padding: 0;
    overflow-y: auto;
    flex-grow: 1;
}

/* Modal Form */
.qp-modal-form {
    padding: 0;
}

.qp-modal-form .form-field {
    margin-bottom: 0;
}

.qp-modal-form textarea {
    width: 100%;
    padding: 15px;
    border: none;
    border-bottom: 1px solid #eee;
    resize: vertical;
    font-family: inherit;
    font-size: 14px;
    min-height: 120px;
    box-sizing: border-box;
    outline: none;
    display: block;
}

.qp-modal-form input[type="text"] {
    width: 100%;
    padding: 15px;
    border: none;
    border-bottom: 1px solid #eee;
    font-family: inherit;
    font-size: 14px;
    box-sizing: border-box;
    outline: none;
    display: block;
}

/* Specific styles for the Wrike sub-task title input */
#wrike-subtask-title {
    width: 100%;
    padding: 15px;
    border: none;
    border-bottom: 1px solid #eee;
    font-family: inherit;
    font-size: 14px;
    box-sizing: border-box;
    outline: none;
}

.qp-modal-form .button-container {
    text-align: right;
    padding: 10px 15px;
    background-color: #f6f8fa;
}

.qp-modal-form .save-button {
    background-color: #455afb;
    color: white;
    border: none;
    padding: 6px 12px;
    cursor: pointer;
    text-transform: uppercase;
    border-radius: 4px;
    font-size: 13px;
    font-weight: 600;
}

.qp-modal-form .save-button:hover {
    background-color: #101d2e;
}

/* Modal Message */
.qp-modal-message {
    padding: 10px 15px;
    text-align: center;
    font-size: 0.9em;
    color: #555;
    border-top: 1px solid #eee;
}

.qp-modal-message:empty {
    display: none;
}

.qp-modal-message .success {
    color: #28a745; /* Green */
}

.qp-modal-message .error {
    color: #dc3545; /* Red */
}

.qp-modal-message .info {
    color: #17a2b8; /* Blue */
}

/* Status List (for Page Build Stage) */
.qp-modal-form .status-list {
    list-style: none;
    padding: 0;
    margin: 0;
    border: 1px solid #ddd;
    border-radius: 4px;
    overflow: hidden;
}

.qp-modal-form .status-item {
    display: flex;
    align-items: center;
    padding: 8px 15px;
    border-bottom: 1px solid #ddd;
    cursor: pointer;
    transition: background-color 0.2s ease;
    font-size: 14px;
}

.qp-modal-form .status-item:last-child {
    border-bottom: none;
}

.qp-modal-form .status-item:hover {
    background-color: #f5f5f5;
}

.qp-modal-form .status-item.current {
    background-color: #e9ecef;
    font-weight: bold;
}

/* Border-left colors based on Wrike status colors */
.qp-modal-form .status-item {
    border-left-width: 4px;
    border-left-style: solid;
}

.qp-modal-form .status-item[data-color="Gray"] {
    border-left-color: rgb(128, 128, 128);
}

.qp-modal-form .status-item[data-color="Orange"] {
    border-left-color: rgb(242, 126, 2);
}

.qp-modal-form .status-item[data-color="Turquoise"] {
    border-left-color: rgb(108, 227, 236);
}

.qp-modal-form .status-item[data-color="Blue"] {
    border-left-color: rgb(79, 179, 246);
}

.qp-modal-form .status-item[data-color="DarkCyan"] {
    border-left-color: rgb(109, 212, 168);
}

.qp-modal-form .status-item[data-color="Purple"] {
    border-left-color: rgb(169, 98, 230);
}

.qp-modal-form .status-item[data-color="Yellow"] {
    border-left-color: rgb(248, 211, 75);
}

.qp-modal-form .status-item[data-color="DarkBlue"] {
    border-left-color: rgb(77, 111, 214);
}

.qp-modal-form .status-item[data-color="Green"] {
    border-left-color: rgb(46, 156, 75);
}

.qp-modal-form .status-item[data-color="YellowGreen"] {
    border-left-color: rgb(182, 163, 15);
}

.qp-modal-form .status-item[data-color="DarkRed"] {
    border-left-color: rgb(226, 75, 66);
}

.qp-modal-form .status-item[data-color="Brown"] {
    border-left-color: rgb(165, 42, 42);
}

/* User List (for Wrike Tasks) */
.wrike-assign-popup-list {
    list-style: none;
    padding: 0;
    margin: 0;
}

.wrike-assign-popup-list li {
    display: flex;
    align-items: center;
    padding: 10px;
    border-bottom: 1px solid #eee;
    cursor: pointer;
    transition: background-color 0.2s ease;
}

.wrike-assign-popup-list li:hover {
    background-color: #f0f0f0;
}

.wrike-assign-popup-list li:last-child {
    border-bottom: none;
}

.wrike-assign-popup-list li img {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    margin-right: 10px;
    object-fit: cover;
    border: 1px solid #ddd;
}

.wrike-assign-popup-list li span {
    font-weight: bold;
}

/* Communication Intent Container */
.communication-intent-container {
    border-radius: 8px;
    margin: 5px 0 !important;
    overflow: hidden;
    border: 1px solid #d0d7de !important;
    position: relative;
}

.communication-intent-container h4 {
    margin: 0;
    padding: 6px 12px !important;
    font-size: 14px;
    font-weight: 500;
    background-color: #f6f8fa;
    display: flex;
    justify-content: space-between;
    align-items: center;
    line-height: 1.2;
    border-bottom: 1px solid #ccc;
    color: #222222 !important;
}

.communication-intent-content {
    padding: 6px 12px !important;
    background-color: #fff;
    white-space: pre-line;
    line-height: 1.4;
}

.communication-intent-edit,
.communication-intent-add {
    display: inline-block;
    color: #455afb;
    text-decoration: none;
    font-size: 14px;
}

.communication-intent-edit {
    display: inline-flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    width: 24px;
    height: 24px;
    margin-left: 10px;
    color: #455afb;
    cursor: pointer;
}

.communication-intent-edit::before {
    content: '\22EE'; /* Vertical ellipsis character */
    font-size: 18px;
    line-height: 1;
    font-weight: bold;
}

.communication-intent-add {
    font-size: 18px;
    font-weight: bold;
    margin-left: auto;
    color: #455afb;
}

.communication-intent-container.empty {
    min-height: 40px;
}

.communication-intent-container.empty h4 {
    display: flex;
    justify-content: space-between;
    align-items: center;
    height: 100%;
}

.communication-intent-placeholder {
    padding: 12px 15px !important;
    background-color: #fff;
    color: #999;
    font-style: italic;
    line-height: 1.4;
}

/* Wrike Tasks Table Styles */
.wrike-tasks-container {
    max-width: 100%;
    overflow-x: auto;
    margin: 0 !important;
}

.wrike-task-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 6px 15px !important;
    border: solid 1px #d0d7de;
    background-color: #d0d7de;
    font-size: 14px;
}

.wrike-header-item {
    text-align: left;
}

.wrike-header-item.task-col { flex: 4; min-width: 150px; }
.wrike-header-item.assignee-col { flex: 1; min-width: 80px; }
.wrike-header-item.status-col { flex: 1; min-width: 80px; text-align: center; }

.wrike-task-list {
    list-style: none;
    padding: 0 !important;
    margin: 0;
    max-height: 111px; /* Approximately 3 rows  */
    overflow-y: auto;
    border: 1px solid #eee;
    border-top: none;
}

.wrike-task-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    border-bottom: 1px solid #eee;
    padding: 5px 15px !important;
    background-color: #fff;
    flex-wrap: nowrap;
    transition: background-color 0.2s ease; /* Added for hover effect */
}

.wrike-task-item:hover { /* Hover indicator */
    background-color: #f5f5f5;
}

.wrike-task-item:last-child {
    border-bottom: none; /* No border for the last item */
}

.wrike-item-col.task-title {
    flex: 4;
    min-width: 150px;
    text-align: left;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.wrike-item-col.assignee-avatars-wrapper {
    flex: 1;
    display: flex;
    align-items: center; /* Ensures vertical alignment */
    justify-content: flex-start;
}

.assignee-avatar-wrapper {
    position: relative; /* Needed for positioning the tooltip */
    display: inline-block; /* Allows side-by-side stacking and relative positioning */
    margin-right: -8px !important; /* For stacking effect */
    z-index: 1; /* Base z-index, will be overridden inline for stacking order */
}

.assignee-avatar-img {
    width: 24px;
    height: 24px;
    border-radius: 50%;
    border: 1px solid #ddd;
    object-fit: cover;
    cursor: default; /* Not clickable for popup */
}

img.assignee-avatar-img {
    display: block;
}

.tooltip-text {
    visibility: hidden;
    opacity: 0;
    width: max-content; /* Adjust width to content */
    background-color: #333;
    color: #fff !important;
    text-align: center;
    border-radius: 4px;
    padding: 6px 8px !important;
    position: absolute;
    z-index: 1000; /* Ensure tooltip is on top */
    left: 100%; /* Position to the right of the avatar */
    top: 50%; /* Vertically center */
    transform: translateY(-50%); /* Adjust for vertical centering */
    margin-left: 10px; /* Small gap from avatar */
    transition: opacity 0.3s, visibility 0.3s;
    white-space: nowrap; /* Prevent text wrapping */
    font-size: 0.8em;
    pointer-events: none; /* Allow interaction with elements below tooltip */
    line-height: 1;
}

.tooltip-text::after {
    content: "";
    position: absolute;
    top: 50%; /* Vertically center the arrow */
    right: 100%; /* Position at the left edge of the tooltip */
    margin-top: -5px; /* Adjust for vertical centering of arrow */
    border-width: 5px;
    border-style: solid;
    border-color: transparent #333 transparent transparent; /* Pointing left */
}

.assignee-avatar-wrapper:hover .tooltip-text {
    visibility: visible;
    opacity: 1;
}

.assignee-not-assigned {
    color: #666;
    font-size: 0.7em;
}

.wrike-add-assignee-button {
    width: 24px;
    height: 24px;
    border-radius: 50%;
    color: #fff;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.2em;
    font-weight: bold;
    cursor: pointer;
    margin-left: 5px; /* Space between last avatar and button */
    transition: background-color 0.2s ease;
    flex-shrink: 0; /* Prevent it from shrinking */
    background-color: #d0d7de;
}

.wrike-add-assignee-button:hover {
    background-color: #455afb;
    color: white !important;
}

.wrike-item-col.status-display {
    flex: 1;
    text-align: center;
    font-size: 0.9em;
    display: inline-block;
    padding: .2em 1em;
    border-radius: 20px;
    cursor: pointer;
    transition: all 0.3s ease;
    position: relative;
}

.wrike-item-col.status-display:hover {
    box-shadow: 0 0 5px rgba(0, 0, 0, 0.3);
    transform: translateY(-1px);
}


.wrike-task-footer {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 5px 15px !important;
    border: solid 1px #d0d7de;
    background-color: #d0d7de;
    font-size: 14px;
}

.wrike-task-footer p {
    margin: 0;
}

/* Wrike Task Toggle Container */
.wrike-task-toggle-container {
    display: flex;
    justify-content: space-between;
    align-items: center;
    width: 100%;
}

/* Wrike Footer Sections */
.wrike-footer-left {
    display: flex;
    align-items: center;
}

.wrike-footer-center {
    display: flex;
    justify-content: center;
    flex: 1;
}

.wrike-footer-right {
    display: flex;
    justify-content: flex-end;
}

/* Wrike Task Toggle Pill */
.wrike-task-toggle-pill {
    display: flex;
    background-color: #f0f0f0;
    border-radius: 20px;
    overflow: hidden;
    font-size: 14px;
    cursor: pointer;
    border: 1px solid #ddd !important;
}

/* Wrike Task Toggle Options */
.wrike-task-toggle-option {
    padding: 4px 12px !important;
    transition: background-color 0.3s, color 0.3s;
    user-select: none;
    font-weight: 500;
}

/* Active state for the toggle option */
.wrike-task-toggle-option.active {
    background-color: #003D43;
    color: white !important;
}

/* Hover state for the toggle option */
.wrike-task-toggle-option:not(.active):hover {
    background-color: #e0e0e0;
}

/* Wrike View Button */
/* Wrike Add Sub Task Button */
.wrike-add-subtask-button {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 24px;
    height: 24px;
    border-radius: 50%;
    background-color: #003D43;
    color: white !important;
    margin-left: 8px !important;
    cursor: pointer;
    transition: background-color 0.3s ease, transform 0.3s ease;
}

.wrike-add-subtask-button:hover {
    background-color: #00C762;
}

.wrike-add-subtask-button svg {
    width: 14px;
    height: 14px;
    fill: currentColor;
}

/* Wrike Refresh Button */
.wrike-refresh-button {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 24px;
    height: 24px;
    border-radius: 50%;
    background-color: #003D43;
    color: white !important;
    margin-right: 8px;
    cursor: pointer;
    transition: background-color 0.3s ease, transform 0.3s ease;
}

.wrike-refresh-button:hover {
    background-color: #00C762;
}

.wrike-refresh-button svg {
    width: 14px;
    height: 14px;
    fill: currentColor;
}

.wrike-refresh-button.spinning svg {
    animation: spin 1s linear infinite;
}

.wrike-refresh-button.error {
    background-color: #dc3545; /* Red */
}

.wrike-refresh-button.success {
    background-color: #28a745; /* Green */
}

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

.wrike-view-button {
    display: flex;
    align-items: center;
    background-color: #003D43;
    color: white !important;
    padding: 4px 12px !important;
    border-radius: 4px;
    text-decoration: none;
    font-size: 12px;
    text-transform: uppercase;
    transition: background-color 0.3s ease;
}

.wrike-view-button:hover {
    background-color: #00C762;
}

.wrike-logo {
    margin-left: 8px;
    fill: currentColor;
}

.wrike-button {
    display: flex;
    align-items: center;
    border-radius: 4px;
    padding: 4px 12px !important;
    text-decoration: none;
    border: none;
    cursor: pointer;
    transition: background-color 0.3s ease;
    color: #fff; /* Default text color for the button */
}

.wrike-button:hover {
    opacity: 0.9;
}

.wrike-button .task-count-text {
    font-size: 10px;
    padding: 0 5px !important;
    text-transform: capitalize;
}

.wrike-button svg {
    width: 16px;
    height: 16px;
    margin-left: 8px;
    fill: currentColor; /* Inherit color from parent for SVG */
}
.wrike-view-button svg.wrike-logo {
    width: 24px;
    height: 24px;
}

.wrike-button.has-active-tasks {
    color: white !important;
    background-color: #003D43; /* Dark green */
}

.wrike-button.no-active-tasks {
    background-color: #00C762; /* Bright green */
    color: white !important;
}

/* Status colors for task items based on Wrike status colors */
.task-status-new .status-display {
    background-color: rgb(128, 128, 128); /* Gray */
    color: white !important;
}

.task-status-assigned .status-display {
    background-color: rgb(242, 126, 2); /* Orange */
    color: white !important;
}

.task-status-need-info .status-display {
    background-color: rgb(242, 126, 2); /* Orange */
    color: white !important;
}

.task-status-creative-block .status-display {
    background-color: rgb(242, 126, 2); /* Orange */
    color: white !important;
}

.task-status-answered .status-display {
    background-color: rgb(108, 227, 236); /* Turquoise */
    color: black !important;
}

.task-status-in-progress .status-display {
    background-color: rgb(79, 179, 246); /* Blue */
    color: white !important;
}

.task-status-approved .status-display {
    background-color: rgb(109, 212, 168); /* DarkCyan */
    color: white !important;
}

.task-status-for-discussion .status-display {
    background-color: rgb(169, 98, 230); /* Purple */
    color: white !important;
}

.task-status-awaiting-client-info .status-display {
    background-color: rgb(248, 211, 75); /* Yellow */
    color: black !important;
}

.task-status-for-review .status-display {
    background-color: rgb(77, 111, 214); /* DarkBlue */
    color: white !important;
}

.task-status-completed .status-display {
    background-color: rgb(46, 156, 75); /* Green */
    color: white !important;
}

.task-status-not-applicable .status-display {
    background-color: rgb(182, 163, 15); /* YellowGreen */
    color: white !important;
}

.task-status-completed-with-info-attached .status-display {
    background-color: rgb(182, 163, 15); /* YellowGreen */
    color: white !important;
}

.task-status-to-invoice .status-display {
    background-color: rgb(77, 111, 214); /* DarkBlue */
    color: white !important;
}

.task-status-completed-invoiced .status-display {
    background-color: rgb(182, 163, 15); /* YellowGreen */
    color: white !important;
}

.task-status-client-info .status-display {
    background-color: rgb(248, 211, 75); /* Yellow */
    color: black !important;
}

.task-status-on-hold .status-display {
    background-color: rgb(169, 98, 230); /* Purple */
    color: white !important;
}

.task-status-cancelled .status-display {
    background-color: rgb(226, 75, 66); /* DarkRed */
    color: white !important;
}

.task-status-rock .status-display {
    background-color: rgb(165, 42, 42); /* Brown */
    color: white !important;
}

span.tasks-progress {
    font-size: 0.8em;
    padding: .2em 1em !important;
    background: #000;
    color: white !important;
    border-radius: 20px;
}

span.tasks-progress.tasks-complete {
    background-color: #00C762; /* Bright green */
}
