/* Общие стили */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: 'Roboto', 'Segoe UI', Arial, sans-serif;
    line-height: 1.6;
    color: #333;
    background-color: #f5f7fa;
}

.container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 20px;
}

h1, h2, h3 {
    margin-bottom: 15px;
    color: #2c3e50;
}

a {
    color: #3498db;
    text-decoration: none;
}

a:hover {
    text-decoration: underline;
}

/* Шапка сайта */
header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 30px;
    padding-bottom: 15px;
    border-bottom: 1px solid #e1e4e8;
}

header h1 {
    margin-bottom: 0;
}

/* Формы и кнопки */
.form-group {
    margin-bottom: 15px;
}

.form-group label {
    display: block;
    margin-bottom: 5px;
    font-weight: 500;
}

.form-group input,
.form-group select {
    width: 100%;
    padding: 10px;
    border: 1px solid #ddd;
    border-radius: 4px;
    font-size: 16px;
}

.btn {
    display: inline-block;
    padding: 8px 16px;
    background-color: #3498db;
    color: white;
    border: none;
    border-radius: 4px;
    cursor: pointer;
    font-size: 14px;
    transition: background 0.3s;
}

.btn:hover {
    background-color: #2980b9;
    text-decoration: none;
}

.btn-primary {
    background-color: #2980b9;
}

.btn-light {
    background-color: #f5f5f5;
    color: #333;
    border: 1px solid #ddd;
    border-radius: 4px;
    padding: 6px 12px;
}

.btn-light:hover {
    background-color: #e9e9e9;
    color: #333;
}

.btn-danger {
    background-color: #e74c3c;
}

.btn-danger:hover {
    background-color: #c0392b;
}

.btn-small {
    padding: 5px 10px;
    font-size: 12px;
}

/* Кнопка с иконкой */
.btn-icon {
    width: 36px;
    height: 36px;
    padding: 0;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    background-color: #f1f1f1;
    color: #555;
    font-size: 14px;
    border: 1px solid #ddd;
}

.btn-icon:hover {
    background-color: #e1e1e1;
    color: #333;
}

.mobile-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 8px 12px;
    background-color: #f1f1f1;
    color: #555;
    border-radius: 4px;
    border: 1px solid #ddd;
    font-size: 14px;
    text-decoration: none;
    transition: all 0.2s;
}

.mobile-btn:hover {
    background-color: #e1e1e1;
    color: #333;
    text-decoration: none;
}

.mobile-btn-recommend {
    background-color: #2980b9;
    color: white;
    border-color: #2980b9;
}

.mobile-btn-recommend:hover {
    background-color: #3498db;
    color: white;
}

/* Списки */
.portfolio-list {
    margin: 20px 0;
}

.portfolio-list ul {
    list-style: none;
}

