/**
 * Task Goals Frontend Styles
 *
 * @package    Helpme_BBLPro
 * @since      1.0.0
 */

/* Task Goals Container */
.helpme-task-goals-container {
    margin: 20px 0;
    padding: 15px;
    background: #f9f9f9;
    border: 1px solid #ddd;
    border-radius: 4px;
}

.helpme-task-goals-container.readonly {
    background: #fafafa;
}

/* Task Goals List */
.helpme-task-goals-list {
    margin: 0 0 15px 0;
    padding: 0;
    list-style: none;
}

.helpme-task-goals-list:empty {
    display: none;
}

/* Goal item styles */
.helpme-goal-item {
    display: flex;
    align-items: center;
    padding: 12px;
    margin-bottom: 8px;
    background: #fff;
    border: 1px solid #e1e5e9;
    border-radius: 6px;
    transition: all 0.2s ease;
    position: relative;
}

.helpme-goal-item:hover {
    border-color: #c3c4c7;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.05);
}

.helpme-goal-item.completed {
    background-color: #f6f7f7;
    opacity: 0.8;
}

.helpme-goal-item.completed .helpme-goal-display {
    text-decoration: line-through;
    color: #787c82;
}

/* New goal input styles */
.helpme-goal-item-new {
    border-style: dashed;
    border-color: #c3c4c7;
    background-color: #fafafa;
}

.helpme-goal-item-new:hover {
    border-color: #2271b1;
    background-color: #f6f7f7;
}

.helpme-goal-item-new .helpme-goal-new-input {
    border: none;
    background: transparent;
    font-size: 14px;
    color: #50575e;
    width: 100%;
    outline: none;
}

.helpme-goal-item-new .helpme-goal-new-input::placeholder {
    color: #8c8f94;
    font-style: italic;
}

.helpme-goal-item-new .helpme-goal-new-input:focus {
    color: #1d2327;
}

/* Existing goal styles */
.helpme-goal-item-existing .helpme-goal-display {
    cursor: pointer;
    padding: 2px 4px;
    border-radius: 3px;
    transition: background-color 0.2s ease;
}

.helpme-goal-item-existing .helpme-goal-display:hover {
    background-color: #f0f0f1;
}

.helpme-goal-item.completed {
    background: #f0f8f0;
    border-color: #28a745;
}

.helpme-goal-item.ui-sortable-helper {
    box-shadow: 0 4px 8px rgba(0,0,0,0.2);
    transform: rotate(2deg);
}

/* Goal Handle */
.helpme-goal-handle {
    cursor: move;
    padding: 0 8px 0 0;
    color: #666;
    display: flex;
    align-items: center;
}

.helpme-goal-handle:hover {
    color: #333;
}

.helpme-goal-handle .dashicons {
    font-size: 16px;
    width: 16px;
    height: 16px;
}

/* Goal Checkbox */
.helpme-goal-checkbox {
    margin-right: 10px;
    display: flex;
    align-items: center;
}

.helpme-goal-complete {
    margin: 0;
    transform: scale(1.2);
}

/* Goal Content */
.helpme-goal-content {
    flex: 1;
    margin-right: 10px;
    position: relative;
}

.helpme-goal-display {
    font-size: 14px;
    line-height: 1.4;
    padding: 8px 12px;
    cursor: pointer;
    border-radius: 4px;
    transition: background-color 0.2s ease;
    min-height: 20px;
}

.helpme-goal-display:hover {
    background-color: #f0f0f0;
}

.helpme-goal-title {
    width: 100%;
    padding: 8px 12px;
    border: 2px solid #007cba;
    border-radius: 4px;
    font-size: 14px;
    line-height: 1.4;
    background: #fff;
    outline: none;
    box-shadow: 0 0 0 1px rgba(0, 124, 186, 0.1);
}

.helpme-goal-title-display {
    font-size: 14px;
    line-height: 1.4;
    padding: 8px 0;
}

.helpme-goal-title-display.completed {
    text-decoration: line-through;
    color: #666;
}

/* Goal Actions */
.helpme-goal-actions {
    display: flex;
    align-items: center;
    opacity: 0;
    transition: opacity 0.2s ease;
}

.helpme-goal-item:hover .helpme-goal-actions {
    opacity: 1;
}

.helpme-delete-goal {
    background: transparent;
    border: none;
    color: #666;
    padding: 4px;
    border-radius: 4px;
    cursor: pointer;
    transition: all 0.2s ease;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 28px;
    height: 28px;
}

.helpme-delete-goal:hover {
    background: #dc3545;
    color: #fff;
    transform: scale(1.1);
}

.helpme-delete-goal .dashicons {
    font-size: 16px;
    width: 16px;
    height: 16px;
}

/* Task Goals Actions */
.helpme-task-goals-actions {
    margin: 15px 0 10px 0;
}
.helpme-task-goals-actions button,
.helpme-goal-actions button {
    display: inline-flex !important;
}

