/**
 * Responsive CSS
 * Estilos específicos para diferentes tamanhos de tela
 */

/* ============================================
   MODAL STYLES
   ============================================ */

.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-color: rgba(0, 0, 0, 0.5);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.3s ease, visibility 0.3s ease;
    padding: 1rem;
}

.modal-overlay.active {
    opacity: 1;
    visibility: visible;
}

.modal-content {
    background: white;
    border-radius: 8px;
    box-shadow: 0 20px 25px -5px rgba(0, 0, 0, 0.1), 0 10px 10px -5px rgba(0, 0, 0, 0.04);
    max-width: 600px;
    width: 100%;
    max-height: 90vh;
    display: flex;
    flex-direction: column;
    transform: scale(0.9);
    transition: transform 0.3s ease;
}

.modal-overlay.active .modal-content {
    transform: scale(1);
}

.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 1.5rem;
    border-bottom: 1px solid var(--color-gray-200);
}

.modal-title {
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--color-gray-900);
    margin: 0;
}

.modal-close {
    background: none;
    border: none;
    padding: 0.5rem;
    cursor: pointer;
    color: var(--color-gray-500);
    transition: color 0.2s ease;
    border-radius: 4px;
}

.modal-close:hover {
    color: var(--color-gray-700);
    background-color: var(--color-gray-100);
}

.modal-close svg {
    width: 1.5rem;
    height: 1.5rem;
}

.modal-form {
    padding: 1.5rem;
    overflow-y: auto;
    flex: 1;
}

.modal-footer {
    display: flex;
    justify-content: flex-end;
    gap: 0.75rem;
    padding: 1.5rem;
    border-top: 1px solid var(--color-gray-200);
    background-color: white;
    flex-shrink: 0;
}

/* ============================================
   FORM STYLES
   ============================================ */

.form-group {
    margin-bottom: 1.5rem;
}

.form-label {
    display: block;
    font-size: 0.875rem;
    font-weight: 600;
    color: var(--color-gray-700);
    margin-bottom: 0.5rem;
}

.form-input {
    width: 100%;
    padding: 0.625rem 0.875rem;
    font-size: 1rem;
    border: 1px solid var(--color-gray-300);
    border-radius: 6px;
    transition: border-color 0.2s ease, box-shadow 0.2s ease;
    background-color: white;
}

.form-input:focus {
    outline: none;
    border-color: var(--color-primary-500);
    box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.1);
}

.form-input.error {
    border-color: var(--color-danger-500);
}

.form-input.error:focus {
    box-shadow: 0 0 0 3px rgba(239, 68, 68, 0.1);
}

.form-checkbox,
.form-radio {
    width: 1.125rem;
    height: 1.125rem;
    border: 1px solid var(--color-gray-300);
    cursor: pointer;
    transition: all 0.2s ease;
}

.form-checkbox:checked,
.form-radio:checked {
    background-color: var(--color-primary-500);
    border-color: var(--color-primary-500);
}

.form-checkbox:focus,
.form-radio:focus {
    outline: none;
    box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.1);
}

.form-hint {
    font-size: 0.75rem;
    color: var(--color-gray-500);
    margin-top: 0.25rem;
}

.form-error {
    display: none;
    font-size: 0.875rem;
    color: var(--color-danger-600);
    margin-top: 0.5rem;
}

.form-error.active {
    display: block;
}

/* ============================================
   BUTTON STYLES
   ============================================ */

.btn {
    padding: 0.625rem 1.25rem;
    font-size: 0.875rem;
    font-weight: 600;
    border-radius: 6px;
    border: none;
    cursor: pointer;
    transition: all 0.2s ease;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
}

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

.btn-primary {
    background-color: var(--color-primary-500);
    color: white;
}

.btn-primary:hover:not(:disabled) {
    background-color: var(--color-primary-600);
    box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1);
}

.btn-secondary {
    background-color: white;
    color: var(--color-gray-700);
    border: 1px solid var(--color-gray-300);
}

.btn-secondary:hover:not(:disabled) {
    background-color: var(--color-gray-50);
}

.btn-danger {
    background-color: var(--color-danger-500);
    color: white;
}

.btn-danger:hover:not(:disabled) {
    background-color: var(--color-danger-600);
}

