/* Modal Styles */
.modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.5);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
}

.modal-content {
    background: white;
    border-radius: 12px;
    width: 90%;
    max-width: 800px;
    max-height: 90vh;
    overflow: hidden;
    box-shadow: 0 20px 25px -5px rgba(0, 0, 0, 0.1);
}

.modal-header {
    padding: 1.5rem;
    border-bottom: 1px solid #e2e8f0;
    display: flex;
    justify-content: space-between;
    align-items: center;
    background: #f8fafc;
}

.modal-header h3 {
    margin: 0;
    color: #334155;
    font-size: 1.25rem;
}

.modal-body {
    padding: 1.5rem;
    max-height: 60vh;
    overflow-y: auto;
}

.option-group {
    margin-bottom: 1.5rem;
}

.option-row {
    display: flex;
    gap: 1.5rem;
    margin-bottom: 1.5rem;
}

.option-row .option-group {
    flex: 1;
    margin-bottom: 0;
}

.option-label {
    display: block;
    font-size: 0.95rem;
    font-weight: 600;
    color: #374151;
    margin-bottom: 0.5rem;
}

.modal-input,
.modal-select {
    width: 100%;
    padding: 0.6rem 0.75rem;
    border: 2px solid #e2e8f0;
    border-radius: 6px;
    font-size: 0.95rem;
    background: white;
}

.modal-input:focus,
.modal-select:focus {
    outline: none;
    border-color: #4f46e5;
    box-shadow: 0 0 0 3px rgba(79, 70, 229, 0.1);
}

/* Custom Checkboxes */
.checkbox-label {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    cursor: pointer;
    font-size: 0.95rem;
    font-weight: 500;
    color: #374151;
}

.checkbox-label input[type="checkbox"] {
    display: none;
}

.checkbox-custom {
    width: 20px;
    height: 20px;
    border: 2px solid #e2e8f0;
    border-radius: 4px;
    background: white;
    position: relative;
    transition: all 0.2s ease;
}

.checkbox-label input[type="checkbox"]:checked+.checkbox-custom {
    background: #4f46e5;
    border-color: #4f46e5;
}

.checkbox-label input[type="checkbox"]:checked+.checkbox-custom::after {
    content: '✓';
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    color: white;
    font-size: 12px;
    font-weight: bold;
}

.date-controls {
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.date-controls .modal-input {
    flex: 1;
}

.date-separator {
    font-weight: 500;
    color: #64748b;
}

/* Status Toggles in Modal */
.status-toggles {
    display: flex;
    gap: 0.75rem;
    flex-wrap: wrap;
}

.status-toggle {
    padding: 0.6rem 1rem;
    border: 2px solid #e2e8f0;
    border-radius: 8px;
    background: white;
    font-size: 0.9rem;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s ease;
    color: #64748b;
}

.status-toggle:hover {
    border-color: #cbd5e1;
    background: #f8fafc;
}

.status-toggle.active {
    background: #4f46e5;
    border-color: #4f46e5;
    color: white;
}

.modal-footer {
    padding: 1.5rem;
    border-top: 1px solid #e2e8f0;
    display: flex;
    gap: 1rem;
    justify-content: flex-end;
    background: #f8fafc;
}

/* Right side drawer used by overdue comments */
.side-drawer-overlay {
    position: fixed;
    inset: 0;
    background: rgba(15, 23, 42, 0.35);
    z-index: 1190;
}

.side-drawer {
    position: fixed;
    top: 0;
    right: 0;
    width: min(460px, 100vw);
    height: 100vh;
    background: #ffffff;
    box-shadow: -10px 0 30px rgba(15, 23, 42, 0.2);
    transform: translateX(100%);
    transition: transform 0.2s ease-in-out;
    z-index: 1200;
    display: flex;
    flex-direction: column;
}

.side-drawer.open {
    transform: translateX(0);
}

.side-drawer-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 1rem 1.25rem;
    border-bottom: 1px solid #e2e8f0;
    background: #f8fafc;
}

.side-drawer-header h3 {
    margin: 0;
    font-size: 1rem;
    color: #1f2937;
}

.side-drawer-header h3 .comments-title-invoice {
    display: block;
}