.portfolio-list li {
    padding: 15px;
    margin-bottom: 10px;
    background-color: white;
    border-radius: 4px;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.portfolio-name {
    font-size: 18px;
    font-weight: 500;
    flex: 1;
}

.portfolio-date {
    margin-right: 0;
    margin-top: 5px;
    display: block;
}

/* Стили для отображения портфелей на мобилке */
.portfolio-list .portfolio-name {
    font-size: 20px;
    font-weight: 600;
    display: block;
    margin-bottom: 5px;
    width: 100%;
}

/* Секции портфеля */
.portfolio-manager,
.import-section,
.portfolio-summary,
.holdings-section,
.transactions-section,
.empty-portfolio {
    background-color: white;
    padding: 20px;
    margin-bottom: 20px;
    border-radius: 4px;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
}

/* Уведомления */
.alert {
    padding: 12px 15px;
    margin-bottom: 20px;
    border-radius: 4px;
}

.alert-success {
    background-color: #d4edda;
    color: #155724;
    border: 1px solid #c3e6cb;
}

.alert-error {
    background-color: #f8d7da;
    color: #721c24;
    border: 1px solid #f5c6cb;
}

/* Карточки сводки */
.summary-cards {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
    gap: 15px;
    margin-top: 20px;
}

.card {
    background-color: #fff;
    border-radius: 8px;
    padding: 12px;
    box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
    margin-bottom: 15px;
}

.card h3 {
    font-size: 16px;
    margin-bottom: 10px;
    color: #7f8c8d;
}

.card .value {
    font-size: 24px;
    font-weight: 700;
    margin-bottom: 5px;
}

.card .percentage {
    font-size: 16px;
    color: #7f8c8d;
}

.card.profit .value,
.card.profit .percentage {
    color: #27ae60;
}

.card.loss .value,
.card.loss .percentage {
    color: #e74c3c;
}

/* Стиль для информационной карточки с комиссиями */
.card.info {
    background-color: #e8f4f8;
    border-left: 4px solid #4285f4;
}

.card.profit {
    background-color: #e6f4ea;
    border-left: 4px solid #34a853;
}

/* Таблицы */
table {
    width: 100%;
    border-collapse: collapse;
    margin-top: 15px;
}

table th,
table td {
    padding: 12px 15px;
    text-align: left;
    border-bottom: 1px solid #e1e4e8;
}

table th {
    background-color: #f8f9fa;
    font-weight: 500;
}

.holdings-table tr.profit {
    background-color: rgba(39, 174, 96, 0.1);
}

.holdings-table tr.loss {
    background-color: rgba(231, 76, 60, 0.1);
}

.transactions-table tr.buy {
    background-color: rgba(39, 174, 96, 0.05);
}

.transactions-table tr.sell {
    background-color: rgba(231, 76, 60, 0.05);
}

.transactions-table tr.deposit {
    background-color: rgba(52, 152, 219, 0.05);
}

.transactions-table tr.withdraw {
    background-color: rgba(243, 156, 18, 0.05);
}

/* Подвал */
footer {
    margin-top: 40px;
    padding-top: 20px;
    border-top: 1px solid #e1e4e8;
    text-align: center;
    color: #7f8c8d;
    font-size: 14px;
}

/* Стили для адаптивных таблиц */
.table-responsive {
    width: 100%;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
}

/* По умолчанию показываем все колонки на всех устройствах */
th, td,
th.essential, td.essential,
th.secondary, td.secondary,
th.optional, td.optional {
    display: table-cell;
}

/* Адаптивный дизайн - только для мобильных устройств */
@media (max-width: 768px) {
    .summary-cards {
        grid-template-columns: 1fr;
    }
    
    header {
        flex-direction: column;
        align-items: flex-start;
    }
    
    /* Переопределение для нового мобильного заголовка */
    .mobile-flex-header {
        flex-direction: row !important;
        align-items: center !important;
    }
    
    .mobile-flex-header .nav-links {
        width: auto !important;
        margin-top: 0 !important;
        flex-direction: row !important;
    }
    
    .mobile-flex-header .btn {
        margin-top: 0 !important;
    }
    
    /* Стили для страницы списка портфелей (index.php) */
    .portfolio-list > ul > li {
        flex-direction: column;
        align-items: flex-start;
        position: relative;
        padding-bottom: 15px;
    }
    
    .portfolio-list > ul > li > .portfolio-name {
        font-size: 20px;
        font-weight: 600;
        display: block;
        margin-bottom: 5px;
        width: 100%;
    }
    
    .portfolio-dates {
        margin-bottom: 8px;
        width: 100%;
    }
    
    .portfolio-date,
    .portfolio-last-tx {
        margin-right: 0;
        margin-top: 2px;
        display: block;
        font-size: 12px;
    }
    
    .portfolio-list > ul > li > a.btn.btn-small.btn-danger {
        position: absolute;
        top: 12px;
        right: 12px;
        padding: 3px 7px;
        font-size: 11px;
        opacity: 0.8;
        width: auto;
        text-align: center;
        display: inline-block;
    }
    
    .portfolio-list > ul > li > a.btn-trash {
        position: absolute;
        top: 12px;
        right: 12px;
        font-size: 14px;
        width: 28px;
        height: 28px;
    }
    
    /* Остальные стили для мобильных */
    .holdings-table, 
    .transactions-table {
        display: none;
    }
    
    /* Остальные стили */
    .portfolio-date {
        margin: 5px 0;
    }
    
    /* Улучшенная адаптация таблиц для мобильных устройств */
    .holdings-table, 
    .transactions-table {
        display: block;
        width: 100%;
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
    }
    
    /* Переопределение стилей для мобильных устройств */
    table {
        font-size: 12px;
    }
    
    table th,
    table td {
        padding: 6px 8px;
        white-space: nowrap;
    }
    
    /* Скрываем менее важные колонки на мобильных устройствах */
    th.optional, td.optional {
        display: none;
    }
    
    /* Уменьшаем размер текста в карточках */
    .card .value {
        font-size: 18px;
    }
    
    .card .percentage {
        font-size: 14px;
    }
    
    /* Улучшение отображения кнопок на мобильных */
    .btn {
        display: block;
        width: 100%;
        margin-bottom: 8px;
        text-align: center;
    }
    
    /* Исключение для кнопок в списке портфелей */
    .portfolio-list > ul > li > a.btn.btn-small.btn-danger {
        width: auto;
        display: inline-block;
        margin-bottom: 0;
    }
    
    .nav-links {
        width: 100%;
        display: flex;
        flex-direction: column;
    }
}

/* Дополнительные стили для очень маленьких экранов */
@media (max-width: 480px) {
    .container {
        padding: 10px;
    }
    
    h1 {
        font-size: 24px;
    }
    
    h2 {
        font-size: 20px;
    }
    
    /* Дополнительно скрываем колонки на очень маленьких экранах */
    th.secondary, td.secondary {
        display: none;
    }
    
    /* Уменьшаем отступы в карточках на малых экранах */
    .card {
        padding: 12px;
    }
    
    .portfolio-manager,
    .import-section,
    .portfolio-summary,
    .holdings-section,
    .transactions-section,
    .empty-portfolio {
        padding: 15px;
    }
}

/* Стили для выделения колонки с процентом прибыли/убытка */
td.profit {
    color: #27ae60;
    font-weight: 500;
}

td.loss {
    color: #e74c3c;
    font-weight: 500;
}

.no-price {
    color: #888;
    font-style: italic;
}

/* Стили для модального окна */
.modal {
    display: none;
    position: fixed;
    z-index: 1000;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    overflow: auto;
    background-color: rgba(0, 0, 0, 0.4);
}

.modal-content {
    background-color: #fefefe;
    margin: 5% auto;
    padding: 20px;
    border: 1px solid #ddd;
    border-radius: 4px;
    width: 80%;
    max-width: 900px;
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.1);
}

