/**
 * Cubic Aptitude Test - Frontend Styles
 * Responsive design for both desktop and mobile devices
 */

/* Reset and base styles */
.cubic-container {
    max-width: 800px;
    margin: 0 auto;
    padding: 20px;
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, sans-serif;
    line-height: 1.6;
    color: #333;
}

.cubic-container * {
    box-sizing: border-box;
}

/* Typography */
.cubic-title {
    font-size: 2rem;
    font-weight: 700;
    margin: 0 0 10px 0;
    color: #2c3e50;
    text-align: center;
}

.cubic-description {
    font-size: 1.1rem;
    margin: 0 0 30px 0;
    color: #7f8c8d;
    text-align: center;
}

/* Form styles */
.cubic-user-form-container {
    background: #fff;
    border-radius: 8px;
    padding: 30px;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
    border: 1px solid #e1e8ed;
}

.cubic-form-group {
    margin-bottom: 25px;
}

.cubic-label {
    display: block;
    font-weight: 600;
    margin-bottom: 8px;
    color: #2c3e50;
    font-size: 0.95rem;
}

.cubic-required {
    color: #e74c3c;
    font-weight: bold;
}

.cubic-input,
.cubic-select {
    width: 100%;
    padding: 12px 16px;
    border: 2px solid #bdc3c7;
    border-radius: 6px;
    font-size: 1rem;
    transition: border-color 0.3s ease, box-shadow 0.3s ease;
    background: #fff;
}

.cubic-input:focus,
.cubic-select:focus {
    outline: none;
    border-color: #3498db;
    box-shadow: 0 0 0 3px rgba(52, 152, 219, 0.1);
}

.cubic-input.cubic-error,
.cubic-select.cubic-error {
    border-color: #e74c3c;
    box-shadow: 0 0 0 3px rgba(231, 76, 60, 0.1);
}

.cubic-input::placeholder {
    color: #95a5a6;
}

/* Button styles */
.cubic-btn {
    padding: 12px 24px;
    border: none;
    border-radius: 6px;
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
    text-decoration: none;
    display: inline-block;
    text-align: center;
    min-width: 120px;
}

.cubic-btn-primary {
    background: #3498db;
    color: white;
}

.cubic-btn-primary:hover {
    background: #2980b9;
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(52, 152, 219, 0.3);
}

.cubic-btn-secondary {
    background: #95a5a6;
    color: white;
}

.cubic-btn-secondary:hover {
    background: #7f8c8d;
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(149, 165, 166, 0.3);
}

.cubic-btn-warning {
    background: #f39c12;
    color: white;
}

.cubic-btn-warning:hover {
    background: #e67e22;
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(243, 156, 18, 0.3);
}

.cubic-btn-small {
    padding: 6px 12px;
    font-size: 0.8rem;
    min-width: auto;
}

.cubic-form-actions {
    text-align: center;
    margin-top: 30px;
}

/* Test interface styles */
.cubic-test-header {
    background: #fff;
    border-radius: 8px;
    padding: 20px;
    margin-bottom: 20px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 15px;
}

/* Sticky header styles */
.cubic-sticky-header {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    background: #fff;
    padding: 10px 20px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.15);
    z-index: 1000;
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 15px;
    border-bottom: 2px solid #3498db;
    transition: all 0.3s ease;
}

.cubic-sticky-header .cubic-progress-container {
    flex: 1;
    min-width: 200px;
}

.cubic-sticky-header .cubic-progress-text {
    font-size: 0.85rem;
    margin-bottom: 5px;
}

.cubic-sticky-header .cubic-timer {
    font-size: 1.2rem;
    font-weight: 700;
    color: #2c3e50;
    font-family: 'Courier New', monospace;
}

.cubic-sticky-header .cubic-progress-bar {
    height: 6px;
    margin-bottom: 5px;
}

/* Body padding when sticky header is active */
.cubic-container.has-sticky-header {
    padding-top: 80px;
}

.cubic-progress-container {
    flex: 1;
    min-width: 200px;
}

.cubic-progress-bar {
    width: 100%;
    height: 8px;
    background: #ecf0f1;
    border-radius: 4px;
    overflow: hidden;
    margin-bottom: 8px;
}

