:root {
    --primary: #2196F3;
    --success: #4CAF50;
    --danger: #f44336;
    --warning: #ff9800;
    --dark: #263238;
    --light: #eceff1;
    --border: #cfd8dc;
    --shadow: rgba(0,0,0,0.1);
}

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

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, sans-serif;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    min-height: 100vh;
    padding: 20px;
    color: var(--dark);
}

.container {
    max-width: 1600px;
    margin: 0 auto;
}

header {
    background: white;
    padding: 30px;
    border-radius: 15px;
    text-align: center;
    margin-bottom: 20px;
    box-shadow: 0 4px 6px var(--shadow);
}

header h1 {
    font-size: 2.5rem;
    margin-bottom: 10px;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

header p {
    color: #666;
    font-size: 1.1rem;
}

.main-grid {
    display: grid;
    grid-template-columns: 320px 1fr;
    gap: 20px;
}

.card {
    background: white;
    border-radius: 12px;
    padding: 25px;
    margin-bottom: 20px;
    box-shadow: 0 2px 8px var(--shadow);
}

.card h2, .card h3 {
    margin-bottom: 20px;
    color: var(--dark);
    font-size: 1.3rem;
}

/* Panel konfiguracji */
.config-panel {
    position: sticky;
    top: 20px;
    height: fit-content;
}

.form-group {
    margin-bottom: 25px;
}

.form-group label {
    display: block;
    margin-bottom: 10px;
    font-weight: 600;
    color: var(--dark);
}

.form-group input[type="number"],
.form-group input[type="text"] {
    width: 100%;
    padding: 10px;
    border: 2px solid var(--border);
    border-radius: 8px;
    font-size: 1rem;
    transition: border-color 0.3s;
}

.form-group input:focus {
    outline: none;
    border-color: var(--primary);
}

.form-group input[type="range"] {
    width: 100%;
    margin-top: 10px;
}

/* Paleta kolorów */
.color-palette {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 6px;
    margin-bottom: 15px;
}

.color-option {
    aspect-ratio: 1;
    border-radius: 6px;
    cursor: pointer;
    position: relative;
    border: 2px solid transparent;
    transition: all 0.3s;
    display: flex;
    align-items: flex-end;
    justify-content: center;
    padding: 3px;
}

.color-option:hover {
    transform: scale(1.05);
    box-shadow: 0 4px 12px var(--shadow);
}

.color-option.selected {
    border-color: var(--dark);
    box-shadow: 0 0 0 2px white, 0 0 0 4px var(--dark);
}

.color-name {
    font-size: 0.55rem;
    font-weight: 600;
    background: rgba(255,255,255,0.9);
    padding: 1px 3px;
    border-radius: 3px;
    color: var(--dark);
}

.cmyk-display {
    background: var(--light);
    padding: 10px;
    border-radius: 6px;
    font-family: monospace;
    font-size: 0.9rem;
}

/* Wymiary arkusza */
.sheet-size {
    display: flex;
    align-items: center;
    gap: 10px;
}

.sheet-size input {
    flex: 1;
}

.preset-sizes {
    display: flex;
    gap: 5px;
    margin-top: 10px;
}

/* Info o układzie */
.layout-info {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    padding: 20px;
    border-radius: 10px;
    margin-bottom: 20px;
}

.layout-info h3 {
    color: white;
    margin-bottom: 15px;
}

.layout-info p {
    margin-bottom: 8px;
    font-size: 0.95rem;
}

.layout-info strong {
    font-size: 1.2rem;
}

/* Przyciski */
.btn {
    padding: 12px 24px;
    border: none;
    border-radius: 8px;
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s;
    width: 100%;
    margin-bottom: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
}

.btn-primary {
    background: var(--primary);
    color: white;
}

.btn-success {
    background: var(--success);
    color: white;
}

.btn-secondary {
    background: var(--light);
    color: var(--dark);
}

.btn-outline {
    background: transparent;
    border: 2px solid var(--border);
    color: var(--dark);
}

.btn:hover:not(:disabled) {
    transform: translateY(-2px);
    box-shadow: 0 4px 12px var(--shadow);
}

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

.btn-sm {
    padding: 6px 12px;
    font-size: 0.85rem;
    border: 2px solid var(--border);
    background: white;
    border-radius: 6px;
    cursor: pointer;
    transition: all 0.3s;
}

.btn-sm:hover {
    background: var(--primary);
    color: white;
    border-color: var(--primary);
}

.btn-large {
    padding: 16px 32px;
    font-size: 1.2rem;
}

/* Integracja Shoper */
.integration-card {
    background: linear-gradient(135deg, #f093fb 0%, #f5576c 100%);
    color: white;
}

.integration-card h3 {
    color: white;
}

.integration-card small {
    display: block;
    margin-top: 10px;
    opacity: 0.8;
}

/* Wyszukiwanie ikon */
.icon-search {
    display: flex;
    align-items: center;
    gap: 15px;
    margin-bottom: 20px;
}

.search-input-wrapper {
    flex: 1;
    position: relative;
}

.icon-search input {
    width: 100%;
    padding: 12px 40px 12px 12px; /* Extra padding for clear button */
    border: 2px solid var(--border);
    border-radius: 8px;
    font-size: 1rem;
}

.clear-search-btn {
    position: absolute;
    right: 8px;
    top: 50%;
    transform: translateY(-50%);
    background: #999;
    color: white;
    border: none;
    border-radius: 50%;
    width: 24px;
    height: 24px;
    font-size: 14px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s;
    padding: 0;
    line-height: 1;
}

.clear-search-btn:hover {
    background: #666;
    transform: translateY(-50%) scale(1.1);
}

.selected-count {
    white-space: nowrap;
    color: #666;
    flex-shrink: 0;
}

.selected-count strong {
    color: var(--primary);
    font-size: 1.2rem;
}

/* Siatka ikon */
.icon-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(100px, 1fr));
    gap: 15px;
    max-height: 400px;
    overflow-y: auto;
    padding: 10px;
}

