/* ==========================================================================
   Smart Contract Admin Dashboard - Web3 Dark Theme Stylesheet
   ========================================================================== */

:root {
    --bg-main: #0B0E17;
    --bg-sidebar: #0F1422;
    --bg-card: rgba(18, 24, 38, 0.75);
    --bg-card-hover: rgba(26, 34, 52, 0.85);
    --bg-input: #151C2C;
    --bg-input-focus: #1A2338;
    
    --border-color: rgba(255, 255, 255, 0.08);
    --border-glow: rgba(0, 255, 163, 0.25);
    --border-accent: rgba(240, 185, 11, 0.3);

    --text-primary: #FFFFFF;
    --text-secondary: #94A3B8;
    --text-muted: #64748B;
    --text-highlight: #F8FAFC;

    --color-bnb: #F0B90B;
    --color-bnb-hover: #FCD535;
    --color-mint: #00FFA3;
    --color-cyan: #00D8FF;
    --color-purple: #8B5CF6;
    --color-danger: #EF4444;
    --color-warning: #F59E0B;
    --color-success: #10B981;

    --sidebar-width: 270px;
    --header-height: 72px;
    --radius-sm: 6px;
    --radius-md: 10px;
    --radius-lg: 16px;
    --radius-xl: 20px;

    --shadow-sm: 0 2px 8px rgba(0, 0, 0, 0.2);
    --shadow-md: 0 8px 24px rgba(0, 0, 0, 0.35);
    --shadow-glow: 0 0 20px rgba(0, 255, 163, 0.15);
    --shadow-glow-bnb: 0 0 20px rgba(240, 185, 11, 0.15);
}

/* Reset & Base */
*, *::before, *::after {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

body {
    background-color: var(--bg-main);
    color: var(--text-primary);
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
    line-height: 1.5;
    min-height: 100vh;
    display: flex;
    overflow-x: hidden;
    background-image: 
        radial-gradient(circle at 10% 20%, rgba(240, 185, 11, 0.03) 0%, transparent 40%),
        radial-gradient(circle at 90% 80%, rgba(0, 255, 163, 0.03) 0%, transparent 40%),
        radial-gradient(circle at 50% 50%, rgba(0, 216, 255, 0.02) 0%, transparent 50%);
    background-attachment: fixed;
}

/* Custom Scrollbar */
::-webkit-scrollbar {
    width: 6px;
    height: 6px;
}
::-webkit-scrollbar-track {
    background: var(--bg-main);
}
::-webkit-scrollbar-thumb {
    background: #242F48;
    border-radius: 3px;
}
::-webkit-scrollbar-thumb:hover {
    background: #3B4B6E;
}

/* Typography Utilities */
.font-mono {
    font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", "Courier New", monospace;
}
.text-primary { color: var(--text-primary); }
.text-secondary { color: var(--text-secondary); }
.text-muted { color: var(--text-muted); }
.text-highlight { color: var(--text-highlight); }
.text-accent { color: var(--color-mint); }
.text-bnb { color: var(--color-bnb); }
.text-danger { color: var(--color-danger); }

.text-xs { font-size: 0.75rem; }
.text-sm { font-size: 0.875rem; }
.text-base { font-size: 1rem; }
.text-lg { font-size: 1.125rem; }
.text-xl { font-size: 1.25rem; }
.text-2xl { font-size: 1.5rem; }
.text-3xl { font-size: 1.875rem; }

.font-normal { font-weight: 400; }
.font-semibold { font-weight: 600; }
.font-bold { font-weight: 700; }

.uppercase { text-transform: uppercase; }
.tracking-wider { letter-spacing: 0.05em; }
.break-all { word-break: break-all; }
.cursor-pointer { cursor: pointer; }

/* Flex & Layout Utilities */
.flex { display: flex; }
.inline-flex { display: inline-flex; }
.grid { display: grid; }
.items-center { align-items: center; }
.justify-between { justify-content: space-between; }
.justify-center { justify-content: center; }
.justify-end { justify-content: flex-end; }
.flex-wrap { flex-wrap: wrap; }
.flex-col { flex-direction: column; }
.flex-1 { flex: 1 1 0%; }
.gap-1 { gap: 0.25rem; }
.gap-2 { gap: 0.5rem; }
.gap-3 { gap: 0.75rem; }
.gap-4 { gap: 1rem; }
.gap-6 { gap: 1.5rem; }

.mb-1 { margin-bottom: 0.25rem; }
.mb-2 { margin-bottom: 0.5rem; }
.mb-3 { margin-bottom: 0.75rem; }
.mb-4 { margin-bottom: 1rem; }
.mb-6 { margin-bottom: 1.5rem; }
.mt-1 { margin-top: 0.25rem; }
.mt-2 { margin-top: 0.5rem; }
.mt-3 { margin-top: 0.75rem; }
.mt-4 { margin-top: 1rem; }
.mt-5 { margin-top: 1.25rem; }
.mt-6 { margin-top: 1.5rem; }
.p-3 { padding: 0.75rem; }
.p-4 { padding: 1rem; }
.p-6 { padding: 1.5rem; }
.py-6 { padding-top: 1.5rem; padding-bottom: 1.5rem; }
.text-center { text-align: center; }
.w-full { width: 100%; }
.hidden { display: none !important; }

/* Glassmorphism Panel */
.glass-panel {
    background: var(--bg-card);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-sm);
    transition: all 0.2s ease-in-out;
}
.glass-panel:hover {
    border-color: rgba(255, 255, 255, 0.14);
}