.close {
    color: #aaa;
    float: right;
    font-size: 28px;
    font-weight: bold;
    cursor: pointer;
}

.close:hover,
.close:focus {
    color: #555;
    text-decoration: none;
}

.coin-name {
    cursor: pointer;
    font-weight: 500;
    color: #2980b9;
}

.coin-name:hover {
    text-decoration: underline;
}

/* Дополнительно скрываем колонки на очень маленьких экранах */
th.secondary, td.secondary {
    display: none;
}

/* Уменьшаем отступы в карточках на малых экранах */
.card {
    padding: 12px;
}

/* Стили для переключения между таблицами и карточками */
.desktop-only {
    display: block;
}

.mobile-only {
    display: none;
}

/* Стили для карточек транзакций */
.transaction-cards {
    display: flex;
    flex-direction: column;
    gap: 20px;
    margin-top: 20px;
    margin-bottom: 20px;
}

.transaction-card {
    background-color: #ffffff;
    border-radius: 8px;
    box-shadow: 0 3px 8px rgba(0, 0, 0, 0.15);
    overflow: hidden;
    margin-bottom: 5px;
    border: 1px solid #e1e4e8;
}

.transaction-card.buy, .transaction-card.deposit {
    border-left: 5px solid #27ae60;
}

.transaction-card.sell, .transaction-card.withdraw {
    border-left: 5px solid #e74c3c;
}

.card-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 12px 15px;
    background-color: #f8f9fa;
    border-bottom: 1px solid #e1e4e8;
}

.transaction-type {
    font-weight: 600;
    color: #2c3e50;
    font-size: 16px;
}

.transaction-date {
    color: #7f8c8d;
    font-size: 14px;
}

.card-body {
    padding: 15px;
}

.transaction-pair {
    margin-bottom: 12px;
    font-weight: 500;
    color: #34495e;
}

/* Применяем flex только к элементам внутри карточек транзакций, а не к строкам таблицы */
.transaction-card .transaction-row {
    display: flex;
    justify-content: space-between;
    margin-bottom: 10px;
    flex-wrap: wrap;
}

.transaction-row > div {
    flex: 1;
    min-width: 45%;
    margin-bottom: 8px;
}

.card-footer {
    padding: 12px 15px;
    background-color: #f8f9fa;
    border-top: 1px solid #e1e4e8;
}

.percent-change {
    font-weight: 500;
    display: flex;
    flex-direction: column;
}

.percent-change .value {
    font-size: 16px;
    font-weight: 600;
    margin-bottom: 4px;
}

.percent-change .description {
    font-size: 12px;
    color: #7f8c8d;
    font-style: italic;
}

.percent-change.profit .value {
    color: #27ae60;
}

.percent-change.loss .value {
    color: #e74c3c;
}

.transaction-card .label {
    color: #7f8c8d;
    font-size: 13px;
    margin-right: 5px;
    display: block;
}

