/* Shadcn UI Inspired Styles */
:root {
    --background: 0 0% 100%;
    --foreground: 222.2 84% 4.9%;
    --card: 0 0% 100%;
    --card-foreground: 222.2 84% 4.9%;
    --popover: 0 0% 100%;
    --popover-foreground: 222.2 84% 4.9%;
    --primary: 222.2 47.4% 11.2%;
    --primary-foreground: 210 40% 98%;
    --secondary: 210 40% 96.1%;
    --secondary-foreground: 222.2 47.4% 11.2%;
    --muted: 210 40% 96.1%;
    --muted-foreground: 215.4 16.3% 46.9%;
    --accent: 210 40% 96.1%;
    --accent-foreground: 222.2 47.4% 11.2%;
    --destructive: 0 84.2% 60.2%;
    --destructive-foreground: 210 40% 98%;
    --border: 214.3 31.8% 91.4%;
    --input: 214.3 31.8% 91.4%;
    --ring: 222.2 84% 4.9%;
    --radius: 0.5rem;
}

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

body {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
    background: hsl(var(--background));
    color: hsl(var(--foreground));
    line-height: 1.6;
    min-height: 100vh;
}

.container {
    max-width: 1400px;
    margin: 0 auto;
    padding: 2rem 1rem;
}

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

.content-left {
    min-width: 0;
    display: flex;
    flex-direction: column;
    height: 100%;
}

.content-right {
    min-width: 0;
    display: flex;
    flex-direction: column;
    height: 100%;
}

/* No Data State */
.no-data {
    text-align: center;
    padding: 3rem 1rem;
    color: hsl(var(--muted-foreground));
    font-size: 0.875rem;
    font-style: italic;
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 200px;
    width: 100%;
}

/* Responsive - для мобильных устройств */
@media (max-width: 968px) {
    .content-grid {
        grid-template-columns: 1fr;
        gap: 1rem;
    }
    
    .content-left,
    .content-right {
        width: 100%;
    }
    
    /* На мобильных блок результатов должен быть виден */
    #results.card {
        display: flex !important;
        min-height: 300px;
    }
}

/* Header */
.header {
    text-align: center;
    margin-bottom: 3rem;
    padding: 2rem 0;
}

.header-title {
    font-size: 2.5rem;
    font-weight: 700;
    color: hsl(var(--foreground));
    margin-bottom: 0.5rem;
    letter-spacing: -0.025em;
}

.header-description {
    font-size: 1.125rem;
    color: hsl(var(--muted-foreground));
}

/* Card */
.card {
    background: hsl(var(--card));
    border: 1px solid hsl(var(--border));
    border-radius: var(--radius);
    padding: 1.5rem;
    box-shadow: 0 1px 3px 0 rgb(0 0 0 / 0.1), 0 1px 2px -1px rgb(0 0 0 / 0.1);
    height: 100%;
    display: flex;
    flex-direction: column;
    min-height: 0; /* Важно для работы overflow в flex контейнере */
}

.card-hidden {
    display: none;
}

.card-header {
    margin-bottom: 1.5rem;
    flex-shrink: 0; /* Заголовок не сжимается */
}

/* Специальная стилизация для карточки результатов - чтобы скролл был только внутри */
#results.card {
    overflow: hidden; /* Карточка не должна растягиваться за счет содержимого */
    max-height: 100%; /* Ограничиваем максимальную высоту */
}

.card-title {
    font-size: 1.5rem;
    font-weight: 600;
    margin-bottom: 0.5rem;
}

.card-description {
    color: hsl(var(--muted-foreground));
    font-size: 0.875rem;
}

/* Form */
.form {
    display: flex;
    flex-direction: column;
    gap: 1.5rem;
}