/* ============================================
   PROPAGATION OPTIONS
   ============================================ */

.propagation-options {
    background-color: var(--color-blue-50);
    border: 1px solid var(--color-blue-200);
    border-radius: 8px;
    padding: 1rem;
}

.propagation-options label {
    cursor: pointer;
    padding: 0.75rem;
    border-radius: 6px;
    transition: background-color 0.2s ease;
}

.propagation-options label:hover {
    background-color: rgba(255, 255, 255, 0.5);
}

/* ============================================
   MOBILE BREAKPOINTS
   ============================================ */

/* Small devices (landscape phones, 576px and up) */
@media (max-width: 640px) {
    .modal-overlay {
        padding: 0;
        align-items: flex-end;
    }

    .modal-content {
        max-width: 100%;
        max-height: 95vh;
        border-bottom-left-radius: 0;
        border-bottom-right-radius: 0;
        transform: translateY(100%);
    }

    .modal-overlay.active .modal-content {
        transform: translateY(0);
    }

    .modal-header {
        padding: 1rem;
    }

    .modal-title {
        font-size: 1.25rem;
    }

    .modal-form {
        padding: 1rem;
    }

    .modal-footer {
        flex-direction: column-reverse;
        gap: 0.5rem;
    }

    .modal-footer .btn {
        width: 100%;
    }

    .form-group {
        margin-bottom: 1.25rem;
    }

    .form-input {
        font-size: 1rem; /* Previne zoom no iOS */
    }

    /* CORREÇÃO MOBILE: Garantir que botões sejam clicáveis */
    .btn,
    .modal-close,
    button {
        -webkit-tap-highlight-color: rgba(0, 0, 0, 0.1);
        touch-action: manipulation;
        user-select: none;
        -webkit-user-select: none;
    }

    /* CORREÇÃO MOBILE: Aumentar área de toque dos botões */
    .btn {
        min-height: 44px; /* Tamanho mínimo recomendado para touch */
        padding: 0.75rem 1.25rem;
    }

    /* CORREÇÃO MOBILE: Remover hover em dispositivos touch */
    @media (hover: none) {
        .btn:hover,
        .modal-close:hover,
        button:hover {
            background-color: inherit;
        }

        .btn-primary:hover:not(:disabled) {
            background-color: var(--color-primary-500);
        }

        .btn-secondary:hover:not(:disabled) {
            background-color: white;
        }
    }

    /* CORREÇÃO MOBILE: Feedback visual ao tocar */
    .btn:active,
    .modal-close:active,
    button:active {
        transform: scale(0.98);
        opacity: 0.9;
    }
}

/* Medium devices (tablets, 768px and up) */
@media (min-width: 641px) and (max-width: 768px) {
    .modal-content {
        max-width: 90%;
    }
}

/* Large devices (desktops, 992px and up) */
@media (min-width: 992px) {
    .modal-content {
        max-width: 660px;
    }
}

/* ============================================
   TOAST NOTIFICATIONS (preparação para Sprint 5)
   ============================================ */

.toast-container {
    position: fixed;
    z-index: 2000;
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
    max-width: 400px;
    pointer-events: none; /* CORREÇÃO: Permitir cliques através do container vazio */
}

.toast-container.toast-top-right {
    top: 1rem;
    right: 1rem;
}

.toast-container.toast-top-left {
    top: 1rem;
    left: 1rem;
}

.toast-container.toast-bottom-right {
    bottom: 1rem;
    right: 1rem;
}

.toast-container.toast-bottom-left {
    bottom: 1rem;
    left: 1rem;
}

@media (max-width: 640px) {
    .toast-container {
        top: auto;
        bottom: 1rem;
        left: 1rem;
        right: 1rem;
        max-width: none;
    }
}

.toast {
    background: white;
    padding: 1rem 1.25rem;
    pointer-events: auto; /* CORREÇÃO: Toasts individuais devem capturar cliques */
    border-radius: 8px;
    box-shadow: 0 10px 15px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -2px rgba(0, 0, 0, 0.05);
    border-left: 4px solid var(--color-primary-500);
    display: flex;
    align-items: flex-start;
    gap: 0.75rem;
    opacity: 0;
    transform: translateX(100%);
    transition: all 0.3s ease;
}

.toast.show {
    opacity: 1;
    transform: translateX(0);
}