.cubic-progress-fill {
    height: 100%;
    background: linear-gradient(90deg, #3498db, #2ecc71);
    transition: width 0.5s ease;
    border-radius: 4px;
}

.cubic-progress-text {
    font-size: 0.9rem;
    color: #7f8c8d;
    font-weight: 500;
}

.cubic-timer-container {
    text-align: right;
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    gap: 8px;
}

.cubic-timer-label {
    font-size: 0.9rem;
    color: #7f8c8d;
    font-weight: 500;
}

.cubic-timer {
    font-size: 1.5rem;
    font-weight: 700;
    color: #2c3e50;
    font-family: 'Courier New', monospace;
}

.cubic-voluntary-finish {
    font-size: 0.8rem;
    padding: 4px 8px;
    margin-top: 5px;
}

/* Category notice */
.cubic-category-notice {
    background: #f8f9fa;
    border-left: 4px solid #3498db;
    padding: 20px;
    margin-bottom: 20px;
    border-radius: 0 8px 8px 0;
}

/* Category header for page-level category display */
.cubic-category-header {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    padding: 30px;
    margin-bottom: 25px;
    border-radius: 12px;
    text-align: center;
    box-shadow: 0 4px 15px rgba(102, 126, 234, 0.3);
}

.cubic-category-header .cubic-category-title {
    font-size: 1.8rem;
    font-weight: 700;
    margin: 0 0 15px 0;
    color: white;
    text-shadow: 0 1px 3px rgba(0, 0, 0, 0.3);
}

.cubic-category-header .cubic-category-description {
    font-size: 1.1rem;
    margin: 0 0 15px 0;
    color: rgba(255, 255, 255, 0.95);
    line-height: 1.5;
}

.cubic-category-info {
    font-size: 0.9rem;
    color: rgba(255, 255, 255, 0.8);
    margin-top: 10px;
    font-weight: 500;
}

.cubic-category-title {
    font-size: 1.3rem;
    font-weight: 600;
    margin: 0 0 10px 0;
    color: #2c3e50;
}

.cubic-category-description {
    margin: 0;
    color: #5d6d7e;
    font-size: 0.95rem;
}

/* Question styles */
.cubic-questions-container {
    background: #fff;
    border-radius: 8px;
    padding: 25px;
    margin-bottom: 20px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
}

.cubic-question {
    margin-bottom: 30px;
    padding-bottom: 25px;
    border-bottom: 1px solid #ecf0f1;
    transition: all 0.3s ease;
}

.cubic-question.cubic-unanswered {
    border: 2px solid #e74c3c;
    border-radius: 8px;
    padding: 20px;
    background: #fdf2f2;
    animation: pulse-error 2s ease-in-out;
}

.cubic-question.cubic-unanswered .cubic-question-number {
    background: #e74c3c;
    animation: shake 0.5s ease-in-out;
}

.cubic-question.cubic-unanswered::after {
    content: "この設問は必須です";
    display: block;
    color: #e74c3c;
    font-size: 0.9rem;
    font-weight: 600;
    margin-top: 10px;
    padding: 8px 12px;
    background: #fff;
    border-radius: 4px;
    border-left: 3px solid #e74c3c;
}

@keyframes pulse-error {
    0%, 100% { transform: scale(1); }
    50% { transform: scale(1.02); }
}

@keyframes shake {
    0%, 100% { transform: translateX(0); }
    25% { transform: translateX(-2px); }
    75% { transform: translateX(2px); }
}

.cubic-question:last-child {
    margin-bottom: 0;
    padding-bottom: 0;
    border-bottom: none;
}

.cubic-question-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 15px;
    flex-wrap: wrap;
    gap: 10px;
}

.cubic-question-number {
    background: #3498db;
    color: white;
    padding: 4px 12px;
    border-radius: 20px;
    font-weight: 600;
    font-size: 0.9rem;
}

.cubic-question-category {
    background: #e8f4fd;
    color: #2980b9;
    padding: 4px 12px;
    border-radius: 20px;
    font-size: 0.85rem;
    font-weight: 500;
}