/* App Structure */
#app-layout {
    display: flex;
    width: 100vw;
    min-height: 100vh;
}

/* Sidebar */
#sidebar {
    width: var(--sidebar-width);
    background: var(--bg-sidebar);
    border-right: 1px solid var(--border-color);
    display: flex;
    flex-direction: column;
    position: fixed;
    top: 0;
    bottom: 0;
    left: 0;
    z-index: 100;
    transition: transform 0.3s ease;
}

.sidebar-header {
    height: var(--header-height);
    display: flex;
    align-items: center;
    padding: 0 1.5rem;
    border-bottom: 1px solid var(--border-color);
    gap: 0.75rem;
}

.brand-logo {
    width: 38px;
    height: 38px;
    border-radius: var(--radius-md);
    background: linear-gradient(135deg, var(--color-bnb) 0%, #D97706 100%);
    display: flex;
    align-items: center;
    justify-content: center;
    color: #000;
    font-weight: 900;
    font-size: 1.25rem;
    box-shadow: var(--shadow-glow-bnb);
}

.brand-title {
    font-size: 1.05rem;
    font-weight: 700;
    letter-spacing: -0.02em;
}

.brand-subtitle {
    font-size: 0.7rem;
    color: var(--color-bnb);
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.sidebar-nav {
    flex: 1;
    padding: 1.5rem 1rem;
    display: flex;
    flex-direction: column;
    gap: 0.4rem;
    overflow-y: auto;
}

.nav-section-title {
    font-size: 0.7rem;
    font-weight: 700;
    text-transform: uppercase;
    color: var(--text-muted);
    letter-spacing: 0.06em;
    padding: 0.5rem 0.75rem;
    margin-top: 0.5rem;
}

.nav-item {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.75rem 1rem;
    color: var(--text-secondary);
    text-decoration: none;
    border-radius: var(--radius-md);
    font-size: 0.9rem;
    font-weight: 500;
    transition: all 0.2s ease;
    border: 1px solid transparent;
}

.nav-item:hover {
    color: var(--text-primary);
    background: rgba(255, 255, 255, 0.04);
}

.nav-item.active {
    color: var(--color-bnb);
    background: rgba(240, 185, 11, 0.08);
    border-color: rgba(240, 185, 11, 0.25);
    font-weight: 600;
}

.nav-icon {
    font-size: 1.15rem;
    display: flex;
    align-items: center;
    justify-content: center;
}

.sidebar-footer {
    padding: 1rem 1.25rem;
    border-top: 1px solid var(--border-color);
    background: rgba(0, 0, 0, 0.2);
}

.sidebar-wallet-widget {
    background: rgba(255, 255, 255, 0.03);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    padding: 0.75rem;
}

/* Main Content Area */
#main-wrapper {
    flex: 1;
    margin-left: var(--sidebar-width);
    display: flex;
    flex-direction: column;
    min-height: 100vh;
    max-width: calc(100vw - var(--sidebar-width));
}

/* Top Header */
#top-header {
    height: var(--header-height);
    background: rgba(15, 20, 34, 0.8);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border-bottom: 1px solid var(--border-color);
    position: sticky;
    top: 0;
    z-index: 90;
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 2rem;
}

.header-left {
    display: flex;
    align-items: center;
    gap: 1rem;
}