.toast.hide {
    opacity: 0;
    transform: translateX(100%);
}

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

.toast.success {
    border-left-color: var(--color-success-500);
}

.toast.error {
    border-left-color: var(--color-danger-500);
}

.toast.warning {
    border-left-color: var(--color-warning-500);
}

.toast.info {
    border-left-color: var(--color-primary-500);
}

.toast-icon {
    flex-shrink: 0;
    width: 1.25rem;
    height: 1.25rem;
}

.toast-content {
    flex: 1;
}

.toast-title {
    font-weight: 600;
    font-size: 0.875rem;
    margin-bottom: 0.25rem;
    color: var(--color-gray-900);
}

.toast-message {
    font-size: 0.875rem;
    color: var(--color-gray-600);
}

.toast-close {
    background: none;
    border: none;
    cursor: pointer;
    padding: 0.25rem;
    color: var(--color-gray-400);
    transition: color 0.2s ease;
}

.toast-close:hover {
    color: var(--color-gray-600);
}

/* ============================================
   CONFIRMATION DIALOG
   ============================================ */

.dialog-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-color: rgba(0, 0, 0, 0.6);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1500;
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.2s ease, visibility 0.2s ease;
    padding: 1rem;
}

.dialog-overlay.active {
    opacity: 1;
    visibility: visible;
}

.dialog-content {
    background: white;
    border-radius: 8px;
    box-shadow: 0 20px 25px -5px rgba(0, 0, 0, 0.2);
    max-width: 440px;
    width: 100%;
    padding: 1.5rem;
    transform: scale(0.95);
    transition: transform 0.2s ease;
}

.dialog-overlay.active .dialog-content {
    transform: scale(1);
}

.dialog-icon {
    width: 3rem;
    height: 3rem;
    margin: 0 auto 1rem;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
}

.dialog-icon.warning {
    background-color: var(--color-warning-100);
    color: var(--color-warning-600);
}

.dialog-icon.danger {
    background-color: var(--color-danger-100);
    color: var(--color-danger-600);
}

.dialog-title {
    text-align: center;
    font-size: 1.125rem;
    font-weight: 700;
    color: var(--color-gray-900);
    margin-bottom: 0.75rem;
}

.dialog-message {
    text-align: center;
    font-size: 0.875rem;
    color: var(--color-gray-600);
    margin-bottom: 1.5rem;
    line-height: 1.5;
}

.dialog-actions {
    display: flex;
    gap: 0.75rem;
}

.dialog-actions .btn {
    flex: 1;
}

@media (max-width: 640px) {
    .dialog-actions {
        flex-direction: column-reverse;
    }
}

/* ============================================
   LOADING STATES
   ============================================ */

.spinner {
    display: inline-block;
    width: 1.25rem;
    height: 1.25rem;
    border: 2px solid rgba(255, 255, 255, 0.3);
    border-top-color: white;
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

.skeleton {
    background: linear-gradient(
        90deg,
        var(--color-gray-200) 25%,
        var(--color-gray-100) 50%,
        var(--color-gray-200) 75%
    );
    background-size: 200% 100%;
    animation: shimmer 1.5s infinite;
    border-radius: 4px;
}

@keyframes shimmer {
    0% { background-position: 200% 0; }
    100% { background-position: -200% 0; }
}

/* ============================================
   ACCESSIBILITY
   ============================================ */

/* Focus visible (teclado navegação) */
*:focus-visible {
    outline: 2px solid var(--color-primary-500);
    outline-offset: 2px;
}

/* Reduced motion */
@media (prefers-reduced-motion: reduce) {
    *,
    *::before,
    *::after {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
    }
}

/* High contrast mode */
@media (prefers-contrast: high) {
    .form-input,
    .btn {
        border-width: 2px;
    }
}

/* Dark mode preparation (futuro) */
@media (prefers-color-scheme: dark) {
    /* Estilos dark mode podem ser adicionados aqui */
}

/* ============================================
   PRINT STYLES
   ============================================ */

@media print {
    .modal-overlay,
    .dialog-overlay,
    .toast-container,
    .btn,
    .modal-close {
        display: none !important;
    }

    .modal-content {
        box-shadow: none;
        border: 1px solid var(--color-gray-300);
    }
}