.cubic-question-text {
    font-size: 1.1rem;
    margin-bottom: 20px;
    color: #2c3e50;
    line-height: 1.7;
}

.cubic-options {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.cubic-option {
    display: flex;
    align-items: center;
    padding: 15px;
    border: 2px solid #ecf0f1;
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.3s ease;
    background: #fff;
}

.cubic-option:hover {
    border-color: #3498db;
    background: #f8fbff;
    transform: translateX(5px);
}

.cubic-option.selected {
    border-color: #3498db;
    background: #e8f4fd;
    box-shadow: 0 2px 8px rgba(52, 152, 219, 0.2);
}

.cubic-option-letter {
    background: #bdc3c7;
    color: white;
    width: 30px;
    height: 30px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 600;
    margin-right: 15px;
    flex-shrink: 0;
    transition: background-color 0.3s ease;
}

.cubic-option.selected .cubic-option-letter {
    background: #3498db;
}

.cubic-option-text {
    flex: 1;
    font-size: 1rem;
    line-height: 1.5;
}

/* Navigation */
.cubic-navigation {
    display: flex;
    justify-content: space-between;
    align-items: center;
    background: #fff;
    padding: 20px;
    border-radius: 8px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
}

.cubic-page-info {
    font-weight: 600;
    color: #7f8c8d;
    text-align: center;
    flex: 1;
}

/* Results styles */
.cubic-results-container {
    background: #fff;
    border-radius: 8px;
    padding: 40px;
    box-shadow: 0 2px 12px rgba(0, 0, 0, 0.1);
    text-align: center;
}

.cubic-results-header {
    margin-bottom: 40px;
}

.cubic-results-title {
    font-size: 2.2rem;
    color: #27ae60;
    margin-bottom: 10px;
}

.cubic-results-subtitle {
    font-size: 1.1rem;
    color: #7f8c8d;
    margin: 0;
}

.cubic-results-summary {
    background: #f8f9fa;
    border-radius: 8px;
    padding: 30px;
    margin-bottom: 30px;
}

.cubic-summary-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 12px 0;
    border-bottom: 1px solid #ecf0f1;
}

.cubic-summary-item:last-child {
    border-bottom: none;
}

.cubic-summary-label {
    font-weight: 600;
    color: #5d6d7e;
}

.cubic-summary-value {
    color: #2c3e50;
    font-weight: 500;
}

.cubic-score {
    color: #27ae60;
    font-size: 1.2rem;
    font-weight: 700;
}

.cubic-category-scores {
    margin-bottom: 30px;
}

.cubic-category-scores h3 {
    color: #2c3e50;
    margin-bottom: 20px;
}

.cubic-category-score {
    display: flex;
    justify-content: space-between;
    align-items: center;
    background: #fff;
    padding: 15px;
    margin-bottom: 10px;
    border-radius: 6px;
    border: 1px solid #ecf0f1;
}

.cubic-category-name {
    font-weight: 500;
    color: #5d6d7e;
}

.cubic-category-points {
    color: #3498db;
    font-weight: 600;
}

.cubic-completion-message {
    color: #7f8c8d;
    font-size: 0.95rem;
    line-height: 1.6;
    margin: 0;
}

/* Loading states */
.cubic-loading-container {
    text-align: center;
    padding: 60px 20px;
}

.cubic-spinner {
    width: 40px;
    height: 40px;
    border: 4px solid #ecf0f1;
    border-top: 4px solid #3498db;
    border-radius: 50%;
    animation: cubic-spin 1s linear infinite;
    margin: 0 auto 20px;
}

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

.cubic-loading-message {
    color: #7f8c8d;
    font-size: 1.1rem;
}

/* Message styles */
.cubic-message {
    padding: 15px 20px;
    border-radius: 6px;
    margin-bottom: 20px;
    font-weight: 500;
}

.cubic-message-info {
    background: #e8f4fd;
    color: #2980b9;
    border: 1px solid #bde1f7;
}

.cubic-message-error {
    background: #fdf2f2;
    color: #c0392b;
    border: 1px solid #f5b7b1;
}