.form-group {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.label {
    font-size: 0.875rem;
    font-weight: 500;
    color: hsl(var(--foreground));
}

.input,
.select {
    width: 100%;
    padding: 0.5rem 0.75rem;
    font-size: 0.875rem;
    border: 1px solid hsl(var(--input));
    border-radius: calc(var(--radius) - 2px);
    background: hsl(var(--background));
    color: hsl(var(--foreground));
    transition: all 0.2s;
}

.input:focus,
.select:focus {
    outline: none;
    ring: 2px;
    ring-color: hsl(var(--ring));
    border-color: hsl(var(--ring));
    box-shadow: 0 0 0 2px hsl(var(--ring) / 0.2);
}

.input::placeholder {
    color: hsl(var(--muted-foreground));
}

.form-hint {
    font-size: 0.75rem;
    color: hsl(var(--muted-foreground));
}

/* Button */
.button {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 0.5rem 1rem;
    font-size: 0.875rem;
    font-weight: 500;
    border-radius: calc(var(--radius) - 2px);
    border: none;
    cursor: pointer;
    transition: all 0.2s;
    text-decoration: none;
}

.button-primary {
    background: hsl(var(--primary));
    color: hsl(var(--primary-foreground));
}

.button-primary:hover {
    background: hsl(var(--primary) / 0.9);
}

.button:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.button-text {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.button.loading::after {
    content: "";
    width: 1rem;
    height: 1rem;
    border: 2px solid hsl(var(--primary-foreground));
    border-top-color: transparent;
    border-radius: 50%;
    animation: spin 0.6s linear infinite;
    margin-left: 0.5rem;
}

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

/* Alert */
.alert {
    padding: 1rem;
    border-radius: calc(var(--radius) - 2px);
    border: 1px solid;
    margin-bottom: 1rem;
}

.alert-error {
    background: hsl(var(--destructive) / 0.1);
    border-color: hsl(var(--destructive));
    color: hsl(var(--destructive));
}

/* Results - скролл только внутри этого блока */
.results-content {
    display: flex;
    flex-direction: column;
    gap: 1rem;
    flex: 1 1 0;
    min-height: 0;
    overflow-y: auto;
    overflow-x: hidden;
    padding-right: 0.5rem;
    /* Высота ограничена родителем через flex */
}

/* Кастомный скроллбар для результатов */
.results-content::-webkit-scrollbar {
    width: 8px;
}

.results-content::-webkit-scrollbar-track {
    background: hsl(var(--muted) / 0.3);
    border-radius: 4px;
}

.results-content::-webkit-scrollbar-thumb {
    background: hsl(var(--muted-foreground) / 0.5);
    border-radius: 4px;
    transition: background 0.2s;
}

.results-content::-webkit-scrollbar-thumb:hover {
    background: hsl(var(--muted-foreground) / 0.7);
}

/* Для Firefox */
.results-content {
    scrollbar-width: thin;
    scrollbar-color: hsl(var(--muted-foreground) / 0.5) hsl(var(--muted) / 0.3);
}

.result-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 1rem;
    border: 1px solid hsl(var(--border));
    border-radius: calc(var(--radius) - 2px);
    background: hsl(var(--card));
}

.result-item-header {
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
}

.result-coin {
    font-weight: 600;
    font-size: 1rem;
}

.result-details {
    font-size: 0.875rem;
    color: hsl(var(--muted-foreground));
}

.result-value {
    text-align: right;
}

.result-usd {
    font-size: 1.25rem;
    font-weight: 600;
    color: hsl(var(--primary));
}

.result-coins {
    font-size: 0.875rem;
    color: hsl(var(--muted-foreground));
}

.error-message {
    padding: 1rem;
    background: hsl(var(--destructive) / 0.1);
    border: 1px solid hsl(var(--destructive));
    border-radius: calc(var(--radius) - 2px);
    color: hsl(var(--destructive));
    margin-top: 1rem;
}

/* Loading state */
.loading {
    opacity: 0.6;
    pointer-events: none;
}

/* Coins Section */
.coins-section {
    margin-top: 3rem;
    width: 100%;
}

.coins-container {
    display: flex;
    flex-wrap: wrap;
    gap: 0.75rem;
    max-height: 400px;
    overflow-y: auto;
    padding: 0.5rem 0;
}

.coin-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 0.75rem;
    min-width: 100px;
    max-width: 120px;
    border: 1px solid hsl(var(--border));
    border-radius: calc(var(--radius) - 2px);
    background: hsl(var(--card));
    transition: all 0.2s;
}

.coin-item:hover {
    border-color: hsl(var(--ring));
    box-shadow: 0 2px 4px 0 rgb(0 0 0 / 0.1);
    transform: translateY(-2px);
}

.coin-symbol {
    font-weight: 600;
    font-size: 0.875rem;
    color: hsl(var(--foreground));
    margin-bottom: 0.5rem;
    text-align: center;
}

.coin-price-usd {
    font-weight: 600;
    font-size: 0.875rem;
    color: hsl(var(--primary));
    text-align: center;
}

/* Responsive */
@media (max-width: 640px) {
    .container {
        padding: 1rem 0.5rem;
    }

    .header-title {
        font-size: 2rem;
    }

    .card {
        padding: 1rem;
    }
    
    /* На мобильных блок результатов должен быть всегда виден */
    #results.card {
        display: flex !important;
        min-height: 300px;
        max-height: none;
    }
    
    .results-content {
        min-height: 200px;
    }

    .coins-container {
        max-height: 300px;
    }

    .coin-item {
        min-width: 100px;
        padding: 0.75rem;
    }
}

