/* Avoska POS Summary Styles - Light/Dark Theme Support */

:root {
    /* Тёмная тема (по умолчанию) */
    --tps-bg: #1e1e1e;
    --tps-panel-bg: #252525;
    --tps-row-bg: #2a2a2a;
    --tps-row-hover: #333333;
    --tps-input-bg: #333333;
    --tps-input-border: #444444;
    --tps-text-main: #e0e0e0;
    --tps-text-muted: #aaaaaa;
    --tps-text-header: #ffd700;
    --tps-accent: #0073aa;
    --tps-accent-hover: #005a87;
    --tps-border: #333333;
    --tps-shadow: rgba(0, 0, 0, 0.4);

    /* Цвета строк */
    --tps-card-border: #4caf50;
    --tps-cash-border: #2196f3;
    --tps-open-border: #00bfff;
    --tps-other-border: #9c27b0;

    /* Текстовые цвета */
    --tps-positive: #69f0ae;
    --tps-negative: #ff5252;
    --tps-count-bg: #444444;
    --tps-count-text: #dddddd;
    --tps-money-text: #ffffff;
}

[data-tps-theme="light"] {
    /* Светлая тема */
    --tps-bg: #ffffff;
    --tps-panel-bg: #f8f9fa;
    --tps-row-bg: #ffffff;
    --tps-row-hover: #f1f3f5;
    --tps-input-bg: #ffffff;
    --tps-input-border: #ced4da;
    --tps-text-main: #333333;
    --tps-text-muted: #6c757d;
    --tps-text-header: #e6b800;
    --tps-accent: #0073aa;
    --tps-accent-hover: #005a87;
    --tps-border: #e9ecef;
    --tps-shadow: rgba(0, 0, 0, 0.08);

    /* Текстовые цвета */
    --tps-positive: #2e7d32;
    --tps-negative: #d32f2f;
    --tps-count-bg: #e9ecef;
    --tps-count-text: #495057;
    --tps-money-text: #212529;
}

/* Wrapper */
.tps-summary {
    color: var(--tps-text-main);
    background: var(--tps-bg);
    padding: 24px;
    border-radius: 16px;
    max-width: 850px;
    margin: 0 auto;
    font-family: 'Segoe UI', Roboto, Helvetica, Arial, sans-serif;
    box-shadow: 0 8px 24px var(--tps-shadow);
    line-height: 1.5;
    position: relative;
    transition: background 0.3s ease, color 0.3s ease, box-shadow 0.3s ease;
}

/* Theme Switcher */
.tps-theme-toggle {
    position: absolute;
    top: 20px;
    right: 24px;
    background: var(--tps-panel-bg);
    border: 1px solid var(--tps-border);
    color: var(--tps-text-main);
    border-radius: 50%;
    width: 36px;
    height: 36px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    font-size: 16px;
    transition: all 0.2s ease;
    z-index: 10;
}

.tps-theme-toggle:hover {
    transform: scale(1.1);
}

/* Header */
.tps-summary h3 {
    margin: 0 0 24px 0;
    color: var(--tps-text-header);
    font-size: 1.6em;
    text-align: center;
    border-bottom: 2px solid var(--tps-border);
    padding-bottom: 16px;
    font-weight: 700;
}

.tps-summary h4 {
    color: var(--tps-text-muted);
    margin-bottom: 18px;
    border-bottom: 1px solid var(--tps-border);
    display: inline-block;
    font-weight: 600;
}

/* Controls */
.tps-time-controls {
    display: flex;
    gap: 12px;
    margin-bottom: 28px;
    flex-wrap: wrap;
    justify-content: center;
    background: var(--tps-panel-bg);
    padding: 16px;
    border-radius: 12px;
    border: 1px solid var(--tps-border);
}

.tps-time-controls select,
.tps-time-controls input {
    background: var(--tps-input-bg);
    color: var(--tps-text-main);
    border: 1px solid var(--tps-input-border);
    padding: 10px 16px;
    border-radius: 8px;
    font-size: 15px;
    outline: none;
    flex: 1 1 auto;
    transition: all 0.2s ease;
}

.tps-time-controls select:focus,
.tps-time-controls input:focus {
    border-color: var(--tps-accent);
}

.tps-time-controls input[type="date"] {
    min-width: 140px;
}

.tps-time-controls button {
    background: var(--tps-accent);
    color: #fff;
    border: none;
    padding: 10px 24px;
    border-radius: 8px;
    cursor: pointer;
    font-weight: 600;
    font-size: 15px;
    min-width: 110px;
    transition: all 0.2s ease;
    box-shadow: 0 4px 12px rgba(0, 115, 170, 0.2);
}