.cubic-message-success {
    background: #eafaf1;
    color: #27ae60;
    border: 1px solid #a9dfbf;
}

/* Error container styles */
.cubic-error-container {
    background: #fdf2f2;
    border: 2px solid #e74c3c;
    border-radius: 8px;
    padding: 30px;
    margin: 20px auto;
    max-width: 600px;
    text-align: center;
}

.cubic-error-message h3 {
    color: #c0392b;
    margin: 0 0 15px 0;
    font-size: 1.5rem;
}

.cubic-error-message p {
    color: #7f8c8d;
    margin: 0 0 15px 0;
    line-height: 1.6;
}

.cubic-error-message ul {
    text-align: left;
    max-width: 400px;
    margin: 15px auto;
    padding-left: 20px;
}

.cubic-error-message li {
    color: #5d6d7e;
    margin-bottom: 8px;
}

.cubic-error-message code {
    background: #ecf0f1;
    padding: 2px 6px;
    border-radius: 3px;
    font-family: Monaco, 'Courier New', monospace;
    font-size: 0.9em;
    color: #2c3e50;
}

/* Attempt tracking styles */
.cubic-attempt-info {
    margin: 15px 0 25px 0;
    padding: 12px 18px;
    border-radius: 6px;
    border-left: 4px solid;
    font-size: 0.95rem;
    font-weight: 500;
}

.cubic-attempt-info.cubic-info {
    background-color: #e8f4fd;
    color: #2980b9;
    border-left-color: #3498db;
}

.cubic-attempt-info.cubic-warning {
    background-color: #fef9e7;
    color: #d68910;
    border-left-color: #f39c12;
}

.cubic-attempt-info.cubic-error {
    background-color: #fdf2f2;
    color: #c0392b;
    border-left-color: #e74c3c;
}

.cubic-info-message {
    display: flex;
    align-items: center;
    gap: 8px;
}

.cubic-info-icon {
    font-size: 1.1rem;
    margin-right: 4px;
}

/* Enhanced error handling */
.cubic-input.cubic-error {
    border-color: #e74c3c;
    box-shadow: 0 0 0 3px rgba(231, 76, 60, 0.1);
}

.cubic-btn:disabled,
.cubic-btn[disabled] {
    background-color: #bdc3c7;
    border-color: #bdc3c7;
    color: #7f8c8d;
    cursor: not-allowed;
    opacity: 0.6;
}

.cubic-btn:disabled:hover,
.cubic-btn[disabled]:hover {
    background-color: #bdc3c7;
    border-color: #bdc3c7;
    transform: none;
}

/* Better message styling */
.cubic-message {
    animation: cubic-fade-in 0.3s ease-in-out;
}