.transaction-card .value {
    color: #2c3e50;
    font-weight: 500;
}

/* Адаптивный дизайн */
@media (max-width: 768px) {
    .desktop-only {
        display: none;
    }
    
    .mobile-only {
        display: block;
    }
    
    .summary-cards {
        grid-template-columns: 1fr;
    }
}

/* Стили для карточек активов */
.holdings-cards {
    display: flex;
    flex-direction: column;
    gap: 15px;
    margin-top: 20px;
}

.holding-card {
    background-color: #ffffff;
    border-radius: 8px;
    box-shadow: 0 2px 5px rgba(0, 0, 0, 0.1);
    margin-bottom: 15px;
    overflow: hidden;
    position: relative;
    border-left: 4px solid #ccc;
}

.holding-card.profit {
    border-left-color: #27ae60;
}

.holding-card.loss {
    border-left-color: #e74c3c;
}

.holding-card .card-header {
    background-color: #f8f9fa;
    padding: 12px 15px;
    border-bottom: 1px solid #eee;
}

.holding-card .card-header .coin-name {
    font-size: 18px;
    font-weight: 700;
    color: #2c3e50;
}

.holding-card .card-body {
    padding: 12px 15px;
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: space-between;
}

.holding-card .value-item {
    width: 48%;
    margin-bottom: 10px;
    font-size: 16px;
    font-weight: 500;
    position: relative;
}

.text-success {
    color: #27ae60;
}

.text-danger {
    color: #e74c3c;
}

/* При нажатии на элемент показываем всплывающую подсказку */
.value-item:active::before {
    content: attr(data-label);
    position: absolute;
    top: -30px;
    left: 50%;
    transform: translateX(-50%);
    background-color: rgba(0, 0, 0, 0.7);
    color: #fff;
    padding: 5px 10px;
    border-radius: 4px;
    font-size: 12px;
    white-space: nowrap;
    z-index: 10;
}

/* Стили для отладочной секции */
.debug-section {
    margin-top: 30px;
    padding: 20px;
    background-color: #f5f5f5;
    border-radius: 8px;
    border: 1px solid #ddd;
}

.debug-section h2 {
    color: #333;
    margin-bottom: 15px;
}

.debug-section h3 {
    color: #555;
    margin: 15px 0 10px;
    font-size: 18px;
}

.debug-info {
    font-size: 14px;
}

.debug-info pre {
    background-color: #fff;
    padding: 10px;
    border-radius: 4px;
    border: 1px solid #e0e0e0;
    overflow-x: auto;
    white-space: pre-wrap;
    max-height: 300px;
    overflow-y: auto;
}

.debug-table {
    width: 100%;
    border-collapse: collapse;
    margin-bottom: 20px;
    font-size: 13px;
}

.debug-table th, .debug-table td {
    padding: 8px;
    border: 1px solid #ddd;
    text-align: left;
}

.debug-table th {
    background-color: #f0f0f0;
    font-weight: bold;
}

.debug-table tbody tr:nth-child(even) {
    background-color: #fafafa;
}

.debug-table tbody tr:hover {
    background-color: #f0f7ff;
}

/* Добавляем дополнительные стили для удобства чтения данных */
.debug-info ul {
    background-color: #fff;
    padding: 15px;
    border-radius: 4px;
    border: 1px solid #e0e0e0;
    list-style-type: none;
}

.debug-info ul li {
    padding: 5px 0;
    border-bottom: 1px solid #f0f0f0;
}

.debug-info ul li:last-child {
    border-bottom: none;
}

/* Стили для сортируемых таблиц */
th.sortable {
    cursor: pointer;
    position: relative;
    user-select: none;
}

th.sortable:hover {
    background-color: #f0f0f0;
}

th.sortable .sort-icon {
    font-size: 10px;
    margin-left: 5px;
    opacity: 0.5;
}

th.sort-asc .sort-icon:after {
    content: "▲";
    opacity: 1;
}

th.sort-desc .sort-icon:after {
    content: "▼";
    opacity: 1;
}

th.sort-asc .sort-icon, th.sort-desc .sort-icon {
    opacity: 1;
}

th.sort-asc, th.sort-desc {
    background-color: #f0f7ff;
}

/* Стили для мобильной сортировки */
.sort-controls {
    display: flex;
    justify-content: space-between;
    margin-bottom: 15px;
    padding: 0 5px;
}

.sort-btn {
    background-color: #f0f0f0;
    border: 1px solid #ddd;
    padding: 5px 10px;
    border-radius: 4px;
    font-size: 12px;
    color: #333;
    cursor: pointer;
    position: relative;
    transition: all 0.2s ease;
}

