/**
 * Folyo - Modal Styles
 * Styles for login and signup modals
 */

/* Modal overlay */
.modal {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.6);
    backdrop-filter: blur(4px);
    z-index: 10000;
    animation: fadeIn 0.2s ease-out;
}

.theme-light .modal {
    background-color: rgba(0, 0, 0, 0.5);
}

.theme-dark .modal {
    background-color: rgba(0, 0, 0, 0.7);
}

.modal.active {
    display: flex;
    justify-content: center;
    align-items: center;
}

/* Modal content container */
.modal-content {
    background-color: var(--bg-primary);
    border-radius: 12px;
    width: 90%;
    max-width: 440px;
    max-height: 90vh;
    overflow-y: auto;
    animation: slideUp 0.3s ease-out;
}

.theme-light .modal-content {
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.15);
    border: 1px solid var(--border-color);
}

.theme-dark .modal-content {
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.5);
    border: 1px solid var(--border-color);
}

/* Modal header */
.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 24px 24px 16px 24px;
    border-bottom: 1px solid var(--border-color);
}

.modal-header h2 {
    font-size: 24px;
    font-weight: 700;
    color: var(--text-primary);
    margin: 0;
}

.modal-close {
    background: none;
    border: none;
    font-size: 32px;
    color: var(--text-secondary);
    cursor: pointer;
    padding: 0;
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 6px;
    transition: all 0.2s ease;
    line-height: 1;
}

.modal-close:hover {
    background-color: var(--bg-hover);
    color: var(--text-primary);
}

/* Auth form */
.auth-form {
    padding: 24px;
}

.form-group {
    margin-bottom: 20px;
}

.form-group label {
    display: block;
    font-size: 14px;
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: 8px;
}

.form-group input {
    width: 100%;
    padding: 12px 16px;
    font-size: 15px;
    font-family: 'Inter', sans-serif;
    color: var(--text-primary);
    background-color: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    transition: all 0.2s ease;
    box-sizing: border-box;
}

.form-group input:focus {
    outline: none;
    border-color: var(--primary-color);
    background-color: var(--bg-primary);
    box-shadow: 0 0 0 3px rgba(22, 199, 132, 0.1);
}

.form-group input::placeholder {
    color: var(--text-tertiary);
}

/* Textarea styling */
.form-group textarea {
    width: 100%;
    padding: 12px 16px;
    font-size: 14px;
    font-family: 'Inter', sans-serif;
    color: var(--text-primary);
    background-color: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    transition: all 0.2s ease;
    box-sizing: border-box;
    resize: vertical;
    min-height: 80px;
    line-height: 1.5;
}

.form-group textarea:focus {
    outline: none;
    border-color: var(--primary-color);
    background-color: var(--bg-primary);
    box-shadow: 0 0 0 3px rgba(22, 199, 132, 0.1);
}

.form-group textarea::placeholder {
    color: var(--text-tertiary);
}

/* Form helper text */
.form-helper {
    display: block;
    margin-top: 6px;
    font-size: 12px;
    color: var(--text-secondary);
    font-style: italic;
}

/* Submit button */
.btn-submit {
    width: 100%;
    padding: 14px 24px;
    font-size: 16px;
    font-weight: 600;
    font-family: 'Inter', sans-serif;
    color: #ffffff;
    background-color: var(--primary-color);
    border: none;
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.2s ease;
    margin-top: 8px;
}

.btn-submit:hover {
    background-color: var(--primary-hover);
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(22, 199, 132, 0.3);
}

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

/* Auth switch link */
.auth-switch {
    text-align: center;
    margin-top: 20px;
    font-size: 14px;
    color: var(--text-secondary);
}

.auth-switch a {
    color: var(--primary-color);
    text-decoration: none;
    font-weight: 600;
    transition: color 0.2s ease;
}

.auth-switch a:hover {
    color: var(--primary-hover);
    text-decoration: underline;
}

/* Animations */
@keyframes fadeIn {
    from {
        opacity: 0;
    }
    to {
        opacity: 1;
    }
}