@keyframes cubic-fade-in {
    from {
        opacity: 0;
        transform: translateY(-10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* Loading animation improvements */
.cubic-loading {
    position: relative;
}

.cubic-loading::after {
    content: '';
    display: inline-block;
    width: 20px;
    height: 20px;
    margin-left: 10px;
    border: 2px solid #bdc3c7;
    border-top: 2px solid #3498db;
    border-radius: 50%;
    animation: cubic-spin 1s linear infinite;
}

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

/* Mobile responsive design */
@media (max-width: 768px) {
    .cubic-container {
        padding: 15px;
    }
    
    .cubic-title {
        font-size: 1.6rem;
    }
    
    .cubic-user-form-container {
        padding: 20px;
    }
    
    .cubic-test-header {
        flex-direction: column;
        text-align: center;
    }
    
    .cubic-progress-container {
        width: 100%;
        margin-bottom: 15px;
    }
    
    .cubic-timer-container {
        text-align: center;
    }
    
    .cubic-timer {
        font-size: 1.3rem;
    }
    
    .cubic-questions-container {
        padding: 20px;
    }
    
    .cubic-question-header {
        flex-direction: column;
        align-items: flex-start;
        gap: 8px;
    }
    
    .cubic-question-text {
        font-size: 1rem;
    }
    
    .cubic-option {
        padding: 12px;
    }
    
    .cubic-option:hover {
        transform: none;
    }
    
    .cubic-option-letter {
        width: 25px;
        height: 25px;
        margin-right: 12px;
        font-size: 0.9rem;
    }
    
    .cubic-option-text {
        font-size: 0.95rem;
    }
    
    .cubic-navigation {
        flex-direction: column;
        gap: 15px;
        align-items: center;
    }
    
    .cubic-page-info {
        order: -1;
        margin-bottom: 10px;
    }
    
    .cubic-btn {
        width: 100%;
        max-width: 200px;
    }
    
    .cubic-results-container {
        padding: 25px;
    }
    
    .cubic-results-title {
        font-size: 1.8rem;
    }
    
    .cubic-summary-item {
        flex-direction: column;
        align-items: flex-start;
        gap: 5px;
        text-align: left;
    }
    
    .cubic-category-score {
        flex-direction: column;
        align-items: flex-start;
        gap: 5px;
        text-align: left;
    }
}

@media (max-width: 480px) {
    .cubic-container {
        padding: 10px;
    }
    
    .cubic-title {
        font-size: 1.4rem;
    }
    
    .cubic-user-form-container {
        padding: 15px;
    }
    
    .cubic-input,
    .cubic-select,
    .cubic-btn {
        padding: 10px 14px;
    }
    
    .cubic-questions-container {
        padding: 15px;
    }
    
    .cubic-results-container {
        padding: 20px;
    }
}

/* Print styles */
@media print {
    .cubic-test-header,
    .cubic-navigation,
    .cubic-btn {
        display: none !important;
    }
    
    .cubic-container {
        max-width: none;
        padding: 0;
    }
    
    .cubic-question {
        page-break-inside: avoid;
    }
}

/* Custom Confirmation Dialog Styles */
.cubic-confirm-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.5);
    z-index: 10000;
    display: flex;
    align-items: center;
    justify-content: center;
    backdrop-filter: blur(2px);
}

.cubic-confirm-dialog {
    background: #fff;
    border-radius: 8px;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.3);
    max-width: 480px;
    width: 90%;
    margin: 20px;
    animation: cubic-dialog-appear 0.2s ease-out;
}

@keyframes cubic-dialog-appear {
    from {
        opacity: 0;
        transform: translateY(-20px) scale(0.95);
    }
    to {
        opacity: 1;
        transform: translateY(0) scale(1);
    }
}

.cubic-confirm-header {
    padding: 20px 24px 0 24px;
    border-bottom: none;
}

.cubic-confirm-title {
    margin: 0;
    font-size: 1.25rem;
    font-weight: 600;
    color: #2c3e50;
    text-align: center;
}

.cubic-confirm-body {
    padding: 16px 24px 24px 24px;
}

.cubic-confirm-message {
    margin: 0;
    font-size: 1rem;
    line-height: 1.6;
    color: #4a5568;
    white-space: pre-line;
    text-align: center;
}

.cubic-confirm-footer {
    padding: 0 24px 24px 24px;
    display: flex;
    gap: 12px;
    justify-content: center;
}

.cubic-confirm-footer .cubic-btn {
    min-width: 100px;
    flex: 0 0 auto;
}

.cubic-confirm-cancel {
    background: #f8f9fa;
    color: #6c757d;
    border: 1px solid #dee2e6;
}

.cubic-confirm-cancel:hover {
    background: #e9ecef;
    color: #495057;
}

.cubic-confirm-ok {
    background: #007bff;
    color: #fff;
    border: 1px solid #007bff;
}

.cubic-confirm-ok:hover {
    background: #0056b3;
    border-color: #004085;
}

/* Mobile responsiveness for dialog */
@media (max-width: 600px) {
    .cubic-confirm-dialog {
        margin: 10px;
        width: calc(100% - 20px);
    }
    
    .cubic-confirm-header,
    .cubic-confirm-body,
    .cubic-confirm-footer {
        padding-left: 16px;
        padding-right: 16px;
    }
    
    .cubic-confirm-footer {
        flex-direction: column;
    }
    
    .cubic-confirm-footer .cubic-btn {
        width: 100%;
        min-width: auto;
    }
}