.header-title {
    font-size: 1.35rem;
    font-weight: 700;
    letter-spacing: -0.01em;
}

.header-right {
    display: flex;
    align-items: center;
    gap: 1rem;
}

/* Content Container */
#content-container {
    flex: 1;
    padding: 2rem;
}

/* Badges & Status Indicators */
.badge {
    display: inline-flex;
    align-items: center;
    gap: 0.35rem;
    padding: 0.25rem 0.6rem;
    border-radius: 9999px;
    font-size: 0.75rem;
    font-weight: 600;
    line-height: 1;
    border: 1px solid transparent;
}
.badge-primary {
    background: rgba(0, 255, 163, 0.12);
    color: var(--color-mint);
    border-color: rgba(0, 255, 163, 0.25);
}
.badge-secondary {
    background: rgba(255, 255, 255, 0.08);
    color: var(--text-secondary);
    border-color: rgba(255, 255, 255, 0.1);
}
.badge-warning {
    background: rgba(240, 185, 11, 0.12);
    color: var(--color-bnb);
    border-color: rgba(240, 185, 11, 0.25);
}
.badge-success {
    background: rgba(16, 185, 129, 0.12);
    color: var(--color-success);
    border-color: rgba(16, 185, 129, 0.25);
}
.badge-danger {
    background: rgba(239, 68, 68, 0.12);
    color: var(--color-danger);
    border-color: rgba(239, 68, 68, 0.25);
}

.status-dot {
    width: 7px;
    height: 7px;
    border-radius: 50%;
    display: inline-block;
}
.status-dot.online {
    background-color: var(--color-mint);
    box-shadow: 0 0 8px var(--color-mint);
}
.status-dot.offline {
    background-color: var(--color-danger);
    box-shadow: 0 0 8px var(--color-danger);
}

/* Buttons */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    padding: 0.6rem 1.2rem;
    border-radius: var(--radius-md);
    font-size: 0.875rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s ease;
    border: 1px solid transparent;
    text-decoration: none;
    line-height: 1.2;
}
.btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
    pointer-events: none;
}