@keyframes slideUp {
    from {
        opacity: 0;
        transform: translateY(30px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* Responsive styles */
@media (max-width: 768px) {
    .modal-content {
        width: 95%;
        max-width: none;
        margin: 0 10px;
    }

    .modal-header {
        padding: 20px 20px 12px 20px;
    }

    .modal-header h2 {
        font-size: 22px;
    }

    .auth-form {
        padding: 20px;
    }

    .form-group input {
        padding: 11px 14px;
        font-size: 16px; /* Prevents iOS zoom on focus */
    }

    .btn-submit {
        padding: 13px 20px;
        font-size: 15px;
    }
}

@media (max-width: 480px) {
    .modal-header h2 {
        font-size: 20px;
    }

    .form-group input {
        font-size: 16px;
    }
}

/* Prevent body scroll when modal is open */
body.modal-open {
    overflow: hidden;
}

/* Modal Body */
.modal-body {
    padding: 24px;
}

/* Transaction Modal Specific Styles */
.modal-large {
    max-width: 650px;
    max-height: 85vh;
}

.modal-large .modal-body {
    padding: 20px 28px 28px 28px;
}

.transaction-tabs {
    display: flex;
    gap: 0;
    margin-bottom: 28px;
    border-bottom: 2px solid var(--border-color);
    border-radius: 8px 8px 0 0;
    overflow: hidden;
}

.transaction-tab {
    flex: 1;
    padding: 14px 24px;
    background: var(--bg-secondary);
    border: none;
    border-bottom: 3px solid transparent;
    color: var(--text-secondary);
    font-size: 15px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.25s ease;
    margin-bottom: -2px;
    position: relative;
}

.transaction-tab:hover {
    color: var(--text-primary);
    background: var(--bg-hover);
}

.transaction-tab.active {
    color: var(--primary-color);
    border-bottom-color: var(--primary-color);
    background: var(--bg-primary);
    font-weight: 700;
}

.transaction-tab.active::after {
    content: '';
    position: absolute;
    bottom: -2px;
    left: 0;
    right: 0;
    height: 3px;
    background: var(--primary-color);
    box-shadow: 0 0 8px rgba(22, 199, 132, 0.4);
}

.transaction-form {
    display: flex;
    flex-direction: column;
    gap: 18px;
}

.transaction-form .form-group:last-of-type {
    margin-bottom: 8px;
}

.transaction-form label {
    font-size: 13px;
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: 8px;
    display: flex;
    align-items: center;
    gap: 4px;
}

.transaction-form label::after {
    content: attr(data-required);
    color: var(--red);
    font-size: 12px;
}

.transaction-form input[readonly] {
    background-color: var(--bg-hover);
    cursor: not-allowed;
    opacity: 0.7;
}

/* Crypto Search */
.crypto-search-wrapper {
    position: relative;
}

.crypto-search-results {
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    max-height: 320px;
    overflow-y: auto;
    background: var(--bg-primary);
    border: 1.5px solid var(--border-color);
    border-radius: 10px;
    margin-top: 6px;
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.12);
    z-index: 1000;
    display: none;
}

.crypto-search-results.active {
    display: block;
    animation: slideDown 0.2s ease-out;
}

@keyframes slideDown {
    from {
        opacity: 0;
        transform: translateY(-8px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.crypto-search-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 14px;
    cursor: pointer;
    transition: all 0.2s ease;
    border-bottom: 1px solid var(--border-color);
}

.crypto-search-item:first-child {
    border-radius: 10px 10px 0 0;
}

.crypto-search-item:last-child {
    border-bottom: none;
    border-radius: 0 0 10px 10px;
}

.crypto-search-item:hover {
    background: linear-gradient(90deg, rgba(22, 199, 132, 0.06) 0%, rgba(22, 199, 132, 0.02) 100%);
    padding-left: 18px;
}

.crypto-search-item img {
    width: 32px;
    height: 32px;
    border-radius: 50%;
}

.crypto-search-item-info {
    flex: 1;
    display: flex;
    flex-direction: column;
}

.crypto-search-item-name {
    font-size: 14px;
    font-weight: 600;
    color: var(--text-primary);
}

.crypto-search-item-symbol {
    font-size: 12px;
    color: var(--text-secondary);
}

.crypto-search-item-price {
    font-size: 14px;
    font-weight: 500;
    color: var(--text-primary);
}

.crypto-search-loading,
.crypto-search-empty {
    padding: 20px;
    text-align: center;
    color: var(--text-secondary);
    font-size: 14px;
}

/* Selected Crypto */
.selected-crypto {
    display: flex;
    align-items: center;
    gap: 14px;
    padding: 14px 16px;
    background: linear-gradient(135deg, rgba(22, 199, 132, 0.08) 0%, rgba(22, 199, 132, 0.03) 100%);
    border: 2px solid var(--primary-color);
    border-radius: 10px;
    margin-top: 10px;
    box-shadow: 0 2px 8px rgba(22, 199, 132, 0.15);
    transition: all 0.3s ease;
}

.selected-crypto:hover {
    box-shadow: 0 4px 12px rgba(22, 199, 132, 0.25);
    transform: translateY(-1px);
}

.selected-crypto-logo {
    width: 44px;
    height: 44px;
    border-radius: 50%;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.15);
}

.selected-crypto-info {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.selected-crypto-name {
    font-size: 15px;
    font-weight: 700;
    color: var(--text-primary);
    letter-spacing: -0.2px;
}

.selected-crypto-symbol {
    font-size: 12px;
    font-weight: 600;
    color: var(--primary-color);
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.btn-remove-crypto {
    width: 30px;
    height: 30px;
    border-radius: 50%;
    background: rgba(234, 57, 67, 0.1);
    color: var(--red);
    border: 1.5px solid var(--red);
    font-size: 18px;
    line-height: 1;
    cursor: pointer;
    transition: all 0.2s ease;
    display: flex;
    align-items: center;
    justify-content: center;
}

.btn-remove-crypto:hover {
    background: var(--red);
    color: #ffffff;
    transform: scale(1.1) rotate(90deg);
}

/* Form Helpers */
.form-helper {
    display: block;
    margin-top: 6px;
    font-size: 12px;
    color: var(--text-secondary);
}

.form-helper.error {
    color: var(--red);
}

.form-helper.success {
    color: var(--primary-color);
}

.form-helper.warning {
    color: var(--orange);
}

/* Modal Actions */
.modal-actions {
    display: flex;
    gap: 12px;
    justify-content: flex-end;
    margin-top: 28px;
    padding-top: 20px;
    border-top: 1px solid var(--border-color);
}

.modal-actions .btn-primary,
.modal-actions .btn-secondary {
    padding: 12px 24px;
    font-size: 15px;
    font-weight: 600;
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.25s ease;
    border: none;
    font-family: 'Inter', sans-serif;
}

.modal-actions .btn-primary {
    background: var(--primary-color);
    color: #ffffff;
    box-shadow: 0 2px 8px rgba(22, 199, 132, 0.25);
}

.modal-actions .btn-primary:hover:not(:disabled) {
    background: var(--primary-hover);
    transform: translateY(-2px);
    box-shadow: 0 4px 14px rgba(22, 199, 132, 0.4);
}

.modal-actions .btn-primary:active {
    transform: translateY(0);
}

.modal-actions .btn-primary:disabled {
    opacity: 0.6;
    cursor: not-allowed;
}

.modal-actions .btn-secondary {
    background: var(--bg-secondary);
    color: var(--text-primary);
    border: 1.5px solid var(--border-color);
}

.modal-actions .btn-secondary:hover {
    background: var(--bg-hover);
    border-color: var(--text-secondary);
    transform: translateY(-1px);
}

.btn-danger {
    padding: 11px 20px;
    background: var(--red);
    color: #ffffff;
    border: none;
    border-radius: 8px;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
}

.btn-danger:hover {
    background: #d11a2a;
    transform: translateY(-2px);
    box-shadow: 0 4px 8px rgba(234, 57, 67, 0.3);
}

/* Loading State */
.btn-loading {
    display: none !important;
    align-items: center;
    gap: 8px;
}

.spinner {
    width: 14px;
    height: 14px;
    border: 2px solid rgba(255, 255, 255, 0.3);
    border-top-color: #ffffff;
    border-radius: 50%;
    animation: spin 0.6s linear infinite;
}

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

button.loading .btn-text {
    display: none;
}

button.loading .btn-loading {
    display: flex !important;
}

/* Dark Theme Adjustments */
.theme-dark .crypto-search-results {
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.5);
}

.theme-dark .crypto-search-item:hover {
    background: rgba(255, 255, 255, 0.05);
}

/* Responsive */
@media (max-width: 768px) {
    .modal-large {
        max-width: none;
        width: 95%;
    }

    .transaction-tabs {
        gap: 4px;
    }

    .transaction-tab {
        padding: 10px 16px;
        font-size: 14px;
    }

    .modal-actions {
        flex-direction: column-reverse;
    }

    .modal-actions button {
        width: 100%;
    }
}
