/**
 * WalletConnect Plugin - Frontend Styles
 * 
 * @version 1.2.0
 * @since 1.0.0
 */

/* ==========================================================================
   Base Styles
   ========================================================================== */

.wcp-container {
    --wcp-primary-color: #512da8;
    --wcp-primary-hover: #673ab7;
    --wcp-secondary-color: #6c757d;
    --wcp-secondary-hover: #5a6268;
    --wcp-danger-color: #dc3545;
    --wcp-danger-hover: #c82333;
    --wcp-success-color: #28a745;
    --wcp-warning-color: #ffc107;
    --wcp-text-color: #212529;
    --wcp-text-muted: #6c757d;
    --wcp-border-color: #dee2e6;
    --wcp-background: #ffffff;
    --wcp-background-alt: #f8f9fa;
    --wcp-shadow: 0 0.125rem 0.25rem rgba(0, 0, 0, 0.075);
    --wcp-shadow-lg: 0 0.5rem 1rem rgba(0, 0, 0, 0.15);
    --wcp-border-radius: 0.375rem;
    --wcp-border-radius-lg: 0.5rem;
    --wcp-transition: all 0.15s ease-in-out;
    
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
    font-size: 14px;
    line-height: 1.5;
    color: var(--wcp-text-color);
    max-width: 420px;
    margin: 0 auto;
    position: relative;
}

.wcp-container * {
    box-sizing: border-box;
}

/* ==========================================================================
   Main Components
   ========================================================================== */

.wcp-status {
    position: relative;
}

.wcp-connection-state {
    text-align: center;
    margin-bottom: 1rem;
}

.wcp-wallet-info {
    background: var(--wcp-background);
    border: 1px solid var(--wcp-border-color);
    border-radius: var(--wcp-border-radius-lg);
    padding: 1.5rem;
    box-shadow: var(--wcp-shadow);
    transition: var(--wcp-transition);
}

.wcp-wallet-info:hover {
    box-shadow: var(--wcp-shadow-lg);
    transform: translateY(-1px);
}

/* ==========================================================================
   Buttons
   ========================================================================== */

.wcp-button {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    padding: 0.75rem 1.5rem;
    font-size: 0.875rem;
    font-weight: 600;
    line-height: 1;
    border: 1px solid transparent;
    border-radius: var(--wcp-border-radius);
    cursor: pointer;
    text-decoration: none;
    transition: var(--wcp-transition);
    min-height: 44px;
    position: relative;
    overflow: hidden;
}

.wcp-button:focus {
    outline: 2px solid transparent;
    box-shadow: 0 0 0 3px rgba(81, 45, 168, 0.25);
}

.wcp-button:disabled {
    opacity: 0.6;
    cursor: not-allowed;
    transform: none !important;
}

/* Primary Button */
.wcp-button.wcp-primary {
    background: var(--wcp-primary-color);
    color: #ffffff;
    border-color: var(--wcp-primary-color);
}

.wcp-button.wcp-primary:hover:not(:disabled) {
    background: var(--wcp-primary-hover);
    border-color: var(--wcp-primary-hover);
    transform: translateY(-1px);
}

.wcp-button.wcp-primary:active {
    transform: translateY(0);
}

/* Secondary Button */
.wcp-button.wcp-secondary {
    background: var(--wcp-secondary-color);
    color: #ffffff;
    border-color: var(--wcp-secondary-color);
}

.wcp-button.wcp-secondary:hover:not(:disabled) {
    background: var(--wcp-secondary-hover);
    border-color: var(--wcp-secondary-hover);
    transform: translateY(-1px);
}

/* Danger Button */
.wcp-button.wcp-danger {
    background: var(--wcp-danger-color);
    color: #ffffff;
    border-color: var(--wcp-danger-color);
}

.wcp-button.wcp-danger:hover:not(:disabled) {
    background: var(--wcp-danger-hover);
    border-color: var(--wcp-danger-hover);
    transform: translateY(-1px);
}

/* Small Buttons */
.wcp-copy-btn,
.wcp-refresh-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 0.375rem;
    font-size: 0.75rem;
    border: 1px solid var(--wcp-border-color);
    border-radius: var(--wcp-border-radius);
    background: var(--wcp-background-alt);
    color: var(--wcp-text-muted);
    cursor: pointer;
    transition: var(--wcp-transition);
    min-width: 32px;
    min-height: 32px;
}

.wcp-copy-btn:hover,
.wcp-refresh-btn:hover {
    background: var(--wcp-secondary-color);
    color: #ffffff;
    transform: translateY(-1px);
}

.wcp-copy-btn.wcp-copied {
    background: var(--wcp-success-color);
    color: #ffffff;
    border-color: var(--wcp-success-color);
}

/* ==========================================================================
   Loading States
   ========================================================================== */

.wcp-loading-spinner {
    width: 1rem;
    height: 1rem;
    border: 2px solid transparent;
    border-top: 2px solid currentColor;
    border-radius: 50%;
    animation: wcp-spin 1s linear infinite;
}

