/**
 * APCD Inscrições - Frontend Styles
 */

/* Variables */
:root {
    --apcd-primary: #e31837;
    --apcd-primary-dark: #c41530;
    --apcd-primary-light: #ff4d6a;
    --apcd-secondary: #333;
    --apcd-success: #28a745;
    --apcd-danger: #dc3545;
    --apcd-warning: #ffc107;
    --apcd-gray-100: #f8f9fa;
    --apcd-gray-200: #e9ecef;
    --apcd-gray-300: #dee2e6;
    --apcd-gray-400: #ced4da;
    --apcd-gray-500: #adb5bd;
    --apcd-gray-600: #6c757d;
    --apcd-gray-700: #495057;
    --apcd-gray-800: #343a40;
    --apcd-gray-900: #212529;
    --apcd-border-radius: 8px;
    --apcd-border-radius-lg: 12px;
    --apcd-shadow: 0 2px 8px rgba(0, 0, 0, 0.08);
    --apcd-shadow-lg: 0 8px 24px rgba(0, 0, 0, 0.12);
    --apcd-transition: all 0.2s ease;
}

/* Reset box-sizing */
.apcd-form-container *,
.apcd-form-container *::before,
.apcd-form-container *::after {
    box-sizing: border-box;
}

/* Container */
.apcd-form-container {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Oxygen-Sans, Ubuntu, Cantarell, "Helvetica Neue", sans-serif;
    font-size: 16px;
    line-height: 1.5;
    color: var(--apcd-gray-800);
    max-width: 900px;
    margin: 0 auto;
}

/* Title */
.apcd-form-title {
    font-size: 28px;
    font-weight: 700;
    color: var(--apcd-gray-900);
    margin: 0 0 16px 0;
    text-align: center;
}

