/* CSS Custom Properties for Library Theme */
:root {
    --primary-color: #8B4513;
    --secondary-color: #D2691E;
    --accent-color: #CD853F;
    --text-primary: #2C1810;
    --text-secondary: #5D4E37;
    --text-muted: #8B7355;
    --background-primary: #FFF8DC;
    --background-secondary: #F5DEB3;
    --background-paper: #FFFEF7;
    --border-color: #DEB887;
    --success-color: #228B22;
    --error-color: #B22222;
    --warning-color: #DAA520;
    
    --shadow-light: 0 2px 4px rgba(139, 69, 19, 0.1);
    --shadow-medium: 0 4px 12px rgba(139, 69, 19, 0.15);
    --shadow-heavy: 0 8px 24px rgba(139, 69, 19, 0.2);
    
    --border-radius: 8px;
    --border-radius-large: 12px;
    
    --font-serif: 'Playfair Display', serif;
    --font-body: 'Crimson Text', serif;
}

/* Global Styles */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: var(--font-body);
    background: linear-gradient(135deg, var(--background-primary), var(--background-secondary));
    color: var(--text-primary);
    line-height: 1.6;
    min-height: 100vh;
}

.library-container {
    max-width: 1400px;
    margin: 0 auto;
    min-height: 100vh;
    background: var(--background-paper);
    box-shadow: var(--shadow-heavy);
    position: relative;
    z-index: 1;
}

/* Header Styles */
.library-header {
    background: linear-gradient(135deg, var(--primary-color), var(--secondary-color));
    color: white;
    padding: 2rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 1rem;
}

.header-content {
    flex: 1;
    min-width: 300px;
}

.library-title {
    font-family: var(--font-serif);
    font-size: 2.5rem;
    font-weight: 700;
    margin-bottom: 0.5rem;
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.library-title i {
    color: var(--accent-color);
}

.library-subtitle {
    font-size: 1.1rem;
    opacity: 0.9;
    margin-bottom: 1rem;
}

.network-selector {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.network-selector label {
    font-weight: 600;
}

.network-selector select {
    padding: 0.5rem;
    border: none;
    border-radius: var(--border-radius);
    background: white;
    color: var(--text-primary);
    font-family: var(--font-body);
}

/* Wallet Section */
.wallet-section {
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    gap: 1rem;
    min-width: 200px;
}

.wallet-status {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.5rem 1rem;
    border-radius: var(--border-radius);
    font-weight: 600;
    transition: all 0.3s ease;
}

.wallet-status.connected {
    background: rgba(34, 139, 34, 0.2);
    border: 2px solid rgba(34, 139, 34, 0.3);
}

.wallet-status.disconnected {
    background: rgba(178, 34, 34, 0.2);
    border: 2px solid rgba(178, 34, 34, 0.3);
}

.wallet-status::before {
    content: '';
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: currentColor;
}

.connect-btn, .disconnect-btn {
    padding: 0.75rem 1.5rem;
    border: none;
    border-radius: var(--border-radius);
    background: white;
    color: var(--primary-color);
    font-family: var(--font-body);
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.connect-btn:hover, .disconnect-btn:hover {
    background: var(--background-secondary);
    transform: translateY(-2px);
    box-shadow: var(--shadow-medium);
}

/* Navigation */
.library-nav {
    background: var(--background-secondary);
    padding: 0;
    display: flex;
    border-bottom: 3px solid var(--border-color);
}

.nav-btn {
    flex: 1;
    padding: 1.25rem 2rem;
    border: none;
    background: transparent;
    color: var(--text-secondary);
    font-family: var(--font-body);
    font-size: 1.1rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.75rem;
    border-bottom: 3px solid transparent;
}

.nav-btn:hover {
    background: rgba(139, 69, 19, 0.1);
    color: var(--primary-color);
}

.nav-btn.active {
    background: var(--background-paper);
    color: var(--primary-color);
    border-bottom-color: var(--primary-color);
}

/* Main Content */
.library-main {
    padding: 2rem;
}

.library-section {
    display: none;
}

.library-section.active {
    display: block;
}

.section-header {
    text-align: center;
    margin-bottom: 2rem;
    padding: 1.5rem;
    background: linear-gradient(135deg, rgba(139, 69, 19, 0.05), rgba(210, 105, 30, 0.05));
    border-radius: var(--border-radius-large);
    border: 2px solid var(--border-color);
}

.section-header h2 {
    font-family: var(--font-serif);
    font-size: 2rem;
    color: var(--primary-color);
    margin-bottom: 0.5rem;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.75rem;
}

.section-header p {
    color: var(--text-secondary);
    font-size: 1.1rem;
}

/* Content Grid */
.content-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 2rem;
    align-items: start;
}

@media (max-width: 968px) {
    .content-grid {
        grid-template-columns: 1fr;
    }
}

/* Card Styles */
.card {
    background: var(--background-paper);
    border: 2px solid var(--border-color);
    border-radius: var(--border-radius-large);
    padding: 1.5rem;
    box-shadow: var(--shadow-medium);
    transition: all 0.3s ease;
}

.card:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow-heavy);
}