.icon-item {
    text-align: center;
    cursor: pointer;
    padding: 15px;
    border: 2px solid var(--border);
    border-radius: 10px;
    transition: all 0.3s;
    position: relative;
}

.icon-item:hover {
    border-color: var(--primary);
    background: rgba(33, 150, 243, 0.05);
    transform: translateY(-3px);
}

.icon-item.selected {
    border-color: var(--success);
    background: rgba(76, 175, 80, 0.1);
}

/* Badge z ilością */
.icon-quantity-badge {
    position: absolute;
    top: 5px;
    right: 5px;
    background: var(--primary);
    color: white;
    border-radius: 12px;
    min-width: 24px;
    height: 24px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: bold;
    font-size: 0.85rem;
    box-shadow: 0 2px 4px rgba(0,0,0,0.2);
    z-index: 10;
    pointer-events: none;
}

.icon-quantity-badge.high-quantity {
    background: var(--success);
}

/* Kontrolki +/- na ikonie */
.icon-controls {
    position: absolute;
    bottom: 5px;
    left: 50%;
    transform: translateX(-50%);
    display: none;
    gap: 4px;
    background: rgba(255, 255, 255, 0.95);
    padding: 4px;
    border-radius: 6px;
    box-shadow: 0 2px 8px rgba(0,0,0,0.15);
    z-index: 15;
}

.icon-item.selected:hover .icon-controls {
    display: flex;
}

.icon-controls button {
    width: 24px;
    height: 24px;
    border: none;
    background: var(--primary);
    color: white;
    border-radius: 4px;
    cursor: pointer;
    font-weight: bold;
    font-size: 1rem;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s;
}

.icon-controls button:hover {
    background: #1976D2;
    transform: scale(1.1);
}

.icon-controls button.remove {
    background: var(--danger);
}

.icon-controls button.remove:hover {
    background: #d32f2f;
}

.icon-controls .qty-display {
    min-width: 28px;
    text-align: center;
    font-weight: bold;
    color: var(--dark);
    font-size: 0.9rem;
    padding: 0 4px;
}

.icon-preview {
    width: 50px;
    height: 50px;
    margin: 0 auto 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--light);
    border-radius: 8px;
}

.icon-svg-container {
    width: 100%;
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 8px;
}

.icon-svg-container svg {
    width: 100%;
    height: 100%;
    fill: var(--dark);
}

.icon-loading {
    font-size: 0.8rem;
    color: #999;
    animation: pulse 1.5s ease-in-out infinite;
}

@keyframes pulse {
    0%, 100% { opacity: 0.3; }
    50% { opacity: 1; }
}

.mdi-icon {
    font-size: 0.8rem;
    font-weight: bold;
    color: var(--dark);
}

.icon-name {
    font-size: 0.75rem;
    color: #666;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

/* Wizualizacja */
.visualization-tabs {
    display: flex;
    gap: 10px;
    margin-bottom: 20px;
}

.tab-btn {
    flex: 1;
    padding: 10px;
    border: 2px solid var(--border);
    background: white;
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.3s;
    font-weight: 600;
}

.tab-btn.active {
    background: var(--primary);
    color: white;
    border-color: var(--primary);
}

.viewer {
    display: none;
    background: var(--light);
    border-radius: 10px;
    padding: 20px;
    min-height: 400px;
    position: relative;
}

.viewer.active {
    display: block;
}

#canvas-3d {
    width: 100%;
    height: 400px;
    border-radius: 8px;
}

.viewer-controls {
    display: flex;
    gap: 10px;
    margin-top: 15px;
}

.viewer-controls button {
    padding: 8px 16px;
    border: 2px solid var(--border);
    background: white;
    border-radius: 6px;
    cursor: pointer;
    font-weight: 600;
}

.viewer-controls button:hover {
    background: var(--primary);
    color: white;
    border-color: var(--primary);
}

/* Wybrane ikony */
.selected-icons-list {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
}

.selected-icons-list .placeholder {
    color: #999;
    text-align: center;
    width: 100%;
    padding: 40px;
}

.selected-icon-badge {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 8px 12px;
    background: var(--light);
    border-radius: 20px;
    font-size: 0.9rem;
}