/* Instructions */
.apcd-form-instructions {
    background: linear-gradient(135deg, #f0f4ff 0%, #e8f0fe 100%);
    border-left: 4px solid var(--apcd-primary);
    border-radius: 0 var(--apcd-border-radius) var(--apcd-border-radius) 0;
    padding: 20px 24px;
    margin-bottom: 32px;
    font-size: 15px;
    color: var(--apcd-gray-700);
}

.apcd-form-instructions p:last-child {
    margin-bottom: 0;
}

/* Form */
.apcd-form {
    background: #fff;
    border-radius: var(--apcd-border-radius-lg);
    box-shadow: var(--apcd-shadow-lg);
    padding: 32px;
}

/* Section */
.apcd-form-section {
    margin-bottom: 32px;
    padding-bottom: 24px;
    border-bottom: 1px solid var(--apcd-gray-200);
}

.apcd-form-section:last-of-type {
    margin-bottom: 0;
    padding-bottom: 0;
    border-bottom: none;
}

.apcd-form-section[data-conditional-field] {
    display: none;
}

.apcd-form-section[data-conditional-field].apcd-section-visible {
    display: block;
}

.apcd-section-title {
    font-size: 18px;
    font-weight: 600;
    color: var(--apcd-primary);
    margin: 0 0 20px 0;
    padding-bottom: 12px;
    border-bottom: 2px solid var(--apcd-gray-200);
}

/* Fields Row */
.apcd-fields-row {
    display: flex;
    flex-wrap: wrap;
    gap: 20px;
}

/* Field */
.apcd-field {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.apcd-field-full {
    flex: 1 1 100%;
}

.apcd-field-medium {
    flex: 1 1 calc(50% - 10px);
    min-width: 200px;
}

.apcd-field-small {
    flex: 1 1 calc(33.333% - 14px);
    min-width: 120px;
}

/* Labels */
.apcd-form-container .apcd-field > label,
.apcd-form-container .apcd-field label {
    display: block !important;
    font-size: 14px !important;
    font-weight: 600 !important;
    color: var(--apcd-gray-700) !important;
    margin-bottom: 6px !important;
    line-height: 1.4 !important;
}

.apcd-required {
    color: var(--apcd-danger);
    margin-left: 2px;
}

/* Inputs */
.apcd-form-container .apcd-input,
.apcd-form-container .apcd-select,
.apcd-form-container .apcd-textarea,
.apcd-form-container input[type="text"],
.apcd-form-container input[type="email"],
.apcd-form-container input[type="date"],
.apcd-form-container input[type="tel"],
.apcd-form-container select,
.apcd-form-container textarea {
    width: 100% !important;
    padding: 12px 16px !important;
    font-size: 15px !important;
    color: var(--apcd-gray-800) !important;
    background: var(--apcd-gray-100) !important;
    border: 2px solid transparent !important;
    border-radius: var(--apcd-border-radius) !important;
    transition: var(--apcd-transition) !important;
    outline: none !important;
    box-sizing: border-box !important;
    height: auto !important;
    min-height: 48px !important;
    line-height: 1.5 !important;
    margin: 0 !important;
    -webkit-appearance: none !important;
    -moz-appearance: none !important;
    appearance: none !important;
}

.apcd-form-container .apcd-input:hover,
.apcd-form-container .apcd-select:hover,
.apcd-form-container .apcd-textarea:hover,
.apcd-form-container input[type="text"]:hover,
.apcd-form-container input[type="email"]:hover,
.apcd-form-container input[type="date"]:hover,
.apcd-form-container input[type="tel"]:hover,
.apcd-form-container select:hover,
.apcd-form-container textarea:hover {
    background: var(--apcd-gray-200) !important;
}

.apcd-form-container .apcd-input:focus,
.apcd-form-container .apcd-select:focus,
.apcd-form-container .apcd-textarea:focus,
.apcd-form-container input[type="text"]:focus,
.apcd-form-container input[type="email"]:focus,
.apcd-form-container input[type="date"]:focus,
.apcd-form-container input[type="tel"]:focus,
.apcd-form-container select:focus,
.apcd-form-container textarea:focus {
    background: #fff !important;
    border-color: var(--apcd-primary) !important;
    box-shadow: 0 0 0 4px rgba(227, 24, 55, 0.1) !important;
}

.apcd-form-container .apcd-input.apcd-error,
.apcd-form-container .apcd-select.apcd-error,
.apcd-form-container .apcd-textarea.apcd-error {
    border-color: var(--apcd-danger) !important;
    background: #fff8f8 !important;
}

.apcd-form-container .apcd-input.apcd-error:focus,
.apcd-form-container .apcd-select.apcd-error:focus,
.apcd-form-container .apcd-textarea.apcd-error:focus {
    box-shadow: 0 0 0 4px rgba(220, 53, 69, 0.1) !important;
}

.apcd-form-container .apcd-select,
.apcd-form-container select {
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'%3E%3Cpath fill='%23495057' d='M6 8L1 3h10z'/%3E%3C/svg%3E") !important;
    background-repeat: no-repeat !important;
    background-position: right 16px center !important;
    padding-right: 40px !important;
    cursor: pointer !important;
}

.apcd-form-container .apcd-textarea,
.apcd-form-container textarea {
    min-height: 100px !important;
    resize: vertical !important;
}

/* Date Input */
.apcd-form-container .apcd-input[type="date"],
.apcd-form-container input[type="date"] {
    cursor: pointer !important;
}

/* File Upload */
.apcd-file-upload {
    position: relative;
}

.apcd-file-input {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    border: 0;
}

.apcd-file-label {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 24px;
    background: var(--apcd-gray-100);
    border: 2px dashed var(--apcd-gray-400);
    border-radius: var(--apcd-border-radius);
    cursor: pointer;
    transition: var(--apcd-transition);
    text-align: center;
}

.apcd-file-label:hover {
    background: var(--apcd-gray-200);
    border-color: var(--apcd-primary);
}

.apcd-file-input:focus + .apcd-file-label {
    border-color: var(--apcd-primary);
    box-shadow: 0 0 0 4px rgba(227, 24, 55, 0.1);
}

.apcd-file-icon {
    color: var(--apcd-gray-500);
}

.apcd-file-icon svg {
    width: 32px;
    height: 32px;
}

.apcd-file-text {
    font-size: 14px;
    font-weight: 500;
    color: var(--apcd-gray-700);
}

.apcd-file-hint {
    font-size: 12px;
    color: var(--apcd-gray-500);
}

/* File Preview */
.apcd-file-preview {
    margin-top: 12px;
    display: none;
}

.apcd-file-preview.apcd-has-file {
    display: block;
}

.apcd-file-preview-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px;
    background: var(--apcd-gray-100);
    border-radius: var(--apcd-border-radius);
}

.apcd-file-preview-icon {
    width: 40px;
    height: 40px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: #fff;
    border-radius: 8px;
}

.apcd-file-preview-icon img {
    width: 40px;
    height: 40px;
    object-fit: cover;
    border-radius: 8px;
}

.apcd-file-preview-icon svg {
    width: 24px;
    height: 24px;
    color: var(--apcd-danger);
}

.apcd-file-preview-info {
    flex: 1;
    min-width: 0;
}

.apcd-file-preview-name {
    font-size: 14px;
    font-weight: 500;
    color: var(--apcd-gray-800);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.apcd-file-preview-size {
    font-size: 12px;
    color: var(--apcd-gray-500);
}

.apcd-file-preview-remove {
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: none;
    border: none;
    border-radius: 50%;
    color: var(--apcd-gray-500);
    cursor: pointer;
    transition: var(--apcd-transition);
}

.apcd-file-preview-remove:hover {
    background: var(--apcd-danger);
    color: #fff;
}

.apcd-file-upload.apcd-error .apcd-file-label {
    border-color: var(--apcd-danger);
    background: #fff8f8;
}

/* Checkbox */
.apcd-checkbox-wrap {
    display: flex;
    align-items: flex-start;
    gap: 12px;
    flex-wrap: wrap;
}

.apcd-checkbox {
    width: 20px;
    height: 20px;
    margin: 2px 0 0 0;
    accent-color: var(--apcd-primary);
    cursor: pointer;
    flex-shrink: 0;
}

.apcd-checkbox-label {
    font-size: 14px;
    color: var(--apcd-gray-700);
    cursor: pointer;
    flex: 1;
}

.apcd-lgpd-link {
    background: none;
    border: none;
    color: var(--apcd-primary);
    font-size: 13px;
    cursor: pointer;
    text-decoration: underline;
    padding: 0;
}

.apcd-lgpd-link:hover {
    color: var(--apcd-primary-dark);
}

/* Field Error */
.apcd-field-error {
    font-size: 13px;
    color: var(--apcd-danger);
    min-height: 18px;
}

/* Form Footer */
.apcd-form-footer {
    margin-top: 32px;
    text-align: center;
}

/* Submit Button */
.apcd-submit-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    min-width: 220px;
    padding: 16px 40px;
    font-size: 16px;
    font-weight: 600;
    color: #fff;
    background: linear-gradient(135deg, var(--apcd-primary) 0%, var(--apcd-primary-dark) 100%);
    border: none;
    border-radius: 50px;
    cursor: pointer;
    transition: var(--apcd-transition);
    box-shadow: 0 4px 12px rgba(227, 24, 55, 0.3);
}

.apcd-submit-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(227, 24, 55, 0.4);
}