@keyframes wcp-spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

.wcp-loading-text {
    opacity: 0.7;
    font-style: italic;
}

.wcp-rotating {
    animation: wcp-spin 1s linear infinite;
}

/* ==========================================================================
   Fields and Content
   ========================================================================== */

.wcp-field {
    margin-bottom: 1rem;
}

.wcp-field:last-child {
    margin-bottom: 0;
}

.wcp-label {
    display: block;
    font-weight: 600;
    color: var(--wcp-text-color);
    margin-bottom: 0.5rem;
    font-size: 0.875rem;
}

.wcp-address-section,
.wcp-balance-section {
    padding: 1rem 0;
    border-bottom: 1px solid var(--wcp-border-color);
}

.wcp-balance-section:last-of-type,
.wcp-address-section:last-of-type {
    border-bottom: none;
    padding-bottom: 0;
}

.wcp-address-display,
.wcp-balance-display {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.5rem;
    flex-wrap: wrap;
}

.wcp-address-value {
    font-family: 'Courier New', Consolas, Monaco, monospace;
    font-size: 0.875rem;
    background: var(--wcp-background-alt);
    padding: 0.5rem 0.75rem;
    border-radius: var(--wcp-border-radius);
    border: 1px solid var(--wcp-border-color);
    flex: 1;
    min-width: 0;
    word-break: break-all;
}

.wcp-balance-value {
    font-weight: 700;
    font-size: 1rem;
    color: var(--wcp-success-color);
    flex: 1;
}

.wcp-error-text {
    color: var(--wcp-danger-color);
    font-weight: 500;
}

/* ==========================================================================
   Actions
   ========================================================================== */

.wcp-actions {
    display: flex;
    gap: 0.75rem;
    justify-content: center;
    margin-top: 1.5rem;
    padding-top: 1rem;
    border-top: 1px solid var(--wcp-border-color);
}

.wcp-actions .wcp-button {
    flex: 1;
    min-width: 0;
    font-size: 0.8125rem;
    padding: 0.625rem 1rem;
}

/* ==========================================================================
   Error Messages
   ========================================================================== */

