/**
 * Frontend Styles for Course Code Manager
 */

/* Code Input Container */
.ccm-code-input-container {
    margin: 20px 0;
    padding: 20px;
    background: #f8f9fa;
    border: 1px solid #e9ecef;
    border-radius: 8px;
    box-shadow: 0 2px 4px rgba(0,0,0,0.1);
}

.ccm-code-input-box {
    max-width: 500px;
    margin: 0 auto;
}

.ccm-code-input-title {
    margin: 0 0 10px 0;
    color: #1d2327;
    font-size: 20px;
    font-weight: 600;
    text-align: center;
}

.ccm-code-input-description {
    margin: 0 0 20px 0;
    color: #646970;
    text-align: center;
    line-height: 1.5;
}

/* Form Styles */
.ccm-code-form {
    width: 100%;
}

.ccm-input-group {
    margin-bottom: 15px;
}

.ccm-input-label {
    display: block;
    margin-bottom: 8px;
    font-weight: 500;
    color: #1d2327;
    font-size: 14px;
}

.ccm-input-wrapper {
    display: flex;
    gap: 10px;
    align-items: stretch;
}

.ccm-code-input {
    flex: 1;
    padding: 12px 16px;
    border: 2px solid #ddd;
    border-radius: 6px;
    font-size: 16px;
    font-family: 'Courier New', monospace;
    text-transform: uppercase;
    letter-spacing: 2px;
    transition: border-color 0.3s ease, box-shadow 0.3s ease;
    background: #fff;
}

.ccm-code-input:focus {
    outline: none;
    border-color: #007cba;
    box-shadow: 0 0 0 3px rgba(0, 124, 186, 0.1);
}

.ccm-code-input.valid {
    border-color: #46b450;
}

.ccm-code-input.invalid {
    border-color: #dc3232;
}

.ccm-redeem-button {
    padding: 12px 24px;
    background: #007cba;
    color: #fff;
    border: none;
    border-radius: 6px;
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    transition: background-color 0.3s ease, transform 0.2s ease;
    white-space: nowrap;
    display: flex;
    align-items: center;
    gap: 8px;
}

.ccm-redeem-button:hover:not(:disabled) {
    background: #005a87;
    transform: translateY(-1px);
}

.ccm-redeem-button:disabled {
    background: #ccc;
    cursor: not-allowed;
    transform: none;
}

.ccm-redeem-button .ccm-button-loading {
    display: flex;
    align-items: center;
    gap: 8px;
}

/* Message Container */
.ccm-message-container {
    margin-top: 15px;
}

.ccm-message {
    padding: 12px 16px;
    border-radius: 6px;
    font-size: 14px;
    line-height: 1.4;
    animation: ccm-fade-in 0.3s ease;
}

.ccm-message.success {
    background: #d4edda;
    border: 1px solid #c3e6cb;
    color: #155724;
}

.ccm-message.error {
    background: #f8d7da;
    border: 1px solid #f5c6cb;
    color: #721c24;
}

.ccm-message.info {
    background: #cce5ff;
    border: 1px solid #b3d7ff;
    color: #004085;
}

/* Code Info */
.ccm-code-info {
    margin-top: 15px;
    padding-top: 15px;
    border-top: 1px solid #e9ecef;
}

.ccm-code-help {
    margin: 0;
    font-size: 12px;
    color: #6c757d;
    text-align: center;
    line-height: 1.4;
}

/* Spinner Animation */
.ccm-spinner {
    display: inline-block;
    width: 16px;
    height: 16px;
    border: 2px solid #f3f3f3;
    border-top: 2px solid #007cba;
    border-radius: 50%;
    animation: ccm-spin 1s linear infinite;
}

@keyframes ccm-spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