#helpme-add-task-goal {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 10px 16px;
    background: #f8f9fa;
    border: 2px dashed #ccc;
    border-radius: 6px;
    color: #666;
    font-weight: 500;
    transition: all 0.2s ease;
    cursor: pointer;
}

#helpme-add-task-goal:hover {
    background: #007cba;
    border-color: #007cba;
    color: #fff;
    transform: translateY(-1px);
}

#helpme-add-task-goal .dashicons {
    font-size: 18px;
    width: 18px;
    height: 18px;
}

/* Progress Bar */
.helpme-task-progress {
    margin-top: 15px;
    padding-top: 15px;
    border-top: 1px solid #e1e1e1;
}

.helpme-task-progress label {
    display: block;
    margin-bottom: 5px;
    font-weight: 600;
    font-size: 13px;
}

.helpme-progress-bar {
    position: relative;
    height: 20px;
    background: #e9ecef;
    border-radius: 10px;
    overflow: hidden;
}

.helpme-progress-fill {
    height: 100%;
    background: linear-gradient(90deg, #28a745, #20c997);
    border-radius: 10px;
    transition: width 0.3s ease;
    min-width: 0;
}

.helpme-progress-text {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    font-size: 11px;
    font-weight: 600;
    color: #333;
    text-shadow: 0 0 3px rgba(255,255,255,0.8);
}

/* Single Task Goals Display */
.helpme-task-goals-single {
    margin: 30px 0;
    padding: 20px;
    background: #fff;
    border: 1px solid #e1e1e1;
    border-radius: 6px;
}

.helpme-task-goals-single h3 {
    margin: 0 0 15px 0;
    color: #333;
    font-size: 18px;
}

/* Goals Display (Read-only) */
.helpme-task-goals-display {
    margin: 20px 0;
}

.helpme-goals-list {
    margin: 0;
    padding: 0;
    list-style: none;
}

.helpme-goals-list .helpme-goal-item {
    display: flex;
    align-items: center;
    padding: 8px 0;
    border-bottom: 1px solid #f0f0f0;
}

.helpme-goals-list .helpme-goal-item:last-child {
    border-bottom: none;
}

.helpme-goal-status {
    margin-right: 10px;
    color: #666;
}

.helpme-goal-status .dashicons {
    font-size: 16px;
    width: 16px;
    height: 16px;
}

.helpme-goal-item.completed .helpme-goal-status {
    color: #28a745;
}

.helpme-goal-item.completed .helpme-goal-title {
    text-decoration: line-through;
    color: #666;
}

/* Progress Info */
.helpme-task-goals-progress {
    margin: 15px 0;
}

.helpme-progress-info {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 8px;
}

.helpme-progress-label {
    font-weight: 600;
    font-size: 13px;
    color: #333;
}

.helpme-progress-count {
    font-size: 12px;
    color: #666;
    background: #f8f9fa;
    padding: 2px 6px;
    border-radius: 3px;
}

/* Loading States */
.helpme-goal-item.loading {
    opacity: 0.6;
    pointer-events: none;
}

.helpme-goal-item.loading::after {
    content: '';
    position: absolute;
    top: 50%;
    right: 10px;
    width: 16px;
    height: 16px;
    border: 2px solid #f3f3f3;
    border-top: 2px solid #007cba;
    border-radius: 50%;
    animation: helpme-spin 1s linear infinite;
}

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

/* Form Field Integration */
.bbl-form-field-task-goals .bbl-form-label {
    display: block;
    margin-bottom: 10px;
    font-weight: 600;
}

.bbl-form-field-description {
    display: block;
    font-size: 12px;
    color: #666;
    font-weight: normal;
    margin-top: 4px;
}

/* Responsive Design */
@media (max-width: 768px) {
    .helpme-goal-item {
        flex-wrap: wrap;
        padding: 8px;
    }
    
    .helpme-goal-handle {
        order: -1;
        width: 100%;
        justify-content: center;
        padding: 0 0 8px 0;
        border-bottom: 1px solid #eee;
        margin-bottom: 8px;
    }
    
    .helpme-goal-content {
        flex: 1;
        margin-right: 8px;
    }
    
    .helpme-goal-actions {
        flex-shrink: 0;
    }
    
    .helpme-progress-info {
        flex-direction: column;
        align-items: flex-start;
        gap: 4px;
    }
}

/* Accessibility */
.helpme-goal-complete:focus {
    outline: 2px solid #007cba;
    outline-offset: 2px;
}

.helpme-goal-actions .button:focus {
    outline: 2px solid #007cba;
    outline-offset: 1px;
}

/* Animation for new goals */
.helpme-goal-item.newly-added {
    animation: helpme-slideIn 0.3s ease-out;
}

@keyframes helpme-slideIn {
    from {
        opacity: 0;
        transform: translateY(-10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}
