/**
 * Shared Inline Editing Styles for 鋒兄 System
 * Provides consistent styling for inline editing across all pages
 */

/* Inline Editing Containers */
.inline-edit {
    display: none;
}

.inline-edit-always {
    display: block;
}

.inline-view {
    display: block;
}

/* Inline Add Card */
.inline-add-card {
    background: #f8f9fa;
    border: 2px dashed #dee2e6;
    transition: all 0.3s ease;
}

.inline-add-card:hover {
    border-color: #007bff;
    background: #f0f8ff;
}

/* Inline Add Row */
.inline-add-row {
    display: none;
}

/* Inline Input Fields */
.inline-input {
    width: 100%;
    padding: 8px 12px;
    border: 1px solid #ddd;
    border-radius: 4px;
    font-size: 14px;
    transition: border-color 0.3s ease, box-shadow 0.3s ease;
}

.inline-input:focus {
    outline: none;
    border-color: #007bff;
    box-shadow: 0 0 0 2px rgba(0, 123, 255, 0.25);
}

.inline-input.error {
    border-color: #dc3545;
    box-shadow: 0 0 0 2px rgba(220, 53, 69, 0.25);
}

/* Inline Actions */
.inline-actions {
    display: flex;
    gap: 8px;
    margin-top: 15px;
    padding-top: 15px;
    border-top: 1px solid #dee2e6;
}

.inline-actions .btn {
    padding: 6px 12px;
    font-size: 13px;
    border-radius: 4px;
    cursor: pointer;
    transition: all 0.3s ease;
}

.inline-actions .btn-primary {
    background: #007bff;
    color: white;
    border: none;
}

.inline-actions .btn-primary:hover {
    background: #0056b3;
}

.inline-actions .btn-primary:disabled {
    background: #6c757d;
    cursor: not-allowed;
}

.inline-actions .btn-secondary {
    background: #6c757d;
    color: white;
    border: none;
}

.inline-actions .btn-secondary:hover {
    background: #545b62;
}

/* Form Groups in Inline Editing */
.inline-edit .form-group {
    margin-bottom: 15px;
}

.inline-edit .form-group label {
    display: block;
    margin-bottom: 5px;
    font-weight: 600;
    color: #495057;
    font-size: 13px;
}

.inline-edit .form-row {
    display: flex;
    gap: 15px;
}

.inline-edit .form-row .form-group {
    flex: 1;
}

/* Card Grid Inline Editing */
.card-grid .inline-add-card {
    margin-bottom: 20px;
}

.card[data-id] .inline-edit {
    padding: 15px;
    background: #f8f9fa;
    border-radius: 8px;
    margin-top: 10px;
}

/* Table Inline Editing */
.table .inline-edit {
    padding: 8px;
}

.table .inline-input {
    padding: 4px 8px;
    font-size: 13px;
}

.table .inline-actions {
    margin-top: 8px;
    padding-top: 8px;
}

/* Mobile Responsive */
@media (max-width: 768px) {
    .inline-edit .form-row {
        flex-direction: column;
        gap: 10px;
    }
    
    .inline-actions {
        flex-direction: column;
    }
    
    .inline-actions .btn {
        width: 100%;
        text-align: center;
    }
    
    .inline-input {
        font-size: 16px; /* Prevent zoom on iOS */
    }
}

/* Dark Mode Support */
[data-theme="dark"] .inline-add-card {
    background: #2d3748;
    border-color: #4a5568;
}

[data-theme="dark"] .inline-add-card:hover {
    background: #1a202c;
    border-color: #4299e1;
}

[data-theme="dark"] .inline-input {
    background: #2d3748;
    border-color: #4a5568;
    color: #e2e8f0;
}

[data-theme="dark"] .inline-input:focus {
    border-color: #4299e1;
    box-shadow: 0 0 0 2px rgba(66, 153, 225, 0.25);
}

[data-theme="dark"] .inline-edit {
    background: #2d3748;
}

[data-theme="dark"] .inline-edit .form-group label {
    color: #e2e8f0;
}

[data-theme="dark"] .inline-actions {
    border-color: #4a5568;
}

/* Loading States */
.inline-loading {
    position: relative;
    pointer-events: none;
}

.inline-loading::after {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    width: 20px;
    height: 20px;
    margin: -10px 0 0 -10px;
    border: 2px solid #f3f3f3;
    border-top: 2px solid #007bff;
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

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

/* Validation Messages */
.inline-validation-message {
    color: #dc3545;
    font-size: 12px;
    margin-top: 5px;
    display: none;
}

.inline-validation-message.show {
    display: block;
}

[data-theme="dark"] .inline-validation-message {
    color: #fc8181;
}

/* Success/Error Feedback */
.inline-success {
    border-color: #28a745 !important;
    box-shadow: 0 0 0 2px rgba(40, 167, 69, 0.25) !important;
}

/* Card Header with Checkbox */
.card-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 15px;
    padding: 0;
}

.card-header .select-checkbox {
    margin-right: 10px;
    width: auto;
}

.card-header .card-actions {
    display: flex;
    gap: 8px;
    margin-left: auto;
}

/* Adjust card padding when header is present */
.card .card-header + .card-title {
    margin-top: 0;
}

/* Mobile responsive adjustments */
@media (max-width: 768px) {
    .card-header {
        flex-wrap: wrap;
        gap: 8px;
    }
    
    .card-header .card-actions {
        order: -1;
        margin-left: 0;
    }
}

.inline-error {
    border-color: #dc3545 !important;
    box-shadow: 0 0 0 2px rgba(220, 53, 69, 0.25) !important;
}

/* Transition Effects */
.inline-edit,
.inline-view {
    transition: opacity 0.3s ease, transform 0.3s ease;
}

.inline-edit.fade-in,
.inline-view.fade-in {
    opacity: 1;
    transform: translateY(0);
}

.inline-edit.fade-out,
.inline-view.fade-out {
    opacity: 0;
    transform: translateY(-10px);
}