.tps-time-controls button:hover {
    background: var(--tps-accent-hover);
    transform: translateY(-1px);
    box-shadow: 0 6px 14px rgba(0, 115, 170, 0.3);
}

/* Data Rows */
.tps-data-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 10px;
    padding: 14px 18px;
    background: var(--tps-row-bg);
    border-radius: 10px;
    font-size: 15px;
    border-left: 5px solid transparent;
    border: 1px solid var(--tps-border);
    border-left-width: 5px;
    transition: all 0.2s ease;
}

.tps-data-row:hover {
    background: var(--tps-row-hover);
    transform: translateX(2px);
}

/* Border colors for types */
.tps-row-card {
    border-left-color: var(--tps-card-border);
}

.tps-row-cash {
    border-left-color: var(--tps-cash-border);
}

.tps-row-open {
    border-left-color: var(--tps-open-border);
}

.tps-row-other {
    border-left-color: var(--tps-other-border);
}

.tps-cell-label {
    font-weight: 600;
    color: var(--tps-text-muted);
    display: flex;
    align-items: center;
    gap: 10px;
}

.tps-cell-data {
    display: flex;
    align-items: center;
    gap: 12px;
}

.tps-count {
    background: var(--tps-count-bg);
    padding: 3px 10px;
    border-radius: 6px;
    font-size: 0.9em;
    color: var(--tps-count-text);
    font-weight: 500;
}

.tps-money {
    font-weight: 800;
    font-size: 1.15em;
    color: var(--tps-money-text);
}

.tps-diff {
    font-size: 0.9em;
    font-weight: 700;
}

.tps-summary .positive {
    color: var(--tps-positive);
}

.tps-summary .negative {
    color: var(--tps-negative);
}

.tps-summary .open-order {
    color: var(--tps-open-border);
}

/* fallback logic for simple rendering */

.tps-summary hr {
    border: 0;
    border-top: 2px dashed var(--tps-border);
    margin: 28px 0;
}

/* Totals Section */
.tps-totals {
    background: linear-gradient(135deg, var(--tps-panel-bg) 0%, var(--tps-row-bg) 100%);
    padding: 24px;
    border-radius: 12px;
    text-align: center;
    margin-top: 20px;
    border: 1px solid var(--tps-border);
    position: relative;
    overflow: hidden;
}

.tps-totals::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 4px;
    background: linear-gradient(90deg, #0073aa, #00bfff);
}

.tps-total-line {
    margin: 8px 0;
    font-size: 1.15em;
    color: var(--tps-text-main);
}

.tps-total-big {
    font-size: 1.8em;
    color: var(--tps-text-header);
    margin-top: 14px;
    font-weight: 900;
    text-shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
}

.tps-info-item {
    margin-bottom: 8px;
    color: var(--tps-text-muted);
    font-size: 1em;
    padding: 10px;
    background: var(--tps-row-bg);
    border-radius: 8px;
    border: 1px solid var(--tps-border);
}

.tps-info-item strong {
    color: var(--tps-text-main);
}

/* Loading Skeleton */
.tps-skeleton {
    animation: pulse 1.5s infinite;
}

.tps-skeleton-title {
    height: 28px;
    width: 60%;
    margin: 0 auto 24px;
    background: var(--tps-border);
    border-radius: 8px;
}

.tps-skeleton-row {
    height: 52px;
    margin-bottom: 10px;
    background: var(--tps-row-bg);
    border-radius: 10px;
    border: 1px solid var(--tps-border);
}

@keyframes pulse {
    0% {
        opacity: 0.6;
    }

    50% {
        opacity: 1;
    }

    100% {
        opacity: 0.6;
    }
}

@media (max-width: 600px) {
    .tps-summary {
        padding: 16px;
        width: 100%;
        border-radius: 8px;
    }

    .tps-time-controls {
        flex-direction: column;
        gap: 14px;
    }

    .tps-time-controls select,
    .tps-time-controls input,
    .tps-time-controls button {
        width: 100%;
    }

    .tps-data-row {
        flex-direction: column;
        align-items: flex-start;
        gap: 10px;
        padding: 16px;
    }

    .tps-cell-data {
        width: 100%;
        justify-content: space-between;
    }

    .tps-money {
        font-size: 1.25em;
    }

    .tps-theme-toggle {
        top: 10px;
        right: 10px;
        width: 32px;
        height: 32px;
    }
}