.btn-primary {
    background: linear-gradient(135deg, var(--color-bnb) 0%, #EAB308 100%);
    color: #000;
    font-weight: 700;
    box-shadow: 0 2px 10px rgba(240, 185, 11, 0.2);
}
.btn-primary:hover {
    background: linear-gradient(135deg, var(--color-bnb-hover) 0%, #F59E0B 100%);
    box-shadow: 0 4px 16px rgba(240, 185, 11, 0.35);
    transform: translateY(-1px);
}

.btn-accent {
    background: linear-gradient(135deg, var(--color-mint) 0%, #05D686 100%);
    color: #000;
    font-weight: 700;
    box-shadow: 0 2px 10px rgba(0, 255, 163, 0.2);
}
.btn-accent:hover {
    box-shadow: 0 4px 16px rgba(0, 255, 163, 0.35);
    transform: translateY(-1px);
}

.btn-outline {
    background: rgba(255, 255, 255, 0.04);
    border-color: var(--border-color);
    color: var(--text-primary);
}
.btn-outline:hover {
    background: rgba(255, 255, 255, 0.08);
    border-color: rgba(255, 255, 255, 0.2);
    color: #FFF;
}

.btn-outline-danger {
    background: rgba(239, 68, 68, 0.08);
    border-color: rgba(239, 68, 68, 0.3);
    color: var(--color-danger);
}
.btn-outline-danger:hover {
    background: rgba(239, 68, 68, 0.15);
    border-color: var(--color-danger);
}

.btn-sm {
    padding: 0.45rem 0.8rem;
    font-size: 0.8rem;
    border-radius: var(--radius-sm);
}

.btn-icon-xs {
    background: transparent;
    border: none;
    color: var(--text-secondary);
    cursor: pointer;
    padding: 2px 4px;
    border-radius: 4px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    transition: all 0.15s ease;
}
.btn-icon-xs:hover {
    color: var(--text-primary);
    background: rgba(255, 255, 255, 0.1);
}

/* Forms & Inputs */
.form-group {
    display: flex;
    flex-direction: column;
}
.form-label {
    margin-bottom: 0.35rem;
    color: var(--text-secondary);
}
.form-control {
    width: 100%;
    background: var(--bg-input);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    color: var(--text-primary);
    padding: 0.6rem 0.85rem;
    font-size: 0.85rem;
    transition: all 0.2s ease;
    outline: none;
}
.form-control:focus {
    background: var(--bg-input-focus);
    border-color: var(--color-mint);
    box-shadow: 0 0 0 2px rgba(0, 255, 163, 0.15);
}
.form-control::placeholder {
    color: var(--text-muted);
}

.input-with-button {
    position: relative;
    display: flex;
    align-items: center;
}
.input-with-button .form-control {
    padding-right: 3.5rem;
}
.btn-input-action {
    position: absolute;
    right: 6px;
    background: rgba(255, 255, 255, 0.08);
    border: 1px solid var(--border-color);
    color: var(--color-mint);
    border-radius: var(--radius-sm);
    padding: 2px 8px;
    font-size: 0.72rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.15s ease;
}
.btn-input-action:hover {
    background: rgba(0, 255, 163, 0.15);
    border-color: var(--color-mint);
}

/* Search Box & Filters */
.search-box-wrapper {
    position: relative;
    display: flex;
    align-items: center;
}
.search-icon {
    position: absolute;
    left: 12px;
    color: var(--text-muted);
    pointer-events: none;
}
.search-input {
    width: 100%;
    background: var(--bg-input);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    padding: 0.65rem 1rem 0.65rem 2.4rem;
    color: var(--text-primary);
    font-size: 0.875rem;
    outline: none;
    transition: all 0.2s ease;
}
.search-input:focus {
    border-color: var(--color-bnb);
    box-shadow: 0 0 0 2px rgba(240, 185, 11, 0.15);
}

.filter-tab {
    background: rgba(255, 255, 255, 0.04);
    border: 1px solid var(--border-color);
    color: var(--text-secondary);
    padding: 0.5rem 1rem;
    border-radius: var(--radius-md);
    font-size: 0.8rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.15s ease;
}
.filter-tab:hover {
    color: var(--text-primary);
    background: rgba(255, 255, 255, 0.08);
}
.filter-tab.active {
    background: var(--color-bnb);
    color: #000;
    border-color: var(--color-bnb);
}

/* Dashboard Overview Cards */
.dashboard-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(320px, 1fr));
    gap: 1.5rem;
}
.contract-card {
    padding: 1.5rem;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    min-height: 240px;
}
.contract-card:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow-md);
    border-color: rgba(255, 255, 255, 0.16);
}
.contract-card-header {
    display: flex;
    align-items: center;
    gap: 1rem;
    margin-bottom: 0.75rem;
}
.contract-card-icon {
    width: 44px;
    height: 44px;
    border-radius: var(--radius-md);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.5rem;
}
.contract-card-title {
    font-size: 1.15rem;
    font-weight: 700;
}
.contract-card-desc {
    color: var(--text-secondary);
    font-size: 0.82rem;
    margin-bottom: 1rem;
    line-height: 1.4;
}
.contract-card-meta {
    display: flex;
    flex-direction: column;
    gap: 0.4rem;
    padding: 0.75rem 0;
    border-top: 1px solid var(--border-color);
    border-bottom: 1px solid var(--border-color);
    margin-bottom: 1rem;
}
.meta-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-size: 0.8rem;
}
.contract-card-footer {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

/* Wallet Card Stats */
.wallet-stat-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0.6rem 0;
    border-bottom: 1px solid rgba(255, 255, 255, 0.04);
    font-size: 0.85rem;
}
.wallet-stat-row:last-child {
    border-bottom: none;
}

/* Contract Pages Layout */
.contract-detail-header {
    padding: 1.5rem;
    margin-bottom: 1.5rem;
}

.functions-section-heading {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    font-size: 1.15rem;
    font-weight: 700;
    margin-bottom: 1.25rem;
    padding-bottom: 0.5rem;
    border-bottom: 1px solid var(--border-color);
}

.functions-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(350px, 1fr));
    gap: 1.25rem;
}

.function-card {
    padding: 1.25rem;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    transition: all 0.2s ease;
}
.function-card:hover {
    border-color: rgba(255, 255, 255, 0.16);
    box-shadow: var(--shadow-md);
}

.function-card.read-card {
    border-top: 3px solid var(--color-mint);
}
.function-card.write-card {
    border-top: 3px solid var(--color-bnb);
}

