/**
 * Frontend styles for LearnDash Interactive Assignments
 */

/* Assignment Container */
.lda-assignment-container {
    max-width: 800px;
    margin: 20px 0;
    padding: 20px;
    border: 1px solid #ddd;
    border-radius: 8px;
    background: #fff;
    box-shadow: 0 2px 4px rgba(0,0,0,0.1);
}

/* Assignment Header */
.lda-assignment-header {
    margin-bottom: 20px;
    padding-bottom: 15px;
    border-bottom: 2px solid #f0f0f0;
}

.lda-assignment-title {
    margin: 0 0 10px 0;
    color: #333;
    font-size: 1.5em;
    font-weight: 600;
}

/* Submission Status */
.lda-submission-status {
    display: inline-block;
    padding: 8px 12px;
    border-radius: 20px;
    font-size: 0.9em;
    font-weight: 500;
    margin-bottom: 10px;
}

.lda-submission-status.status-submitted {
    background: #fff3cd;
    color: #856404;
    border: 1px solid #ffeaa7;
}

.lda-submission-status.status-approved {
    background: #d4edda;
    color: #155724;
    border: 1px solid #c3e6cb;
}

.lda-submission-status.status-needs_revision {
    background: #f8d7da;
    color: #721c24;
    border: 1px solid #f5c6cb;
}

.status-icon {
    margin-right: 5px;
}

/* Feedback Section */
.lda-feedback {
    background: #f8f9fa;
    border: 1px solid #dee2e6;
    border-radius: 6px;
    padding: 15px;
    margin-bottom: 20px;
}

.lda-feedback h4 {
    margin: 0 0 10px 0;
    color: #495057;
    font-size: 1.1em;
}

.feedback-content {
    color: #6c757d;
    line-height: 1.5;
}

/* Assignment Content */
.lda-assignment-content {
    margin-bottom: 20px;
    line-height: 1.6;
}

.lda-assignment-content p {
    margin-bottom: 15px;
}

/* Form Elements */
.lda-blank-input,
.lda-blank-paragraph {
    border: 2px solid #e1e5e9;
    border-radius: 8px;
    padding: 12px 16px;
    font-size: 15px;
    font-family: inherit;
    line-height: 1.5;
    transition: all 0.3s ease;
    background: #fff;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.05);
    margin: 8px 4px;
    display: inline-block;
    vertical-align: top;
}

/* Spacing for consecutive fields */
.lda-blank-input + .lda-blank-input,
.lda-blank-input + .lda-blank-paragraph,
.lda-blank-paragraph + .lda-blank-input,
.lda-blank-paragraph + .lda-blank-paragraph {
    margin-left: 12px;
}

/* Block-level spacing for paragraph fields */
.lda-blank-paragraph {
    display: block;
    width: 100%;
    margin: 16px 0;
    resize: vertical;
    min-height: 100px;
}

/* Enhanced focus states */
.lda-blank-input:focus,
.lda-blank-paragraph:focus {
    outline: none;
    border-color: #007cba;
    box-shadow: 0 0 0 3px rgba(0, 124, 186, 0.15), 0 2px 8px rgba(0, 124, 186, 0.1);
    transform: translateY(-1px);
}

/* Hover states */
.lda-blank-input:hover:not(:focus),
.lda-blank-paragraph:hover:not(:focus) {
    border-color: #c6d0d7;
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.08);
}

/* Error states */
.lda-blank-input.lda-error-field,
.lda-blank-paragraph.lda-error-field {
    border-color: #dc3545;
    background-color: #fef7f7;
    box-shadow: 0 0 0 3px rgba(220, 53, 69, 0.1);
}

.lda-blank-input.lda-error-field:focus,
.lda-blank-paragraph.lda-error-field:focus {
    box-shadow: 0 0 0 3px rgba(220, 53, 69, 0.2), 0 2px 8px rgba(220, 53, 69, 0.1);
}

/* Placeholder styling */
.lda-blank-input::placeholder,
.lda-blank-paragraph::placeholder {
    color: #8a9ba8;
    font-style: italic;
    opacity: 1;
}

/* Field sizing variations - respect inline width styles */
.lda-blank-input[style*="width"] {
    min-width: 120px !important;
    max-width: 100% !important;
}

/* Text input specific styling - only apply when no inline width is set */
.lda-blank-input:not([style*="width"]) {
    min-width: 150px;
    max-width: 100%;
}