@keyframes ccm-fade-in {
    from {
        opacity: 0;
        transform: translateY(-10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* Character Counter */
.ccm-char-counter {
    font-size: 12px;
    color: #6c757d;
    margin-top: 5px;
    text-align: right;
}

.ccm-char-counter.warning {
    color: #fd7e14;
}

.ccm-char-counter.danger {
    color: #dc3545;
}

/* Progress Indicator */
.ccm-progress-dots {
    display: flex;
    justify-content: center;
    gap: 8px;
    margin: 15px 0;
}

.ccm-progress-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: #dee2e6;
    transition: background-color 0.3s ease;
}

.ccm-progress-dot.active {
    background: #007cba;
}

.ccm-progress-dot.completed {
    background: #46b450;
}

/* Enrollment Button */
.ccm-enroll-button {
    display: inline-block;
    padding: 12px 24px;
    background: #28a745;
    color: #fff;
    text-decoration: none;
    border-radius: 6px;
    font-weight: 500;
    transition: background-color 0.3s ease, transform 0.2s ease;
    margin-top: 10px;
}

.ccm-enroll-button:hover {
    background: #218838;
    color: #fff;
    text-decoration: none;
    transform: translateY(-1px);
}

.ccm-enroll-button.ccm-free-course {
    background: #17a2b8;
}

.ccm-enroll-button.ccm-free-course:hover {
    background: #138496;
}

/* Injected form specific styles */
.ccm-injected-form {
    margin: 20px 0;
    clear: both;
}

.ccm-injected-form .ccm-code-container {
    border: 1px solid #ddd;
    border-radius: 8px;
    background: #f9f9f9;
    padding: 20px;
    margin-bottom: 20px;
}

/* Responsive Design */
@media (max-width: 768px) {
    .ccm-code-input-container {
        margin: 15px 0;
        padding: 15px;
    }
    
    .ccm-input-wrapper {
        flex-direction: column;
    }
    
    .ccm-redeem-button {
        width: 100%;
        justify-content: center;
    }
    
    .ccm-code-input-title {
        font-size: 18px;
    }
    
    .ccm-code-input {
        font-size: 14px;
        letter-spacing: 1px;
    }
}

@media (max-width: 480px) {
    .ccm-code-input-container {
        margin: 10px 0;
        padding: 12px;
        border-radius: 6px;
    }
    
    .ccm-code-input-title {
        font-size: 16px;
    }
    
    .ccm-code-input-description {
        font-size: 14px;
    }
    
    .ccm-code-input {
        padding: 10px 12px;
        font-size: 14px;
    }
    
    .ccm-redeem-button {
        padding: 10px 20px;
        font-size: 13px;
    }
}

/* High Contrast Mode */
@media (prefers-contrast: high) {
    .ccm-code-input-container {
        border: 2px solid #000;
        background: #fff;
    }
    
    .ccm-code-input {
        border: 2px solid #000;
    }
    
    .ccm-redeem-button {
        background: #000;
        border: 2px solid #000;
    }
    
    .ccm-message.success {
        background: #fff;
        border: 2px solid #000;
        color: #000;
    }
    
    .ccm-message.error {
        background: #fff;
        border: 2px solid #000;
        color: #000;
    }
}

/* Reduced Motion */
@media (prefers-reduced-motion: reduce) {
    .ccm-code-input,
    .ccm-redeem-button,
    .ccm-message,
    .ccm-progress-dot {
        transition: none;
    }
    
    .ccm-spinner {
        animation: none;
    }
    
    @keyframes ccm-fade-in {
        from { opacity: 0; }
        to { opacity: 1; }
    }
}

/* Focus Styles for Accessibility */
.ccm-code-input:focus-visible,
.ccm-redeem-button:focus-visible {
    outline: 2px solid #005fcc;
    outline-offset: 2px;
}

/* Screen Reader Only Text */
.ccm-sr-only {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
}

/* Success actions */
.ccm-success-actions {
    padding: 15px;
    background: #f0f8ff;
    border: 1px solid #00a0d2;
    border-radius: 4px;
    margin-top: 15px;
    text-align: center;
}

.ccm-reload-btn {
    background: #00a0d2;
    color: white;
    border: none;
    padding: 8px 16px;
    border-radius: 4px;
    cursor: pointer;
    font-size: 14px;
    margin-right: 10px;
}

.ccm-reload-btn:hover {
    background: #0073aa;
}

.ccm-success-note {
    color: #00a0d2;
    font-weight: 500;
}

.ccm-code-form.ccm-success {
    border-color: #00a0d2;
}

.ccm-code-input-container.ccm-redeemed {
    background: linear-gradient(135deg, #f0f8ff 0%, #e6f3ff 100%);
} 