.sort-btn:hover {
    background-color: #e0e0e0;
}

.sort-btn.sort-asc:after,
.sort-btn.sort-desc:after {
    content: '';
    display: inline-block;
    width: 0;
    height: 0;
    margin-left: 5px;
    vertical-align: middle;
}

.sort-btn.sort-asc:after {
    border-left: 4px solid transparent;
    border-right: 4px solid transparent;
    border-bottom: 4px solid #333;
}

.sort-btn.sort-desc:after {
    border-left: 4px solid transparent;
    border-right: 4px solid transparent;
    border-top: 4px solid #333;
}

.sort-btn.sort-asc,
.sort-btn.sort-desc {
    background-color: #e6f0fa;
    border-color: #a0c8e0;
}

.cards-container {
    display: flex;
    flex-direction: column;
    gap: 15px;
}

/* Стили для мобильного заголовка в одну строку */
.mobile-flex-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: nowrap;
    gap: 10px;
    width: 100%;
}

.mobile-small-title {
    font-size: 18px;
    margin-bottom: 0;
    flex: 1;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.btn-mobile {
    padding: 6px 10px;
    font-size: 13px;
    white-space: nowrap;
}

@media (max-width: 480px) {
    .mobile-flex-header .nav-links {
        display: flex;
        flex-direction: row;
        gap: 5px;
        width: auto;
        flex-wrap: nowrap;
    }
    
    .mobile-small-title {
        font-size: 16px;
    }
    
    .btn-mobile {
        padding: 4px 8px;
        font-size: 12px;
    }
}

.portfolio-dates {
    display: flex;
    flex-direction: column;
    margin: 5px 0;
}

.portfolio-date,
.portfolio-last-tx {
    color: #777;
    font-size: 13px;
    margin-bottom: 2px;
}

.portfolio-last-tx {
    color: #3498db;
}

/* Стили для отображения портфелей на мобилке */
.portfolio-list .portfolio-name {
    font-size: 20px;
    font-weight: 600;
    display: block;
    margin-bottom: 5px;
    width: 100%;
}

/* Стили для отображения портфелей на мобилке */
.portfolio-list .portfolio-date {
    font-size: 13px;
    margin-bottom: 2px;
}

.btn-trash {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    color: #aaa;
    font-size: 16px;
    width: 32px;
    height: 32px;
    border-radius: 4px;
    transition: all 0.2s ease;
    border: 1px solid transparent;
}

.btn-trash:hover {
    color: #e74c3c;
    background-color: #f8f8f8;
    border-color: #ddd;
}

/* Адаптивный дизайн - только для мобильных устройств */
@media (max-width: 768px) {
    .desktop-only {
        display: none;
    }
    
    .mobile-only {
        display: block;
    }
    
    .summary-cards {
        grid-template-columns: 1fr;
    }
}

/* Стили для иконок редактирования и описания портфеля */
.portfolio-actions {
    display: inline-flex;
    align-items: center;
    margin-left: 3px;
    vertical-align: middle;
}

.portfolio-actions i {
    cursor: pointer;
    margin-left: 8px;
    font-size: 14px;
    padding: 6px;
    border-radius: 50%;
    background-color: #f8f9fa;
    width: 26px;
    height: 26px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.3s ease;
    box-shadow: 0 1px 3px rgba(0,0,0,0.1);
}

.edit-portfolio-btn {
    color: #007bff;
}

.edit-portfolio-btn:hover {
    color: #0056b3;
    background-color: #e2e6ea;
    transform: scale(1.1);
}

.show-description-btn {
    color: #17a2b8;
}

.show-description-btn:hover {
    color: #117a8b;
    background-color: #e2e6ea;
    transform: scale(1.1);
}

/* Стили для контейнера заголовка и иконок */
.title-with-actions {
    display: flex;
    align-items: center;
    overflow: hidden;
    flex: 1;
}

/* Стили для блока комментариев в карточках транзакций */
.notes-row {
    margin-top: 10px;
    border-top: 1px dashed #e1e4e8;
    padding-top: 10px;
}

.notes-block {
    width: 100%;
}

.notes-block .label {
    color: #7f8c8d;
    font-size: 13px;
    font-weight: 500;
}

.notes-block .value {
    color: #34495e;
    font-style: italic;
    display: block;
    margin-top: 3px;
    word-break: break-word;
}

.stat-method {
    font-size: 0.8em;
    color: #777;
    margin-top: 5px;
    font-style: italic;
} 