/* Submitted Answers Display */
.lda-submitted-answer {
    display: inline-block;
    background: #e3f2fd;
    border: 1px solid #bbdefb;
    border-radius: 4px;
    padding: 6px 10px;
    margin: 0 2px;
    font-weight: 500;
    color: #1565c0;
}

.lda-submitted-paragraph {
    background: #e3f2fd;
    border: 1px solid #bbdefb;
    border-radius: 4px;
    padding: 12px;
    margin: 10px 0;
    color: #1565c0;
    white-space: pre-wrap;
}

/* Form Actions */
.lda-form-actions {
    text-align: center;
    padding: 20px 0;
    border-top: 1px solid #eee;
    margin-top: 20px;
}

.lda-submit-btn {
    background: #007cba;
    color: white;
    border: none;
    padding: 12px 30px;
    border-radius: 6px;
    font-size: 16px;
    font-weight: 500;
    cursor: pointer;
    transition: background-color 0.3s ease;
}

.lda-submit-btn:hover:not(:disabled) {
    background: #005a87;
}

.lda-submit-btn:disabled {
    background: #6c757d;
    cursor: not-allowed;
}

.lda-loading {
    margin-top: 10px;
    color: #6c757d;
    font-style: italic;
}

/* Assignment States */
.lda-assignment-completed,
.lda-assignment-submitted {
    background: #f8f9fa;
    border: 1px solid #dee2e6;
    border-radius: 6px;
    padding: 20px;
    margin-bottom: 20px;
}

.lda-assignment-completed h4,
.lda-assignment-submitted h4 {
    margin: 0 0 15px 0;
    color: #495057;
}

.lda-info {
    background: #d1ecf1;
    border: 1px solid #bee5eb;
    color: #0c5460;
    padding: 12px;
    border-radius: 4px;
    margin-bottom: 15px;
}

.lda-error {
    background: #f8d7da;
    border: 1px solid #f5c6cb;
    color: #721c24;
    padding: 12px;
    border-radius: 4px;
    margin: 10px 0;
}

/* Submission History */
.lda-submission-history {
    margin-top: 30px;
    border-top: 1px solid #eee;
    padding-top: 20px;
}

.lda-submission-history details {
    border: 1px solid #dee2e6;
    border-radius: 6px;
    overflow: hidden;
}

.lda-submission-history summary {
    background: #f8f9fa;
    padding: 12px 15px;
    cursor: pointer;
    font-weight: 500;
    border-bottom: 1px solid #dee2e6;
}

.lda-submission-history summary:hover {
    background: #e9ecef;
}

.history-list {
    padding: 15px;
}

.history-item {
    border-left: 4px solid #dee2e6;
    padding: 12px 15px;
    margin-bottom: 15px;
    background: #f8f9fa;
    border-radius: 0 4px 4px 0;
}

.history-item.status-submitted {
    border-left-color: #ffc107;
}

.history-item.status-approved {
    border-left-color: #28a745;
}

.history-item.status-needs_revision {
    border-left-color: #dc3545;
}

.history-meta {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 8px;
    flex-wrap: wrap;
    gap: 10px;
}

.history-date {
    color: #6c757d;
    font-size: 0.9em;
}

.history-status {
    font-size: 0.85em;
    padding: 2px 8px;
    border-radius: 12px;
    background: #e9ecef;
    color: #495057;
}

.history-feedback {
    margin-top: 10px;
    padding: 10px;
    background: #fff;
    border-radius: 4px;
    border: 1px solid #dee2e6;
}

.history-feedback strong {
    color: #495057;
    display: block;
    margin-bottom: 5px;
}

/* Status Shortcode Styles */
.lda-status-not-submitted {
    color: #6c757d;
    font-style: italic;
}

.lda-status-submitted {
    color: #856404;
    font-weight: 500;
}

.lda-status-approved {
    color: #155724;
    font-weight: 500;
}

.lda-status-needs_revision {
    color: #721c24;
    font-weight: 500;
}

