/* 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);
}

/* 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"], 
.form-group input[type="number"] {
    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,
.form-group input[type="number"]:focus {
    outline: none;
    border-color: var(--primary-color);
    box-shadow: 0 0 0 3px rgba(139, 69, 19, 0.1);
}

.form-group small {
    display: block;
    margin-top: 0.25rem;
    color: var(--text-muted);
    font-size: 0.8rem;
}

/* 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 Cards */
.result-card {
    background: var(--background-secondary);
    border: 1px solid var(--border-color);
    border-radius: var(--border-radius);
    padding: 1rem;
    margin-bottom: 1rem;
}

.result-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 0.75rem;
    padding-bottom: 0.5rem;
    border-bottom: 1px solid var(--border-color);
}

.result-title {
    font-weight: 600;
    color: var(--primary-color);
}

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

.result-content {
    background: white;
    padding: 1rem;
    border-radius: var(--border-radius);
    border: 1px solid var(--border-color);
    word-break: break-all;
    font-family: 'Courier New', monospace;
    font-size: 0.9rem;
    line-height: 1.4;
}

.result-success {
    border-left: 4px solid var(--success-color);
}

.result-error {
    border-left: 4px solid var(--error-color);
}

.result-pending {
    border-left: 4px solid var(--warning-color);
}

/* Transaction Status */
.tx-status {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.25rem 0.75rem;
    border-radius: var(--border-radius);
    font-size: 0.8rem;
    font-weight: 600;
    text-transform: uppercase;
}

.tx-status.success {
    background: rgba(34, 139, 34, 0.1);
    color: var(--success-color);
}

.tx-status.error {
    background: rgba(178, 34, 34, 0.1);
    color: var(--error-color);
}

.tx-status.pending {
    background: rgba(218, 165, 32, 0.1);
    color: var(--warning-color);
}

.tx-link {
    color: var(--primary-color);
    text-decoration: none;
    font-weight: 600;
}

.tx-link:hover {
    text-decoration: underline;
}

/* Modal Styles */
.modal {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.7);
    z-index: 1000;
    align-items: center;
    justify-content: center;
}

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

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

.modal-header h3 {
    font-family: var(--font-serif);
    color: var(--primary-color);
    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);
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    transition: all 0.3s ease;
}

.modal-close:hover {
    background: var(--background-secondary);
    color: var(--primary-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;
}

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

.wallet-icon {
    width: 48px;
    height: 48px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--primary-color);
    color: white;
    border-radius: var(--border-radius);
    font-size: 1.5rem;
}

.wallet-info h4 {
    margin: 0 0 0.25rem 0;
    color: var(--primary-color);
    font-family: var(--font-serif);
}

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

/* Loading Modal */
.loading-modal {
    text-align: center;
    padding: 2rem;
    max-width: 300px;
}

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

.loading-spinner i {
    animation: spin 1s linear infinite;
}

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

/* Responsive Design */
@media (max-width: 768px) {
    .library-header {
        flex-direction: column;
        align-items: stretch;
        gap: 1.5rem;
    }
    
    .wallet-section {
        align-items: center;
    }
    
    .library-title {
        font-size: 2rem;
        justify-content: center;
    }
    
    .library-nav {
        flex-direction: column;
    }
    
    .nav-btn {
        padding: 1rem;
    }
    
    .library-main {
        padding: 1rem;
    }
    
    .content-grid {
        grid-template-columns: 1fr;
    }
    
    .modal-content {
        width: 95%;
        margin: 1rem;
    }
}

@media (max-width: 480px) {
    .library-title {
        font-size: 1.5rem;
    }
    
    .section-header h2 {
        font-size: 1.5rem;
        flex-direction: column;
        gap: 0.5rem;
    }
    
    .argument-controls {
        flex-direction: column;
        align-items: stretch;
    }
    
    .remove-arg-btn {
        width: 100%;
        height: auto;
        padding: 0.75rem;
    }
}

/* Message Styles */
.error-message, .success-message {
    padding: 1rem 1.5rem;
    border-radius: var(--border-radius);
    margin-bottom: 1.5rem;
    display: flex;
    align-items: center;
    gap: 0.75rem;
    font-weight: 600;
    animation: slideDown 0.3s ease-out;
}

.error-message {
    background: rgba(178, 34, 34, 0.1);
    border: 2px solid var(--error-color);
    color: var(--error-color);
}

.success-message {
    background: rgba(34, 139, 34, 0.1);
    border: 2px solid var(--success-color);
    color: var(--success-color);
}

.error-message i, .success-message i {
    font-size: 1.2rem;
}

/* Animation Classes */
.fade-in {
    animation: fadeIn 0.3s ease-in;
}

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

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

.slide-in {
    animation: slideIn 0.3s ease-out;
}

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

/* Error and Success States */
.error-message {
    background: rgba(178, 34, 34, 0.1);
    border: 1px solid var(--error-color);
    color: var(--error-color);
    padding: 1rem;
    border-radius: var(--border-radius);
    margin: 1rem 0;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.success-message {
    background: rgba(34, 139, 34, 0.1);
    border: 1px solid var(--success-color);
    color: var(--success-color);
    padding: 1rem;
    border-radius: var(--border-radius);
    margin: 1rem 0;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.warning-message {
    background: rgba(218, 165, 32, 0.1);
    border: 1px solid var(--warning-color);
    color: var(--warning-color);
    padding: 1rem;
    border-radius: var(--border-radius);
    margin: 1rem 0;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

/* Utility Classes */
.text-center { text-align: center; }
.text-left { text-align: left; }
.text-right { text-align: right; }

.mt-1 { margin-top: 0.5rem; }
.mt-2 { margin-top: 1rem; }
.mt-3 { margin-top: 1.5rem; }

.mb-1 { margin-bottom: 0.5rem; }
.mb-2 { margin-bottom: 1rem; }
.mb-3 { margin-bottom: 1.5rem; }

.p-1 { padding: 0.5rem; }
.p-2 { padding: 1rem; }
.p-3 { padding: 1.5rem; }

.hidden { display: none !important; }
.visible { display: block !important; }

/* Code Highlighting */
.code-block {
    background: #f8f8f8;
    border: 1px solid var(--border-color);
    border-radius: var(--border-radius);
    padding: 1rem;
    font-family: 'Courier New', monospace;
    font-size: 0.9rem;
    line-height: 1.4;
    overflow-x: auto;
    margin: 1rem 0;
}

.json-key {
    color: #0451A5;
    font-weight: 600;
}

.json-string {
    color: #0B7F47;
}

.json-number {
    color: #09885A;
}

.json-boolean {
    color: #0000FF;
}

.json-null {
    color: #795E26;
}
