/* ========================================
   UNIFORM STYLES FOR ALL PAGES
   Ensures consistent sizing and appearance
   ======================================== */

/* Font Face Declarations */
@font-face {
    font-family: head;
    src: url(/DARKLINOS.ttf);
}

@font-face {
    font-family: texts;
    src: url(/Robit-Regular.ttf);
}

/* Global Font Classes */
.font-texts {
    font-family: texts, sans-serif;
}

.font-head {
    font-family: head, sans-serif;
}

.font-display {
    font-family: head, sans-serif;
}

.font-medium {
    font-family: head, sans-serif;
}

/* Text Size Classes */
.text-sm {
    font-family: texts, sans-serif;
}

.text-xs {
    font-family: texts, sans-serif;
}

.text-base {
    font-family: texts, sans-serif;
}

.text-lg {
    font-family: texts, sans-serif;
}

.text-xl {
    font-family: head, sans-serif;
}

.text-2xl {
    font-family: head, sans-serif;
}

.text-3xl {
    font-family: head, sans-serif;
}

/* Modifier Classes */
.text-muted-foreground {
    font-family: texts, sans-serif;
}

.font-semibold {
    font-family: texts, sans-serif;
    font-weight: 600;
}

.font-bold {
    font-family: head, sans-serif;
    font-weight: 700;
}

/* ========================================
   SIDEBAR UNIFORM STYLING
   ======================================== */

/* Sidebar Base Styles - Prevent Overflow */
aside[data-testid="sidebar"] {
    overflow-x: hidden;
    overflow-y: auto;
}

aside[data-testid="sidebar"] * {
    word-wrap: break-word;
    overflow-wrap: break-word;
}

/* Logo Container - Fixed Height */
aside[data-testid="sidebar"] .px-6.py-5 {
    min-height: 80px;
    display: flex;
    align-items: center;
    overflow: hidden;
}

/* Logo Images - Consistent Sizing */
aside[data-testid="sidebar"] img[alt="Dexari Logo"] {
    height: 32px;
    width: auto;
    object-fit: contain;
    flex-shrink: 0;
}

/* Logo Text Container */
aside[data-testid="sidebar"] .px-6.py-5 > div {
    display: flex;
    flex-direction: column;
    gap: 2px;
    overflow: hidden;
    flex: 1;
    min-width: 0;
}