.side-drawer-header h3 .comments-title-company {
    display: block;
    margin-top: 0.15rem;
    font-weight: 500;
    color: var(--primary-indigo);
}

.side-drawer-body {
    padding: 1rem 1.25rem;
    overflow-y: auto;
}

.side-drawer .option-label {
    color: #1976d2;
    font-size: 0.9rem;
}

.side-drawer .modal-input,
.side-drawer .modal-select,
.side-drawer #overdue-comment-save,
.side-drawer .comments-empty,
.side-drawer .comment-author,
.side-drawer .comment-date,
.side-drawer .comment-body {
    font-size: 0.9rem;
}

#overdue-comment-save {
    background: #1976d2;
    border-color: #1976d2;
    color: #ffffff;
}

#overdue-comment-save:hover,
#overdue-comment-save:focus {
    background: #1565c0;
    border-color: #1565c0;
}

.comments-sort-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.75rem;
    margin-bottom: 0.5rem;
}

.comments-sort-row .option-label {
    margin-bottom: 0;
}

#overdue-comment-sort-order:focus,
#overdue-comment-sort-order:active {
    outline: none;
    border-color: #d1d5db;
    box-shadow: none;
}

.comments-history-list {
    border: 1px solid #e2e8f0;
    border-radius: 8px;
    background: #f8fafc;
    max-height: 320px;
    overflow-y: auto;
    padding: 0.5rem;
}

.comments-empty {
    color: #64748b;
    padding: 0.5rem;
}

.comment-item {
    background: #ffffff;
    border: 1px solid #e2e8f0;
    border-radius: 8px;
    padding: 0.6rem 0.7rem;
    margin-bottom: 0.5rem;
}

.comment-item:last-child {
    margin-bottom: 0;
}

.comment-item-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 0.5rem;
    margin-bottom: 0.35rem;
}

.comment-author {
    font-weight: 600;
    color: #1f2937;
}

.comment-date {
    color: #64748b;
}

.comment-header-left {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.comment-body {
    color: #334155;
    white-space: pre-wrap;
    word-break: break-word;
    line-height: 1.35;
}

.comment-edit-wrapper {
    display: flex;
    align-items: center;
    gap: 0.35rem;
    flex-shrink: 0;
}

.comment-edit-countdown {
    font-size: 0.72rem;
    font-weight: 600;
    color: #ef4444;
    min-width: 1.4rem;
    text-align: right;
}

.comment-edit-btn {
    background: none;
    border: 1px solid #cbd5e1;
    border-radius: 4px;
    color: #3b82f6;
    font-size: 0.75rem;
    padding: 2px 8px;
    cursor: pointer;
    transition: background 0.15s, color 0.15s;
    flex-shrink: 0;
}

.comment-edit-btn:hover {
    background: #eff6ff;
    border-color: #3b82f6;
}

.comment-edit-textarea {
    width: 100%;
    margin-top: 0.4rem;
    padding: 0.4rem 0.5rem;
    font-size: 0.85rem;
    font-family: inherit;
    border: 1px solid #93c5fd;
    border-radius: 6px;
    resize: vertical;
    min-height: 60px;
    box-sizing: border-box;
}

.comment-edit-textarea:focus {
    outline: none;
    border-color: #3b82f6;
    box-shadow: 0 0 0 2px rgba(59, 130, 246, 0.15);
}

.comment-edit-actions {
    display: flex;
    gap: 0.4rem;
    margin-top: 0.35rem;
    justify-content: flex-end;
}

.comment-edit-save-btn,
.comment-edit-cancel-btn {
    font-size: 0.78rem;
    padding: 3px 12px;
    border-radius: 4px;
    cursor: pointer;
    border: 1px solid #cbd5e1;
}

.comment-edit-save-btn {
    background: #3b82f6;
    color: #fff;
    border-color: #3b82f6;
}

.comment-edit-save-btn:hover {
    background: #2563eb;
}

.comment-edit-save-btn:disabled {
    opacity: 0.6;
    cursor: not-allowed;
}

.comment-edit-cancel-btn {
    background: #fff;
    color: #64748b;
}

.comment-edit-cancel-btn:hover {
    background: #f1f5f9;
}

.comment-edit-cancel-btn:disabled {
    opacity: 0.6;
    cursor: not-allowed;
}