.card h3 {
    font-family: var(--font-serif);
    color: var(--primary-color);
    margin-bottom: 1.5rem;
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-size: 1.3rem;
}

/* Form Styles */
.form-group {
    margin-bottom: 1.25rem;
}

.form-group label {
    display: block;
    margin-bottom: 0.5rem;
    color: var(--text-secondary);
    font-weight: 600;
    font-size: 0.9rem;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.form-group input[type="text"] {
    width: 100%;
    padding: 0.75rem;
    border: 2px solid var(--border-color);
    border-radius: var(--border-radius);
    background: white;
    font-family: var(--font-body);
    font-size: 1rem;
    transition: all 0.3s ease;
}

.form-group input[type="text"]:focus {
    outline: none;
    border-color: var(--primary-color);
    box-shadow: 0 0 0 3px rgba(139, 69, 19, 0.1);
}

/* Arguments Section */
.arguments-section {
    margin-top: 2rem;
    padding-top: 1.5rem;
    border-top: 2px solid var(--border-color);
}

.arguments-section h4 {
    color: var(--primary-color);
    margin-bottom: 1rem;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.argument-group {
    margin-bottom: 1rem;
    padding: 1rem;
    background: var(--background-secondary);
    border-radius: var(--border-radius);
    border: 1px solid var(--border-color);
}

.argument-controls {
    display: flex;
    gap: 0.5rem;
    margin-bottom: 0.75rem;
    align-items: center;
}

.arg-type {
    flex: 1;
    padding: 0.5rem;
    border: 1px solid var(--border-color);
    border-radius: var(--border-radius);
    background: white;
    font-family: var(--font-body);
}

.remove-arg-btn {
    padding: 0.5rem;
    background: var(--error-color);
    color: white;
    border: none;
    border-radius: var(--border-radius);
    cursor: pointer;
    transition: all 0.3s ease;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 36px;
    height: 36px;
}

.remove-arg-btn:hover {
    background: #8B0000;
    transform: scale(1.05);
}

.argument-input {
    position: relative;
}

.arg-value, .arg-text-area {
    width: 100%;
    padding: 0.75rem;
    border: 1px solid var(--border-color);
    border-radius: var(--border-radius);
    background: white;
    font-family: var(--font-body);
    font-size: 1rem;
    transition: all 0.3s ease;
}

.arg-text-area {
    resize: vertical;
    min-height: 120px;
    font-family: 'Courier New', monospace;
    line-height: 1.5;
}

.arg-value:focus, .arg-text-area:focus {
    outline: none;
    border-color: var(--primary-color);
    box-shadow: 0 0 0 3px rgba(139, 69, 19, 0.1);
}

.add-arg-btn {
    width: 100%;
    padding: 0.75rem;
    background: var(--accent-color);
    color: white;
    border: none;
    border-radius: var(--border-radius);
    font-family: var(--font-body);
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    margin-top: 1rem;
}

.add-arg-btn:hover {
    background: var(--secondary-color);
    transform: translateY(-2px);
}

/* Submit Buttons */
.submit-btn {
    width: 100%;
    padding: 1rem 2rem;
    border: none;
    border-radius: var(--border-radius);
    font-family: var(--font-body);
    font-size: 1.1rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.75rem;
    margin-top: 2rem;
}

.read-btn {
    background: var(--success-color);
    color: white;
}

.read-btn:hover:not(:disabled) {
    background: #1F7A1F;
    transform: translateY(-2px);
    box-shadow: var(--shadow-medium);
}

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

.write-btn:hover:not(:disabled) {
    background: #723A10;
    transform: translateY(-2px);
    box-shadow: var(--shadow-medium);
}

.submit-btn:disabled {
    background: var(--text-muted);
    cursor: not-allowed;
    transform: none;
}

/* Results Display */
.results-display, .transaction-status {
    height: fit-content;
    min-height: 300px;
}

.results-content {
    min-height: 200px;
    max-height: 600px;
    overflow-y: auto;
}

.empty-state {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    min-height: 200px;
    color: var(--text-muted);
    text-align: center;
    padding: 2rem;
}

.empty-state i {
    font-size: 3rem;
    margin-bottom: 1rem;
    opacity: 0.5;
}

.empty-state p {
    font-size: 1.1rem;
    line-height: 1.6;
}

/* Result Items */
.result-item {
    padding: 1.5rem;
    margin-bottom: 1rem;
    border-radius: var(--border-radius);
    border-left: 4px solid var(--border-color);
}

.result-item.success {
    border-left-color: var(--success-color);
    background: rgba(34, 139, 34, 0.05);
}

.result-item.error {
    border-left-color: var(--error-color);
    background: rgba(178, 34, 34, 0.05);
}

.result-item h4 {
    color: var(--primary-color);
    margin-bottom: 1rem;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.result-data {
    margin-bottom: 1rem;
}

.result-data pre {
    background: var(--background-secondary);
    padding: 1rem;
    border-radius: var(--border-radius);
    overflow-x: auto;
    font-size: 0.9rem;
    border: 1px solid var(--border-color);
}

.result-data code {
    background: var(--background-secondary);
    padding: 0.25rem 0.5rem;
    border-radius: 4px;
    font-family: 'Courier New', monospace;
    word-break: break-all;
    display: block;
    margin: 0.5rem 0;
}

.explorer-link {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    color: var(--primary-color);
    text-decoration: none;
    margin-top: 1rem;
    padding: 0.5rem 1rem;
    border: 1px solid var(--primary-color);
    border-radius: var(--border-radius);
    transition: all 0.3s ease;
}

.explorer-link:hover {
    background: var(--primary-color);
    color: white;
}

.result-meta {
    color: var(--text-muted);
    font-size: 0.9rem;
}

/* Loading Overlay */
.loading-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.5);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 9999;
}

.loading-spinner {
    background: white;
    padding: 2rem;
    border-radius: var(--border-radius-large);
    text-align: center;
    box-shadow: var(--shadow-heavy);
}

.loading-spinner i {
    font-size: 2rem;
    color: var(--primary-color);
    margin-bottom: 1rem;
}

.loading-spinner p {
    color: var(--text-secondary);
    font-weight: 600;
}

/* Modals */
.modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.5);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 10000;
}