/* Responsive Design */
@media (max-width: 768px) {
    .lda-assignment-container {
        margin: 10px 0;
        padding: 15px;
    }
    
    .lda-assignment-title {
        font-size: 1.3em;
    }
    
    .history-meta {
        flex-direction: column;
        align-items: flex-start;
    }
    
    /* Mobile-optimized input fields - respect inline width styles */
    .lda-blank-input:not([style*="width"]) {
        width: 100%;
        max-width: none;
        margin: 12px 0;
        padding: 14px 16px;
        font-size: 16px; /* Prevents zoom on iOS */
        box-sizing: border-box;
        display: block;
    }
    
    /* For inputs with custom width on mobile, maintain inline styling but ensure readability */
    .lda-blank-input[style*="width"] {
        margin: 12px 0;
        padding: 14px 16px;
        font-size: 16px; /* Prevents zoom on iOS */
        box-sizing: border-box;
        display: inline-block;
        vertical-align: top;
    }
    
    .lda-blank-paragraph {
        margin: 16px 0;
        padding: 14px 16px;
        font-size: 16px; /* Prevents zoom on iOS */
        min-height: 120px;
    }
    
    /* Remove consecutive field spacing on mobile */
    .lda-blank-input + .lda-blank-input,
    .lda-blank-input + .lda-blank-paragraph,
    .lda-blank-paragraph + .lda-blank-input,
    .lda-blank-paragraph + .lda-blank-paragraph {
        margin-left: 0;
    }
    
    /* Enhanced touch targets */
    .lda-blank-input:focus,
    .lda-blank-paragraph:focus {
        transform: none; /* Remove transform on mobile for better performance */
    }
}

/* Tablet-specific adjustments */
@media (min-width: 769px) and (max-width: 1024px) {
    .lda-blank-input:not([style*="width"]) {
        min-width: 180px;
        max-width: 350px;
    }
    
    .lda-blank-paragraph {
        margin: 14px 0;
    }
}

/* Large screen optimizations */
@media (min-width: 1200px) {
    .lda-assignment-container {
        max-width: 900px;
    }
    
    .lda-blank-input:not([style*="width"]) {
        max-width: 100%;
    }
}

/* Assignment Approval Styles */
.lda-assignment-approval {
    max-width: 800px;
    margin: 20px 0;
    padding: 20px;
    border: 1px solid #ddd;
    border-radius: 8px;
    background: #fff;
    box-shadow: 0 2px 4px rgba(0,0,0,0.1);
}

.lda-approval-header {
    margin-bottom: 30px;
    padding-bottom: 20px;
    border-bottom: 2px solid #f0f0f0;
}

.lda-approval-header h2 {
    margin: 0 0 15px 0;
    color: #333;
    font-size: 1.6em;
}

.lda-submission-meta {
    background: #f8f9fa;
    padding: 15px;
    border-radius: 6px;
    border: 1px solid #dee2e6;
}

.lda-submission-meta p {
    margin: 5px 0;
    color: #495057;
}

.lda-status {
    display: inline-block;
    padding: 4px 8px;
    border-radius: 12px;
    font-size: 0.85em;
    font-weight: 500;
    text-transform: capitalize;
}

.lda-status-submitted {
    background: #fff3cd;
    color: #856404;
    border: 1px solid #ffeaa7;
}

.lda-status-approved {
    background: #d4edda;
    color: #155724;
    border: 1px solid #c3e6cb;
}

.lda-status-needs-revision {
    background: #f8d7da;
    color: #721c24;
    border: 1px solid #f5c6cb;
}

.lda-approval-content {
    margin: 30px 0;
}

.lda-approval-content h3 {
    margin: 0 0 15px 0;
    color: #333;
    font-size: 1.3em;
}

.lda-worksheet-content {
    background: #f8f9fa;
    padding: 20px;
    border-radius: 6px;
    border: 1px solid #dee2e6;
    margin-bottom: 20px;
}

.lda-approval-actions {
    margin-top: 30px;
    padding-top: 20px;
    border-top: 1px solid #eee;
}

.lda-approval-actions h3 {
    margin: 0 0 20px 0;
    color: #333;
    font-size: 1.2em;
}

.lda-feedback-section {
    margin-bottom: 20px;
}

.lda-feedback-section label {
    display: block;
    margin-bottom: 8px;
    color: #495057;
    font-weight: 500;
}

.lda-feedback-section textarea {
    width: 100%;
    padding: 12px;
    border: 1px solid #ced4da;
    border-radius: 4px;
    font-family: inherit;
    font-size: 14px;
    line-height: 1.5;
    resize: vertical;
    min-height: 100px;
}

.lda-feedback-section textarea:focus {
    outline: none;
    border-color: #007cba;
    box-shadow: 0 0 0 2px rgba(0, 124, 186, 0.25);
}

.lda-action-buttons {
    display: flex;
    gap: 15px;
    flex-wrap: wrap;
}

