:root {
    --primary-color: #2563eb;
    --primary-hover: #1d4ed8;
    --bg-color: #f8fafc;
    --card-bg: #ffffff;
    --text-main: #1e293b;
    --text-secondary: #64748b;
    --border-color: #e2e8f0;
    --shadow-sm: 0 1px 2px 0 rgb(0 0 0 / 0.05);
    --shadow-md: 0 4px 6px -1px rgb(0 0 0 / 0.1), 0 2px 4px -2px rgb(0 0 0 / 0.1);
    --shadow-lg: 0 10px 15px -3px rgb(0 0 0 / 0.1), 0 4px 6px -4px rgb(0 0 0 / 0.1);
}

* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

body {
    font-family: 'Inter', sans-serif;
    background-color: var(--bg-color);
    color: var(--text-main);
    min-height: 100vh;
    display: flex;
    justify-content: center;
    padding: 20px;
}

.app-container {
    width: 100%;
    max-width: 600px;
    background: var(--card-bg);
    border-radius: 24px;
    box-shadow: var(--shadow-lg);
    padding: 32px;
    display: flex;
    flex-direction: column;
    gap: 24px;
    height: fit-content;
}

header {
    text-align: center;
}

header h1 {
    font-size: 24px;
    font-weight: 700;
    margin-bottom: 8px;
    background: linear-gradient(135deg, #2563eb 0%, #3b82f6 100%);
    background-clip: text;
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
}

header p {
    color: var(--text-secondary);
    font-size: 14px;
}

.upload-section {
    border: 2px dashed var(--border-color);
    border-radius: 16px;
    padding: 40px 20px;
    text-align: center;
    cursor: pointer;
    transition: all 0.3s ease;
    background: #f8fafc;
}

.upload-section:hover {
    border-color: var(--primary-color);
    background: #eff6ff;
}

.upload-box .icon {
    font-size: 48px;
    margin-bottom: 16px;
}

.upload-box h3 {
    font-size: 16px;
    font-weight: 600;
    margin-bottom: 4px;
}

.upload-box p {
    font-size: 12px;
    color: var(--text-secondary);
}

.hidden {
    display: none;
}

#preview-section {
    display: flex;
    flex-direction: column;
    gap: 20px;
    animation: fadeIn 0.5s ease;
}

@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(10px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.preview-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.preview-header h2 {
    font-size: 18px;
    font-weight: 600;
}

.canvas-container {
    background: #525659;
    padding: 20px;
    border-radius: 12px;
    display: flex;
    justify-content: center;
    overflow: auto;
    max-height: 500px;
}

canvas {
    box-shadow: var(--shadow-md);
    max-width: 100%;
}

.controls {
    display: flex;
    gap: 12px;
}

.primary-btn,
.secondary-btn {
    padding: 12px 24px;
    border-radius: 12px;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
    border: none;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
}

.primary-btn {
    background: var(--primary-color);
    color: white;
    flex: 1;
    box-shadow: 0 4px 6px -1px rgba(37, 99, 235, 0.2);
}

.primary-btn:hover {
    background: var(--primary-hover);
    transform: translateY(-1px);
}

.primary-btn:active {
    transform: translateY(0);
}

.secondary-btn {
    background: transparent;
    color: var(--text-secondary);
    border: 1px solid var(--border-color);
}

.secondary-btn:hover {
    background: #f1f5f9;
    color: var(--text-main);
}

/* Print Styles */
@media print {
    body {
        background: white;
        padding: 0;
        display: block;
    }

    .app-container {
        box-shadow: none;
        padding: 0;
        max-width: none;
        width: 100%;
    }

    header,
    .upload-section,
    .preview-header,
    .controls {
        display: none !important;
    }

    #preview-section {
        display: block !important;
    }

    .canvas-container {
        padding: 0;
        background: white;
        border-radius: 0;
        display: block;
        max-height: none;
    }

    canvas {
        box-shadow: none;
        width: 100% !important;
        height: auto !important;
        /* Force black and white for thermal printers */
        filter: grayscale(100%) contrast(150%);
    }

    /* Ensure content starts at the top */
    @page {
        margin: 0;
    }
}

/* Modal Styles */
.modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.5);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 1000;
}

.modal-content {
    background: white;
    padding: 24px;
    border-radius: 16px;
    width: 90%;
    max-width: 400px;
    box-shadow: var(--shadow-lg);
}

.modal-content h3 {
    margin-bottom: 16px;
    font-size: 18px;
    font-weight: 600;
}

#device-list {
    list-style: none;
    margin-bottom: 16px;
    max-height: 200px;
    overflow-y: auto;
}

#device-list li {
    padding: 12px;
    border: 1px solid var(--border-color);
    border-radius: 8px;
    margin-bottom: 8px;
    cursor: pointer;
    transition: all 0.2s;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

#device-list li:hover {
    background: #eff6ff;
    border-color: var(--primary-color);
}

#device-list li.selected {
    background: #eff6ff;
    border-color: var(--primary-color);
    font-weight: 600;
}

#device-list li.selected::after {
    content: '✓';
    color: var(--primary-color);
}

#close-modal {
    width: 100%;
    padding: 12px;
    background: var(--text-secondary);
    color: white;
    border: none;
    border-radius: 8px;
    cursor: pointer;
    font-weight: 600;
}

/* Fix for modal visibility */
.modal.hidden {
    display: none !important;
}