.selected-icon-badge .remove {
    cursor: pointer;
    color: var(--danger);
    font-weight: bold;
    margin-left: 5px;
}

/* Modal */
.modal {
    display: none;
    position: fixed;
    z-index: 1000;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    background: rgba(0,0,0,0.5);
    animation: fadeIn 0.3s;
}

.modal.show {
    display: flex;
    align-items: center;
    justify-content: center;
}

.modal-content {
    background: white;
    padding: 40px;
    border-radius: 15px;
    max-width: 500px;
    width: 90%;
    box-shadow: 0 10px 40px rgba(0,0,0,0.3);
    animation: slideUp 0.3s;
}

.close {
    float: right;
    font-size: 28px;
    font-weight: bold;
    cursor: pointer;
    color: #999;
}

.close:hover {
    color: var(--dark);
}

.download-info {
    background: var(--light);
    padding: 20px;
    border-radius: 10px;
    margin: 20px 0;
}

.download-info p {
    margin-bottom: 10px;
}

/* Animacje */
@keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

@keyframes slideUp {
    from { 
        transform: translateY(50px);
        opacity: 0;
    }
    to { 
        transform: translateY(0);
        opacity: 1;
    }
}

/* Nawigacja arkuszy */
.sheet-navigation {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 20px;
    padding: 15px;
    background: var(--light);
    border-radius: 8px;
    margin-bottom: 15px;
}

.nav-btn {
    padding: 8px 16px;
    border: 2px solid var(--border);
    background: white;
    border-radius: 6px;
    cursor: pointer;
    font-weight: 600;
    transition: all 0.3s;
}

.nav-btn:hover:not(:disabled) {
    background: var(--primary);
    color: white;
    border-color: var(--primary);
}

.nav-btn:disabled {
    opacity: 0.3;
    cursor: not-allowed;
}

#sheet-info {
    font-size: 1rem;
    color: var(--dark);
}

/* Widok układu arkusza */
.sheet-layout-container {
    background: white;
    border-radius: 10px;
    padding: 20px;
    min-height: 400px;
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: auto;
}

.layout-grid {
    display: inline-block;
    background: white;
    padding: 20px;
    border-radius: 10px;
    box-shadow: 0 4px 12px rgba(0,0,0,0.1);
}

.layout-title {
    text-align: center;
    margin-bottom: 15px;
    font-weight: 600;
    color: var(--dark);
}

.sticker-spot {
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    border: 2px solid #ddd;
    background: white;
    overflow: hidden;
    position: relative;
}

.sticker-spot svg {
    width: 70%;
    height: 70%;
}

.sticker-spot.empty {
    background: #f5f5f5;
    border-color: #e0e0e0;
}

/* Wybrane ikony z ilością */
.selected-icons-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 15px;
    padding-bottom: 10px;
    border-bottom: 2px solid var(--border);
}

.selected-icon-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px;
    background: var(--light);
    border-radius: 8px;
    margin-bottom: 8px;
}

.selected-icon-preview {
    width: 40px;
    height: 40px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: white;
    border-radius: 6px;
    flex-shrink: 0;
}

.selected-icon-preview svg {
    width: 80%;
    height: 80%;
}

.selected-icon-info {
    flex: 1;
    min-width: 0;
}

.selected-icon-name {
    font-weight: 600;
    color: var(--dark);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.selected-icon-quantity {
    font-size: 0.85rem;
    color: #666;
}

.quantity-controls {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-shrink: 0;
}

.qty-btn {
    width: 28px;
    height: 28px;
    border: 2px solid var(--border);
    background: white;
    border-radius: 4px;
    cursor: pointer;
    font-weight: bold;
    font-size: 1rem;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s;
}

.qty-btn:hover {
    background: var(--primary);
    color: white;
    border-color: var(--primary);
}

.qty-value {
    min-width: 35px;
    text-align: center;
    font-weight: 600;
    font-size: 1.1rem;
    color: var(--primary);
}

.remove-icon-btn {
    width: 28px;
    height: 28px;
    border: 2px solid var(--danger);
    background: white;
    color: var(--danger);
    border-radius: 4px;
    cursor: pointer;
    font-weight: bold;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s;
}

.remove-icon-btn:hover {
    background: var(--danger);
    color: white;
}

/* Responsywność */
@media (max-width: 1200px) {
    .main-grid {
        grid-template-columns: 1fr;
    }
    
    .config-panel {
        position: static;
    }
}

@media (max-width: 768px) {
    header h1 {
        font-size: 1.8rem;
    }
    
    .icon-grid {
        grid-template-columns: repeat(auto-fill, minmax(80px, 1fr));
    }
    
    .color-palette {
        grid-template-columns: repeat(2, 1fr);
    }
}

/* Scrollbar */
::-webkit-scrollbar {
    width: 8px;
}

::-webkit-scrollbar-track {
    background: var(--light);
    border-radius: 4px;
}

::-webkit-scrollbar-thumb {
    background: var(--primary);
    border-radius: 4px;
}

::-webkit-scrollbar-thumb:hover {
    background: #1976D2;
}