.apcd-submit-btn:active {
    transform: translateY(0);
}

.apcd-submit-btn:disabled {
    opacity: 0.7;
    cursor: not-allowed;
    transform: none;
}

.apcd-btn-loading {
    display: none;
    align-items: center;
    gap: 8px;
}

.apcd-submit-btn.apcd-loading .apcd-btn-text {
    display: none;
}

.apcd-submit-btn.apcd-loading .apcd-btn-loading {
    display: flex;
}

/* Spinner */
.apcd-spinner {
    animation: apcd-rotate 2s linear infinite;
    width: 20px;
    height: 20px;
}

.apcd-spinner .path {
    stroke: #fff;
    stroke-linecap: round;
    animation: apcd-dash 1.5s ease-in-out infinite;
}

@keyframes apcd-rotate {
    100% {
        transform: rotate(360deg);
    }
}

@keyframes apcd-dash {
    0% {
        stroke-dasharray: 1, 150;
        stroke-dashoffset: 0;
    }
    50% {
        stroke-dasharray: 90, 150;
        stroke-dashoffset: -35;
    }
    100% {
        stroke-dasharray: 90, 150;
        stroke-dashoffset: -124;
    }
}

/* Form Messages */
.apcd-form-messages {
    margin-top: 20px;
    text-align: center;
}

.apcd-message {
    padding: 16px 24px;
    border-radius: var(--apcd-border-radius);
    font-size: 15px;
    animation: apcd-fadeIn 0.3s ease;
}

.apcd-message-success {
    background: #d4edda;
    color: #155724;
    border: 1px solid #c3e6cb;
}

.apcd-message-error {
    background: #f8d7da;
    color: #721c24;
    border: 1px solid #f5c6cb;
}

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

/* Success State */
.apcd-form-container.apcd-success .apcd-form {
    display: none;
}