.modal-content {
    background: white;
    border-radius: var(--border-radius-large);
    box-shadow: var(--shadow-heavy);
    max-width: 500px;
    width: 90%;
    max-height: 80vh;
    overflow-y: auto;
}

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

.modal-header h3 {
    color: var(--primary-color);
    font-family: var(--font-serif);
    display: flex;
    align-items: center;
    gap: 0.5rem;
    margin: 0;
}

.modal-close {
    background: none;
    border: none;
    font-size: 1.5rem;
    cursor: pointer;
    color: var(--text-muted);
    transition: color 0.3s ease;
}

.modal-close:hover {
    color: var(--error-color);
}

.modal-body {
    padding: 1.5rem;
}

/* Wallet Options */
.wallet-options {
    display: flex;
    flex-direction: column;
    gap: 1rem;
    margin-top: 1rem;
}

.wallet-option {
    display: flex;
    align-items: center;
    gap: 1rem;
    padding: 1rem;
    border: 2px solid var(--border-color);
    border-radius: var(--border-radius);
    background: white;
    cursor: pointer;
    transition: all 0.3s ease;
    text-align: left;
    width: 100%;
}

.wallet-option:hover {
    border-color: var(--primary-color);
    background: var(--background-secondary);
    transform: translateY(-2px);
}

.wallet-icon {
    font-size: 2rem;
    min-width: 3rem;
    text-align: center;
}

.wallet-info {
    flex: 1;
}

.wallet-info strong {
    display: block;
    color: var(--primary-color);
    margin-bottom: 0.25rem;
}

.wallet-info span {
    color: var(--text-secondary);
    font-size: 0.9rem;
}

/* Button interaction fixes */
.connect-btn, .disconnect-btn, .nav-btn {
    position: relative;
    z-index: 10;
    pointer-events: auto;
}

.connect-btn:active, .disconnect-btn:active, .nav-btn:active {
    transform: translateY(0);
}

/* Responsive Design */
@media (max-width: 768px) {
    .library-header {
        flex-direction: column;
        text-align: center;
    }
    
    .wallet-section {
        align-items: center;
        width: 100%;
    }
    
    .library-title {
        font-size: 2rem;
    }
    
    .library-main {
        padding: 1rem;
    }
    
    .nav-btn {
        font-size: 1rem;
        padding: 1rem;
    }
    
    .modal-content {
        margin: 1rem;
        width: calc(100% - 2rem);
    }
}

@media (max-width: 480px) {
    .library-title {
        font-size: 1.5rem;
        flex-direction: column;
        gap: 0.5rem;
    }
    
    .content-grid {
        gap: 1rem;
    }
    
    .card {
        padding: 1rem;
    }
    
    .nav-btn {
        flex-direction: column;
        gap: 0.25rem;
        padding: 0.75rem 0.5rem;
    }
    
    .nav-btn i {
        font-size: 1.2rem;
    }
}

/* Animation for smooth transitions */
@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(20px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.library-section.active {
    animation: fadeIn 0.3s ease-out;
}

.result-item {
    animation: fadeIn 0.3s ease-out;
}

.modal {
    animation: fadeIn 0.2s ease-out;
}

/* Additional utility classes */
.text-center {
    text-align: center;
}

.mb-1 {
    margin-bottom: 1rem;
}

.mt-1 {
    margin-top: 1rem;
}

.hidden {
    display: none !important;
}

.visible {
    display: block !important;
}