/* Logo Text - Uniform Sizes with Overflow Protection */
aside[data-testid="sidebar"] .px-6.py-5 p.text-sm {
    font-size: 0.875rem;
    line-height: 1.25rem;
    font-family: texts, sans-serif;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

aside[data-testid="sidebar"] .px-6.py-5 p.text-base {
    font-size: 1rem;
    line-height: 1.5rem;
    font-family: head, sans-serif;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

/* Navigation Items - Uniform Spacing with Overflow Fix */
aside[data-testid="sidebar"] nav ul li a {
    min-height: 44px;
    font-size: 0.875rem;
    line-height: 1.25rem;
    font-family: texts, sans-serif;
    display: flex;
    align-items: center;
    overflow: hidden;
}

/* Navigation Text - Prevent Overflow */
aside[data-testid="sidebar"] nav ul li a span.flex-1 {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    flex: 1;
    min-width: 0;
}

/* Navigation Icons - Fixed Size */
aside[data-testid="sidebar"] nav ul li a span.inline-flex {
    height: 32px;
    width: 32px;
    min-width: 32px;
    min-height: 32px;
    flex-shrink: 0;
}

aside[data-testid="sidebar"] nav ul li a span.inline-flex svg {
    width: 20px;
    height: 20px;
}

/* Connect Wallet Button - Uniform Height with Overflow Fix */
button[data-testid="button-connect-wallet"] {
    min-height: 40px;
    font-size: 0.875rem;
    line-height: 1.25rem;
    font-family: texts, sans-serif;
    padding-top: 0.5rem;
    padding-bottom: 0.5rem;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

/* Shortcuts Section - Uniform Spacing */
aside[data-testid="sidebar"] .text-xs {
    font-size: 0.75rem;
    line-height: 1rem;
    font-family: texts, sans-serif;
}

/* ========================================
   HEADER UNIFORM STYLING
   ======================================== */

/* Header Container - Fixed Height */
header {
    min-height: 64px;
    padding: 1rem;
}

/* Header Buttons - Consistent Sizing */
header button {
    font-family: texts, sans-serif;
    font-size: 0.875rem;
    line-height: 1.25rem;
}

/* Sidebar Toggle Button */
button[data-testid="button-sidebar-toggle"] {
    height: 40px;
    width: 40px;
    min-width: 40px;
    min-height: 40px;
}

/* Theme Toggle Button */
button[data-testid="button-theme-toggle"] {
    height: 40px;
    width: 40px;
    min-width: 40px;
    min-height: 40px;
}

/* ========================================
   WALLET MODAL UNIFORM STYLING
   ======================================== */

/* Modal Container */
[data-testid="wallet-modal"] {
    z-index: 120;
}

/* Modal Content */
[data-testid="wallet-modal"] h2 {
    font-family: head, sans-serif;
    font-size: 1.25rem;
    line-height: 1.75rem;
}

[data-testid="wallet-modal"] p {
    font-family: texts, sans-serif;
    font-size: 0.875rem;
    line-height: 1.25rem;
}

/* Modal Buttons */
[data-testid="wallet-modal"] button {
    min-height: 40px;
    font-family: texts, sans-serif;
    font-size: 0.875rem;
    line-height: 1.25rem;
}

/* ========================================
   RESPONSIVE ADJUSTMENTS
   ======================================== */

/* Ensure consistency on all screen sizes */
@media (min-width: 1024px) {
    /* Desktop: Side-by-side layout */
    aside[data-testid="sidebar"] {
        width: 16rem;
        min-width: 16rem;
        max-width: 16rem;
    }

    /* Ensure main content takes remaining space */
    .flex.flex-col.flex-1.overflow-hidden {
        flex: 1;
        min-width: 0;
        overflow-x: hidden;
    }
}

@media (max-width: 1023px) {
    /* Mobile: Full width sidebar with better spacing */
    aside[data-testid="sidebar"] {
        width: 16rem;
        max-width: 85vw;
    }

    /* Adjust padding for smaller screens */
    aside[data-testid="sidebar"] .px-6 {
        padding-left: 1rem;
        padding-right: 1rem;
    }

    aside[data-testid="sidebar"] .px-3 {
        padding-left: 0.5rem;
        padding-right: 0.5rem;
    }
}

@media (max-width: 640px) {
    /* Extra small screens */
    aside[data-testid="sidebar"] {
        width: 100vw;
        max-width: 100vw;
    }

    /* Reduce font sizes slightly on very small screens */
    aside[data-testid="sidebar"] .px-6.py-5 p.text-base {
        font-size: 0.9375rem;
    }

    aside[data-testid="sidebar"] nav ul li a {
        font-size: 0.8125rem;
    }
}

/* Landscape phone orientation */
@media (max-height: 500px) and (orientation: landscape) {
    aside[data-testid="sidebar"] .px-6.py-5 {
        min-height: 60px;
        padding-top: 0.75rem;
        padding-bottom: 0.75rem;
    }

    aside[data-testid="sidebar"] nav ul li a {
        min-height: 36px;
        padding-top: 0.25rem;
        padding-bottom: 0.25rem;
    }
}

/* ========================================
   BUTTON CONSISTENCY
   ======================================== */

/* All primary buttons */
.bg-primary {
    font-family: texts, sans-serif;
}

/* All input fields - Prevent Overflow */
input,
textarea,
select {
    font-family: texts, sans-serif;
    font-size: 0.875rem;
    line-height: 1.25rem;
    max-width: 100%;
    box-sizing: border-box;
}

/* Labels */
label {
    font-family: texts, sans-serif;
    font-size: 0.875rem;
    line-height: 1.25rem;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* Button base styles - responsive */
button {
    max-width: 100%;
    box-sizing: border-box;
}

@media (max-width: 640px) {
    button {
        font-size: 0.8125rem;
        min-height: 38px;
    }
}

/* ========================================
   CARD CONSISTENCY
   ======================================== */

/* Card titles */
.shadcn-card h2,
.shadcn-card h3 {
    font-family: head, sans-serif;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* Card text */
.shadcn-card p {
    font-family: texts, sans-serif;
    overflow-wrap: break-word;
    word-wrap: break-word;
}

/* Card container - prevent overflow */
.shadcn-card {
    overflow: hidden;
    max-width: 100%;
}

/* Responsive card adjustments */
@media (max-width: 768px) {
    .shadcn-card {
        padding: 1rem;
    }

    .shadcn-card h2 {
        font-size: 1.25rem;
    }

    .shadcn-card h3 {
        font-size: 1.125rem;
    }
}

/* ========================================
   KBD TAG STYLING
   ======================================== */

kbd {
    font-family: texts, sans-serif;
    font-size: 0.75rem;
    line-height: 1rem;
    padding: 0.125rem 0.5rem;
    border-radius: 0.25rem;
    display: inline-block;
    white-space: nowrap;
    flex-shrink: 0;
}

/* ========================================
   ENSURE NO OVERFLOW ISSUES
   ======================================== */

/* Prevent layout shifts */
* {
    box-sizing: border-box;
}

/* Root container - prevent horizontal scroll */
html,
body {
    overflow-x: hidden;
    max-width: 100vw;
}

#root {
    overflow-x: hidden;
    max-width: 100vw;
}

/* Main content area - prevent overflow */
.flex.flex-col.flex-1.overflow-hidden {
    overflow-x: hidden;
    max-width: 100%;
}

/* Smooth transitions */
aside[data-testid="sidebar"],
[data-testid="sidebar-overlay"],
button {
    transition-timing-function: cubic-bezier(0.4, 0, 0.2, 1);
}

/* Prevent text overflow globally */
h1,
h2,
h3,
h4,
h5,
h6 {
    overflow-wrap: break-word;
    word-wrap: break-word;
}

p,
span,
div {
    overflow-wrap: break-word;
    word-wrap: break-word;
}

/* Container queries for better responsiveness */
@container (max-width: 400px) {
    aside[data-testid="sidebar"] nav ul li a {
        font-size: 0.8125rem;
    }
}

/* ========================================
   DARK MODE LOGO SWITCHING
   ======================================== */

/* Light mode - show Black.png */
:not(.dark) img[src="Black-outline.png"] {
    display: none !important;
}

:not(.dark) img[src="Black.png"] {
    display: block !important;
}

/* Dark mode - show Black-outline.png */
.dark img[src="Black.png"] {
    display: none !important;
}

.dark img[src="Black-outline.png"] {
    display: block !important;
}

/* ========================================
   ADDITIONAL RESPONSIVE UTILITIES
   ======================================== */

/* Header responsiveness */
header {
    display: flex;
    flex-wrap: nowrap;
    overflow-x: hidden;
}

header button {
    flex-shrink: 0;
}

@media (max-width: 640px) {
    header {
        padding: 0.75rem;
    }

    header button[data-testid="button-theme-toggle"],
    header button[data-testid="button-sidebar-toggle"] {
        height: 36px;
        width: 36px;
        min-width: 36px;
        min-height: 36px;
    }
}

/* Main content padding adjustments */
@media (max-width: 768px) {
    main {
        padding: 1rem;
    }
}

@media (max-width: 640px) {
    main {
        padding: 0.75rem;
    }
}

/* Grid and flex containers - responsive */
.grid {
    display: grid;
    gap: 1rem;
}

@media (max-width: 768px) {
    .grid {
        gap: 0.75rem;
    }
}

@media (max-width: 640px) {
    .grid {
        gap: 0.5rem;
        grid-template-columns: 2fr !important;
    }
}
@media (max-width: 640px) {
    .grid-dev {
        gap: 0.5rem;
        grid-template-columns: 1fr ;
    }
}


/* Modal responsiveness */
[data-testid="wallet-modal"] {
    max-width: min(500px, 90vw);
    max-height: 90vh;
    overflow-y: auto;
}

@media (max-width: 640px) {
    [data-testid="wallet-modal"] {
        max-width: 95vw;
        max-height: 95vh;
        margin: 0.5rem;
    }

    [data-testid="wallet-modal"] h2 {
        font-size: 1.125rem;
    }

    [data-testid="wallet-modal"] button {
        min-height: 38px;
        font-size: 0.8125rem;
    }
}

/* Table responsiveness */
table {
    width: 100%;
    overflow-x: auto;
    display: block;
}

@media (max-width: 768px) {
    table {
        font-size: 0.8125rem;
    }

    table th,
    table td {
        padding: 0.5rem;
    }
}

/* Form responsiveness */
form {
    max-width: 100%;
}

form input,
form textarea,
form select {
    width: 100%;
}

@media (max-width: 640px) {
    form input,
    form textarea,
    form select {
        font-size: 16px; /* Prevents zoom on iOS */
    }
}