.apcd-success-message {
    text-align: center;
    padding: 60px 40px;
    background: #fff;
    border-radius: var(--apcd-border-radius-lg);
    box-shadow: var(--apcd-shadow-lg);
}

.apcd-success-icon {
    width: 80px;
    height: 80px;
    margin: 0 auto 24px;
    background: var(--apcd-success);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    animation: apcd-scaleIn 0.5s ease;
}

.apcd-success-icon svg {
    width: 40px;
    height: 40px;
    color: #fff;
}

@keyframes apcd-scaleIn {
    from {
        transform: scale(0);
    }
    to {
        transform: scale(1);
    }
}

.apcd-success-message h3 {
    font-size: 24px;
    color: var(--apcd-gray-900);
    margin: 0 0 12px 0;
}

.apcd-success-message p {
    color: var(--apcd-gray-600);
    margin: 0;
}

/* Modal */
.apcd-modal {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 99999;
    padding: 20px;
    overflow-y: auto;
}

.apcd-modal.apcd-modal-open {
    display: flex;
    align-items: flex-start;
    justify-content: center;
}

.apcd-modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.6);
    animation: apcd-fadeIn 0.2s ease;
}

.apcd-modal-content {
    position: relative;
    width: 100%;
    max-width: 700px;
    margin: 40px 0;
    background: #fff;
    border-radius: var(--apcd-border-radius-lg);
    box-shadow: var(--apcd-shadow-lg);
    animation: apcd-slideIn 0.3s ease;
}

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

.apcd-modal-close {
    position: absolute;
    top: 16px;
    right: 16px;
    width: 36px;
    height: 36px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--apcd-gray-100);
    border: none;
    border-radius: 50%;
    font-size: 24px;
    color: var(--apcd-gray-600);
    cursor: pointer;
    transition: var(--apcd-transition);
}

.apcd-modal-close:hover {
    background: var(--apcd-gray-200);
    color: var(--apcd-gray-900);
}

.apcd-modal-body {
    padding: 32px;
    max-height: 60vh;
    overflow-y: auto;
}

.apcd-modal-body h3,
.apcd-modal-body h4 {
    color: var(--apcd-primary);
    margin-top: 24px;
}

.apcd-modal-body h3:first-child,
.apcd-modal-body h4:first-child {
    margin-top: 0;
}

.apcd-modal-body ol,
.apcd-modal-body ul {
    padding-left: 24px;
}

.apcd-modal-body li {
    margin-bottom: 8px;
}

.apcd-modal-footer {
    padding: 16px 32px;
    border-top: 1px solid var(--apcd-gray-200);
    text-align: right;
}

.apcd-modal-btn {
    padding: 10px 24px;
    font-size: 14px;
    font-weight: 600;
    color: #fff;
    background: var(--apcd-primary);
    border: none;
    border-radius: 6px;
    cursor: pointer;
    transition: var(--apcd-transition);
}

.apcd-modal-btn:hover {
    background: var(--apcd-primary-dark);
}

/* Responsive */
@media (max-width: 768px) {
    .apcd-form-container {
        padding: 0 16px;
    }

    .apcd-form-title {
        font-size: 24px;
    }

    .apcd-form {
        padding: 24px 20px;
    }

    .apcd-section-title {
        font-size: 16px;
    }

    .apcd-fields-row {
        gap: 16px;
    }

    .apcd-field-medium,
    .apcd-field-small {
        flex: 1 1 100%;
    }

    .apcd-input,
    .apcd-select,
    .apcd-textarea {
        padding: 10px 14px;
        font-size: 16px; /* Prevents zoom on iOS */
    }

    .apcd-file-label {
        padding: 20px;
    }

    .apcd-submit-btn {
        width: 100%;
        padding: 14px 32px;
    }

    .apcd-modal-content {
        margin: 20px 0;
    }

    .apcd-modal-body {
        padding: 24px 20px;
    }

    .apcd-modal-footer {
        padding: 16px 20px;
    }
}

@media (max-width: 480px) {
    .apcd-form-title {
        font-size: 20px;
    }

    .apcd-form {
        padding: 20px 16px;
    }

    .apcd-form-instructions {
        padding: 16px;
    }

    .apcd-checkbox-wrap {
        flex-direction: column;
        gap: 8px;
    }

    .apcd-checkbox {
        order: -1;
    }
}

/* Print */
@media print {
    .apcd-form-container {
        box-shadow: none;
    }

    .apcd-submit-btn {
        display: none;
    }
}