.lda-btn {
    padding: 10px 20px;
    border: none;
    border-radius: 4px;
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s ease;
    text-decoration: none;
    display: inline-block;
    text-align: center;
}

.lda-btn:disabled {
    opacity: 0.6;
    cursor: not-allowed;
}

.lda-btn-success {
    background-color: #28a745;
    color: white;
}

.lda-btn-success:hover:not(:disabled) {
    background-color: #218838;
}

.lda-btn-warning {
    background-color: #ffc107;
    color: #212529;
}

.lda-btn-warning:hover:not(:disabled) {
    background-color: #e0a800;
}

.lda-approval-messages {
    margin-top: 20px;
}

.lda-success {
    background: #d4edda;
    border: 1px solid #c3e6cb;
    color: #155724;
    padding: 12px;
    border-radius: 4px;
    margin: 10px 0;
}

.lda-error {
    background: #f8d7da;
    border: 1px solid #f5c6cb;
    color: #721c24;
    padding: 12px;
    border-radius: 4px;
    margin: 10px 0;
}

/* Print Styles */
@media print {
    .lda-form-actions,
    .lda-submission-history,
    .lda-approval-actions {
        display: none;
    }
    
    .lda-assignment-container,
    .lda-assignment-approval {
        box-shadow: none;
        border: 1px solid #000;
    }
}

/* Enhanced Notification Styles */
.lda-notification {
    position: fixed;
    top: 20px;
    right: 20px;
    z-index: 10000;
    max-width: 450px;
    padding: 16px 20px;
    border-radius: 8px;
    box-shadow: 0 8px 24px rgba(0,0,0,0.15);
    font-size: 15px;
    line-height: 1.5;
    font-weight: 500;
    display: flex;
    align-items: flex-start;
    gap: 12px;
    animation: slideInRight 0.3s ease-out;
}

.lda-notification-message {
    flex: 1;
}

.lda-notification-close {
    background: none;
    border: none;
    font-size: 18px;
    cursor: pointer;
    padding: 0;
    width: 20px;
    height: 20px;
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0.7;
    transition: opacity 0.2s ease;
}

.lda-notification-close:hover {
    opacity: 1;
}

.lda-notification-success {
    background: linear-gradient(135deg, #d4edda 0%, #c3e6cb 100%);
    color: #155724;
    border: 2px solid #28a745;
}

.lda-notification-error {
    background: linear-gradient(135deg, #f8d7da 0%, #f5c6cb 100%);
    color: #721c24;
    border: 2px solid #dc3545;
}

.lda-notification-warning {
    background: linear-gradient(135deg, #fff3cd 0%, #ffeaa7 100%);
    color: #856404;
    border: 2px solid #ffc107;
}

.lda-notification-info {
    background: linear-gradient(135deg, #d1ecf1 0%, #bee5eb 100%);
    color: #0c5460;
    border: 2px solid #17a2b8;
}

@keyframes slideInRight {
    from {
        transform: translateX(100%);
        opacity: 0;
    }
    to {
        transform: translateX(0);
        opacity: 1;
    }
}

/* Submitted Form Styles */
.lda-form-submitted {
    opacity: 0.8;
    pointer-events: none;
    position: relative;
}

.lda-form-submitted::after {
    content: "✅ Submitted Successfully";
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    background: rgba(40, 167, 69, 0.95);
    color: white;
    padding: 12px 24px;
    border-radius: 8px;
    font-weight: 600;
    font-size: 16px;
    box-shadow: 0 4px 12px rgba(40, 167, 69, 0.3);
    z-index: 10;
}

.lda-form-submitted .lda-blank-input,
.lda-form-submitted .lda-blank-paragraph {
    background-color: #f8f9fa;
    border-color: #dee2e6;
    color: #6c757d;
}

/* Field Error Styles */
.lda-field-error {
    display: block;
    color: #dc3545;
    font-size: 13px;
    margin-top: 4px;
    margin-left: 4px;
    font-weight: 500;
}

/* Character Counter Styles */
.lda-char-counter {
    font-size: 12px;
    color: #6c757d;
    text-align: right;
    margin-top: 4px;
}

.lda-char-counter.lda-char-warning {
    color: #dc3545;
    font-weight: 500;
}

/* Mobile Notification Adjustments */
@media (max-width: 768px) {
    .lda-notification {
        top: 10px;
        right: 10px;
        left: 10px;
        max-width: none;
        font-size: 14px;
    }
    
    .lda-form-submitted::after {
        font-size: 14px;
        padding: 10px 20px;
    }
}