.result-box {
    background: #080B12;
    border: 1px solid rgba(0, 255, 163, 0.2);
    border-radius: var(--radius-sm);
    padding: 0.75rem;
    max-height: 220px;
    overflow-y: auto;
}
.result-struct-wrapper {
    display: flex;
    flex-direction: column;
    gap: 0.35rem;
}
.result-struct-row {
    display: flex;
    justify-content: space-between;
    font-size: 0.78rem;
    border-bottom: 1px solid rgba(255, 255, 255, 0.04);
    padding-bottom: 2px;
}
.result-array-item {
    padding: 2px 0;
    font-size: 0.78rem;
    border-bottom: 1px solid rgba(255, 255, 255, 0.04);
}
.json-code {
    font-size: 0.75rem;
    color: var(--color-mint);
}

/* Modals */
.modal-backdrop {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.75);
    backdrop-filter: blur(6px);
    z-index: 1000;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 1.5rem;
}
.modal-window {
    background: var(--bg-sidebar);
    border: 1px solid rgba(255, 255, 255, 0.15);
    border-radius: var(--radius-xl);
    width: 100%;
    max-width: 520px;
    padding: 2rem;
    box-shadow: 0 20px 50px rgba(0, 0, 0, 0.7);
}

.status-modal-icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    margin-bottom: 0.5rem;
}

.spinner-lg {
    width: 50px;
    height: 50px;
    border: 4px solid rgba(240, 185, 11, 0.2);
    border-top-color: var(--color-bnb);
    border-radius: 50%;
    animation: spin 0.9s linear infinite;
}

.spinner-sm {
    width: 14px;
    height: 14px;
    border: 2px solid rgba(0, 0, 0, 0.2);
    border-top-color: #000;
    border-radius: 50%;
    animation: spin 0.7s linear infinite;
    display: inline-block;
}

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

/* Toasts */
#toast-container {
    position: fixed;
    bottom: 24px;
    right: 24px;
    z-index: 2000;
    display: flex;
    flex-direction: column;
    gap: 10px;
    max-width: 380px;
}

.toast {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.85rem 1.2rem;
    border-radius: var(--radius-md);
    background: #151B2B;
    border: 1px solid var(--border-color);
    box-shadow: var(--shadow-md);
    font-size: 0.85rem;
    color: #FFF;
}
.toast-icon {
    width: 20px;
    height: 20px;
    flex-shrink: 0;
}
.toast-message {
    flex: 1;
    word-break: break-word;
}
.toast-close {
    background: transparent;
    border: none;
    color: var(--text-muted);
    cursor: pointer;
    font-size: 1.2rem;
    line-height: 1;
    padding: 0 4px;
}
.toast-close:hover {
    color: #FFF;
}

.toast-success { border-color: rgba(0, 255, 163, 0.4); }
.toast-error { border-color: rgba(239, 68, 68, 0.4); }
.toast-warning { border-color: rgba(240, 185, 11, 0.4); }

/* Animation Helpers */
.animate-fade-in {
    animation: fadeIn 0.3s ease-in-out;
}
@keyframes fadeIn {
    from { opacity: 0; transform: translateY(6px); }
    to { opacity: 1; transform: translateY(0); }
}

.animate-slide-in {
    animation: slideIn 0.25s ease-out;
}
@keyframes slideIn {
    from { opacity: 0; transform: translateX(20px); }
    to { opacity: 1; transform: translateX(0); }
}

.animate-pulse {
    animation: pulse 1.5s cubic-bezier(0.4, 0, 0.6, 1) infinite;
}
@keyframes pulse {
    0%, 100% { opacity: 1; }
    50% { opacity: .5; }
}

/* Links & Glow */
.link-glow {
    transition: all 0.2s ease;
}
.link-glow:hover {
    text-shadow: 0 0 8px rgba(0, 255, 163, 0.6);
}

/* Mobile Sidebar Overlay */
#sidebar-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.6);
    z-index: 95;
}

/* Responsive Media Queries */
@media (max-width: 1024px) {
    :root {
        --sidebar-width: 240px;
    }
}

@media (max-width: 768px) {
    #sidebar {
        transform: translateX(-100%);
    }
    #sidebar.open {
        transform: translateX(0);
    }
    #main-wrapper {
        margin-left: 0;
        max-width: 100vw;
    }
    #top-header {
        padding: 0 1rem;
    }
    #content-container {
        padding: 1rem;
    }
    .functions-grid {
        grid-template-columns: 1fr;
    }
    .dashboard-grid {
        grid-template-columns: 1fr;
    }
}