.wcp-error-message {
    background: #fff5f5;
    border: 1px solid #feb2b2;
    color: #e53e3e;
    padding: 0.75rem 1rem;
    border-radius: var(--wcp-border-radius);
    font-size: 0.875rem;
    margin-top: 1rem;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.wcp-error-message::before {
    content: "⚠️";
    font-size: 1rem;
}

/* ==========================================================================
   Themes
   ========================================================================== */

/* Dark Theme */
.wcp-theme-dark {
    --wcp-primary-color: #9c88ff;
    --wcp-primary-hover: #7c63ff;
    --wcp-text-color: #ffffff;
    --wcp-text-muted: #a0a0a0;
    --wcp-border-color: #4a4a4a;
    --wcp-background: #1a1a1a;
    --wcp-background-alt: #2d2d2d;
    --wcp-shadow: 0 0.125rem 0.25rem rgba(0, 0, 0, 0.3);
    --wcp-shadow-lg: 0 0.5rem 1rem rgba(0, 0, 0, 0.4);
}

.wcp-theme-dark .wcp-error-message {
    background: #2d1b1b;
    border-color: #8b4b4b;
    color: #ff7a7a;
}

/* Light Theme */
.wcp-theme-light {
    --wcp-background: #ffffff;
    --wcp-background-alt: #f8f9fa;
    --wcp-border-color: #e9ecef;
    --wcp-shadow: 0 0.125rem 0.25rem rgba(0, 0, 0, 0.05);
    --wcp-shadow-lg: 0 0.5rem 1rem rgba(0, 0, 0, 0.1);
}

/* Minimal Theme */
.wcp-theme-minimal {
    --wcp-border-radius: 0.25rem;
    --wcp-border-radius-lg: 0.25rem;
    --wcp-shadow: none;
    --wcp-shadow-lg: 0 2px 8px rgba(0, 0, 0, 0.1);
}

.wcp-theme-minimal .wcp-wallet-info {
    border: 2px solid var(--wcp-border-color);
    box-shadow: none;
}

.wcp-theme-minimal .wcp-button {
    border-radius: 0.25rem;
    font-weight: 500;
}

/* ==========================================================================
   Responsive Design
   ========================================================================== */

@media (max-width: 768px) {
    .wcp-container {
        max-width: 100%;
        padding: 0 1rem;
        font-size: 16px; /* Prevent zoom on iOS */
    }
    
    .wcp-wallet-info {
        padding: 1rem;
    }
    
    .wcp-actions {
        flex-direction: column;
    }
    
    .wcp-actions .wcp-button {
        flex: none;
        width: 100%;
    }
    
    .wcp-address-display,
    .wcp-balance-display {
        flex-direction: column;
        align-items: stretch;
        gap: 0.75rem;
    }
    
    .wcp-address-value {
        word-break: break-all;
        font-size: 0.8125rem;
    }
    
    .wcp-field {
        margin-bottom: 1.25rem;
    }
}

@media (max-width: 480px) {
    .wcp-container {
        font-size: 14px;
    }
    
    .wcp-wallet-info {
        padding: 0.875rem;
    }
    
    .wcp-button {
        padding: 0.625rem 1rem;
        font-size: 0.8125rem;
    }
    
    .wcp-address-value {
        font-size: 0.75rem;
        padding: 0.375rem 0.5rem;
    }
    
    .wcp-balance-value {
        font-size: 0.9375rem;
    }
}

/* ==========================================================================
   Animations and Transitions
   ========================================================================== */

/* Fade in animation for wallet info */
.wcp-wallet-info {
    animation: wcp-fadeInUp 0.3s ease-out;
}

@keyframes wcp-fadeInUp {
    from {
        opacity: 0;
        transform: translateY(10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* Button press animation */
.wcp-button:active:not(:disabled) {
    transform: translateY(1px);
}

/* Balance update animation */
.wcp-balance-value {
    transition: color 0.3s ease;
}

.wcp-balance-value.wcp-updating {
    color: var(--wcp-warning-color);
}

/* Copy feedback animation */
.wcp-copy-btn {
    position: relative;
    overflow: hidden;
}

.wcp-copy-btn.wcp-copied::after {
    content: '';
    position: absolute;
    top: 0;
    left: -100%;
    width: 100%;
    height: 100%;
    background: linear-gradient(90deg, transparent, rgba(255,255,255,0.4), transparent);
    animation: wcp-shine 0.6s ease-in-out;
}

@keyframes wcp-shine {
    0% { left: -100%; }
    100% { left: 100%; }
}

/* ==========================================================================
   Accessibility
   ========================================================================== */

/* Focus indicators */
.wcp-button:focus,
.wcp-copy-btn:focus,
.wcp-refresh-btn:focus {
    outline: 2px solid var(--wcp-primary-color);
    outline-offset: 2px;
}

/* High contrast mode support */
@media (prefers-contrast: high) {
    .wcp-container {
        --wcp-border-color: #000000;
        --wcp-text-muted: #000000;
    }
    
    .wcp-wallet-info {
        border-width: 2px;
    }
}

/* Reduced motion support */
@media (prefers-reduced-motion: reduce) {
    .wcp-container * {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
    }
    
    .wcp-loading-spinner {
        animation: none;
        border: 2px solid var(--wcp-text-muted);
    }
}

/* ==========================================================================
   Print Styles
   ========================================================================== */

@media print {
    .wcp-container {
        box-shadow: none;
        border: 1px solid #000;
    }
    
    .wcp-button,
    .wcp-copy-btn,
    .wcp-refresh-btn {
        display: none;
    }
    
    .wcp-actions {
        display: none;
    }
    
    .wcp-address-value {
        background: transparent;
        border: 1px solid #000;
        word-break: break-all;
    }
}

/* ==========================================================================
   RTL Support
   ========================================================================== */

[dir="rtl"] .wcp-address-display,
[dir="rtl"] .wcp-balance-display {
    direction: rtl;
}

[dir="rtl"] .wcp-actions {
    flex-direction: row-reverse;
}

/* ==========================================================================
   Custom Properties for Advanced Customization
   ========================================================================== */



/* ==========================================================================
   Utility Classes
   ========================================================================== */

.wcp-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;
}

.wcp-text-center {
    text-align: center;
}

.wcp-text-left {
    text-align: left;
}

.wcp-text-right {
    text-align: right;
}

.wcp-mb-0 {
    margin-bottom: 0 !important;
}

.wcp-mt-1 {
    margin-top: 0.5rem !important;
}

.wcp-hidden {
    display: none !important;
}

/* ==========================================================================
   Component Variations
   ========================================================================== */

/* Compact version */
.wcp-container.wcp-compact .wcp-wallet-info {
    padding: 1rem;
}

.wcp-container.wcp-compact .wcp-field {
    margin-bottom: 0.75rem;
}

.wcp-container.wcp-compact .wcp-actions {
    margin-top: 1rem;
    padding-top: 0.75rem;
}

/* Expanded version */
.wcp-container.wcp-expanded .wcp-wallet-info {
    padding: 2rem;
}

.wcp-container.wcp-expanded .wcp-field {
    margin-bottom: 1.5rem;
}

.wcp-container.wcp-expanded .wcp-button {
    padding: 1rem 2rem;
    font-size: 1rem;
}

/* ==========================================================================
   State Classes
   ========================================================================== */

.wcp-container.wcp-connecting .wcp-button {
    pointer-events: none;
}

.wcp-container.wcp-error .wcp-wallet-info {
    border-color: var(--wcp-danger-color);
}

.wcp-container.wcp-success .wcp-wallet-info {
    border-color: var(--wcp-success-color);
}